-
-
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.
- Loading branch information
Showing
9 changed files
with
224 additions
and
171 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
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,35 @@ | ||
#include "preferences/colorpalettesettings.h" | ||
|
||
ColorPaletteSettings::ColorPaletteSettings(QString group, UserSettingsPointer pConfig) | ||
: m_configGroup(group), | ||
m_palette(ColorPalette::mixxxPalette), | ||
m_pConfig(pConfig) { | ||
loadFromConfig(); | ||
} | ||
|
||
ColorPaletteSettings::~ColorPaletteSettings() { | ||
save(); | ||
} | ||
|
||
void ColorPaletteSettings::loadFromConfig() { | ||
VERIFY_OR_DEBUG_ASSERT(!m_configGroup.isEmpty()) { | ||
return; | ||
} | ||
|
||
QList<QColor> colorList; | ||
for (const ConfigKey& key : m_pConfig->getKeysWithGroup(m_configGroup)) { | ||
QColor color = m_pConfig->getValue<QColor>(key); | ||
if (color.isValid()) { | ||
colorList.append(color); | ||
} | ||
} | ||
|
||
m_palette = ColorPalette(colorList); | ||
} | ||
|
||
void ColorPaletteSettings::save() { | ||
for (int index = 0; index < m_palette.m_colorList.count(); ++index) { | ||
QColor color = m_palette.m_colorList[index]; | ||
m_pConfig->setValue<QColor>(keyForIndex(index), color); | ||
} | ||
} |
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 "preferences/usersettings.h" | ||
#include "util/color/colorpalette.h" | ||
|
||
class ColorPaletteSettings { | ||
public: | ||
explicit ColorPaletteSettings(QString group, UserSettingsPointer pConfig); | ||
~ColorPaletteSettings(); | ||
|
||
ColorPalette getPalette() const { | ||
return m_palette; | ||
} | ||
|
||
void setPalette(const ColorPalette& newPalette) { | ||
m_palette = newPalette; | ||
save(); | ||
} | ||
|
||
private: | ||
void loadFromConfig(); | ||
void save(); | ||
|
||
ConfigKey keyForIndex(int index) { | ||
return ConfigKey(m_configGroup, QString::number(index)); | ||
} | ||
|
||
QString m_configGroup; | ||
ColorPalette m_palette; | ||
UserSettingsPointer m_pConfig; | ||
}; |
Oops, something went wrong.