From a653006f3cd3342490636bb36ed7dfe1397b34fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 22 Mar 2020 16:55:56 +0100 Subject: [PATCH 01/42] Improve strings in the color preferences pane --- src/preferences/dialog/dlgprefcolorsdlg.ui | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index 08bf006daa6..eeebc7ffbf7 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -6,7 +6,7 @@ 0 0 - 524 + 656 333 @@ -29,27 +29,41 @@ - Hotcues: + Hotcue Palette - + + + + 0 + 0 + + + - Track: + Track Palette - + + + + 0 + 0 + + + - Auto hotcue colors + Cycle hotcue colors checkBoxAssignHotcueColors @@ -62,7 +76,7 @@ Automatically assigns a predefined color to a newly created hotcue point, based on its index. - Assign predefined colors to newly created hotcue points + Select consecutive palette colors for new hotcues From 29158a54a305923bc382f217c664db2a126e248b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 22 Mar 2020 17:04:20 +0100 Subject: [PATCH 02/42] Allow to translate "Name" in the ColorPaletteEditor --- src/preferences/colorpaletteeditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 5e1ca4d5561..9c8b12d4c29 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -31,7 +31,7 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) m_pDiscardButton = pButtonBox->addButton(QDialogButtonBox::Discard); QHBoxLayout* pTopLayout = new QHBoxLayout(); - pTopLayout->addWidget(new QLabel("Name:")); + pTopLayout->addWidget(new QLabel(tr("Name"))); pTopLayout->addWidget(m_pPaletteNameComboBox, 1); pTopLayout->addWidget(pButtonBox); From 7e1be9eabeb1cbdb26aabca315c248918170cce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 22 Mar 2020 18:57:50 +0100 Subject: [PATCH 03/42] Move button row below the palette and optimize column widths --- src/preferences/colorpaletteeditor.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 9c8b12d4c29..24c7333f2d7 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -33,18 +33,19 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) QHBoxLayout* pTopLayout = new QHBoxLayout(); pTopLayout->addWidget(new QLabel(tr("Name"))); pTopLayout->addWidget(m_pPaletteNameComboBox, 1); - pTopLayout->addWidget(pButtonBox); QVBoxLayout* pLayout = new QVBoxLayout(); pLayout->addLayout(pTopLayout); pLayout->addWidget(m_pTableView, 1); + pLayout->addWidget(pButtonBox); setLayout(pLayout); setContentsMargins(0, 0, 0, 0); // Set up model - m_pModel->setColumnCount(2); + m_pModel->setColumnCount(3); m_pModel->setHeaderData(0, Qt::Horizontal, tr("Color"), Qt::DisplayRole); - m_pModel->setHeaderData(1, Qt::Horizontal, tr("Assign to Hotcue"), Qt::DisplayRole); + m_pModel->setHeaderData(1, Qt::Horizontal, tr("Assign to Hotcue Number"), Qt::DisplayRole); + m_pModel->setHeaderData(2, Qt::Horizontal, QString(), Qt::DisplayRole); connect(m_pModel, &ColorPaletteEditorModel::dirtyChanged, this, @@ -63,6 +64,10 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) m_pTableView->setContextMenuPolicy(Qt::CustomContextMenu); m_pTableView->setModel(m_pModel); + m_pTableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + m_pTableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + m_pTableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); + connect(m_pTableView, &QTableView::doubleClicked, this, From 30aaea8a51e98dd242848c0a46f12f53c59c3c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 22 Mar 2020 20:06:49 +0100 Subject: [PATCH 04/42] Fill table with assigned cue numbers if no cue numbers are set --- src/preferences/colorpaletteeditormodel.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditormodel.cpp b/src/preferences/colorpaletteeditormodel.cpp index 62d958fbe16..9335edd13b5 100644 --- a/src/preferences/colorpaletteeditormodel.cpp +++ b/src/preferences/colorpaletteeditormodel.cpp @@ -103,9 +103,15 @@ void ColorPaletteEditorModel::setColorPalette(const ColorPalette& palette) { // Make a map of hotcue indices QMap hotcueColorIndicesMap; QList hotcueColorIndices = palette.getHotcueIndices(); - for (int i = 0; i < hotcueColorIndices.size(); i++) { - int colorIndex = hotcueColorIndices.at(i); - hotcueColorIndicesMap.insert(colorIndex, i); + if (hotcueColorIndices.size()) { + for (int i = 0; i < hotcueColorIndices.size(); i++) { + int colorIndex = hotcueColorIndices.at(i); + hotcueColorIndicesMap.insert(colorIndex, i); + } + } else { + for (int i = 0; i < palette.size(); i++) { + hotcueColorIndicesMap.insert(i, i); + } } for (int i = 0; i < palette.size(); i++) { From 3b66047a7fb2431a4ae0d0187c9c7fc3e332ef51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 11:43:09 +0100 Subject: [PATCH 05/42] Introduce Compbobox for selecting the hotcue default color --- src/preferences/dialog/dlgprefcolors.cpp | 56 ++++++++++++++++++++-- src/preferences/dialog/dlgprefcolorsdlg.ui | 40 ++++++---------- src/util/color/predefinedcolorpalettes.cpp | 1 + 3 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 6888e8db98b..2bd28aa27b4 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -1,12 +1,19 @@ #include "preferences/dialog/dlgprefcolors.h" #include +#include #include #include #include "control/controlobject.h" #include "util/color/predefinedcolorpalettes.h" +namespace { + +constexpr int kHotcueDefaultColorIndex = -1; + +} // anonymous namespace + DlgPrefColors::DlgPrefColors( QWidget* parent, UserSettingsPointer pConfig) : DlgPreferencePage(parent), @@ -47,12 +54,44 @@ void DlgPrefColors::loadSettings() { comboBoxTrackColors->addItem(paletteName); } + const ColorPalette hotcuePalette = m_colorPaletteSettings.getHotcueColorPalette(); + comboBoxHotcueColors->setCurrentText( - m_colorPaletteSettings.getHotcueColorPalette().getName()); + hotcuePalette.getName()); comboBoxTrackColors->setCurrentText( m_colorPaletteSettings.getTrackColorPalette().getName()); - slotApply(); + QPixmap pixmap(80, 80); + QPainter painter(&pixmap); + pixmap.fill(Qt::black); + + comboBoxHotcueDefaultColor->addItem(tr("By hotcue number"), -1); + + for (int i = 0; i < hotcuePalette.size() && i < 4; ++i) { + painter.setBrush(mixxx::RgbColor::toQColor(hotcuePalette.at(i))); + painter.drawRect(0, i * 20, 80, 20); + } + comboBoxHotcueDefaultColor->setItemIcon(0, QIcon(pixmap)); + + for (int i = 0; i < hotcuePalette.size(); ++i) { + comboBoxHotcueDefaultColor->addItem(tr("Palette") + + QStringLiteral(" ") + QString::number(i + 1), + i); + pixmap.fill(mixxx::RgbColor::toQColor(hotcuePalette.at(i))); + comboBoxHotcueDefaultColor->setItemIcon(i + 1, QIcon(pixmap)); + } + + bool autoHotcueColors = + m_pConfig->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false); + if (autoHotcueColors) { + comboBoxHotcueDefaultColor->setCurrentIndex(0); + } else { + int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), kHotcueDefaultColorIndex); + if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcuePalette.size()) { + hotcueDefaultColorIndex = hotcuePalette.size() - 1; // default to last color (orange) + } + comboBoxHotcueDefaultColor->setCurrentIndex(hotcueDefaultColorIndex + 1); + } } // Set the default values for all the widgets @@ -61,6 +100,7 @@ void DlgPrefColors::slotResetToDefaults() { mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette.getName()); comboBoxTrackColors->setCurrentText( mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette.getName()); + comboBoxHotcueDefaultColor->setCurrentIndex(1); slotApply(); } @@ -94,7 +134,13 @@ void DlgPrefColors::slotApply() { m_colorPaletteSettings.getTrackColorPalette())); } - m_pConfig->setValue( - ConfigKey("[Controls]", "auto_hotcue_colors"), - checkBoxAssignHotcueColors->isChecked()); + int index = comboBoxHotcueDefaultColor->currentIndex(); + + if (index > 0) { + m_pConfig->setValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false); + m_pConfig->setValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), index - 1); + } else { + m_pConfig->setValue(ConfigKey("[Controls]", "auto_hotcue_colors"), true); + m_pConfig->setValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), -1); + } } diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index eeebc7ffbf7..3f053f56275 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -26,14 +26,14 @@ Colors - + - Hotcue Palette + Hotcue palette - + @@ -43,14 +43,21 @@ - + + + + Hotcue default color + + + + - Track Palette + Track palette - + @@ -60,25 +67,8 @@ - - - - Cycle hotcue colors - - - checkBoxAssignHotcueColors - - - - - - - Automatically assigns a predefined color to a newly created hotcue point, based on its index. - - - Select consecutive palette colors for new hotcues - - + + diff --git a/src/util/color/predefinedcolorpalettes.cpp b/src/util/color/predefinedcolorpalettes.cpp index db6deb0ed7b..26d59f5eccb 100644 --- a/src/util/color/predefinedcolorpalettes.cpp +++ b/src/util/color/predefinedcolorpalettes.cpp @@ -122,6 +122,7 @@ const ColorPalette PredefinedColorPalettes::kMixxxHotcueColorPalette = kColorMixxxPurple, kColorMixxxPink, kColorMixxxWhite, + kSchemaMigrationReplacementColor, }); const ColorPalette PredefinedColorPalettes::kSeratoDJIntroHotcueColorPalette = From d990c5ea7873eda6a36adb01cbfd712e538b6cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 12:24:26 +0100 Subject: [PATCH 06/42] Respect new hotcue default settings --- src/engine/controls/cuecontrol.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 15c3fa77af2..7869dd640a5 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -618,12 +618,16 @@ void CueControl::hotcueSet(HotcueControl* pControl, double v) { pCue->setLabel(); pCue->setType(mixxx::CueType::HotCue); - ConfigKey autoHotcueColorsKey("[Controls]", "auto_hotcue_colors"); - if (getConfig()->getValue(autoHotcueColorsKey, false)) { - auto hotcueColorPalette = m_colorPaletteSettings.getHotcueColorPalette(); + const ColorPalette hotcueColorPalette = + m_colorPaletteSettings.getHotcueColorPalette(); + if (getConfig()->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false)) { pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcue)); } else { - pCue->setColor(mixxx::PredefinedColorPalettes::kDefaultCueColor); + int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), -1); + if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcueColorPalette.size()) { + hotcueDefaultColorIndex = hotcueColorPalette.size() - 1; // default to last color (orange) + } + pCue->setColor(hotcueColorPalette.at(hotcueDefaultColorIndex)); } // TODO(XXX) deal with spurious signals From c53f7c17a7760178341a5a38dfc1aa9b5eb8c3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 15:37:19 +0100 Subject: [PATCH 07/42] Added a preview stripe for the selected palette. Repopulate the default color selector when changing the palette. --- src/preferences/dialog/dlgprefcolors.cpp | 136 ++++++++++++++------- src/preferences/dialog/dlgprefcolors.h | 5 + src/preferences/dialog/dlgprefcolorsdlg.ui | 22 +++- 3 files changed, 118 insertions(+), 45 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 2bd28aa27b4..9cce1909c11 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -7,6 +7,8 @@ #include "control/controlobject.h" #include "util/color/predefinedcolorpalettes.h" +#include "util/compatibility.h" +#include "util/math.h" namespace { @@ -26,14 +28,22 @@ DlgPrefColors::DlgPrefColors( connect(colorPaletteEditor, &ColorPaletteEditor::paletteChanged, - [this] { - loadSettings(); - }); + this, + &DlgPrefColors::loadSettings); connect(colorPaletteEditor, &ColorPaletteEditor::paletteRemoved, - [this] { - loadSettings(); - }); + this, + &DlgPrefColors::loadSettings); + + connect(comboBoxTrackColors, + QOverload::of(&QComboBox::currentIndexChanged), + this, + &DlgPrefColors::slotTrackPaletteChanged); + + connect(comboBoxHotcueColors, + QOverload::of(&QComboBox::currentIndexChanged), + this, + &DlgPrefColors::slotHotcuePaletteChanged); } DlgPrefColors::~DlgPrefColors() { @@ -54,44 +64,17 @@ void DlgPrefColors::loadSettings() { comboBoxTrackColors->addItem(paletteName); } - const ColorPalette hotcuePalette = m_colorPaletteSettings.getHotcueColorPalette(); - + const ColorPalette hotcuePalette = + m_colorPaletteSettings.getHotcueColorPalette(); comboBoxHotcueColors->setCurrentText( hotcuePalette.getName()); - comboBoxTrackColors->setCurrentText( - m_colorPaletteSettings.getTrackColorPalette().getName()); + slotHotcuePaletteChanged(hotcuePalette.getName()); - QPixmap pixmap(80, 80); - QPainter painter(&pixmap); - pixmap.fill(Qt::black); - - comboBoxHotcueDefaultColor->addItem(tr("By hotcue number"), -1); - - for (int i = 0; i < hotcuePalette.size() && i < 4; ++i) { - painter.setBrush(mixxx::RgbColor::toQColor(hotcuePalette.at(i))); - painter.drawRect(0, i * 20, 80, 20); - } - comboBoxHotcueDefaultColor->setItemIcon(0, QIcon(pixmap)); - - for (int i = 0; i < hotcuePalette.size(); ++i) { - comboBoxHotcueDefaultColor->addItem(tr("Palette") + - QStringLiteral(" ") + QString::number(i + 1), - i); - pixmap.fill(mixxx::RgbColor::toQColor(hotcuePalette.at(i))); - comboBoxHotcueDefaultColor->setItemIcon(i + 1, QIcon(pixmap)); - } - - bool autoHotcueColors = - m_pConfig->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false); - if (autoHotcueColors) { - comboBoxHotcueDefaultColor->setCurrentIndex(0); - } else { - int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), kHotcueDefaultColorIndex); - if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcuePalette.size()) { - hotcueDefaultColorIndex = hotcuePalette.size() - 1; // default to last color (orange) - } - comboBoxHotcueDefaultColor->setCurrentIndex(hotcueDefaultColorIndex + 1); - } + const ColorPalette trackPalette = + m_colorPaletteSettings.getTrackColorPalette(); + comboBoxTrackColors->setCurrentText( + trackPalette.getName()); + slotTrackPaletteChanged(trackPalette.getName()); } // Set the default values for all the widgets @@ -144,3 +127,74 @@ void DlgPrefColors::slotApply() { m_pConfig->setValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), -1); } } + +QPixmap DlgPrefColors::drawPalettePreview(const QString& paletteName) { + foreach (const ColorPalette& palette, mixxx::PredefinedColorPalettes::kPalettes) { + if (paletteName == palette.getName()) { + int count = math_max(palette.size(), 1); + int width = math_min((200 / count), 16); + QPixmap pixmap(count * width, 16); + pixmap.fill(Qt::black); + QPainter painter(&pixmap); + for (int i = 0; i < palette.size(); ++i) { + painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); + painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); + painter.drawRect(i * width, 0, width, 16); + } + return pixmap; + } + } + return QPixmap(); +} + +void DlgPrefColors::slotTrackPaletteChanged(const QString& paletteName) { + QPixmap pixmap = drawPalettePreview(paletteName); + labelTrackPalette->setPixmap(pixmap); +} + +void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { + QPixmap preview = drawPalettePreview(paletteName); + labelHotcuePalette->setPixmap(preview); + + ColorPalette palette = mixxx::PredefinedColorPalettes::kPalettes[0]; + foreach (const ColorPalette& pal, mixxx::PredefinedColorPalettes::kPalettes) { + if (paletteName == pal.getName()) { + palette = pal; + break; + } + } + + comboBoxHotcueDefaultColor->clear(); + + QPixmap pixmap(80, 80); + QPainter painter(&pixmap); + pixmap.fill(Qt::black); + + comboBoxHotcueDefaultColor->addItem(tr("By hotcue number"), -1); + for (int i = 0; i < palette.size() && i < 4; ++i) { + painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); + painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); + painter.drawRect(0, i * 20, 80, 20); + } + comboBoxHotcueDefaultColor->setItemIcon(0, QIcon(pixmap)); + + for (int i = 0; i < palette.size(); ++i) { + comboBoxHotcueDefaultColor->addItem(tr("Palette") + + QStringLiteral(" ") + QString::number(i + 1), + i); + pixmap.fill(mixxx::RgbColor::toQColor(palette.at(i))); + comboBoxHotcueDefaultColor->setItemIcon(i + 1, QIcon(pixmap)); + } + + bool autoHotcueColors = + m_pConfig->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false); + if (autoHotcueColors) { + comboBoxHotcueDefaultColor->setCurrentIndex(0); + } else { + int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), kHotcueDefaultColorIndex); + if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= palette.size()) { + hotcueDefaultColorIndex = palette.size() - 1; // default to last color (orange) + } + comboBoxHotcueDefaultColor->setCurrentIndex(hotcueDefaultColorIndex + 1); + } +} diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index 9feb41a873b..fb77d862d3b 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -22,9 +22,14 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { signals: void apply(const QString&); + private slots: + void slotTrackPaletteChanged(const QString& palette); + void slotHotcuePaletteChanged(const QString& palette); + private: void loadSettings(); void loadPaletteIntoEditor(const ColorPalette& palette); + QPixmap drawPalettePreview(const QString& paletteName); const UserSettingsPointer m_pConfig; ColorPaletteSettings m_colorPaletteSettings; diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index 3f053f56275..023567dbc7d 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -26,14 +26,21 @@ Colors - + + + + Hotcue Palette + + + + Hotcue palette - + @@ -43,7 +50,7 @@ - + Hotcue default color @@ -67,9 +74,16 @@ - + + + + + Track Palette + + + From b4d3fa54fad8a4302698d4d1819a087ce17519c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 15:47:10 +0100 Subject: [PATCH 08/42] Fix default default hotcue selection --- src/preferences/dialog/dlgprefcolors.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 9cce1909c11..cc4948cd099 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -83,7 +83,8 @@ void DlgPrefColors::slotResetToDefaults() { mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette.getName()); comboBoxTrackColors->setCurrentText( mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette.getName()); - comboBoxHotcueDefaultColor->setCurrentIndex(1); + comboBoxHotcueDefaultColor->setCurrentIndex( + mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette.size()); slotApply(); } @@ -156,7 +157,7 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { QPixmap preview = drawPalettePreview(paletteName); labelHotcuePalette->setPixmap(preview); - ColorPalette palette = mixxx::PredefinedColorPalettes::kPalettes[0]; + ColorPalette palette = mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette; foreach (const ColorPalette& pal, mixxx::PredefinedColorPalettes::kPalettes) { if (paletteName == pal.getName()) { palette = pal; From 04ed4681ccfe11de082a57964641d58eb2fdf85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 22:03:33 +0100 Subject: [PATCH 09/42] Revert "Fill table with assigned cue numbers if no cue numbers are set" This reverts commit 30aaea8a51e98dd242848c0a46f12f53c59c3c65. --- src/preferences/colorpaletteeditormodel.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/preferences/colorpaletteeditormodel.cpp b/src/preferences/colorpaletteeditormodel.cpp index 9335edd13b5..62d958fbe16 100644 --- a/src/preferences/colorpaletteeditormodel.cpp +++ b/src/preferences/colorpaletteeditormodel.cpp @@ -103,15 +103,9 @@ void ColorPaletteEditorModel::setColorPalette(const ColorPalette& palette) { // Make a map of hotcue indices QMap hotcueColorIndicesMap; QList hotcueColorIndices = palette.getHotcueIndices(); - if (hotcueColorIndices.size()) { - for (int i = 0; i < hotcueColorIndices.size(); i++) { - int colorIndex = hotcueColorIndices.at(i); - hotcueColorIndicesMap.insert(colorIndex, i); - } - } else { - for (int i = 0; i < palette.size(); i++) { - hotcueColorIndicesMap.insert(i, i); - } + for (int i = 0; i < hotcueColorIndices.size(); i++) { + int colorIndex = hotcueColorIndices.at(i); + hotcueColorIndicesMap.insert(colorIndex, i); } for (int i = 0; i < palette.size(); i++) { From a171d135db334c493155987f9d87911186b28ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 22:10:43 +0100 Subject: [PATCH 10/42] Improve the labels of the colors in the combobox --- src/preferences/dialog/dlgprefcolors.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index cc4948cd099..586d6b9ff9d 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -180,10 +180,15 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->setItemIcon(0, QIcon(pixmap)); for (int i = 0; i < palette.size(); ++i) { - comboBoxHotcueDefaultColor->addItem(tr("Palette") + - QStringLiteral(" ") + QString::number(i + 1), + QColor color = mixxx::RgbColor::toQColor(palette.at(i)); + comboBoxHotcueDefaultColor->addItem( + tr("Color") + + QStringLiteral(" ") + + QString::number(i + 1) + + QStringLiteral(": ") + + color.name(), i); - pixmap.fill(mixxx::RgbColor::toQColor(palette.at(i))); + pixmap.fill(color); comboBoxHotcueDefaultColor->setItemIcon(i + 1, QIcon(pixmap)); } From 68742d99617b9eda1edd43bffb38c93c579fa4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 23:04:43 +0100 Subject: [PATCH 11/42] introduce getHotcueColorPalette(const QString&) and make use of it. --- src/preferences/colorpalettesettings.cpp | 18 +++++++++-- src/preferences/colorpalettesettings.h | 6 +++- src/preferences/dialog/dlgprefcolors.cpp | 40 ++++++++++-------------- src/util/color/colorpalette.h | 5 ++- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/preferences/colorpalettesettings.cpp b/src/preferences/colorpalettesettings.cpp index fed31b32743..1b01ca9973b 100644 --- a/src/preferences/colorpalettesettings.cpp +++ b/src/preferences/colorpalettesettings.cpp @@ -110,7 +110,14 @@ void ColorPaletteSettings::removePalette(const QString& name) { ColorPalette ColorPaletteSettings::getHotcueColorPalette() const { QString name = m_pConfig->getValueString(kHotcueColorPaletteConfigKey); - return getColorPalette(name, mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette); + return getHotcueColorPalette(name); +} + +ColorPalette ColorPaletteSettings::getHotcueColorPalette( + const QString& name) const { + return getColorPalette( + name, + mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette); } void ColorPaletteSettings::setHotcueColorPalette(const ColorPalette& colorPalette) { @@ -123,9 +130,16 @@ void ColorPaletteSettings::setHotcueColorPalette(const ColorPalette& colorPalett setColorPalette(name, colorPalette); } +ColorPalette ColorPaletteSettings::getTrackColorPalette( + const QString& name) const { + return getColorPalette( + name, + mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette); +} + ColorPalette ColorPaletteSettings::getTrackColorPalette() const { QString name = m_pConfig->getValueString(kTrackColorPaletteConfigKey); - return getColorPalette(name, mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette); + return getTrackColorPalette(name); } void ColorPaletteSettings::setTrackColorPalette(const ColorPalette& colorPalette) { diff --git a/src/preferences/colorpalettesettings.h b/src/preferences/colorpalettesettings.h index 39ce03e49e1..3816073f744 100644 --- a/src/preferences/colorpalettesettings.h +++ b/src/preferences/colorpalettesettings.h @@ -9,13 +9,17 @@ class ColorPaletteSettings { : m_pConfig(pConfig) { } + ColorPalette getHotcueColorPalette(const QString& name) const; ColorPalette getHotcueColorPalette() const; void setHotcueColorPalette(const ColorPalette& colorPalette); + ColorPalette getTrackColorPalette(const QString& name) const; ColorPalette getTrackColorPalette() const; void setTrackColorPalette(const ColorPalette& colorPalette); - ColorPalette getColorPalette(const QString& name, const ColorPalette& defaultPalette) const; + ColorPalette getColorPalette( + const QString& name, + const ColorPalette& defaultPalette) const; void setColorPalette(const QString& name, const ColorPalette& colorPalette); void removePalette(const QString& name); QSet getColorPaletteNames() const; diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 586d6b9ff9d..de37ec7e605 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -53,13 +53,13 @@ DlgPrefColors::~DlgPrefColors() { void DlgPrefColors::loadSettings() { comboBoxHotcueColors->clear(); comboBoxTrackColors->clear(); - foreach (const ColorPalette& palette, mixxx::PredefinedColorPalettes::kPalettes) { + for (const auto& palette : qAsConst(mixxx::PredefinedColorPalettes::kPalettes)) { QString paletteName = palette.getName(); comboBoxHotcueColors->addItem(paletteName); comboBoxTrackColors->addItem(paletteName); } - foreach (const QString& paletteName, m_colorPaletteSettings.getColorPaletteNames()) { + for (const auto& paletteName : m_colorPaletteSettings.getColorPaletteNames()) { comboBoxHotcueColors->addItem(paletteName); comboBoxTrackColors->addItem(paletteName); } @@ -95,7 +95,7 @@ void DlgPrefColors::slotApply() { bool bHotcueColorPaletteFound = false; bool bTrackColorPaletteFound = false; - foreach (const ColorPalette& palette, mixxx::PredefinedColorPalettes::kPalettes) { + for (const auto& palette : qAsConst(mixxx::PredefinedColorPalettes::kPalettes)) { if (!bHotcueColorPaletteFound && hotcueColorPaletteName == palette.getName()) { m_colorPaletteSettings.setHotcueColorPalette(palette); bHotcueColorPaletteFound = true; @@ -130,20 +130,19 @@ void DlgPrefColors::slotApply() { } QPixmap DlgPrefColors::drawPalettePreview(const QString& paletteName) { - foreach (const ColorPalette& palette, mixxx::PredefinedColorPalettes::kPalettes) { - if (paletteName == palette.getName()) { - int count = math_max(palette.size(), 1); - int width = math_min((200 / count), 16); - QPixmap pixmap(count * width, 16); - pixmap.fill(Qt::black); - QPainter painter(&pixmap); - for (int i = 0; i < palette.size(); ++i) { - painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); - painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); - painter.drawRect(i * width, 0, width, 16); - } - return pixmap; + ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); + if (paletteName == palette.getName()) { + int count = math_max(palette.size(), 1); + int width = math_min((200 / count), 16); + QPixmap pixmap(count * width, 16); + pixmap.fill(Qt::black); + QPainter painter(&pixmap); + for (int i = 0; i < palette.size(); ++i) { + painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); + painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); + painter.drawRect(i * width, 0, width, 16); } + return pixmap; } return QPixmap(); } @@ -157,13 +156,8 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { QPixmap preview = drawPalettePreview(paletteName); labelHotcuePalette->setPixmap(preview); - ColorPalette palette = mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette; - foreach (const ColorPalette& pal, mixxx::PredefinedColorPalettes::kPalettes) { - if (paletteName == pal.getName()) { - palette = pal; - break; - } - } + ColorPalette palette = + m_colorPaletteSettings.getHotcueColorPalette(paletteName); comboBoxHotcueDefaultColor->clear(); diff --git a/src/util/color/colorpalette.h b/src/util/color/colorpalette.h index 1354df10af7..410f9542af3 100644 --- a/src/util/color/colorpalette.h +++ b/src/util/color/colorpalette.h @@ -6,7 +6,10 @@ class ColorPalette final { public: - explicit ColorPalette(QString name, QList colorList, QList hotcueColorIndices = {}) + ColorPalette( + QString name, + QList colorList, + QList hotcueColorIndices = {}) : m_name(name), m_colorList(colorList), m_hotcueColorIndices(hotcueColorIndices) { From f9714bbe6100fa046d9cbd2c52fba40ab8febd3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 24 Mar 2020 23:48:45 +0100 Subject: [PATCH 12/42] Added Icons to the palette select boxes --- src/preferences/dialog/dlgprefcolors.cpp | 45 ++++++++++++++++++------ src/preferences/dialog/dlgprefcolors.h | 1 + 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index de37ec7e605..12bfb81cd1a 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -55,13 +55,28 @@ void DlgPrefColors::loadSettings() { comboBoxTrackColors->clear(); for (const auto& palette : qAsConst(mixxx::PredefinedColorPalettes::kPalettes)) { QString paletteName = palette.getName(); + QIcon paletteIcon = drawPaletteIcon(paletteName); comboBoxHotcueColors->addItem(paletteName); + comboBoxHotcueColors->setItemIcon( + comboBoxHotcueColors->count() - 1, + paletteIcon); + comboBoxTrackColors->addItem(paletteName); + comboBoxTrackColors->setItemIcon( + comboBoxTrackColors->count() - 1, + paletteIcon); } for (const auto& paletteName : m_colorPaletteSettings.getColorPaletteNames()) { + QIcon paletteIcon = drawPaletteIcon(paletteName); comboBoxHotcueColors->addItem(paletteName); + comboBoxHotcueColors->setItemIcon( + comboBoxHotcueColors->count() - 1, + paletteIcon); comboBoxTrackColors->addItem(paletteName); + comboBoxTrackColors->setItemIcon( + comboBoxHotcueColors->count() - 1, + paletteIcon); } const ColorPalette hotcuePalette = @@ -147,6 +162,23 @@ QPixmap DlgPrefColors::drawPalettePreview(const QString& paletteName) { return QPixmap(); } +QIcon DlgPrefColors::drawPaletteIcon(const QString& paletteName) { + QPixmap pixmap(16, 16); + QPainter painter(&pixmap); + pixmap.fill(Qt::black); + + ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); + if (paletteName == palette.getName()) { + for (int i = 0; i < palette.size() && i < 4; ++i) { + painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); + painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); + painter.drawRect(0, i * 4, 16, 4); + } + return QIcon(pixmap); + } + return QIcon(); +} + void DlgPrefColors::slotTrackPaletteChanged(const QString& paletteName) { QPixmap pixmap = drawPalettePreview(paletteName); labelTrackPalette->setPixmap(pixmap); @@ -161,18 +193,11 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->clear(); - QPixmap pixmap(80, 80); - QPainter painter(&pixmap); - pixmap.fill(Qt::black); - comboBoxHotcueDefaultColor->addItem(tr("By hotcue number"), -1); - for (int i = 0; i < palette.size() && i < 4; ++i) { - painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); - painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); - painter.drawRect(0, i * 20, 80, 20); - } - comboBoxHotcueDefaultColor->setItemIcon(0, QIcon(pixmap)); + QIcon icon = drawPaletteIcon(paletteName); + comboBoxHotcueDefaultColor->setItemIcon(0, icon); + QPixmap pixmap(16, 16); for (int i = 0; i < palette.size(); ++i) { QColor color = mixxx::RgbColor::toQColor(palette.at(i)); comboBoxHotcueDefaultColor->addItem( diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index fb77d862d3b..5ced4c710cf 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -30,6 +30,7 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { void loadSettings(); void loadPaletteIntoEditor(const ColorPalette& palette); QPixmap drawPalettePreview(const QString& paletteName); + QIcon drawPaletteIcon(const QString& paletteName); const UserSettingsPointer m_pConfig; ColorPaletteSettings m_colorPaletteSettings; From 539d4daadf499cd5d750e75bd01b0163ec215458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 25 Mar 2020 00:20:20 +0100 Subject: [PATCH 13/42] Limit auto color asignment to 8 --- src/util/color/colorpalette.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/color/colorpalette.cpp b/src/util/color/colorpalette.cpp index f5ff71be249..d6d57b15e6f 100644 --- a/src/util/color/colorpalette.cpp +++ b/src/util/color/colorpalette.cpp @@ -20,7 +20,8 @@ mixxx::RgbColor ColorPalette::colorForHotcueIndex(unsigned int hotcueIndex) cons int colorIndex; if (m_hotcueColorIndices.isEmpty()) { // For hotcue n, get nth color from palette - colorIndex = hotcueIndex; + // But use only 8 to avoid odd apearances on Hercules P32 or similar + colorIndex = hotcueIndex % 8; } else { // For hotcue n, get nth color from palette colorIndex = m_hotcueColorIndices.at(hotcueIndex % m_hotcueColorIndices.size()); From 7b151703f49a7f54c000b4ee073f73acf78d7de5 Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 24 Mar 2020 21:42:41 -0500 Subject: [PATCH 14/42] DlgPrefColors: use full palette preview for icons in comboboxes --- src/preferences/dialog/dlgprefcolors.cpp | 19 +++++----- src/preferences/dialog/dlgprefcolorsdlg.ui | 42 ++++++++-------------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 12bfb81cd1a..cca242c7f43 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -13,6 +13,7 @@ namespace { constexpr int kHotcueDefaultColorIndex = -1; +constexpr QSize kPalettePreviewSize = QSize(200, 16); } // anonymous namespace @@ -23,6 +24,8 @@ DlgPrefColors::DlgPrefColors( m_colorPaletteSettings(ColorPaletteSettings(pConfig)) { setupUi(this); colorPaletteEditor->initialize(pConfig); + comboBoxHotcueColors->setIconSize(kPalettePreviewSize); + comboBoxTrackColors->setIconSize(kPalettePreviewSize); loadSettings(); @@ -55,7 +58,7 @@ void DlgPrefColors::loadSettings() { comboBoxTrackColors->clear(); for (const auto& palette : qAsConst(mixxx::PredefinedColorPalettes::kPalettes)) { QString paletteName = palette.getName(); - QIcon paletteIcon = drawPaletteIcon(paletteName); + QIcon paletteIcon = drawPalettePreview(paletteName); comboBoxHotcueColors->addItem(paletteName); comboBoxHotcueColors->setItemIcon( comboBoxHotcueColors->count() - 1, @@ -68,7 +71,7 @@ void DlgPrefColors::loadSettings() { } for (const auto& paletteName : m_colorPaletteSettings.getColorPaletteNames()) { - QIcon paletteIcon = drawPaletteIcon(paletteName); + QIcon paletteIcon = drawPalettePreview(paletteName); comboBoxHotcueColors->addItem(paletteName); comboBoxHotcueColors->setItemIcon( comboBoxHotcueColors->count() - 1, @@ -147,15 +150,15 @@ void DlgPrefColors::slotApply() { QPixmap DlgPrefColors::drawPalettePreview(const QString& paletteName) { ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); if (paletteName == palette.getName()) { + QPixmap pixmap(kPalettePreviewSize); int count = math_max(palette.size(), 1); - int width = math_min((200 / count), 16); - QPixmap pixmap(count * width, 16); + int widthPerColor = pixmap.width() / count; pixmap.fill(Qt::black); QPainter painter(&pixmap); for (int i = 0; i < palette.size(); ++i) { painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); - painter.drawRect(i * width, 0, width, 16); + painter.drawRect(i * widthPerColor, 0, widthPerColor, pixmap.height()); } return pixmap; } @@ -180,14 +183,10 @@ QIcon DlgPrefColors::drawPaletteIcon(const QString& paletteName) { } void DlgPrefColors::slotTrackPaletteChanged(const QString& paletteName) { - QPixmap pixmap = drawPalettePreview(paletteName); - labelTrackPalette->setPixmap(pixmap); + Q_UNUSED(paletteName); } void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { - QPixmap preview = drawPalettePreview(paletteName); - labelHotcuePalette->setPixmap(preview); - ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index 023567dbc7d..5e621e0780a 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -26,14 +26,7 @@ Colors - - - - Hotcue Palette - - - - + Hotcue palette @@ -41,21 +34,7 @@ - - - - 0 - 0 - - - - - - - - Hotcue default color - - + @@ -74,13 +53,20 @@ - - + + + + Hotcue default color + + - - - Track Palette + + + + 0 + 0 + From 5d4321f037d3db020a8641813d6b1db321020503 Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 24 Mar 2020 22:21:11 -0500 Subject: [PATCH 15/42] limit default hotcue palette to 8 colors --- src/util/color/colorpalette.cpp | 5 +---- src/util/color/predefinedcolorpalettes.cpp | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/color/colorpalette.cpp b/src/util/color/colorpalette.cpp index d6d57b15e6f..0e6dd4286b4 100644 --- a/src/util/color/colorpalette.cpp +++ b/src/util/color/colorpalette.cpp @@ -19,11 +19,8 @@ mixxx::RgbColor ColorPalette::previousColor(mixxx::RgbColor color) const { mixxx::RgbColor ColorPalette::colorForHotcueIndex(unsigned int hotcueIndex) const { int colorIndex; if (m_hotcueColorIndices.isEmpty()) { - // For hotcue n, get nth color from palette - // But use only 8 to avoid odd apearances on Hercules P32 or similar - colorIndex = hotcueIndex % 8; + colorIndex = hotcueIndex; } else { - // For hotcue n, get nth color from palette colorIndex = m_hotcueColorIndices.at(hotcueIndex % m_hotcueColorIndices.size()); } return at(colorIndex % size()); diff --git a/src/util/color/predefinedcolorpalettes.cpp b/src/util/color/predefinedcolorpalettes.cpp index 26d59f5eccb..7dabeb4273d 100644 --- a/src/util/color/predefinedcolorpalettes.cpp +++ b/src/util/color/predefinedcolorpalettes.cpp @@ -123,7 +123,11 @@ const ColorPalette PredefinedColorPalettes::kMixxxHotcueColorPalette = kColorMixxxPink, kColorMixxxWhite, kSchemaMigrationReplacementColor, - }); + }, + // Exclude kSchemaMigrationReplacementColor from the colors assigned to hotcues. + // If there were 9 colors assigned to hotcues, that would look weird on + // controllers with >8 hotcue buttons, for example a Novation Launchpad. + QList{0, 1, 2, 3, 4, 5, 6, 7}); const ColorPalette PredefinedColorPalettes::kSeratoDJIntroHotcueColorPalette = ColorPalette( From edc4af63551a672c94d8c72c7edddb1e83e44d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 26 Mar 2020 21:34:43 +0100 Subject: [PATCH 16/42] Rename Intro Palette to Track Metadata und remove it from the user available list. --- src/util/color/predefinedcolorpalettes.cpp | 83 +++++++++++----------- src/util/color/predefinedcolorpalettes.h | 2 +- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/util/color/predefinedcolorpalettes.cpp b/src/util/color/predefinedcolorpalettes.cpp index 26d59f5eccb..4a5a9ac7048 100644 --- a/src/util/color/predefinedcolorpalettes.cpp +++ b/src/util/color/predefinedcolorpalettes.cpp @@ -31,25 +31,28 @@ constexpr mixxx::RgbColor kTraktorProTrackColorBlue(0x0187FF); constexpr mixxx::RgbColor kTraktorProTrackColorViolet(0xA669FF); constexpr mixxx::RgbColor kTraktorProTrackColorMagenta(0xFE55EA); -// Serato DJ Intro Hotcue Color Palette -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorRed(0xCC0000); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorOrange(0xCC4400); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorBrown(0xCC8800); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorYellow(0xCCCC00); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorEmerald(0x88CC00); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorKelly(0x44CC00); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorGreen(0x00CC00); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorSea(0x00CC44); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorJade(0x00CC88); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorTurquoise(0x00CCCC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorTeal(0x0088CC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorBlue(0x0044CC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorDarkBlue(0x0000CC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorViolet(0x4400CC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorPurple(0x8800CC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorFuchsia(0xCC00CC); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorMagenta(0xCC0088); -constexpr mixxx::RgbColor kSeratoDJIntroHotcueColorCarmine(0xCC0044); +// Serato Track Metadata Hotcue Color Palette +// The Serato DJ Pro hotcue colors, shown in the GUI, are stored as these +// colors into the Serato's file metadata. +// Original these colors where shown in the obsolete Serato DJ Intro. +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorRed(0xCC0000); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorOrange(0xCC4400); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorBrown(0xCC8800); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorYellow(0xCCCC00); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorEmerald(0x88CC00); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorKelly(0x44CC00); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorGreen(0x00CC00); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorSea(0x00CC44); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorJade(0x00CC88); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorTurquoise(0x00CCCC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorTeal(0x0088CC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorBlue(0x0044CC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorDarkBlue(0x0000CC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorViolet(0x4400CC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorPurple(0x8800CC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorFuchsia(0xCC00CC); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorMagenta(0xCC0088); +constexpr mixxx::RgbColor kSeratoTrackMetadataHotcueColorCarmine(0xCC0044); // Serato DJ Pro Hotcue Color Palette constexpr mixxx::RgbColor kSeratoDJProHotcueColorRed1(0xC02626); @@ -125,28 +128,28 @@ const ColorPalette PredefinedColorPalettes::kMixxxHotcueColorPalette = kSchemaMigrationReplacementColor, }); -const ColorPalette PredefinedColorPalettes::kSeratoDJIntroHotcueColorPalette = +const ColorPalette PredefinedColorPalettes::kSeratoTrackMetadataHotcueColorPalette = ColorPalette( - QStringLiteral("Serato DJ Intro Hotcue Colors"), + QStringLiteral("Serato DJ Track Metadata Hotcue Colors"), QList{ - kSeratoDJIntroHotcueColorRed, - kSeratoDJIntroHotcueColorOrange, - kSeratoDJIntroHotcueColorBrown, - kSeratoDJIntroHotcueColorYellow, - kSeratoDJIntroHotcueColorEmerald, - kSeratoDJIntroHotcueColorKelly, - kSeratoDJIntroHotcueColorGreen, - kSeratoDJIntroHotcueColorSea, - kSeratoDJIntroHotcueColorJade, - kSeratoDJIntroHotcueColorTurquoise, - kSeratoDJIntroHotcueColorTeal, - kSeratoDJIntroHotcueColorBlue, - kSeratoDJIntroHotcueColorDarkBlue, - kSeratoDJIntroHotcueColorViolet, - kSeratoDJIntroHotcueColorPurple, - kSeratoDJIntroHotcueColorFuchsia, - kSeratoDJIntroHotcueColorMagenta, - kSeratoDJIntroHotcueColorCarmine, + kSeratoTrackMetadataHotcueColorRed, + kSeratoTrackMetadataHotcueColorOrange, + kSeratoTrackMetadataHotcueColorBrown, + kSeratoTrackMetadataHotcueColorYellow, + kSeratoTrackMetadataHotcueColorEmerald, + kSeratoTrackMetadataHotcueColorKelly, + kSeratoTrackMetadataHotcueColorGreen, + kSeratoTrackMetadataHotcueColorSea, + kSeratoTrackMetadataHotcueColorJade, + kSeratoTrackMetadataHotcueColorTurquoise, + kSeratoTrackMetadataHotcueColorTeal, + kSeratoTrackMetadataHotcueColorBlue, + kSeratoTrackMetadataHotcueColorDarkBlue, + kSeratoTrackMetadataHotcueColorViolet, + kSeratoTrackMetadataHotcueColorPurple, + kSeratoTrackMetadataHotcueColorFuchsia, + kSeratoTrackMetadataHotcueColorMagenta, + kSeratoTrackMetadataHotcueColorCarmine, }, QList{0, 2, 12, 3, 6, 15, 9, 14}); @@ -251,8 +254,6 @@ const QList PredefinedColorPalettes::kPalettes{ // Hotcue Color Palettes mixxx::PredefinedColorPalettes::kMixxxHotcueColorPalette, mixxx::PredefinedColorPalettes::kSeratoDJProHotcueColorPalette, - mixxx::PredefinedColorPalettes::kSeratoDJIntroHotcueColorPalette, - // Track Color Palettes mixxx::PredefinedColorPalettes::kRekordboxTrackColorPalette, mixxx::PredefinedColorPalettes::kSeratoDJProTrackColorPalette, diff --git a/src/util/color/predefinedcolorpalettes.h b/src/util/color/predefinedcolorpalettes.h index a1f910fc3be..87deb01f2f7 100644 --- a/src/util/color/predefinedcolorpalettes.h +++ b/src/util/color/predefinedcolorpalettes.h @@ -6,7 +6,7 @@ namespace mixxx { class PredefinedColorPalettes { public: static const ColorPalette kMixxxHotcueColorPalette; - static const ColorPalette kSeratoDJIntroHotcueColorPalette; + static const ColorPalette kSeratoTrackMetadataHotcueColorPalette; static const ColorPalette kSeratoDJProHotcueColorPalette; static const ColorPalette kRekordboxTrackColorPalette; From 3ab4f6372d38f7cd69d17f0adf246336c827dc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 26 Mar 2020 23:03:20 +0100 Subject: [PATCH 17/42] Inital hide the palette editor --- src/preferences/colorpaletteeditor.cpp | 13 ++++++----- src/preferences/colorpaletteeditor.h | 6 ++++-- src/preferences/dialog/dlgprefcolors.cpp | 25 ++++++++++++++++++++++ src/preferences/dialog/dlgprefcolors.h | 2 ++ src/preferences/dialog/dlgprefcolorsdlg.ui | 24 +++++++++++++++++++++ 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 24c7333f2d7..6e89c14f00d 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -28,7 +28,7 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) QDialogButtonBox* pButtonBox = new QDialogButtonBox(); m_pSaveButton = pButtonBox->addButton(QDialogButtonBox::Save); m_pResetButton = pButtonBox->addButton(QDialogButtonBox::Reset); - m_pDiscardButton = pButtonBox->addButton(QDialogButtonBox::Discard); + m_pCloseButton = pButtonBox->addButton(QDialogButtonBox::Close); QHBoxLayout* pTopLayout = new QHBoxLayout(); pTopLayout->addWidget(new QLabel(tr("Name"))); @@ -84,10 +84,10 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &QPushButton::clicked, this, &ColorPaletteEditor::slotResetButtonClicked); - connect(m_pDiscardButton, + connect(m_pCloseButton, &QPushButton::clicked, this, - &ColorPaletteEditor::slotDiscardButtonClicked); + &ColorPaletteEditor::slotCloseButtonClicked); connect(m_pSaveButton, &QPushButton::clicked, this, @@ -117,7 +117,6 @@ void ColorPaletteEditor::slotUpdateButtons() { bool bEmpty = m_pModel->isEmpty(); m_pResetButton->setEnabled(bDirty); m_pSaveButton->setEnabled(!m_bPaletteExists || (!m_bPaletteIsReadOnly && bDirty && !bEmpty)); - m_pDiscardButton->setEnabled(m_bPaletteExists && !m_bPaletteIsReadOnly); } void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { @@ -187,7 +186,11 @@ void ColorPaletteEditor::slotPaletteNameChanged(const QString& text) { slotUpdateButtons(); } -void ColorPaletteEditor::slotDiscardButtonClicked() { +void ColorPaletteEditor::slotCloseButtonClicked() { + emit closeButtonClicked(); +} + +void ColorPaletteEditor::slotRemoveButtonClicked() { QString paletteName = m_pPaletteNameComboBox->currentText(); ColorPaletteSettings colorPaletteSettings(m_pConfig); colorPaletteSettings.removePalette(paletteName); diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 9786c10b592..4da688b96ac 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -21,15 +21,17 @@ class ColorPaletteEditor : public QWidget { signals: void paletteChanged(QString name); void paletteRemoved(QString name); + void closeButtonClicked(); private slots: void slotUpdateButtons(); void slotTableViewDoubleClicked(const QModelIndex& index); void slotTableViewContextMenuRequested(const QPoint& pos); void slotPaletteNameChanged(const QString& text); - void slotDiscardButtonClicked(); + void slotCloseButtonClicked(); void slotSaveButtonClicked(); void slotResetButtonClicked(); + void slotRemoveButtonClicked(); private: bool m_bPaletteExists; @@ -40,6 +42,6 @@ class ColorPaletteEditor : public QWidget { parented_ptr m_pTableView; parented_ptr m_pModel; QPushButton* m_pSaveButton; - QPushButton* m_pDiscardButton; + QPushButton* m_pCloseButton; QPushButton* m_pResetButton; }; diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 12bfb81cd1a..d2573ef8fee 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -24,6 +24,8 @@ DlgPrefColors::DlgPrefColors( setupUi(this); colorPaletteEditor->initialize(pConfig); + groupBoxPaletteEditor->hide(); + loadSettings(); connect(colorPaletteEditor, @@ -34,6 +36,10 @@ DlgPrefColors::DlgPrefColors( &ColorPaletteEditor::paletteRemoved, this, &DlgPrefColors::loadSettings); + connect(colorPaletteEditor, + &ColorPaletteEditor::closeButtonClicked, + this, + &DlgPrefColors::slotCloseClicked); connect(comboBoxTrackColors, QOverload::of(&QComboBox::currentIndexChanged), @@ -44,6 +50,11 @@ DlgPrefColors::DlgPrefColors( QOverload::of(&QComboBox::currentIndexChanged), this, &DlgPrefColors::slotHotcuePaletteChanged); + + connect(pushButtonEdit, + &QPushButton::clicked, + this, + &DlgPrefColors::slotEditClicked); } DlgPrefColors::~DlgPrefColors() { @@ -223,3 +234,17 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->setCurrentIndex(hotcueDefaultColorIndex + 1); } } + +void DlgPrefColors::slotEditClicked() { + pushButtonEdit->hide(); + labelCustomPalette->hide(); + widgetSpacer->hide(); + groupBoxPaletteEditor->show(); +} + +void DlgPrefColors::slotCloseClicked() { + groupBoxPaletteEditor->hide(); + widgetSpacer->show(); + pushButtonEdit->show(); + labelCustomPalette->show(); +} diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index 5ced4c710cf..09a42b26fc2 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -18,6 +18,8 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { // Apply changes to widget void slotApply(); void slotResetToDefaults(); + void slotEditClicked(); + void slotCloseClicked(); signals: void apply(const QString&); diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index 023567dbc7d..7f3a6dd6884 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -84,6 +84,30 @@ + + + + Custom palettes + + + + + + + Edit + + + + + + + + 0 + 20 + + + + From 5cb7e2f375a0e7649a9f06b571be928f20d11c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 27 Mar 2020 00:29:09 +0100 Subject: [PATCH 18/42] Split Save as and Template Combobox --- src/preferences/colorpaletteeditor.cpp | 79 ++++++++++++++++---------- src/preferences/colorpaletteeditor.h | 6 +- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 6e89c14f00d..2cc0b709e39 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -20,23 +20,34 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) : QWidget(parent), m_bPaletteExists(false), m_bPaletteIsReadOnly(false), - m_pPaletteNameComboBox(make_parented()), + m_pPaletteTemplateComboBox(make_parented()), + m_pSaveAsComboBox(make_parented()), m_pTableView(make_parented()), m_pModel(make_parented(m_pTableView)) { - m_pPaletteNameComboBox->setEditable(true); + m_pSaveAsComboBox->setEditable(true); + + m_pResetButton = make_parented(tr("Reset"), this); QDialogButtonBox* pButtonBox = new QDialogButtonBox(); + m_pRemoveButton = pButtonBox->addButton( + tr("Remove Palette"), + QDialogButtonBox::DestructiveRole); m_pSaveButton = pButtonBox->addButton(QDialogButtonBox::Save); - m_pResetButton = pButtonBox->addButton(QDialogButtonBox::Reset); m_pCloseButton = pButtonBox->addButton(QDialogButtonBox::Close); QHBoxLayout* pTopLayout = new QHBoxLayout(); pTopLayout->addWidget(new QLabel(tr("Name"))); - pTopLayout->addWidget(m_pPaletteNameComboBox, 1); + pTopLayout->addWidget(m_pSaveAsComboBox, 1); + + QHBoxLayout* pBottomLayout = new QHBoxLayout(); + pBottomLayout->addWidget(new QLabel(tr("Reset to"))); + pBottomLayout->addWidget(m_pPaletteTemplateComboBox, 1); + pBottomLayout->addWidget(m_pResetButton.get()); QVBoxLayout* pLayout = new QVBoxLayout(); pLayout->addLayout(pTopLayout); pLayout->addWidget(m_pTableView, 1); + pLayout->addLayout(pBottomLayout); pLayout->addWidget(pButtonBox); setLayout(pLayout); setContentsMargins(0, 0, 0, 0); @@ -76,7 +87,7 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &QTableView::customContextMenuRequested, this, &ColorPaletteEditor::slotTableViewContextMenuRequested); - connect(m_pPaletteNameComboBox, + connect(m_pSaveAsComboBox, &QComboBox::editTextChanged, this, &ColorPaletteEditor::slotPaletteNameChanged); @@ -92,6 +103,10 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &QPushButton::clicked, this, &ColorPaletteEditor::slotSaveButtonClicked); + connect(m_pRemoveButton, + &QPushButton::clicked, + this, + &ColorPaletteEditor::slotRemoveButtonClicked); } void ColorPaletteEditor::initialize(UserSettingsPointer pConfig) { @@ -101,22 +116,34 @@ void ColorPaletteEditor::initialize(UserSettingsPointer pConfig) { } void ColorPaletteEditor::reset() { - m_pPaletteNameComboBox->clear(); + m_pPaletteTemplateComboBox->clear(); + m_pSaveAsComboBox->clear(); + for (const ColorPalette& palette : mixxx::PredefinedColorPalettes::kPalettes) { - m_pPaletteNameComboBox->addItem(palette.getName()); + m_pPaletteTemplateComboBox->addItem(palette.getName()); } - m_pPaletteNameComboBox->insertSeparator(mixxx::PredefinedColorPalettes::kPalettes.size()); + ColorPaletteSettings colorPaletteSettings(m_pConfig); - for (const QString& paletteName : colorPaletteSettings.getColorPaletteNames()) { - m_pPaletteNameComboBox->addItem(paletteName); + if (colorPaletteSettings.getColorPaletteNames().count()) { + for (const QString& paletteName : colorPaletteSettings.getColorPaletteNames()) { + m_pSaveAsComboBox->addItem(paletteName); + m_pPaletteTemplateComboBox->addItem(paletteName); + } + } else { + m_pSaveAsComboBox->addItem(tr("Custom Color Palette")); + slotResetButtonClicked(); } } void ColorPaletteEditor::slotUpdateButtons() { bool bDirty = m_pModel->isDirty(); bool bEmpty = m_pModel->isEmpty(); - m_pResetButton->setEnabled(bDirty); - m_pSaveButton->setEnabled(!m_bPaletteExists || (!m_bPaletteIsReadOnly && bDirty && !bEmpty)); + m_pSaveButton->setEnabled( + !m_pSaveAsComboBox->currentText().isEmpty() && + (!m_bPaletteExists || (!m_bPaletteIsReadOnly && bDirty && !bEmpty))); + m_pRemoveButton->setEnabled( + m_bPaletteExists && + !m_bPaletteIsReadOnly); } void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { @@ -191,7 +218,7 @@ void ColorPaletteEditor::slotCloseButtonClicked() { } void ColorPaletteEditor::slotRemoveButtonClicked() { - QString paletteName = m_pPaletteNameComboBox->currentText(); + QString paletteName = m_pSaveAsComboBox->currentText(); ColorPaletteSettings colorPaletteSettings(m_pConfig); colorPaletteSettings.removePalette(paletteName); reset(); @@ -199,30 +226,22 @@ void ColorPaletteEditor::slotRemoveButtonClicked() { } void ColorPaletteEditor::slotSaveButtonClicked() { - QString paletteName = m_pPaletteNameComboBox->currentText(); + QString paletteName = m_pSaveAsComboBox->currentText(); ColorPaletteSettings colorPaletteSettings(m_pConfig); colorPaletteSettings.setColorPalette(paletteName, m_pModel->getColorPalette(paletteName)); m_pModel->setDirty(false); reset(); - m_pPaletteNameComboBox->setCurrentText(paletteName); + m_pSaveAsComboBox->setCurrentText(paletteName); emit paletteChanged(paletteName); } void ColorPaletteEditor::slotResetButtonClicked() { - QString paletteName = m_pPaletteNameComboBox->currentText(); + QString paletteName = m_pPaletteTemplateComboBox->currentText(); ColorPaletteSettings colorPaletteSettings(m_pConfig); - bool bPaletteExists = colorPaletteSettings.getColorPaletteNames().contains(paletteName); - if (!bPaletteExists) { - for (const ColorPalette& palette : mixxx::PredefinedColorPalettes::kPalettes) { - if (paletteName == palette.getName()) { - bPaletteExists = true; - break; - } - } - } - m_pModel->setDirty(false); - reset(); - if (bPaletteExists) { - m_pPaletteNameComboBox->setCurrentText(paletteName); - } + ColorPalette palette = colorPaletteSettings.getColorPalette( + paletteName, + mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette); + m_pModel->setColorPalette(palette); + m_pModel->setDirty(true); + slotUpdateButtons(); } diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 4da688b96ac..308154a1990 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -38,10 +38,12 @@ class ColorPaletteEditor : public QWidget { bool m_bPaletteIsReadOnly; UserSettingsPointer m_pConfig; - parented_ptr m_pPaletteNameComboBox; + parented_ptr m_pPaletteTemplateComboBox; + parented_ptr m_pSaveAsComboBox; parented_ptr m_pTableView; parented_ptr m_pModel; QPushButton* m_pSaveButton; QPushButton* m_pCloseButton; - QPushButton* m_pResetButton; + QPushButton* m_pRemoveButton; + parented_ptr(m_pResetButton); }; From b267a448a8958ba0fe8b331c2cd4072e2287adcd Mon Sep 17 00:00:00 2001 From: Be Date: Fri, 27 Mar 2020 10:19:12 -0500 Subject: [PATCH 19/42] DlgPrefColors: remove unused slotTrackPaletteChanged --- src/preferences/dialog/dlgprefcolors.cpp | 10 ---------- src/preferences/dialog/dlgprefcolors.h | 1 - 2 files changed, 11 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 4c1d1e16945..57fb727f813 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -44,11 +44,6 @@ DlgPrefColors::DlgPrefColors( this, &DlgPrefColors::slotCloseClicked); - connect(comboBoxTrackColors, - QOverload::of(&QComboBox::currentIndexChanged), - this, - &DlgPrefColors::slotTrackPaletteChanged); - connect(comboBoxHotcueColors, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -103,7 +98,6 @@ void DlgPrefColors::loadSettings() { m_colorPaletteSettings.getTrackColorPalette(); comboBoxTrackColors->setCurrentText( trackPalette.getName()); - slotTrackPaletteChanged(trackPalette.getName()); } // Set the default values for all the widgets @@ -193,10 +187,6 @@ QIcon DlgPrefColors::drawPaletteIcon(const QString& paletteName) { return QIcon(); } -void DlgPrefColors::slotTrackPaletteChanged(const QString& paletteName) { - Q_UNUSED(paletteName); -} - void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index 09a42b26fc2..e03b1bd7d8a 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -25,7 +25,6 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { void apply(const QString&); private slots: - void slotTrackPaletteChanged(const QString& palette); void slotHotcuePaletteChanged(const QString& palette); private: From 417601360ff47431e21e434ac62ba913379042cc Mon Sep 17 00:00:00 2001 From: Be Date: Fri, 27 Mar 2020 10:53:23 -0500 Subject: [PATCH 20/42] DlgPrefColors: fix black edge of palette preview pixmaps --- src/preferences/dialog/dlgprefcolors.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 57fb727f813..8bfe5ac1153 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -157,8 +157,8 @@ QPixmap DlgPrefColors::drawPalettePreview(const QString& paletteName) { if (paletteName == palette.getName()) { QPixmap pixmap(kPalettePreviewSize); int count = math_max(palette.size(), 1); - int widthPerColor = pixmap.width() / count; - pixmap.fill(Qt::black); + // Rounding up is required so the entire width of the pixmap is filled up to the edge. + int widthPerColor = ceil(pixmap.width() / static_cast(count)); QPainter painter(&pixmap); for (int i = 0; i < palette.size(); ++i) { painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); From fa3cac9aa0fce7e030536b002a70654f282b8268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 27 Mar 2020 22:19:19 +0100 Subject: [PATCH 21/42] Use small edit button with elipsis --- src/preferences/dialog/dlgprefcolorsdlg.ui | 73 ++++++++++++++-------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index 51d49776a42..2a27b65008e 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -33,9 +33,6 @@ - - - @@ -43,16 +40,6 @@ - - - - - 0 - 0 - - - - @@ -60,27 +47,17 @@ - - - - - 0 - 0 - - - - - + Custom palettes - + - Edit + Edit… @@ -89,9 +66,45 @@ 0 + 15 + + + + + + + + Qt::Horizontal + + + + 40 20 + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + @@ -100,7 +113,13 @@ - Palette Editor + Custom Palettes Editor + + + false + + + false From 089fc08aad13ace01f40e918f7fe7d38f04fb853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 27 Mar 2020 22:21:00 +0100 Subject: [PATCH 22/42] Remove superfluid parenthes --- src/preferences/colorpaletteeditor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 308154a1990..d70c36f747a 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -45,5 +45,5 @@ class ColorPaletteEditor : public QWidget { QPushButton* m_pSaveButton; QPushButton* m_pCloseButton; QPushButton* m_pRemoveButton; - parented_ptr(m_pResetButton); + parented_ptr m_pResetButton; }; From 61ecb244bcef99c8390137b1785856a1d1911c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 27 Mar 2020 22:59:19 +0100 Subject: [PATCH 23/42] Added message box when closing Palette Editor wit unsaved changes --- src/preferences/colorpaletteeditor.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 2cc0b709e39..f8eff4f3538 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -214,7 +215,21 @@ void ColorPaletteEditor::slotPaletteNameChanged(const QString& text) { } void ColorPaletteEditor::slotCloseButtonClicked() { - emit closeButtonClicked(); + if (m_pSaveButton->isEnabled()) { + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Custom Palettes Editor")); + msgBox.setText(tr( + "The custom palette is not saved.\n" + "Close anyway?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) { + emit closeButtonClicked(); + } + } else { + emit closeButtonClicked(); + } } void ColorPaletteEditor::slotRemoveButtonClicked() { From 37a57b7d81621aef1a33e429cdbf3b89c82e2340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 27 Mar 2020 23:18:38 +0100 Subject: [PATCH 24/42] Keep temoraray selections when updateding custom paletts --- src/preferences/dialog/dlgprefcolors.cpp | 16 ++++++++++++++-- src/preferences/dialog/dlgprefcolors.h | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 8bfe5ac1153..5eac89521ce 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -34,11 +34,11 @@ DlgPrefColors::DlgPrefColors( connect(colorPaletteEditor, &ColorPaletteEditor::paletteChanged, this, - &DlgPrefColors::loadSettings); + &DlgPrefColors::palettesUpdated); connect(colorPaletteEditor, &ColorPaletteEditor::paletteRemoved, this, - &DlgPrefColors::loadSettings); + &DlgPrefColors::palettesUpdated); connect(colorPaletteEditor, &ColorPaletteEditor::closeButtonClicked, this, @@ -237,3 +237,15 @@ void DlgPrefColors::slotCloseClicked() { pushButtonEdit->show(); labelCustomPalette->show(); } + +void DlgPrefColors::palettesUpdated() { + QString hotcueColors = comboBoxHotcueColors->currentText(); + QString trackColors = comboBoxTrackColors->currentText(); + int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); + + loadSettings(); + + comboBoxHotcueColors->setCurrentText(hotcueColors); + comboBoxTrackColors->setCurrentText(trackColors); + comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); +} diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index e03b1bd7d8a..01fe4d660db 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -26,9 +26,10 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { private slots: void slotHotcuePaletteChanged(const QString& palette); + void loadSettings(); + void palettesUpdated(); private: - void loadSettings(); void loadPaletteIntoEditor(const ColorPalette& palette); QPixmap drawPalettePreview(const QString& paletteName); QIcon drawPaletteIcon(const QString& paletteName); From 3d683152bbb3eda4b7da9a0acfab43c2b6e99ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 27 Mar 2020 23:28:18 +0100 Subject: [PATCH 25/42] Keep temorary selected default color after chanigng palette --- src/preferences/dialog/dlgprefcolors.cpp | 33 +++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 5eac89521ce..d76a525570d 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -88,16 +88,28 @@ void DlgPrefColors::loadSettings() { paletteIcon); } + const ColorPalette trackPalette = + m_colorPaletteSettings.getTrackColorPalette(); + comboBoxTrackColors->setCurrentText( + trackPalette.getName()); + const ColorPalette hotcuePalette = m_colorPaletteSettings.getHotcueColorPalette(); comboBoxHotcueColors->setCurrentText( hotcuePalette.getName()); slotHotcuePaletteChanged(hotcuePalette.getName()); - const ColorPalette trackPalette = - m_colorPaletteSettings.getTrackColorPalette(); - comboBoxTrackColors->setCurrentText( - trackPalette.getName()); + bool autoHotcueColors = + m_pConfig->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false); + if (autoHotcueColors) { + comboBoxHotcueDefaultColor->setCurrentIndex(0); + } else { + int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), kHotcueDefaultColorIndex); + if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcuePalette.size()) { + hotcueDefaultColorIndex = hotcuePalette.size() - 1; // default to last color (orange) + } + comboBoxHotcueDefaultColor->setCurrentIndex(hotcueDefaultColorIndex + 1); + } } // Set the default values for all the widgets @@ -191,6 +203,7 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); + int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); comboBoxHotcueDefaultColor->clear(); comboBoxHotcueDefaultColor->addItem(tr("By hotcue number"), -1); @@ -211,17 +224,7 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->setItemIcon(i + 1, QIcon(pixmap)); } - bool autoHotcueColors = - m_pConfig->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false); - if (autoHotcueColors) { - comboBoxHotcueDefaultColor->setCurrentIndex(0); - } else { - int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), kHotcueDefaultColorIndex); - if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= palette.size()) { - hotcueDefaultColorIndex = palette.size() - 1; // default to last color (orange) - } - comboBoxHotcueDefaultColor->setCurrentIndex(hotcueDefaultColorIndex + 1); - } + comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); } void DlgPrefColors::slotEditClicked() { From 73ee2640803e58c395bc5325dc0c68981cfd3202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 28 Mar 2020 00:16:46 +0100 Subject: [PATCH 26/42] Improve gray out state of save and reset button --- src/preferences/colorpaletteeditor.cpp | 21 +++++++++++++++++++-- src/preferences/colorpaletteeditor.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index f8eff4f3538..717e158693b 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -89,9 +89,13 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) this, &ColorPaletteEditor::slotTableViewContextMenuRequested); connect(m_pSaveAsComboBox, - &QComboBox::editTextChanged, + &QComboBox::currentTextChanged, this, &ColorPaletteEditor::slotPaletteNameChanged); + connect(m_pPaletteTemplateComboBox, + &QComboBox::currentTextChanged, + this, + &ColorPaletteEditor::slotUpdateButtons); connect(m_pResetButton, &QPushButton::clicked, this, @@ -130,6 +134,9 @@ void ColorPaletteEditor::reset() { m_pSaveAsComboBox->addItem(paletteName); m_pPaletteTemplateComboBox->addItem(paletteName); } + QString current = m_pSaveAsComboBox->currentText(); + m_pPaletteTemplateComboBox->setCurrentText(current); + m_resetedPalette = current; } else { m_pSaveAsComboBox->addItem(tr("Custom Color Palette")); slotResetButtonClicked(); @@ -145,6 +152,8 @@ void ColorPaletteEditor::slotUpdateButtons() { m_pRemoveButton->setEnabled( m_bPaletteExists && !m_bPaletteIsReadOnly); + m_pResetButton->setEnabled(bDirty || + m_resetedPalette != m_pPaletteTemplateComboBox->currentText()); } void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { @@ -211,6 +220,14 @@ void ColorPaletteEditor::slotPaletteNameChanged(const QString& text) { m_bPaletteExists = bPaletteExists; m_bPaletteIsReadOnly = bPaletteIsReadOnly; + + if (bPaletteExists && !bPaletteIsReadOnly) { + m_pPaletteTemplateComboBox->setCurrentText(text); + if (!m_pModel->isDirty()) { + m_resetedPalette = text; + } + } + slotUpdateButtons(); } @@ -257,6 +274,6 @@ void ColorPaletteEditor::slotResetButtonClicked() { paletteName, mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette); m_pModel->setColorPalette(palette); - m_pModel->setDirty(true); + m_resetedPalette = paletteName; slotUpdateButtons(); } diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index d70c36f747a..4c52d4a26f2 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -46,4 +46,5 @@ class ColorPaletteEditor : public QWidget { QPushButton* m_pCloseButton; QPushButton* m_pRemoveButton; parented_ptr m_pResetButton; + QString m_resetedPalette; }; From 8e95102333bd1987e34b8f15c969a54cea6e5101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 28 Mar 2020 13:38:41 +0100 Subject: [PATCH 27/42] Improve naming and use int as index like Qt --- src/preferences/colorpaletteeditormodel.cpp | 10 ++++++---- src/preferences/colorpalettesettings.cpp | 6 +++--- src/util/color/colorpalette.cpp | 4 ++-- src/util/color/colorpalette.h | 10 +++++----- src/util/color/predefinedcolorpalettes.cpp | 6 +++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/preferences/colorpaletteeditormodel.cpp b/src/preferences/colorpaletteeditormodel.cpp index 62d958fbe16..291e9aef668 100644 --- a/src/preferences/colorpaletteeditormodel.cpp +++ b/src/preferences/colorpaletteeditormodel.cpp @@ -102,9 +102,9 @@ void ColorPaletteEditorModel::setColorPalette(const ColorPalette& palette) { // Make a map of hotcue indices QMap hotcueColorIndicesMap; - QList hotcueColorIndices = palette.getHotcueIndices(); - for (int i = 0; i < hotcueColorIndices.size(); i++) { - int colorIndex = hotcueColorIndices.at(i); + QList colorIndicesByHotcue = palette.getIndicesByHotcue(); + for (int i = 0; i < colorIndicesByHotcue.size(); i++) { + int colorIndex = colorIndicesByHotcue.at(i); hotcueColorIndicesMap.insert(colorIndex, i); } @@ -119,7 +119,7 @@ void ColorPaletteEditorModel::setColorPalette(const ColorPalette& palette) { ColorPalette ColorPaletteEditorModel::getColorPalette(const QString& name) const { QList colors; - QMap hotcueColorIndices; + QMap hotcueColorIndices; for (int i = 0; i < rowCount(); i++) { QStandardItem* pColorItem = item(i, 0); QStandardItem* pHotcueIndexItem = item(i, 1); @@ -134,5 +134,7 @@ ColorPalette ColorPaletteEditorModel::getColorPalette(const QString& name) const } } } + // If we have a non consequitive list of hotcue indexes, indexes are shifted down + // due to the sorting nature of QMap. This is intended, this way we have a color for every hotcue. return ColorPalette(name, colors, hotcueColorIndices.values()); } diff --git a/src/preferences/colorpalettesettings.cpp b/src/preferences/colorpalettesettings.cpp index 1b01ca9973b..238bff1dd88 100644 --- a/src/preferences/colorpalettesettings.cpp +++ b/src/preferences/colorpalettesettings.cpp @@ -44,7 +44,7 @@ ColorPalette ColorPaletteSettings::getColorPalette( // Read colors from configuration const QString group = kColorPaletteGroupStart + name + kColorPaletteGroupEnd; QList colorList; - QList hotcueIndices; + QList hotcueIndices; for (const ConfigKey& key : m_pConfig->getKeysWithGroup(group)) { if (key.item == kColorPaletteHotcueIndicesConfigItem) { for (const QString& stringIndex : @@ -52,7 +52,7 @@ ColorPalette ColorPaletteSettings::getColorPalette( bool ok; int index = stringIndex.toInt(&ok); if (ok && index >= 0) { - hotcueIndices << static_cast(index); + hotcueIndices << index; } } } else { @@ -91,7 +91,7 @@ void ColorPaletteSettings::setColorPalette(const QString& name, const ColorPalet } QStringList stringIndices; - for (const unsigned int index : colorPalette.getHotcueIndices()) { + for (const unsigned int index : colorPalette.getIndicesByHotcue()) { stringIndices << QString::number(index); } if (!stringIndices.isEmpty()) { diff --git a/src/util/color/colorpalette.cpp b/src/util/color/colorpalette.cpp index 0e6dd4286b4..9d4d7186a96 100644 --- a/src/util/color/colorpalette.cpp +++ b/src/util/color/colorpalette.cpp @@ -18,10 +18,10 @@ mixxx::RgbColor ColorPalette::previousColor(mixxx::RgbColor color) const { mixxx::RgbColor ColorPalette::colorForHotcueIndex(unsigned int hotcueIndex) const { int colorIndex; - if (m_hotcueColorIndices.isEmpty()) { + if (m_colorIndicesByHotcue.isEmpty()) { colorIndex = hotcueIndex; } else { - colorIndex = m_hotcueColorIndices.at(hotcueIndex % m_hotcueColorIndices.size()); + colorIndex = m_colorIndicesByHotcue.at(hotcueIndex % m_colorIndicesByHotcue.size()); } return at(colorIndex % size()); } diff --git a/src/util/color/colorpalette.h b/src/util/color/colorpalette.h index 410f9542af3..d52852a9439 100644 --- a/src/util/color/colorpalette.h +++ b/src/util/color/colorpalette.h @@ -9,10 +9,10 @@ class ColorPalette final { ColorPalette( QString name, QList colorList, - QList hotcueColorIndices = {}) + QList colorIndicesByHotcue = {}) : m_name(name), m_colorList(colorList), - m_hotcueColorIndices(hotcueColorIndices) { + m_colorIndicesByHotcue(colorIndicesByHotcue) { DEBUG_ASSERT(m_colorList.size() != 0); } @@ -52,14 +52,14 @@ class ColorPalette final { return m_colorList; } - QList getHotcueIndices() const { - return m_hotcueColorIndices; + QList getIndicesByHotcue() const { + return m_colorIndicesByHotcue; } private: QString m_name; QList m_colorList; - QList m_hotcueColorIndices; + QList m_colorIndicesByHotcue; }; inline bool operator==( diff --git a/src/util/color/predefinedcolorpalettes.cpp b/src/util/color/predefinedcolorpalettes.cpp index 5fd3125a0b1..4ff3d79e57f 100644 --- a/src/util/color/predefinedcolorpalettes.cpp +++ b/src/util/color/predefinedcolorpalettes.cpp @@ -130,7 +130,7 @@ const ColorPalette PredefinedColorPalettes::kMixxxHotcueColorPalette = // Exclude kSchemaMigrationReplacementColor from the colors assigned to hotcues. // If there were 9 colors assigned to hotcues, that would look weird on // controllers with >8 hotcue buttons, for example a Novation Launchpad. - QList{0, 1, 2, 3, 4, 5, 6, 7}); + QList{0, 1, 2, 3, 4, 5, 6, 7}); const ColorPalette PredefinedColorPalettes::kSeratoTrackMetadataHotcueColorPalette = ColorPalette( @@ -155,7 +155,7 @@ const ColorPalette PredefinedColorPalettes::kSeratoTrackMetadataHotcueColorPalet kSeratoTrackMetadataHotcueColorMagenta, kSeratoTrackMetadataHotcueColorCarmine, }, - QList{0, 2, 12, 3, 6, 15, 9, 14}); + QList{0, 2, 12, 3, 6, 15, 9, 14}); const ColorPalette PredefinedColorPalettes::kSeratoDJProHotcueColorPalette = ColorPalette( @@ -180,7 +180,7 @@ const ColorPalette PredefinedColorPalettes::kSeratoDJProHotcueColorPalette = kSeratoDJProHotcueColorPurple, kSeratoDJProHotcueColorRed2, }, - QList{0, 2, 12, 3, 6, 15, 9, 14}); + QList{0, 2, 12, 3, 6, 15, 9, 14}); const ColorPalette PredefinedColorPalettes::kRekordboxTrackColorPalette = ColorPalette( From 5f601ce0f8749142a6921d4ffef46f2de4185cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 29 Mar 2020 23:39:43 +0200 Subject: [PATCH 28/42] Made the Palette editor a context depending pop up box for the palette combo boxes --- src/preferences/colorpaletteeditor.cpp | 117 +++++++-------------- src/preferences/colorpaletteeditor.h | 21 ++-- src/preferences/dialog/dlgprefcolors.cpp | 92 +++++++++++----- src/preferences/dialog/dlgprefcolors.h | 12 ++- src/preferences/dialog/dlgprefcolorsdlg.ui | 91 ++++------------ 5 files changed, 139 insertions(+), 194 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 717e158693b..ad40f2527df 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -18,37 +18,27 @@ const QColor kDefaultPaletteColor(0, 0, 0); } ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) - : QWidget(parent), + : QDialog(parent), m_bPaletteExists(false), m_bPaletteIsReadOnly(false), - m_pPaletteTemplateComboBox(make_parented()), - m_pSaveAsComboBox(make_parented()), - m_pTableView(make_parented()), + m_pSaveAsEdit(make_parented(this)), + m_pTableView(make_parented(this)), m_pModel(make_parented(m_pTableView)) { - m_pSaveAsComboBox->setEditable(true); - - m_pResetButton = make_parented(tr("Reset"), this); - QDialogButtonBox* pButtonBox = new QDialogButtonBox(); m_pRemoveButton = pButtonBox->addButton( tr("Remove Palette"), QDialogButtonBox::DestructiveRole); + m_pCloseButton = pButtonBox->addButton(QDialogButtonBox::Discard); + m_pResetButton = pButtonBox->addButton(QDialogButtonBox::Reset); m_pSaveButton = pButtonBox->addButton(QDialogButtonBox::Save); - m_pCloseButton = pButtonBox->addButton(QDialogButtonBox::Close); - - QHBoxLayout* pTopLayout = new QHBoxLayout(); - pTopLayout->addWidget(new QLabel(tr("Name"))); - pTopLayout->addWidget(m_pSaveAsComboBox, 1); - QHBoxLayout* pBottomLayout = new QHBoxLayout(); - pBottomLayout->addWidget(new QLabel(tr("Reset to"))); - pBottomLayout->addWidget(m_pPaletteTemplateComboBox, 1); - pBottomLayout->addWidget(m_pResetButton.get()); + QHBoxLayout* pNameLayout = new QHBoxLayout(); + pNameLayout->addWidget(new QLabel(tr("Name"))); + pNameLayout->addWidget(m_pSaveAsEdit, 1); QVBoxLayout* pLayout = new QVBoxLayout(); - pLayout->addLayout(pTopLayout); pLayout->addWidget(m_pTableView, 1); - pLayout->addLayout(pBottomLayout); + pLayout->addLayout(pNameLayout); pLayout->addWidget(pButtonBox); setLayout(pLayout); setContentsMargins(0, 0, 0, 0); @@ -88,14 +78,10 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &QTableView::customContextMenuRequested, this, &ColorPaletteEditor::slotTableViewContextMenuRequested); - connect(m_pSaveAsComboBox, - &QComboBox::currentTextChanged, + connect(m_pSaveAsEdit, + &QLineEdit::textChanged, this, &ColorPaletteEditor::slotPaletteNameChanged); - connect(m_pPaletteTemplateComboBox, - &QComboBox::currentTextChanged, - this, - &ColorPaletteEditor::slotUpdateButtons); connect(m_pResetButton, &QPushButton::clicked, this, @@ -114,46 +100,40 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &ColorPaletteEditor::slotRemoveButtonClicked); } -void ColorPaletteEditor::initialize(UserSettingsPointer pConfig) { +void ColorPaletteEditor::initialize( + UserSettingsPointer pConfig, + const QString& paletteName) { DEBUG_ASSERT(!m_pConfig); m_pConfig = pConfig; - reset(); -} - -void ColorPaletteEditor::reset() { - m_pPaletteTemplateComboBox->clear(); - m_pSaveAsComboBox->clear(); + m_resetPalette = paletteName; + QString saveName = paletteName; for (const ColorPalette& palette : mixxx::PredefinedColorPalettes::kPalettes) { - m_pPaletteTemplateComboBox->addItem(palette.getName()); - } - - ColorPaletteSettings colorPaletteSettings(m_pConfig); - if (colorPaletteSettings.getColorPaletteNames().count()) { - for (const QString& paletteName : colorPaletteSettings.getColorPaletteNames()) { - m_pSaveAsComboBox->addItem(paletteName); - m_pPaletteTemplateComboBox->addItem(paletteName); + if (paletteName == palette.getName()) { + saveName = paletteName + QChar(' ') + tr("(Edited)"); + ColorPaletteSettings colorPaletteSettings(m_pConfig); + if (colorPaletteSettings.getColorPaletteNames().contains(saveName)) { + m_resetPalette = saveName; + } + break; } - QString current = m_pSaveAsComboBox->currentText(); - m_pPaletteTemplateComboBox->setCurrentText(current); - m_resetedPalette = current; - } else { - m_pSaveAsComboBox->addItem(tr("Custom Color Palette")); - slotResetButtonClicked(); } + + m_pSaveAsEdit->setText(saveName); + + slotResetButtonClicked(); } void ColorPaletteEditor::slotUpdateButtons() { bool bDirty = m_pModel->isDirty(); bool bEmpty = m_pModel->isEmpty(); m_pSaveButton->setEnabled( - !m_pSaveAsComboBox->currentText().isEmpty() && + !m_pSaveAsEdit->text().trimmed().isEmpty() && (!m_bPaletteExists || (!m_bPaletteIsReadOnly && bDirty && !bEmpty))); m_pRemoveButton->setEnabled( m_bPaletteExists && !m_bPaletteIsReadOnly); - m_pResetButton->setEnabled(bDirty || - m_resetedPalette != m_pPaletteTemplateComboBox->currentText()); + m_pResetButton->setEnabled(bDirty); } void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { @@ -213,7 +193,8 @@ void ColorPaletteEditor::slotPaletteNameChanged(const QString& text) { } } if (!bPaletteFound) { - m_pModel->setColorPalette(colorPaletteSettings.getColorPalette(text, mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette)); + m_pModel->setColorPalette(colorPaletteSettings.getColorPalette( + text, mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette)); } } } @@ -221,59 +202,35 @@ void ColorPaletteEditor::slotPaletteNameChanged(const QString& text) { m_bPaletteExists = bPaletteExists; m_bPaletteIsReadOnly = bPaletteIsReadOnly; - if (bPaletteExists && !bPaletteIsReadOnly) { - m_pPaletteTemplateComboBox->setCurrentText(text); - if (!m_pModel->isDirty()) { - m_resetedPalette = text; - } - } - slotUpdateButtons(); } void ColorPaletteEditor::slotCloseButtonClicked() { - if (m_pSaveButton->isEnabled()) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Custom Palettes Editor")); - msgBox.setText(tr( - "The custom palette is not saved.\n" - "Close anyway?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Cancel); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) { - emit closeButtonClicked(); - } - } else { - emit closeButtonClicked(); - } + reject(); } void ColorPaletteEditor::slotRemoveButtonClicked() { - QString paletteName = m_pSaveAsComboBox->currentText(); + QString paletteName = m_pSaveAsEdit->text().trimmed(); ColorPaletteSettings colorPaletteSettings(m_pConfig); colorPaletteSettings.removePalette(paletteName); - reset(); emit paletteRemoved(paletteName); + accept(); } void ColorPaletteEditor::slotSaveButtonClicked() { - QString paletteName = m_pSaveAsComboBox->currentText(); + QString paletteName = m_pSaveAsEdit->text().trimmed(); ColorPaletteSettings colorPaletteSettings(m_pConfig); colorPaletteSettings.setColorPalette(paletteName, m_pModel->getColorPalette(paletteName)); m_pModel->setDirty(false); - reset(); - m_pSaveAsComboBox->setCurrentText(paletteName); emit paletteChanged(paletteName); + accept(); } void ColorPaletteEditor::slotResetButtonClicked() { - QString paletteName = m_pPaletteTemplateComboBox->currentText(); ColorPaletteSettings colorPaletteSettings(m_pConfig); ColorPalette palette = colorPaletteSettings.getColorPalette( - paletteName, + m_resetPalette, mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette); m_pModel->setColorPalette(palette); - m_resetedPalette = paletteName; slotUpdateButtons(); } diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 4c52d4a26f2..4871f0c6907 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -1,26 +1,24 @@ #pragma once #include +#include +#include #include #include -#include #include "preferences/colorpaletteeditormodel.h" #include "preferences/usersettings.h" #include "util/parented_ptr.h" -// Widget for viewing, adding, editing and removing color palettes that can be -// used for track/hotcue colors. -class ColorPaletteEditor : public QWidget { +class ColorPaletteEditor : public QDialog { Q_OBJECT public: ColorPaletteEditor(QWidget* parent = nullptr); - void initialize(UserSettingsPointer pConfig); - void reset(); + void initialize(UserSettingsPointer pConfig, const QString& paletteName); signals: - void paletteChanged(QString name); - void paletteRemoved(QString name); + void paletteChanged(const QString& name); + void paletteRemoved(const QString& name); void closeButtonClicked(); private slots: @@ -38,13 +36,12 @@ class ColorPaletteEditor : public QWidget { bool m_bPaletteIsReadOnly; UserSettingsPointer m_pConfig; - parented_ptr m_pPaletteTemplateComboBox; - parented_ptr m_pSaveAsComboBox; + parented_ptr m_pSaveAsEdit; parented_ptr m_pTableView; parented_ptr m_pModel; QPushButton* m_pSaveButton; QPushButton* m_pCloseButton; QPushButton* m_pRemoveButton; - parented_ptr m_pResetButton; - QString m_resetedPalette; + QPushButton* m_pResetButton; + QString m_resetPalette; }; diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index d76a525570d..240a4a9d897 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -9,11 +9,12 @@ #include "util/color/predefinedcolorpalettes.h" #include "util/compatibility.h" #include "util/math.h" +#include "util/memory.h" namespace { constexpr int kHotcueDefaultColorIndex = -1; -constexpr QSize kPalettePreviewSize = QSize(200, 16); +constexpr QSize kPalettePreviewSize = QSize(108, 16); } // anonymous namespace @@ -23,36 +24,25 @@ DlgPrefColors::DlgPrefColors( m_pConfig(pConfig), m_colorPaletteSettings(ColorPaletteSettings(pConfig)) { setupUi(this); - colorPaletteEditor->initialize(pConfig); comboBoxHotcueColors->setIconSize(kPalettePreviewSize); comboBoxTrackColors->setIconSize(kPalettePreviewSize); - groupBoxPaletteEditor->hide(); - loadSettings(); - connect(colorPaletteEditor, - &ColorPaletteEditor::paletteChanged, - this, - &DlgPrefColors::palettesUpdated); - connect(colorPaletteEditor, - &ColorPaletteEditor::paletteRemoved, - this, - &DlgPrefColors::palettesUpdated); - connect(colorPaletteEditor, - &ColorPaletteEditor::closeButtonClicked, - this, - &DlgPrefColors::slotCloseClicked); - connect(comboBoxHotcueColors, QOverload::of(&QComboBox::currentIndexChanged), this, &DlgPrefColors::slotHotcuePaletteChanged); - connect(pushButtonEdit, + connect(pushButtonEditHotcuePalette, + &QPushButton::clicked, + this, + &DlgPrefColors::slotEditHotcuePaletteClicked); + + connect(pushButtonEditTrackPalette, &QPushButton::clicked, this, - &DlgPrefColors::slotEditClicked); + &DlgPrefColors::slotEditTrackPaletteClicked); } DlgPrefColors::~DlgPrefColors() { @@ -227,18 +217,62 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); } -void DlgPrefColors::slotEditClicked() { - pushButtonEdit->hide(); - labelCustomPalette->hide(); - widgetSpacer->hide(); - groupBoxPaletteEditor->show(); +void DlgPrefColors::slotEditTrackPaletteClicked() { + QString trackColorPaletteName = comboBoxTrackColors->currentText(); + openColorPaletteEditor(trackColorPaletteName, false); } -void DlgPrefColors::slotCloseClicked() { - groupBoxPaletteEditor->hide(); - widgetSpacer->show(); - pushButtonEdit->show(); - labelCustomPalette->show(); +void DlgPrefColors::slotEditHotcuePaletteClicked() { + QString hotcueColorPaletteName = comboBoxHotcueColors->currentText(); + openColorPaletteEditor(hotcueColorPaletteName, true); +} + +void DlgPrefColors::openColorPaletteEditor( + const QString& paletteName, + bool editHotcuePalette) { + std::unique_ptr pColorPaletteEditor = + std::make_unique(this); + + if (editHotcuePalette) { + connect(pColorPaletteEditor.get(), + &ColorPaletteEditor::paletteChanged, + this, + &DlgPrefColors::hotcuePaletteUpdated); + } else { + connect(pColorPaletteEditor.get(), + &ColorPaletteEditor::paletteChanged, + this, + &DlgPrefColors::trackPaletteUpdated); + } + connect(pColorPaletteEditor.get(), + &ColorPaletteEditor::paletteRemoved, + this, + &DlgPrefColors::palettesUpdated); + + pColorPaletteEditor->initialize(m_pConfig, paletteName); + pColorPaletteEditor->exec(); +} + +void DlgPrefColors::trackPaletteUpdated(const QString& trackColors) { + QString hotcueColors = comboBoxHotcueColors->currentText(); + int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); + + loadSettings(); + + comboBoxHotcueColors->setCurrentText(hotcueColors); + comboBoxTrackColors->setCurrentText(trackColors); + comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); +} + +void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) { + QString trackColors = comboBoxTrackColors->currentText(); + int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); + + loadSettings(); + + comboBoxHotcueColors->setCurrentText(hotcueColors); + comboBoxTrackColors->setCurrentText(trackColors); + comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); } void DlgPrefColors::palettesUpdated() { diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index 01fe4d660db..739aafd95e6 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -3,10 +3,12 @@ #include #include "control/controlproxy.h" +#include "preferences/colorpaletteeditor.h" #include "preferences/colorpalettesettings.h" #include "preferences/dialog/ui_dlgprefcolorsdlg.h" #include "preferences/dlgpreferencepage.h" #include "preferences/usersettings.h" +#include "util/parented_ptr.h" class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { Q_OBJECT @@ -18,8 +20,6 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { // Apply changes to widget void slotApply(); void slotResetToDefaults(); - void slotEditClicked(); - void slotCloseClicked(); signals: void apply(const QString&); @@ -27,10 +27,16 @@ 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(); + void slotEditTrackPaletteClicked(); + void slotEditHotcuePaletteClicked(); private: - void loadPaletteIntoEditor(const ColorPalette& palette); + void openColorPaletteEditor( + const QString& paletteName, + bool editHotcuePalette); QPixmap drawPalettePreview(const QString& paletteName); QIcon drawPaletteIcon(const QString& paletteName); diff --git a/src/preferences/dialog/dlgprefcolorsdlg.ui b/src/preferences/dialog/dlgprefcolorsdlg.ui index 2a27b65008e..c9d3f25a375 100644 --- a/src/preferences/dialog/dlgprefcolorsdlg.ui +++ b/src/preferences/dialog/dlgprefcolorsdlg.ui @@ -26,6 +26,16 @@ Colors + + + + + 0 + 0 + + + + @@ -47,48 +57,15 @@ - - - - Custom palettes - - - - - + + Edit… - - - - - 0 - 15 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - + + 0 @@ -97,37 +74,19 @@ - - - - - 0 - 0 - + + + + + + + Edit… - - - - Custom Palettes Editor - - - false - - - false - - - - - - - - @@ -144,14 +103,6 @@ - - - ColorPaletteEditor - QWidget -
preferences/colorpaletteeditor.h
- 1 -
-
From e9c2d34fe8dcadcf80c2aa22d0c9574ce70f54a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 00:55:34 +0200 Subject: [PATCH 29/42] Seti inital color for QColorDialog --- src/preferences/colorpaletteeditor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index ad40f2527df..2cd90ecd1d0 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -138,9 +138,11 @@ void ColorPaletteEditor::slotUpdateButtons() { void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { if (index.isValid() && index.column() == 0) { - QColor color = QColorDialog::getColor(); - if (color.isValid()) { - m_pModel->setColor(index.row(), color); + QStandardItem* pColorItem = m_pModel->item(index.row(), 0); + QColor oldColor = QColor(pColorItem->text()); + QColor newColor = QColorDialog::getColor(oldColor); + if (newColor.isValid() && oldColor != newColor) { + m_pModel->setColor(index.row(), newColor); } } } From 74b47c3e151fbd5729e8e91714a6b4b92075b04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 01:03:24 +0200 Subject: [PATCH 30/42] Don't translate parentheses --- src/preferences/colorpaletteeditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 2cd90ecd1d0..75a326cbd99 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -110,7 +110,7 @@ void ColorPaletteEditor::initialize( for (const ColorPalette& palette : mixxx::PredefinedColorPalettes::kPalettes) { if (paletteName == palette.getName()) { - saveName = paletteName + QChar(' ') + tr("(Edited)"); + saveName = paletteName + QStringLiteral(" (") + tr("Edited") + QChar(')'); ColorPaletteSettings colorPaletteSettings(m_pConfig); if (colorPaletteSettings.getColorPaletteNames().contains(saveName)) { m_resetPalette = saveName; From 441b0693bc68cb69047e186ccbcc0a978c2246bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 01:32:47 +0200 Subject: [PATCH 31/42] Adjust default index when it is out set the new palette selected --- src/preferences/dialog/dlgprefcolors.cpp | 30 ++++++++++++++++-------- src/preferences/dialog/dlgprefcolors.h | 4 ++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 240a4a9d897..d373a15878f 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -214,7 +214,12 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->setItemIcon(i + 1, QIcon(pixmap)); } - comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); + if (comboBoxHotcueDefaultColor->count() > defaultColor) { + comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); + } else { + comboBoxHotcueDefaultColor->setCurrentIndex( + comboBoxHotcueDefaultColor->count() - 1); + } } void DlgPrefColors::slotEditTrackPaletteClicked() { @@ -258,10 +263,7 @@ void DlgPrefColors::trackPaletteUpdated(const QString& trackColors) { int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); loadSettings(); - - comboBoxHotcueColors->setCurrentText(hotcueColors); - comboBoxTrackColors->setCurrentText(trackColors); - comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); + restoreComboBoxed(hotcueColors, trackColors, defaultColor); } void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) { @@ -269,10 +271,7 @@ void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) { int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); loadSettings(); - - comboBoxHotcueColors->setCurrentText(hotcueColors); - comboBoxTrackColors->setCurrentText(trackColors); - comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); + restoreComboBoxed(hotcueColors, trackColors, defaultColor); } void DlgPrefColors::palettesUpdated() { @@ -281,8 +280,19 @@ void DlgPrefColors::palettesUpdated() { int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); loadSettings(); + restoreComboBoxed(hotcueColors, trackColors, defaultColor); +} +void DlgPrefColors::restoreComboBoxed( + const QString& hotcueColors, + const QString& trackColors, + int defaultColor) { comboBoxHotcueColors->setCurrentText(hotcueColors); comboBoxTrackColors->setCurrentText(trackColors); - comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); + if (comboBoxHotcueDefaultColor->count() > defaultColor) { + comboBoxHotcueDefaultColor->setCurrentIndex(defaultColor); + } else { + comboBoxHotcueDefaultColor->setCurrentIndex( + comboBoxHotcueDefaultColor->count() - 1); + } } diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index 739aafd95e6..eddc07cc6de 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -39,6 +39,10 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { bool editHotcuePalette); QPixmap drawPalettePreview(const QString& paletteName); QIcon drawPaletteIcon(const QString& paletteName); + void restoreComboBoxed( + const QString& hotcueColors, + const QString& trackColors, + int defaultColor); const UserSettingsPointer m_pConfig; ColorPaletteSettings m_colorPaletteSettings; From f1a7c73b6056850955d15fa14d956f90bbad16ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 01:36:58 +0200 Subject: [PATCH 32/42] fix typo --- src/preferences/dialog/dlgprefcolors.cpp | 8 ++++---- src/preferences/dialog/dlgprefcolors.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index d373a15878f..7fb144d0ced 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -263,7 +263,7 @@ void DlgPrefColors::trackPaletteUpdated(const QString& trackColors) { int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); loadSettings(); - restoreComboBoxed(hotcueColors, trackColors, defaultColor); + restoreComboBoxes(hotcueColors, trackColors, defaultColor); } void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) { @@ -271,7 +271,7 @@ void DlgPrefColors::hotcuePaletteUpdated(const QString& hotcueColors) { int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); loadSettings(); - restoreComboBoxed(hotcueColors, trackColors, defaultColor); + restoreComboBoxes(hotcueColors, trackColors, defaultColor); } void DlgPrefColors::palettesUpdated() { @@ -280,10 +280,10 @@ void DlgPrefColors::palettesUpdated() { int defaultColor = comboBoxHotcueDefaultColor->currentIndex(); loadSettings(); - restoreComboBoxed(hotcueColors, trackColors, defaultColor); + restoreComboBoxes(hotcueColors, trackColors, defaultColor); } -void DlgPrefColors::restoreComboBoxed( +void DlgPrefColors::restoreComboBoxes( const QString& hotcueColors, const QString& trackColors, int defaultColor) { diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index eddc07cc6de..caec1a0d7ab 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -39,7 +39,7 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { bool editHotcuePalette); QPixmap drawPalettePreview(const QString& paletteName); QIcon drawPaletteIcon(const QString& paletteName); - void restoreComboBoxed( + void restoreComboBoxes( const QString& hotcueColors, const QString& trackColors, int defaultColor); From 989d33556bd04da77daf9c4d425f906048ce66db Mon Sep 17 00:00:00 2001 From: Be Date: Sun, 29 Mar 2020 19:53:34 -0500 Subject: [PATCH 33/42] ColorPaletteEditor: move Add/Remove Color to buttons instead of a right click menu where they were not easily discoverable --- src/preferences/colorpaletteeditor.cpp | 63 ++++++++++++++------------ src/preferences/colorpaletteeditor.h | 5 +- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 75a326cbd99..e6514976326 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -24,22 +24,39 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) m_pSaveAsEdit(make_parented(this)), m_pTableView(make_parented(this)), m_pModel(make_parented(m_pTableView)) { - QDialogButtonBox* pButtonBox = new QDialogButtonBox(); - m_pRemoveButton = pButtonBox->addButton( - tr("Remove Palette"), - QDialogButtonBox::DestructiveRole); - m_pCloseButton = pButtonBox->addButton(QDialogButtonBox::Discard); - m_pResetButton = pButtonBox->addButton(QDialogButtonBox::Reset); - m_pSaveButton = pButtonBox->addButton(QDialogButtonBox::Save); + // Create widgets + QHBoxLayout* pColorButtonLayout = new QHBoxLayout(); + m_pAddColorButton = new QPushButton(tr("Add Color"), this); + pColorButtonLayout->addWidget(m_pAddColorButton); + connect(m_pAddColorButton, + &QPushButton::clicked, + this, + &ColorPaletteEditor::slotAddColor); + m_pRemoveColorButton = new QPushButton(tr("Remove Color"), this); + pColorButtonLayout->addWidget(m_pRemoveColorButton); + connect(m_pRemoveColorButton, + &QPushButton::clicked, + this, + &ColorPaletteEditor::slotRemoveColor); QHBoxLayout* pNameLayout = new QHBoxLayout(); pNameLayout->addWidget(new QLabel(tr("Name"))); pNameLayout->addWidget(m_pSaveAsEdit, 1); + QDialogButtonBox* pPaletteButtonBox = new QDialogButtonBox(); + m_pRemoveButton = pPaletteButtonBox->addButton( + tr("Remove Palette"), + QDialogButtonBox::DestructiveRole); + m_pCloseButton = pPaletteButtonBox->addButton(QDialogButtonBox::Discard); + m_pResetButton = pPaletteButtonBox->addButton(QDialogButtonBox::Reset); + m_pSaveButton = pPaletteButtonBox->addButton(QDialogButtonBox::Save); + + // Add widgets to dialog QVBoxLayout* pLayout = new QVBoxLayout(); + pLayout->addLayout(pColorButtonLayout); pLayout->addWidget(m_pTableView, 1); pLayout->addLayout(pNameLayout); - pLayout->addWidget(pButtonBox); + pLayout->addWidget(pPaletteButtonBox); setLayout(pLayout); setContentsMargins(0, 0, 0, 0); @@ -74,10 +91,6 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &QTableView::doubleClicked, this, &ColorPaletteEditor::slotTableViewDoubleClicked); - connect(m_pTableView, - &QTableView::customContextMenuRequested, - this, - &ColorPaletteEditor::slotTableViewContextMenuRequested); connect(m_pSaveAsEdit, &QLineEdit::textChanged, this, @@ -147,24 +160,18 @@ void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { } } -void ColorPaletteEditor::slotTableViewContextMenuRequested(const QPoint& pos) { - QMenu menu(this); - - QAction* pAddAction = menu.addAction("Add"); - QAction* pRemoveAction = menu.addAction("Remove"); - QAction* pAction = menu.exec(m_pTableView->viewport()->mapToGlobal(pos)); - if (pAction == pAddAction) { - m_pModel->appendRow(kDefaultPaletteColor); - } else if (pAction == pRemoveAction) { - QModelIndexList selection = m_pTableView->selectionModel()->selectedRows(); +void ColorPaletteEditor::slotAddColor() { + m_pModel->appendRow(kDefaultPaletteColor); +} - if (selection.count() > 0) { - QModelIndex index = selection.at(0); +void ColorPaletteEditor::slotRemoveColor() { + QModelIndexList selection = m_pTableView->selectionModel()->selectedRows(); - //row selected - int row = index.row(); - m_pModel->removeRow(row); - } + if (selection.count() > 0) { + QModelIndex index = selection.at(0); + //row selected + int row = index.row(); + m_pModel->removeRow(row); } } diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 4871f0c6907..abc812e29c6 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -24,7 +24,8 @@ class ColorPaletteEditor : public QDialog { private slots: void slotUpdateButtons(); void slotTableViewDoubleClicked(const QModelIndex& index); - void slotTableViewContextMenuRequested(const QPoint& pos); + void slotAddColor(); + void slotRemoveColor(); void slotPaletteNameChanged(const QString& text); void slotCloseButtonClicked(); void slotSaveButtonClicked(); @@ -39,6 +40,8 @@ class ColorPaletteEditor : public QDialog { parented_ptr m_pSaveAsEdit; parented_ptr m_pTableView; parented_ptr m_pModel; + QPushButton* m_pAddColorButton; + QPushButton* m_pRemoveColorButton; QPushButton* m_pSaveButton; QPushButton* m_pCloseButton; QPushButton* m_pRemoveButton; From 2a8f635685ff4dd0b27678223c82958a2dfd3801 Mon Sep 17 00:00:00 2001 From: Be Date: Sun, 29 Mar 2020 20:11:39 -0500 Subject: [PATCH 34/42] ColorPaletteEditor: hide hotcue number column for track palette It has no meaning in this context. --- src/preferences/colorpaletteeditor.cpp | 6 +++++- src/preferences/colorpaletteeditor.h | 2 +- src/preferences/dialog/dlgprefcolors.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 75a326cbd99..f9a491f41f9 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -17,7 +17,7 @@ namespace { const QColor kDefaultPaletteColor(0, 0, 0); } -ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) +ColorPaletteEditor::ColorPaletteEditor(QWidget* parent, bool showHotcueNumbers) : QDialog(parent), m_bPaletteExists(false), m_bPaletteIsReadOnly(false), @@ -70,6 +70,10 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) m_pTableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); m_pTableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); + if (!showHotcueNumbers) { + m_pTableView->hideColumn(1); + } + connect(m_pTableView, &QTableView::doubleClicked, this, diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 4871f0c6907..9996a2f1a9a 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -13,7 +13,7 @@ class ColorPaletteEditor : public QDialog { Q_OBJECT public: - ColorPaletteEditor(QWidget* parent = nullptr); + ColorPaletteEditor(QWidget* parent = nullptr, bool showHotcueNumbers = true); void initialize(UserSettingsPointer pConfig, const QString& paletteName); signals: diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 7fb144d0ced..7aa7e350da8 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -236,7 +236,7 @@ void DlgPrefColors::openColorPaletteEditor( const QString& paletteName, bool editHotcuePalette) { std::unique_ptr pColorPaletteEditor = - std::make_unique(this); + std::make_unique(this, editHotcuePalette); if (editHotcuePalette) { connect(pColorPaletteEditor.get(), From 61f5a71c5fe63c18d08c429b1121360635ce43c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 21:43:12 +0200 Subject: [PATCH 35/42] Resort the palette editor buttons. Replace "Save" with "OK" --- src/preferences/colorpaletteeditor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index e6514976326..91fbd86a7bd 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -44,12 +44,12 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) pNameLayout->addWidget(m_pSaveAsEdit, 1); QDialogButtonBox* pPaletteButtonBox = new QDialogButtonBox(); + m_pResetButton = pPaletteButtonBox->addButton(QDialogButtonBox::Reset); m_pRemoveButton = pPaletteButtonBox->addButton( tr("Remove Palette"), - QDialogButtonBox::DestructiveRole); + QDialogButtonBox::ResetRole); m_pCloseButton = pPaletteButtonBox->addButton(QDialogButtonBox::Discard); - m_pResetButton = pPaletteButtonBox->addButton(QDialogButtonBox::Reset); - m_pSaveButton = pPaletteButtonBox->addButton(QDialogButtonBox::Save); + m_pSaveButton = pPaletteButtonBox->addButton(QDialogButtonBox::Ok); // Add widgets to dialog QVBoxLayout* pLayout = new QVBoxLayout(); From f189feee589a898e93491bfa5cb402e80ed80a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 22:06:39 +0200 Subject: [PATCH 36/42] Shrink add and remove button to + and - and move it below the table. --- src/preferences/colorpaletteeditor.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 91fbd86a7bd..4ef30cb6bc8 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -26,13 +26,21 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) m_pModel(make_parented(m_pTableView)) { // Create widgets QHBoxLayout* pColorButtonLayout = new QHBoxLayout(); - m_pAddColorButton = new QPushButton(tr("Add Color"), this); + QWidget* pExpander = new QWidget(this); + pExpander->setSizePolicy( + QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); + pColorButtonLayout->addWidget(pExpander); + m_pAddColorButton = new QPushButton("+", this); + m_pAddColorButton->setFixedWidth(32); + m_pAddColorButton->setToolTip(tr("Add Color")); pColorButtonLayout->addWidget(m_pAddColorButton); connect(m_pAddColorButton, &QPushButton::clicked, this, &ColorPaletteEditor::slotAddColor); - m_pRemoveColorButton = new QPushButton(tr("Remove Color"), this); + m_pRemoveColorButton = new QPushButton("-", this); + m_pRemoveColorButton->setFixedWidth(32); + m_pRemoveColorButton->setToolTip(tr("Remove Color")); pColorButtonLayout->addWidget(m_pRemoveColorButton); connect(m_pRemoveColorButton, &QPushButton::clicked, @@ -53,8 +61,8 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) // Add widgets to dialog QVBoxLayout* pLayout = new QVBoxLayout(); - pLayout->addLayout(pColorButtonLayout); pLayout->addWidget(m_pTableView, 1); + pLayout->addLayout(pColorButtonLayout); pLayout->addLayout(pNameLayout); pLayout->addWidget(pPaletteButtonBox); setLayout(pLayout); From 40302801d5b37be6d5ff9fa991503341ad4f3641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 23:12:22 +0200 Subject: [PATCH 37/42] Improve selection behaviour during palette edit --- src/preferences/colorpaletteeditor.cpp | 24 +++++++++++++++++++++--- src/preferences/colorpaletteeditor.h | 3 +++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 4ef30cb6bc8..21f3143a5a1 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -41,6 +41,7 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) m_pRemoveColorButton = new QPushButton("-", this); m_pRemoveColorButton->setFixedWidth(32); m_pRemoveColorButton->setToolTip(tr("Remove Color")); + m_pRemoveColorButton->setDisabled(true); pColorButtonLayout->addWidget(m_pRemoveColorButton); connect(m_pRemoveColorButton, &QPushButton::clicked, @@ -99,6 +100,10 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) &QTableView::doubleClicked, this, &ColorPaletteEditor::slotTableViewDoubleClicked); + connect(m_pTableView->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &ColorPaletteEditor::slotSelectionChanged); connect(m_pSaveAsEdit, &QLineEdit::textChanged, this, @@ -170,17 +175,23 @@ void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { void ColorPaletteEditor::slotAddColor() { m_pModel->appendRow(kDefaultPaletteColor); + m_pTableView->scrollToBottom(); + //m_pTableView->selectionModel()->select(QItemSelection + // m_pModel->index(m_pModel->rowCount() - 1, 0), + // QItemSelectionModel::ClearAndSelect ); + m_pTableView->setCurrentIndex( + m_pModel->index(m_pModel->rowCount() - 1, 0)); } void ColorPaletteEditor::slotRemoveColor() { QModelIndexList selection = m_pTableView->selectionModel()->selectedRows(); - - if (selection.count() > 0) { - QModelIndex index = selection.at(0); + for (const auto& index : selection) { //row selected int row = index.row(); m_pModel->removeRow(row); } + m_pRemoveColorButton->setDisabled( + !m_pTableView->selectionModel()->hasSelection()); } void ColorPaletteEditor::slotPaletteNameChanged(const QString& text) { @@ -251,3 +262,10 @@ void ColorPaletteEditor::slotResetButtonClicked() { m_pModel->setColorPalette(palette); slotUpdateButtons(); } + +void ColorPaletteEditor::slotSelectionChanged( + const QItemSelection& selected, + const QItemSelection& deselected) { + Q_UNUSED(deselected); + m_pRemoveColorButton->setDisabled(!selected.count()); +} diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index abc812e29c6..4d5293acdee 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -31,6 +31,9 @@ class ColorPaletteEditor : public QDialog { void slotSaveButtonClicked(); void slotResetButtonClicked(); void slotRemoveButtonClicked(); + void slotSelectionChanged( + const QItemSelection& selected, + const QItemSelection& deselected); private: bool m_bPaletteExists; From 4b3f9b49e182aa23e59a24666523e63bbbc226a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Mar 2020 23:21:35 +0200 Subject: [PATCH 38/42] Added a warning dialog when removing the palette. --- src/preferences/colorpaletteeditor.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 21f3143a5a1..5f7d0c595f4 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -239,10 +239,20 @@ void ColorPaletteEditor::slotCloseButtonClicked() { void ColorPaletteEditor::slotRemoveButtonClicked() { QString paletteName = m_pSaveAsEdit->text().trimmed(); - ColorPaletteSettings colorPaletteSettings(m_pConfig); - colorPaletteSettings.removePalette(paletteName); - emit paletteRemoved(paletteName); - accept(); + + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Remove Palette")); + msgBox.setText(tr( + "Do you really want to remove the palette permanently?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) { + ColorPaletteSettings colorPaletteSettings(m_pConfig); + colorPaletteSettings.removePalette(paletteName); + emit paletteRemoved(paletteName); + accept(); + } } void ColorPaletteEditor::slotSaveButtonClicked() { From a82bf80654c2c4d663317fcf63ba90f2c12fc41c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 31 Mar 2020 08:25:35 +0200 Subject: [PATCH 39/42] Remove commented code --- src/preferences/colorpaletteeditor.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index 5f7d0c595f4..dfeb671e9a9 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -176,9 +176,6 @@ void ColorPaletteEditor::slotTableViewDoubleClicked(const QModelIndex& index) { void ColorPaletteEditor::slotAddColor() { m_pModel->appendRow(kDefaultPaletteColor); m_pTableView->scrollToBottom(); - //m_pTableView->selectionModel()->select(QItemSelection - // m_pModel->index(m_pModel->rowCount() - 1, 0), - // QItemSelectionModel::ClearAndSelect ); m_pTableView->setCurrentIndex( m_pModel->index(m_pModel->rowCount() - 1, 0)); } From cfce95139b591d4491982aeb3eb1e97c95c516df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 31 Mar 2020 21:30:27 +0200 Subject: [PATCH 40/42] Swap "+" and "-" button --- src/preferences/colorpaletteeditor.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/preferences/colorpaletteeditor.cpp b/src/preferences/colorpaletteeditor.cpp index dfeb671e9a9..30d4c946e6e 100644 --- a/src/preferences/colorpaletteeditor.cpp +++ b/src/preferences/colorpaletteeditor.cpp @@ -30,14 +30,7 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) pExpander->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); pColorButtonLayout->addWidget(pExpander); - m_pAddColorButton = new QPushButton("+", this); - m_pAddColorButton->setFixedWidth(32); - m_pAddColorButton->setToolTip(tr("Add Color")); - pColorButtonLayout->addWidget(m_pAddColorButton); - connect(m_pAddColorButton, - &QPushButton::clicked, - this, - &ColorPaletteEditor::slotAddColor); + m_pRemoveColorButton = new QPushButton("-", this); m_pRemoveColorButton->setFixedWidth(32); m_pRemoveColorButton->setToolTip(tr("Remove Color")); @@ -48,6 +41,15 @@ ColorPaletteEditor::ColorPaletteEditor(QWidget* parent) this, &ColorPaletteEditor::slotRemoveColor); + m_pAddColorButton = new QPushButton("+", this); + m_pAddColorButton->setFixedWidth(32); + m_pAddColorButton->setToolTip(tr("Add Color")); + pColorButtonLayout->addWidget(m_pAddColorButton); + connect(m_pAddColorButton, + &QPushButton::clicked, + this, + &ColorPaletteEditor::slotAddColor); + QHBoxLayout* pNameLayout = new QHBoxLayout(); pNameLayout->addWidget(new QLabel(tr("Name"))); pNameLayout->addWidget(m_pSaveAsEdit, 1); From f29e3b8c40f94c9c8eeeeef516b507655bb647a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 31 Mar 2020 22:58:49 +0200 Subject: [PATCH 41/42] Added some comments --- src/preferences/colorpaletteeditor.h | 2 ++ src/preferences/colorpalettesettings.h | 1 + src/util/color/colorpalette.h | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/preferences/colorpaletteeditor.h b/src/preferences/colorpaletteeditor.h index 4d5293acdee..cfe7b3d1101 100644 --- a/src/preferences/colorpaletteeditor.h +++ b/src/preferences/colorpaletteeditor.h @@ -10,6 +10,8 @@ #include "preferences/usersettings.h" #include "util/parented_ptr.h" +// Widget for viewing, adding, editing and removing color palettes that can be +// used for track/hotcue colors. Used by the Edit buttons in DlgPrefColors. class ColorPaletteEditor : public QDialog { Q_OBJECT public: diff --git a/src/preferences/colorpalettesettings.h b/src/preferences/colorpalettesettings.h index 3816073f744..df9f37d0787 100644 --- a/src/preferences/colorpalettesettings.h +++ b/src/preferences/colorpalettesettings.h @@ -3,6 +3,7 @@ #include "preferences/usersettings.h" #include "util/color/colorpalette.h" +// Saves ColorPalettes to and loads ColorPalettes from the mixxx.cfg file class ColorPaletteSettings { public: explicit ColorPaletteSettings(UserSettingsPointer pConfig) diff --git a/src/util/color/colorpalette.h b/src/util/color/colorpalette.h index d52852a9439..bdd0f859b4c 100644 --- a/src/util/color/colorpalette.h +++ b/src/util/color/colorpalette.h @@ -4,6 +4,9 @@ #include "util/color/rgbcolor.h" +// An ordered list of colors that can be picked by the user from WColorPicker, +// used for cue and track colors. Also used by CueControl to map default +// colors to hotcues based on their hotcue number class ColorPalette final { public: ColorPalette( From 9db6ad21029d61642108280c22156271d260165c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 2 Apr 2020 16:41:06 +0200 Subject: [PATCH 42/42] Use the real hotcue colors when coloring the icon --- src/preferences/dialog/dlgprefcolors.cpp | 12 +++++++----- src/preferences/dialog/dlgprefcolors.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index 7aa7e350da8..a3e09d090d9 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -172,16 +172,18 @@ QPixmap DlgPrefColors::drawPalettePreview(const QString& paletteName) { return QPixmap(); } -QIcon DlgPrefColors::drawPaletteIcon(const QString& paletteName) { +QIcon DlgPrefColors::drawHotcueColorByPaletteIcon(const QString& paletteName) { QPixmap pixmap(16, 16); QPainter painter(&pixmap); pixmap.fill(Qt::black); ColorPalette palette = m_colorPaletteSettings.getHotcueColorPalette(paletteName); if (paletteName == palette.getName()) { - for (int i = 0; i < palette.size() && i < 4; ++i) { - painter.setPen(mixxx::RgbColor::toQColor(palette.at(i))); - painter.setBrush(mixxx::RgbColor::toQColor(palette.at(i))); + for (int i = 0; i < 4; ++i) { + QColor color = mixxx::RgbColor::toQColor( + palette.colorForHotcueIndex(i)); + painter.setPen(color); + painter.setBrush(color); painter.drawRect(0, i * 4, 16, 4); } return QIcon(pixmap); @@ -197,7 +199,7 @@ void DlgPrefColors::slotHotcuePaletteChanged(const QString& paletteName) { comboBoxHotcueDefaultColor->clear(); comboBoxHotcueDefaultColor->addItem(tr("By hotcue number"), -1); - QIcon icon = drawPaletteIcon(paletteName); + QIcon icon = drawHotcueColorByPaletteIcon(paletteName); comboBoxHotcueDefaultColor->setItemIcon(0, icon); QPixmap pixmap(16, 16); diff --git a/src/preferences/dialog/dlgprefcolors.h b/src/preferences/dialog/dlgprefcolors.h index caec1a0d7ab..9ef61679cf7 100644 --- a/src/preferences/dialog/dlgprefcolors.h +++ b/src/preferences/dialog/dlgprefcolors.h @@ -38,7 +38,7 @@ class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg { const QString& paletteName, bool editHotcuePalette); QPixmap drawPalettePreview(const QString& paletteName); - QIcon drawPaletteIcon(const QString& paletteName); + QIcon drawHotcueColorByPaletteIcon(const QString& paletteName); void restoreComboBoxes( const QString& hotcueColors, const QString& trackColors,