From c0dc779b6d33d2a24839208598ea10dec188bc02 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:10:09 +0200 Subject: [PATCH 01/10] preferences/dialog/dlgprefcolors: Implement slotUpdate --- src/preferences/dialog/dlgprefcolors.cpp | 12 ++++++------ src/preferences/dialog/dlgprefcolors.h | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index a3e09d090d9..2b9779ac32f 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -27,8 +27,6 @@ DlgPrefColors::DlgPrefColors( comboBoxHotcueColors->setIconSize(kPalettePreviewSize); comboBoxTrackColors->setIconSize(kPalettePreviewSize); - loadSettings(); - connect(comboBoxHotcueColors, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -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)) { @@ -264,7 +264,7 @@ void DlgPrefColors::trackPaletteUpdated(const QString& trackColors) { QString hotcueColors = comboBoxHotcueColors->currentText(); int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); - loadSettings(); + slotUpdate(); restoreComboBoxes(hotcueColors, trackColors, defaultColor); } @@ -272,7 +272,7 @@ void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) { QString trackColors = comboBoxTrackColors->currentText(); int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); - loadSettings(); + slotUpdate(); restoreComboBoxes(hotcueColors, trackColors, defaultColor); } @@ -281,7 +281,7 @@ void DlgPrefColors::palettesUpdated() { QString trackColors = comboBoxTrackColors->currentText(); int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); - loadSettings(); + slotUpdate(); restoreComboBoxes(hotcueColors, trackColors, defaultColor); } diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index 9ef61679cf7..b17e544aaa8 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -17,8 +17,11 @@ 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. + 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: @@ -26,7 +29,6 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { private slots: void slotHotcuePaletteChanged(const QString& palette); - void loadSettings(); void trackPaletteUpdated(const QString& palette); void hotcuePaletteUpdated(const QString& palette); void palettesUpdated(); From 9898c234e6f092bdce56d4ffd2b40574c2edc583 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:10:55 +0200 Subject: [PATCH 02/10] controllers/dlgprefcontrollers: Implement slotResetToDefaults --- src/controllers/dlgprefcontrollers.cpp | 7 +++++++ src/controllers/dlgprefcontrollers.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/controllers/dlgprefcontrollers.cpp b/src/controllers/dlgprefcontrollers.cpp index 3af59017f85..301274b47f7 100644 --- a/src/controllers/dlgprefcontrollers.cpp +++ b/src/controllers/dlgprefcontrollers.cpp @@ -57,6 +57,13 @@ void DlgPrefControllers::slotApply() { } } +void DlgPrefControllers::slotResetToDefaults() { + // Update our sub-windows. + foreach (DlgPrefController* pControllerWindows, m_controllerWindows) { + pControllerWindows->slotResetToDefaults(); + } +} + bool DlgPrefControllers::handleTreeItemClick(QTreeWidgetItem* clickedItem) { int controllerIndex = m_controllerTreeItems.indexOf(clickedItem); if (controllerIndex >= 0) { diff --git a/src/controllers/dlgprefcontrollers.h b/src/controllers/dlgprefcontrollers.h index 5e704f211ca..49946d26f1c 100644 --- a/src/controllers/dlgprefcontrollers.h +++ b/src/controllers/dlgprefcontrollers.h @@ -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(); From 1855bffeb658c7ba64912ab4a35ba92dd19c7449 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:11:32 +0200 Subject: [PATCH 03/10] preferences/dialog/dlgpreflv2: Add dummy slotUpdate/slotResetToDefaults --- src/preferences/dialog/dlgpreflv2.cpp | 8 ++++++++ src/preferences/dialog/dlgpreflv2.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/preferences/dialog/dlgpreflv2.cpp b/src/preferences/dialog/dlgpreflv2.cpp index 04ec537a79c..ef3d7f4949f 100644 --- a/src/preferences/dialog/dlgpreflv2.cpp +++ b/src/preferences/dialog/dlgpreflv2.cpp @@ -111,6 +111,14 @@ void DlgPrefLV2::slotDisplayParameters() { lv2_vertical_layout_params->addStretch(); } +void DlgPrefLV2::slotUpdate() { + // TODO: Implement this +} + +void DlgPrefLV2::slotResetToDefaults() { + // TODO: Implement this +} + void DlgPrefLV2::slotApply() { EffectManifestPointer pCurrentEffectManifest = m_pLV2Backend->getManifest(m_currentEffectId); diff --git a/src/preferences/dialog/dlgpreflv2.h b/src/preferences/dialog/dlgpreflv2.h index fc4b1f4e580..0498e6d6c4a 100644 --- a/src/preferences/dialog/dlgpreflv2.h +++ b/src/preferences/dialog/dlgpreflv2.h @@ -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(); From 1a778536deffaf013da7e918b52ab868d1f1a491 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:14:52 +0200 Subject: [PATCH 04/10] controllers/dlgprefcontroller: Call slotUpdate in slotCancel --- src/controllers/dlgprefcontroller.cpp | 2 +- src/controllers/dlgprefcontroller.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index e281bbb5011..4359f6f2770 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -368,7 +368,7 @@ void DlgPrefController::slotUpdate() { } void DlgPrefController::slotCancel() { - slotShowPreset(m_pController->getPreset()); + slotUpdate(); } void DlgPrefController::applyPresetChanges() { diff --git a/src/controllers/dlgprefcontroller.h b/src/controllers/dlgprefcontroller.h index 45774383310..b4ffed87ae5 100644 --- a/src/controllers/dlgprefcontroller.h +++ b/src/controllers/dlgprefcontroller.h @@ -32,12 +32,12 @@ 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(); signals: void applyPreset(Controller* pController, ControllerPresetPointer pPreset, bool bEnabled); From 4fdd680b4b9a22c35fdaac17869355d5412b2684 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:16:44 +0200 Subject: [PATCH 05/10] controllers/dlgprefcontroller: Implement slotResetToDefaults --- src/controllers/dlgprefcontroller.cpp | 5 +++++ src/controllers/dlgprefcontroller.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index 4359f6f2770..a7202510622 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -371,6 +371,11 @@ void DlgPrefController::slotCancel() { slotUpdate(); } +void DlgPrefController::slotResetToDefaults() { + m_ui.chkEnabledDevice->setChecked(false); + enumeratePresets(QString()); +} + void DlgPrefController::applyPresetChanges() { if (m_pInputTableModel) { m_pInputTableModel->apply(); diff --git a/src/controllers/dlgprefcontroller.h b/src/controllers/dlgprefcontroller.h index b4ffed87ae5..561a3f25079 100644 --- a/src/controllers/dlgprefcontroller.h +++ b/src/controllers/dlgprefcontroller.h @@ -38,6 +38,8 @@ class DlgPrefController : public DlgPreferencePage { 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(); signals: void applyPreset(Controller* pController, ControllerPresetPointer pPreset, bool bEnabled); From feedddee2a5619befb649bd433fc44402e32754b Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:17:41 +0200 Subject: [PATCH 06/10] preferences/dlgpreferencepage: Make DlgPreferencePage abstract --- src/preferences/dlgpreferencepage.h | 52 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/preferences/dlgpreferencepage.h b/src/preferences/dlgpreferencepage.h index 4f7db5e40d2..92a79268478 100644 --- a/src/preferences/dlgpreferencepage.h +++ b/src/preferences/dlgpreferencepage.h @@ -1,9 +1,8 @@ -#ifndef DLGPREFERENCEPAGE_H -#define DLGPREFERENCEPAGE_H +#pragma once #include -// API that all preference pages should implement. +/// Interface that all preference pages have to implement. class DlgPreferencePage : public QWidget { Q_OBJECT public: @@ -11,31 +10,30 @@ class DlgPreferencePage : public QWidget { 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; + + /// 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 */ From b7bbb665156fd293f0723b9c8a95d1dad64e5b4d Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Apr 2020 13:18:07 +0200 Subject: [PATCH 07/10] controllers/dlgprefcontroller: Use default implementation for slotCancel --- src/controllers/dlgprefcontroller.cpp | 4 ---- src/controllers/dlgprefcontroller.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index a7202510622..3c0d476151d 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -367,10 +367,6 @@ void DlgPrefController::slotUpdate() { m_ui.outputMappingsTab->setEnabled(isMappable); } -void DlgPrefController::slotCancel() { - slotUpdate(); -} - void DlgPrefController::slotResetToDefaults() { m_ui.chkEnabledDevice->setChecked(false); enumeratePresets(QString()); diff --git a/src/controllers/dlgprefcontroller.h b/src/controllers/dlgprefcontroller.h index 561a3f25079..347bab533cc 100644 --- a/src/controllers/dlgprefcontroller.h +++ b/src/controllers/dlgprefcontroller.h @@ -36,8 +36,6 @@ class DlgPrefController : public DlgPreferencePage { 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(); From 1e8f7058dab8416d75efc03c49648c9d35c2de17 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 16 Apr 2020 14:36:20 +0200 Subject: [PATCH 08/10] controllers/dlgprefcontrollers: Replace foreach with for loops --- src/controllers/dlgprefcontrollers.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/controllers/dlgprefcontrollers.cpp b/src/controllers/dlgprefcontrollers.cpp index 301274b47f7..70a0268521c 100644 --- a/src/controllers/dlgprefcontrollers.cpp +++ b/src/controllers/dlgprefcontrollers.cpp @@ -37,29 +37,25 @@ void DlgPrefControllers::slotOpenLocalFile(const QString& file) { } void DlgPrefControllers::slotUpdate() { - // Update our sub-windows. - foreach (DlgPrefController* pControllerWindows, m_controllerWindows) { + for (DlgPrefController* pControllerWindows : qAsConst(m_controllerWindows)) { pControllerWindows->slotUpdate(); } } void DlgPrefControllers::slotCancel() { - // Update our sub-windows. - foreach (DlgPrefController* pControllerWindows, m_controllerWindows) { + for (DlgPrefController* pControllerWindows : qAsConst(m_controllerWindows)) { pControllerWindows->slotCancel(); } } void DlgPrefControllers::slotApply() { - // Update our sub-windows. - foreach (DlgPrefController* pControllerWindows, m_controllerWindows) { + for (DlgPrefController* pControllerWindows : qAsConst(m_controllerWindows)) { pControllerWindows->slotApply(); } } void DlgPrefControllers::slotResetToDefaults() { - // Update our sub-windows. - foreach (DlgPrefController* pControllerWindows, m_controllerWindows) { + for (DlgPrefController* pControllerWindows : qAsConst(m_controllerWindows)) { pControllerWindows->slotResetToDefaults(); } } From 607b33f1aac72a4f7c399a29d6e4d86e37f18e83 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 16 Apr 2020 14:44:34 +0200 Subject: [PATCH 09/10] preferences/dialog/dlgpreflv2: Remove TODO as page will be removed anyway --- src/preferences/dialog/dlgpreflv2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/preferences/dialog/dlgpreflv2.cpp b/src/preferences/dialog/dlgpreflv2.cpp index ef3d7f4949f..25777e285ff 100644 --- a/src/preferences/dialog/dlgpreflv2.cpp +++ b/src/preferences/dialog/dlgpreflv2.cpp @@ -112,11 +112,13 @@ void DlgPrefLV2::slotDisplayParameters() { } void DlgPrefLV2::slotUpdate() { - // TODO: Implement this + // This preferences page will be removed in PR #2618 anyway, so we'll just + // leave this empty for now. } void DlgPrefLV2::slotResetToDefaults() { - // TODO: Implement this + // This preferences page will be removed in PR #2618 anyway, so we'll just + // leave this empty for now. } void DlgPrefLV2::slotApply() { From dffaa86a10e85d238046dbc3cd317675183d74d1 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Apr 2020 13:28:05 +0200 Subject: [PATCH 10/10] controllers/dlgprefcontroller: Fix preset details and dirty state on reset --- src/controllers/dlgprefcontroller.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index 3c0d476151d..594e953bd72 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -370,6 +370,7 @@ void DlgPrefController::slotUpdate() { void DlgPrefController::slotResetToDefaults() { m_ui.chkEnabledDevice->setChecked(false); enumeratePresets(QString()); + slotPresetSelected(m_ui.comboBoxPreset->currentIndex()); } void DlgPrefController::applyPresetChanges() {