-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preferences: Add colors dialog to preferences menu
- Loading branch information
Showing
7 changed files
with
210 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "preferences/dialog/dlgprefcolors.h" | ||
|
||
#include <QtDebug> | ||
|
||
#include "control/controlobject.h" | ||
#include "util/color/predefinedcolorpalettes.h" | ||
|
||
DlgPrefColors::DlgPrefColors( | ||
QWidget* parent, UserSettingsPointer config) | ||
: DlgPreferencePage(parent), | ||
m_config(config), | ||
m_colorPaletteSettings(ColorPaletteSettings(config)) { | ||
setupUi(this); | ||
|
||
loadSettings(); | ||
} | ||
|
||
DlgPrefColors::~DlgPrefColors() { | ||
} | ||
|
||
// Loads the config keys and sets the widgets in the dialog to match | ||
void DlgPrefColors::loadSettings() { | ||
foreach (const ColorPalette& palette, mixxx::PredefinedColorPalettes::kPalettes) { | ||
QString paletteName = palette.getName(); | ||
comboBoxHotcueColors->addItem(paletteName); | ||
comboBoxTrackColors->addItem(paletteName); | ||
} | ||
|
||
foreach (const QString& value, m_colorPaletteSettings.getColorPaletteNames()) { | ||
qDebug() << value; | ||
} | ||
|
||
comboBoxHotcueColors->setCurrentText( | ||
m_colorPaletteSettings.getHotcueColorPalette().getName()); | ||
comboBoxTrackColors->setCurrentText( | ||
m_colorPaletteSettings.getTrackColorPalette().getName()); | ||
slotApply(); | ||
} | ||
|
||
// Set the default values for all the widgets | ||
void DlgPrefColors::slotResetToDefaults() { | ||
comboBoxHotcueColors->setCurrentText( | ||
mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette.getName()); | ||
comboBoxTrackColors->setCurrentText( | ||
mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette.getName()); | ||
slotApply(); | ||
} | ||
|
||
// Apply and save any changes made in the dialog | ||
void DlgPrefColors::slotApply() { | ||
QString hotcueColorPaletteName = comboBoxHotcueColors->currentText(); | ||
QString trackColorPaletteName = comboBoxTrackColors->currentText(); | ||
bool bHotcueColorPaletteFound = false; | ||
bool bTrackColorPaletteFound = false; | ||
|
||
foreach (const ColorPalette& palette, mixxx::PredefinedColorPalettes::kPalettes) { | ||
if (!bHotcueColorPaletteFound && hotcueColorPaletteName == palette.getName()) { | ||
m_colorPaletteSettings.setHotcueColorPalette(palette); | ||
bHotcueColorPaletteFound = true; | ||
} | ||
if (!bTrackColorPaletteFound && trackColorPaletteName == palette.getName()) { | ||
m_colorPaletteSettings.setTrackColorPalette(palette); | ||
bTrackColorPaletteFound = true; | ||
} | ||
} | ||
|
||
if (!bHotcueColorPaletteFound) { | ||
m_colorPaletteSettings.setHotcueColorPalette( | ||
m_colorPaletteSettings.getColorPalette(hotcueColorPaletteName, | ||
m_colorPaletteSettings.getHotcueColorPalette())); | ||
} | ||
|
||
if (!bTrackColorPaletteFound) { | ||
m_colorPaletteSettings.setTrackColorPalette( | ||
m_colorPaletteSettings.getColorPalette(trackColorPaletteName, | ||
m_colorPaletteSettings.getTrackColorPalette())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <QWidget> | ||
|
||
#include "control/controlproxy.h" | ||
#include "preferences/colorpalettesettings.h" | ||
#include "preferences/dialog/ui_dlgprefcolorsdlg.h" | ||
#include "preferences/dlgpreferencepage.h" | ||
#include "preferences/usersettings.h" | ||
|
||
class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { | ||
Q_OBJECT | ||
public: | ||
DlgPrefColors(QWidget* parent, UserSettingsPointer _config); | ||
virtual ~DlgPrefColors(); | ||
|
||
public slots: | ||
// Apply changes to widget | ||
void slotApply(); | ||
void slotResetToDefaults(); | ||
|
||
signals: | ||
void apply(const QString&); | ||
|
||
private: | ||
void loadSettings(); | ||
|
||
// Pointer to config object | ||
UserSettingsPointer m_config; | ||
ColorPaletteSettings m_colorPaletteSettings; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>DlgPrefColorsDlg</class> | ||
<widget class="QWidget" name="DlgPrefColorsDlg"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>427</width> | ||
<height>333</height> | ||
</rect> | ||
</property> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Color Preferences</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QGroupBox" name="groupBox"> | ||
<property name="title"> | ||
<string>Color Palettes</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="labelHotcueColors"> | ||
<property name="text"> | ||
<string>Hotcue Colors:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QComboBox" name="comboBoxHotcueColors"/> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="labelTrackColors"> | ||
<property name="text"> | ||
<string>Track Colors:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QComboBox" name="comboBoxTrackColors"/> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
<layoutdefault spacing="6" margin="11"/> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters