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: 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