Skip to content

Commit

Permalink
preferences: Add colors dialog to preferences menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Mar 4, 2020
1 parent 65df687 commit a0d1724
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/preferences/dialog/dlgprefautodjdlg.ui
src/preferences/dialog/dlgprefbeats.cpp
src/preferences/dialog/dlgprefbeatsdlg.ui
src/preferences/dialog/dlgprefcolors.cpp
src/preferences/dialog/dlgprefcolorsdlg.ui
src/preferences/dialog/dlgprefcrossfader.cpp
src/preferences/dialog/dlgprefcrossfaderdlg.ui
src/preferences/dialog/dlgprefdeck.cpp
Expand Down
2 changes: 2 additions & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ def sources(self, build):
"src/preferences/configobject.cpp",
"src/preferences/dialog/dlgprefautodj.cpp",
"src/preferences/dialog/dlgprefdeck.cpp",
"src/preferences/dialog/dlgprefcolors.cpp",
"src/preferences/dialog/dlgprefcrossfader.cpp",
"src/preferences/dialog/dlgprefeffects.cpp",
"src/preferences/dialog/dlgprefeq.cpp",
Expand Down Expand Up @@ -1343,6 +1344,7 @@ def sources(self, build):
'src/preferences/dialog/dlgprefautodjdlg.ui',
'src/preferences/dialog/dlgprefbeatsdlg.ui',
'src/preferences/dialog/dlgprefdeckdlg.ui',
'src/preferences/dialog/dlgprefcolorsdlg.ui',
'src/preferences/dialog/dlgprefcrossfaderdlg.ui',
'src/preferences/dialog/dlgpreflv2dlg.ui',
'src/preferences/dialog/dlgprefeffectsdlg.ui',
Expand Down
78 changes: 78 additions & 0 deletions src/preferences/dialog/dlgprefcolors.cpp
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()));
}
}
31 changes: 31 additions & 0 deletions src/preferences/dialog/dlgprefcolors.h
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;
};
70 changes: 70 additions & 0 deletions src/preferences/dialog/dlgprefcolorsdlg.ui
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>
17 changes: 14 additions & 3 deletions src/preferences/dialog/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
#include "preferences/dialog/dlgprefnovinyl.h"
#endif

#include "preferences/dialog/dlgprefinterface.h"
#include "preferences/dialog/dlgprefwaveform.h"
#include "preferences/dialog/dlgprefcolors.h"
#include "preferences/dialog/dlgprefcrossfader.h"
#include "preferences/dialog/dlgprefdeck.h"
#include "preferences/dialog/dlgprefeq.h"
#include "preferences/dialog/dlgprefcrossfader.h"
#include "preferences/dialog/dlgprefinterface.h"
#include "preferences/dialog/dlgprefwaveform.h"
#ifdef __LILV__
#include "preferences/dialog/dlgpreflv2.h"
#endif /* __LILV__ */
Expand Down Expand Up @@ -121,6 +122,8 @@ DlgPreferences::DlgPreferences(MixxxMainWindow * mixxx, SkinLoader* pSkinLoader,
addPageWidget(m_waveformPage);
m_deckPage = new DlgPrefDeck(this, mixxx, pPlayerManager, m_pConfig);
addPageWidget(m_deckPage);
m_colorsPage = new DlgPrefColors(this, m_pConfig);
addPageWidget(m_colorsPage);
m_equalizerPage = new DlgPrefEQ(this, pEffectsManager, m_pConfig);
addPageWidget(m_equalizerPage);
m_crossfaderPage = new DlgPrefCrossfader(this, m_pConfig);
Expand Down Expand Up @@ -234,6 +237,12 @@ void DlgPreferences::createIcons() {
m_pDecksButton->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
m_pDecksButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

m_pColorsButton = new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type);
m_pColorsButton->setIcon(0, QIcon(":/images/preferences/ic_preferences_colors.svg"));
m_pColorsButton->setText(0, tr("Colors"));
m_pColorsButton->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
m_pColorsButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

m_pEqButton = new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type);
m_pEqButton->setIcon(0, QIcon(":/images/preferences/ic_preferences_equalizers.svg"));
m_pEqButton->setText(0, tr("Equalizers"));
Expand Down Expand Up @@ -334,6 +343,8 @@ void DlgPreferences::changePage(QTreeWidgetItem* current, QTreeWidgetItem* previ
switchToPage(m_waveformPage);
} else if (current == m_pDecksButton) {
switchToPage(m_deckPage);
} else if (current == m_pColorsButton) {
switchToPage(m_colorsPage);
} else if (current == m_pEqButton) {
switchToPage(m_equalizerPage);
} else if (current == m_pCrossfaderButton) {
Expand Down
18 changes: 13 additions & 5 deletions src/preferences/dialog/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DlgPrefNoVinyl;
class DlgPrefInterface;
class DlgPrefWaveform;
class DlgPrefDeck;
class DlgPrefColors;
class DlgPrefEQ;
class DlgPrefEffects;
class DlgPrefCrossfader;
Expand All @@ -66,11 +67,16 @@ class DlgPrefModplug;
class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
Q_OBJECT
public:
DlgPreferences(MixxxMainWindow* mixxx, SkinLoader* pSkinLoader, SoundManager* soundman,
PlayerManager* pPlayerManager, ControllerManager* controllers,
VinylControlManager* pVCManager, LV2Backend* pLV2Backend,
EffectsManager* pEffectsManager,
SettingsManager* pSettingsManager, Library *pLibrary);
DlgPreferences(MixxxMainWindow* mixxx,
SkinLoader* pSkinLoader,
SoundManager* soundman,
PlayerManager* pPlayerManager,
ControllerManager* controllers,
VinylControlManager* pVCManager,
LV2Backend* pLV2Backend,
EffectsManager* pEffectsManager,
SettingsManager* pSettingsManager,
Library* pLibrary);
virtual ~DlgPreferences();

void addPageWidget(DlgPreferencePage* pWidget);
Expand Down Expand Up @@ -115,6 +121,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
DlgPrefInterface* m_interfacePage;
DlgPrefWaveform* m_waveformPage;
DlgPrefDeck* m_deckPage;
DlgPrefColors* m_colorsPage;
DlgPrefEQ* m_equalizerPage;
DlgPrefCrossfader* m_crossfaderPage;
DlgPrefEffects* m_effectsPage;
Expand All @@ -138,6 +145,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
QTreeWidgetItem* m_pInterfaceButton;
QTreeWidgetItem* m_pWaveformButton;
QTreeWidgetItem* m_pDecksButton;
QTreeWidgetItem* m_pColorsButton;
QTreeWidgetItem* m_pEqButton;
#ifdef __LILV__
QTreeWidgetItem* m_pLV2Button;
Expand Down

0 comments on commit a0d1724

Please sign in to comment.