diff --git a/src/dialog/dlgreplacecuecolor.cpp b/src/dialog/dlgreplacecuecolor.cpp index c8c5e112f47..7d0e600450a 100644 --- a/src/dialog/dlgreplacecuecolor.cpp +++ b/src/dialog/dlgreplacecuecolor.cpp @@ -90,9 +90,11 @@ DlgReplaceCueColor::DlgReplaceCueColor( } setButtonColor(pushButtonNewColor, mixxx::RgbColor::toQColor(firstColor)); - // Add menu for new color button + // Add menu for 'New color' button m_pNewColorPickerAction = make_parented( - WColorPicker::Option::AllowCustomColor, + WColorPicker::Option::AllowCustomColor | + // TODO(xxx) remove this once the preferences are themed via QSS + WColorPicker::Option::NoExtStyleSheet, colorPaletteSettings.getHotcueColorPalette(), this); m_pNewColorPickerAction->setObjectName("HotcueColorPickerAction"); @@ -110,7 +112,7 @@ DlgReplaceCueColor::DlgReplaceCueColor( m_pNewColorMenu->addAction(m_pNewColorPickerAction); pushButtonNewColor->setMenu(m_pNewColorMenu); - // Set up current color button + // Set up 'Current color' button setButtonColor(pushButtonCurrentColor, mixxx::RgbColor::toQColor( mixxx::PredefinedColorPalettes::kDefaultCueColor)); @@ -122,13 +124,15 @@ DlgReplaceCueColor::DlgReplaceCueColor( this, &DlgReplaceCueColor::slotUpdateWidgets); - // Add menu for current color button + // Add menu for 'Current color' button m_pCurrentColorPickerAction = make_parented( - WColorPicker::Option::AllowCustomColor, + WColorPicker::Option::AllowCustomColor | + // TODO(xxx) remove this once the preferences are themed via QSS + WColorPicker::Option::NoExtStyleSheet, colorPaletteSettings.getHotcueColorPalette(), this); m_pCurrentColorPickerAction->setObjectName("HotcueColorPickerAction"); - m_pNewColorPickerAction->setSelectedColor( + m_pCurrentColorPickerAction->setSelectedColor( mixxx::PredefinedColorPalettes::kDefaultCueColor); connect(m_pCurrentColorPickerAction, &WColorPickerAction::colorPicked, diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 6fe3f842a5c..5f1e5141991 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -152,6 +152,9 @@ void WColorPicker::addColorButton(mixxx::RgbColor color, QGridLayout* pLayout, i QString("QPushButton { background-color: %1; }").arg(mixxx::RgbColor::toQString(color))); pButton->setToolTip(mixxx::RgbColor::toQString(color)); pButton->setCheckable(true); + // Without this the button might shrink when setting the checkmark icon, + // both here or via external stylesheets. + pButton->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); m_colorButtons.append(pButton); connect(pButton, @@ -174,6 +177,7 @@ void WColorPicker::addNoColorButton(QGridLayout* pLayout, int row, int column) { pButton->setProperty("noColor", true); pButton->setToolTip(tr("No color")); pButton->setCheckable(true); + pButton->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); connect(pButton, &QPushButton::clicked, this, @@ -227,6 +231,9 @@ void WColorPicker::setColorButtonChecked(mixxx::RgbColor::optional_t color, bool } pButton->setChecked(checked); + if (m_options.testFlag(Option::NoExtStyleSheet)) { + pButton->setIcon(QIcon(checked ? ":/images/ic_checkmark.svg" : "")); + } // This is needed to re-apply skin styles (e.g. to show/hide a checkmark icon) pButton->style()->unpolish(pButton); pButton->style()->polish(pButton); diff --git a/src/widget/wcolorpicker.h b/src/widget/wcolorpicker.h index 52f5aa4c56b..c542e5380e8 100644 --- a/src/widget/wcolorpicker.h +++ b/src/widget/wcolorpicker.h @@ -18,6 +18,12 @@ class WColorPicker : public QWidget { NoOptions = 0, AllowNoColor = 1, AllowCustomColor = 1 << 1, + // Some color pickers can be styled with the skin stylesheets, + // for example in WCueMenuPopup or WTrackMenu. + // If that's not possible (or just not done yet), for example in + // DlgReplaceCueColor and DlgTrackInfo, use this option to un/set + // the checkmark icon on de/selected color buttons in c++. + NoExtStyleSheet = 1 << 2, }; Q_DECLARE_FLAGS(Options, Option);