-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User Preference to Hide beat grid on waveform #1247
Changes from 4 commits
d5d35b0
7619c22
c26605e
809590c
3e40760
e2f1923
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ WaveformWidgetFactory::WaveformWidgetFactory() : | |
m_overviewNormalized(false), | ||
m_openGLAvailable(false), | ||
m_openGLShaderAvailable(false), | ||
m_beatGridEnabled(true), | ||
m_vsyncThread(NULL), | ||
m_frameCnt(0), | ||
m_actualFrameRate(0), | ||
|
@@ -223,6 +224,13 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { | |
m_config->set(ConfigKey("[Waveform]","ZoomSynchronization"), ConfigValue(m_zoomSync)); | ||
} | ||
|
||
int showBeatGrid = m_config->getValue(ConfigKey("[Waveform]", "beatGridLinesCheckBox")).toInt(&ok); | ||
if (ok) { | ||
setDisplayBeatGrid(static_cast<bool>(showBeatGrid)); | ||
} else { | ||
m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled)); | ||
} | ||
|
||
WaveformWidgetType::Type type = static_cast<WaveformWidgetType::Type>( | ||
m_config->getValueString(ConfigKey("[Waveform]","WaveformType")).toInt(&ok)); | ||
if (!ok || !setWidgetType(type)) { | ||
|
@@ -296,6 +304,7 @@ bool WaveformWidgetFactory::setWaveformWidget(WWaveformViewer* viewer, | |
} | ||
|
||
viewer->setZoom(m_defaultZoom); | ||
viewer->setDisplayBeatGrid(m_beatGridEnabled); | ||
viewer->update(); | ||
|
||
qDebug() << "WaveformWidgetFactory::setWaveformWidget - waveform widget added in factory, index" << index; | ||
|
@@ -432,6 +441,22 @@ void WaveformWidgetFactory::setZoomSync(bool sync) { | |
} | ||
} | ||
|
||
void WaveformWidgetFactory::setDisplayBeatGrid(bool sync) { | ||
m_beatGridEnabled = sync; | ||
if (m_config) { | ||
m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we normally do not set the value, if not required. We try to load the value and if it fails pick the default. Is it required here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dlgprefwaveform calls this in order to update the Config Would there be a better way to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would make more sense to set the ConfigKey in DlgPrefWaveform than here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see the way you did it is consistent with the surrounding code. You don't have to clean this up if you don't have time, but it would be nice to move the setting of the ConfigKeys into DlgPrefWaveform. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I do this just for the display grid preference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, keep it consistent. Either leave it how it is or refactor how all the settings in this function are set. |
||
} | ||
|
||
if (m_waveformWidgetHolders.size() == 0) { | ||
return; | ||
} | ||
|
||
for (int i = 0; i < m_waveformWidgetHolders.size(); i++) { | ||
m_waveformWidgetHolders[i].m_waveformWidget->setDisplayBeatGrid(m_beatGridEnabled); | ||
} | ||
|
||
} | ||
|
||
void WaveformWidgetFactory::setVisualGain(FilterIndex index, double gain) { | ||
m_visualGain[index] = gain; | ||
if (m_config) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can simplify the code passing the default value
int showBeatGrid = m_config->getValue("[Waveform]", "beatGridLinesCheckBox", m_showBeatGrid)
(not sure about the exact syntax though)