Skip to content
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

Fix Preferences Buttons #2664

Merged
merged 10 commits into from
Apr 17, 2020
7 changes: 6 additions & 1 deletion src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ void DlgPrefController::slotUpdate() {
}

void DlgPrefController::slotCancel() {
slotShowPreset(m_pController->getPreset());
slotUpdate();
}

void DlgPrefController::slotResetToDefaults() {
m_ui.chkEnabledDevice->setChecked(false);
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
enumeratePresets(QString());
}

void DlgPrefController::applyPresetChanges() {
Expand Down
10 changes: 6 additions & 4 deletions src/controllers/dlgprefcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ class DlgPrefController : public DlgPreferencePage {
virtual ~DlgPrefController();

public slots:
// Called when we should apply / save our changes.
/// Called when the preference dialog (not this page) is shown to the user.
void slotUpdate();
/// Called when the user clicks the global "Apply" button.
void slotApply();
// Called when we should cancel the changes made.
/// Called when the user clicks the global "Cancel" button.
void slotCancel();
// Called when preference dialog (not this dialog) is displayed.
void slotUpdate();
/// Called when the user clicks the global "Reset to Defaults" button.
void slotResetToDefaults();

signals:
void applyPreset(Controller* pController, ControllerPresetPointer pPreset, bool bEnabled);
Expand Down
7 changes: 7 additions & 0 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ void DlgPrefControllers::slotApply() {
}
}

void DlgPrefControllers::slotResetToDefaults() {
// Update our sub-windows.
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
foreach (DlgPrefController* pControllerWindows, m_controllerWindows) {
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
pControllerWindows->slotResetToDefaults();
}
}

bool DlgPrefControllers::handleTreeItemClick(QTreeWidgetItem* clickedItem) {
int controllerIndex = m_controllerTreeItems.indexOf(clickedItem);
if (controllerIndex >= 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/controllers/dlgprefcontrollers.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ class DlgPrefControllers : public DlgPreferencePage, public Ui::DlgPrefControlle
bool handleTreeItemClick(QTreeWidgetItem* clickedItem);

public slots:
/// Called when the preference dialog (not this page) is shown to the user.
void slotUpdate();
/// Called when the user clicks the global "Apply" button.
void slotApply();
/// Called when the user clicks the global "Cancel" button.
void slotCancel();
/// Called when the user clicks the global "Reset to Defaults" button.
void slotResetToDefaults();

private slots:
void rescanControllers();
Expand Down
12 changes: 6 additions & 6 deletions src/preferences/dialog/dlgprefcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ DlgPrefColors::DlgPrefColors(
comboBoxHotcueColors->setIconSize(kPalettePreviewSize);
comboBoxTrackColors->setIconSize(kPalettePreviewSize);

loadSettings();

connect(comboBoxHotcueColors,
QOverload<const QString&>::of(&QComboBox::currentIndexChanged),
this,
Expand All @@ -43,13 +41,15 @@ DlgPrefColors::DlgPrefColors(
&QPushButton::clicked,
this,
&DlgPrefColors::slotEditTrackPaletteClicked);

slotUpdate();
}

DlgPrefColors::~DlgPrefColors() {
}

// Loads the config keys and sets the widgets in the dialog to match
void DlgPrefColors::loadSettings() {
void DlgPrefColors::slotUpdate() {
comboBoxHotcueColors->clear();
comboBoxTrackColors->clear();
for (const auto& palette : qAsConst(mixxx::PredefinedColorPalettes::kPalettes)) {
Expand Down Expand Up @@ -264,15 +264,15 @@ void DlgPrefColors::trackPaletteUpdated(const QString& trackColors) {
QString hotcueColors = comboBoxHotcueColors->currentText();
int defaultColor = comboBoxHotcueDefaultColor->currentIndex();

loadSettings();
slotUpdate();
restoreComboBoxes(hotcueColors, trackColors, defaultColor);
}

void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) {
QString trackColors = comboBoxTrackColors->currentText();
int defaultColor = comboBoxHotcueDefaultColor->currentIndex();

loadSettings();
slotUpdate();
restoreComboBoxes(hotcueColors, trackColors, defaultColor);
}

Expand All @@ -281,7 +281,7 @@ void DlgPrefColors::palettesUpdated() {
QString trackColors = comboBoxTrackColors->currentText();
int defaultColor = comboBoxHotcueDefaultColor->currentIndex();

loadSettings();
slotUpdate();
restoreComboBoxes(hotcueColors, trackColors, defaultColor);
}

Expand Down
6 changes: 4 additions & 2 deletions src/preferences/dialog/dlgprefcolors.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg {
virtual ~DlgPrefColors();

public slots:
// Apply changes to widget
/// Called when the preference dialog (not this page) is shown to the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to copy documentation from parent classes into every derived class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but it doesn't hurt either. I just replaced the already existing comments with better ones.

void slotUpdate();
/// Called when the user clicks the global "Apply" button.
void slotApply();
/// Called when the user clicks the global "Reset to Defaults" button.
void slotResetToDefaults();

signals:
void apply(const QString&);

private slots:
void slotHotcuePaletteChanged(const QString& palette);
void loadSettings();
void trackPaletteUpdated(const QString& palette);
void hotcuePaletteUpdated(const QString& palette);
void palettesUpdated();
Expand Down
8 changes: 8 additions & 0 deletions src/preferences/dialog/dlgpreflv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ void DlgPrefLV2::slotDisplayParameters() {
lv2_vertical_layout_params->addStretch();
}

void DlgPrefLV2::slotUpdate() {
// TODO: Implement this
}

void DlgPrefLV2::slotResetToDefaults() {
// TODO: Implement this
}

Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
void DlgPrefLV2::slotApply() {
EffectManifestPointer pCurrentEffectManifest =
m_pLV2Backend->getManifest(m_currentEffectId);
Expand Down
5 changes: 5 additions & 0 deletions src/preferences/dialog/dlgpreflv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ class DlgPrefLV2 : public DlgPreferencePage, public Ui::DlgPrefLV2Dlg {
virtual ~DlgPrefLV2();

public slots:
/// Called when the preference dialog (not this page) is shown to the user.
void slotUpdate();
/// Called when the user clicks the global "Apply" button.
void slotApply();
/// Called when the user clicks the global "Reset to Defaults" button.
void slotResetToDefaults();

private slots:
void slotDisplayParameters();
Expand Down
52 changes: 25 additions & 27 deletions src/preferences/dlgpreferencepage.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
#ifndef DLGPREFERENCEPAGE_H
#define DLGPREFERENCEPAGE_H
#pragma once

#include <QWidget>

// API that all preference pages should implement.
/// Interface that all preference pages have to implement.
class DlgPreferencePage : public QWidget {
Q_OBJECT
public:
DlgPreferencePage(QWidget* pParent);
virtual ~DlgPreferencePage();

public slots:
// Called when the preference dialog is shown to the user (not necessarily
// when this PreferencePage is shown to the user). At this point, the
// PreferencePage should update all of its setting to the latest values.
virtual void slotUpdate() {}

// Called when the user clicks the global "Apply" button. The preference
// dialog should make all of the current setting of the UI widgets active.
virtual void slotApply() {}

// Called when the user clicks the global "Cancel" button. The preference
// dialog should revert all of the changes the user made since the last
// slotUpdate.
virtual void slotCancel() {}

// Called when the user clicks the global "Reset to Defaults" button. The
// preference dialog should revert settings to their default values.
virtual void slotResetToDefaults() {}

// Called when the preferences dialog is shown to the user (not necessarily
// when this PreferencePage is shown to the user).
/// Called when the preference dialog is shown to the user (not necessarily
/// when this PreferencePage is shown to the user). At this point, the
/// PreferencePage should update all of its setting to the latest values.
virtual void slotUpdate() = 0;
Be-ing marked this conversation as resolved.
Show resolved Hide resolved

/// Called when the user clicks the global "Apply" button. The preference
/// dialog should make all of the current setting of the UI widgets active.
virtual void slotApply() = 0;

/// Called when the user clicks the global "Cancel" button. The preference
/// dialog should revert all of the changes the user made since the last
/// slotUpdate. The default implementation just class slotUpdate.
virtual void slotCancel() {
slotUpdate();
}

/// Called when the user clicks the global "Reset to Defaults" button. The
/// preference dialog should revert settings to their default values.
virtual void slotResetToDefaults() = 0;

/// Called when the preferences dialog is shown to the user (not necessarily
/// when this PreferencePage is shown to the user).
virtual void slotShow() {}

// Called when the preferences dialog is hidden from the user.
/// Called when the preferences dialog is hidden from the user.
virtual void slotHide() {}
};


#endif /* DLGPREFERENCEPAGE_H */