From 87da9a1049e09fe85971d0176ac14e98b829681b Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sat, 16 Nov 2019 18:43:49 +0100 Subject: [PATCH 01/45] src/widget: Replace CueMenu implementation with a custom popup --- src/widget/colormenu.cpp | 43 ++++++++++++++++++++++++++++++---------- src/widget/colormenu.h | 10 ++++++---- src/widget/cuemenu.cpp | 43 ++++++++++++++++++++++++---------------- src/widget/cuemenu.h | 37 ++++++++++++++++++++++++++++------ src/widget/woverview.cpp | 2 +- 5 files changed, 97 insertions(+), 38 deletions(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index 543b2710842..15b1d631151 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -1,31 +1,54 @@ #include "widget/colormenu.h" + +#include +#include +#include + #include "util/color/color.h" -ColorMenu::ColorMenu(QWidget *parent) - : QMenu(parent) { +namespace { +const int kNumColumns = 4; +} + +ColorMenu::ColorMenu(QWidget* parent) + : QWidget(parent) { // If another title would be more appropriate in some context, setTitle // can be called again after construction. - setTitle(tr("Set color")); + QGridLayout* pLayout = new QGridLayout(); + pLayout->setMargin(0); + pLayout->setContentsMargins(0,0,0,0); + int row = 0; + int column = 0; for (const auto& pColor : Color::kPredefinedColorsSet.allColors) { if (*pColor == *Color::kPredefinedColorsSet.noColor) { continue; } - QAction* pColorAction = new QAction(pColor->m_sDisplayName, this); - QPixmap pixmap(80, 80); + QPushButton* pColorButton = new QPushButton("", this); + QPixmap pixmap(35, 20); pixmap.fill(pColor->m_defaultRgba); - pColorAction->setIcon(QIcon(pixmap)); + pColorButton->setIcon(QIcon(pixmap)); + pColorButton->setIconSize(pixmap.rect().size()); + pColorButton->setFixedSize(pixmap.rect().size()); + pColorButton->setFlat(true); + pColorButton->setToolTip(pColor->m_sDisplayName); + + pLayout->addWidget(pColorButton, row, column); + column++; + if (column == kNumColumns) { + column = 0; + row++; + } - m_pColorActions.insert(pColor, pColorAction); - addAction(pColorAction); - connect(pColorAction, &QAction::triggered, this, [pColor, this]() { + connect(pColorButton, &QPushButton::clicked, this, [pColor, this]() { emit(colorPicked(pColor)); }); } + setLayout(pLayout); } void ColorMenu::useColorSet(PredefinedColorsRepresentation* pColorRepresentation) { - QMapIterator i(m_pColorActions); + QMapIterator i(m_pColorButtons); while (i.hasNext()) { i.next(); QPixmap pixmap(80, 80); diff --git a/src/widget/colormenu.h b/src/widget/colormenu.h index 4c82943cbb8..87b0b278df9 100644 --- a/src/widget/colormenu.h +++ b/src/widget/colormenu.h @@ -1,13 +1,15 @@ #pragma once -#include +#include +#include +#include #include "util/color/color.h" -class ColorMenu : public QMenu { +class ColorMenu : public QWidget { Q_OBJECT public: - ColorMenu(QWidget *parent = nullptr); + ColorMenu(QWidget* parent = nullptr); void useColorSet(PredefinedColorsRepresentation* pColorRepresentation); @@ -15,5 +17,5 @@ class ColorMenu : public QMenu { void colorPicked(PredefinedColorPointer pColor); private: - QMap m_pColorActions; + QMap m_pColorButtons; }; diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index b9d62a30911..19947cacaa0 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -1,21 +1,34 @@ +#include "widget/cuemenu.h" + +#include #include +#include -#include "widget/cuemenu.h" #include "util/color/color.h" -CueMenu::CueMenu(QWidget *parent) - : QMenu(parent) { - m_pEditLabel = new QAction(tr("Edit label"), this); - addAction(m_pEditLabel); - connect(m_pEditLabel, &QAction::triggered, this, &CueMenu::slotEditLabel); +CueMenu::CueMenu(QWidget* parent) + : QWidget(parent) { + QWidget::hide(); + setWindowFlags(Qt::Popup); + + m_pEditLabel = new QLineEdit(this); + m_pEditLabel->setToolTip(tr("Edit cue label")); + connect(m_pEditLabel, &QLineEdit::textEdited, this, &CueMenu::slotEditLabel); m_pColorMenu = new ColorMenu(this); connect(m_pColorMenu, &ColorMenu::colorPicked, this, &CueMenu::slotChangeCueColor); - addMenu(m_pColorMenu); - m_pRemoveCue = new QAction(tr("Remove"), this); - addAction(m_pRemoveCue); - connect(m_pRemoveCue, &QAction::triggered, this, &CueMenu::slotRemoveCue); + m_pRemoveCue = new QPushButton(tr("Remove"), this); + m_pRemoveCue->setToolTip(tr("Remove this cue point")); + connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); + + QVBoxLayout* pMainLayout = new QVBoxLayout(); + QHBoxLayout* pTopLayout = new QHBoxLayout(); + pTopLayout->addWidget(m_pEditLabel); + pTopLayout->addWidget(m_pRemoveCue); + pMainLayout->addLayout(pTopLayout); + pMainLayout->addWidget(m_pColorMenu); + setLayout(pMainLayout); } CueMenu::~CueMenu() { @@ -28,13 +41,7 @@ void CueMenu::slotEditLabel() { VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { return; } - bool okay = false; - QString newLabel = QInputDialog::getText(this, tr("Edit cue label"), - tr("New cue label"), QLineEdit::Normal, - m_pCue->getLabel(), &okay); - if (okay) { - m_pCue->setLabel(newLabel); - } + m_pCue->setLabel(m_pEditLabel->text()); } void CueMenu::slotChangeCueColor(PredefinedColorPointer pColor) { @@ -45,6 +52,7 @@ void CueMenu::slotChangeCueColor(PredefinedColorPointer pColor) { return; } m_pCue->setColor(pColor); + hide(); } void CueMenu::slotRemoveCue() { @@ -55,4 +63,5 @@ void CueMenu::slotRemoveCue() { return; } m_pTrack->removeCue(m_pCue); + hide(); } diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index 3802292e44a..c59dc8b8376 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -1,19 +1,23 @@ #pragma once -#include +#include +#include -#include "track/track.h" #include "track/cue.h" +#include "track/track.h" #include "widget/colormenu.h" -class CueMenu : public QMenu { +class CueMenu : public QWidget { Q_OBJECT public: - CueMenu(QWidget *parent = nullptr); + CueMenu(QWidget* parent = nullptr); ~CueMenu() override; void setCue(CuePointer pCue) { m_pCue = pCue; + if (m_pCue) { + m_pEditLabel->setText(m_pCue->getLabel()); + } } void setTrack(TrackPointer pTrack) { @@ -26,6 +30,27 @@ class CueMenu : public QMenu { } } + void popup(const QPoint &p, QAction *atAction = nullptr) { + Q_UNUSED(atAction); + qDebug() << "Showing menu at" << p; + move(p); + show(); + } + + void hide() { + emit(aboutToHide()); + QWidget::hide(); + } + + void show() { + emit(aboutToShow()); + QWidget::show(); + } + + signals: + void aboutToHide(); + void aboutToShow(); + private slots: void slotEditLabel(); void slotRemoveCue(); @@ -35,7 +60,7 @@ class CueMenu : public QMenu { CuePointer m_pCue; TrackPointer m_pTrack; - QAction* m_pEditLabel; + QLineEdit* m_pEditLabel; ColorMenu* m_pColorMenu; - QAction* m_pRemoveCue; + QPushButton* m_pRemoveCue; }; diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 62697f2ae01..0ec8c32effb 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -87,7 +87,7 @@ WOverview::WOverview( connect(pPlayerManager, &PlayerManager::trackAnalyzerProgress, this, &WOverview::onTrackAnalyzerProgress); - connect(m_pCueMenu.get(), &QMenu::aboutToHide, this, &WOverview::slotCueMenuAboutToHide); + connect(m_pCueMenu.get(), &CueMenu::aboutToHide, this, &WOverview::slotCueMenuAboutToHide); } void WOverview::setup(const QDomNode& node, const SkinContext& context) { From 18a1298c95f4803d93fb6138261d6c8d3a71fd16 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sun, 17 Nov 2019 02:36:38 +0100 Subject: [PATCH 02/45] src/widget/colormenu: Use QPalette for button color instead of QIcon --- src/widget/colormenu.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index 15b1d631151..a0ccf9ea09f 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -25,11 +25,9 @@ ColorMenu::ColorMenu(QWidget* parent) } QPushButton* pColorButton = new QPushButton("", this); - QPixmap pixmap(35, 20); - pixmap.fill(pColor->m_defaultRgba); - pColorButton->setIcon(QIcon(pixmap)); - pColorButton->setIconSize(pixmap.rect().size()); - pColorButton->setFixedSize(pixmap.rect().size()); + QPalette p(pColorButton->palette()); + p.setColor(QPalette::Button, pColor->m_defaultRgba); + pColorButton->setPalette(p); pColorButton->setFlat(true); pColorButton->setToolTip(pColor->m_sDisplayName); From 57d5a038729e6f9b1945a83f06cd45912309052a Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sun, 17 Nov 2019 02:37:37 +0100 Subject: [PATCH 03/45] src/widget/colormenu: Do not make the color buttons flat --- src/widget/colormenu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index a0ccf9ea09f..11e39e65fb2 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -28,7 +28,6 @@ ColorMenu::ColorMenu(QWidget* parent) QPalette p(pColorButton->palette()); p.setColor(QPalette::Button, pColor->m_defaultRgba); pColorButton->setPalette(p); - pColorButton->setFlat(true); pColorButton->setToolTip(pColor->m_sDisplayName); pLayout->addWidget(pColorButton, row, column); From 911f0696919d6f6f5bd82901043bfa9b8f8dd239 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 18 Nov 2019 16:26:58 +0100 Subject: [PATCH 04/45] widget/cuemenu: Use icon instead of label for remove cue button --- src/widget/cuemenu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 19947cacaa0..dca066dfa81 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -18,8 +18,10 @@ CueMenu::CueMenu(QWidget* parent) m_pColorMenu = new ColorMenu(this); connect(m_pColorMenu, &ColorMenu::colorPicked, this, &CueMenu::slotChangeCueColor); - m_pRemoveCue = new QPushButton(tr("Remove"), this); + QIcon icon(":/images/library/ic_library_cross.svg"); + m_pRemoveCue = new QPushButton(icon, "", this); m_pRemoveCue->setToolTip(tr("Remove this cue point")); + m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); QVBoxLayout* pMainLayout = new QVBoxLayout(); From 9fbabdd76c69e9be41f4e4b82243af186ec1893e Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 10:06:35 +0100 Subject: [PATCH 05/45] widget/colormenu: Use better variable name for QPalette object --- src/widget/colormenu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index 11e39e65fb2..df2cef9c705 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -25,9 +25,9 @@ ColorMenu::ColorMenu(QWidget* parent) } QPushButton* pColorButton = new QPushButton("", this); - QPalette p(pColorButton->palette()); - p.setColor(QPalette::Button, pColor->m_defaultRgba); - pColorButton->setPalette(p); + QPalette palette = pColorButton->palette(); + palette.setColor(QPalette::Button, pColor->m_defaultRgba); + pColorButton->setPalette(palette); pColorButton->setToolTip(pColor->m_sDisplayName); pLayout->addWidget(pColorButton, row, column); From e318fa089b5ca7baed30473363d1d908e3a7fb42 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 10:31:18 +0100 Subject: [PATCH 06/45] widget/colormenu: Add missing spaces after comma in function parameters --- src/widget/colormenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index df2cef9c705..4ab58319e17 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -16,7 +16,7 @@ ColorMenu::ColorMenu(QWidget* parent) // can be called again after construction. QGridLayout* pLayout = new QGridLayout(); pLayout->setMargin(0); - pLayout->setContentsMargins(0,0,0,0); + pLayout->setContentsMargins(0, 0, 0, 0); int row = 0; int column = 0; for (const auto& pColor : Color::kPredefinedColorsSet.allColors) { From 98d0e3b2de91ac49dddd1d13b291554e58609a99 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 10:40:32 +0100 Subject: [PATCH 07/45] widget/cuemenu: Add object names for CueMenu items --- src/widget/cuemenu.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index dca066dfa81..940c0c8ffde 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -10,18 +10,22 @@ CueMenu::CueMenu(QWidget* parent) : QWidget(parent) { QWidget::hide(); setWindowFlags(Qt::Popup); + setObjectName("CueMenu"); m_pEditLabel = new QLineEdit(this); m_pEditLabel->setToolTip(tr("Edit cue label")); + m_pEditLabel->setObjectName("CueLabelEdit"); connect(m_pEditLabel, &QLineEdit::textEdited, this, &CueMenu::slotEditLabel); m_pColorMenu = new ColorMenu(this); + m_pColorMenu->setObjectName("CueColorPicker"); connect(m_pColorMenu, &ColorMenu::colorPicked, this, &CueMenu::slotChangeCueColor); QIcon icon(":/images/library/ic_library_cross.svg"); m_pRemoveCue = new QPushButton(icon, "", this); m_pRemoveCue->setToolTip(tr("Remove this cue point")); m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); + m_pRemoveCue->setObjectName("RemoveCueButton"); connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); QVBoxLayout* pMainLayout = new QVBoxLayout(); From 16820ceb76fa07d16596c4836d60fb88ae368663 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 11:26:41 +0100 Subject: [PATCH 08/45] widget/colormenu: Fix ColorMenu::useColorSet() implementation --- src/widget/colormenu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index 4ab58319e17..d2c93038824 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -48,12 +48,15 @@ void ColorMenu::useColorSet(PredefinedColorsRepresentation* pColorRepresentation QMapIterator i(m_pColorButtons); while (i.hasNext()) { i.next(); - QPixmap pixmap(80, 80); + PredefinedColorPointer pColor = i.key(); + QPushButton* pColorButton = i.value(); + QPalette palette = pColorButton->palette(); if (pColorRepresentation == nullptr) { - pixmap.fill(i.key()->m_defaultRgba); + palette.setColor(QPalette::Button, pColor->m_defaultRgba); } else { - pixmap.fill(pColorRepresentation->representationFor(i.key())); + palette.setColor(QPalette::Button, pColorRepresentation->representationFor(pColor)); } - i.value()->setIcon(QIcon(pixmap)); + pColorButton->setToolTip(pColor->m_sDisplayName); + pColorButton->setPalette(palette); } } From b20f56b85a0d62cae4a8aaed0175a4ebac86b919 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 11:35:44 +0100 Subject: [PATCH 09/45] widget/colormenu: Use parented_ptr for QPushButtons --- src/widget/colormenu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index d2c93038824..4158117a1c5 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -5,6 +5,7 @@ #include #include "util/color/color.h" +#include "util/parented_ptr.h" namespace { const int kNumColumns = 4; @@ -24,7 +25,7 @@ ColorMenu::ColorMenu(QWidget* parent) continue; } - QPushButton* pColorButton = new QPushButton("", this); + parented_ptr pColorButton = make_parented("", this); QPalette palette = pColorButton->palette(); palette.setColor(QPalette::Button, pColor->m_defaultRgba); pColorButton->setPalette(palette); From 8e545fd79dadd7a28736f1263deec72cec122ddf Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 12:03:23 +0100 Subject: [PATCH 10/45] widget/cuemenu: Replace RemoveCueButton object name with CueRemoveButton --- src/widget/cuemenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 940c0c8ffde..5b485a5d418 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -25,7 +25,7 @@ CueMenu::CueMenu(QWidget* parent) m_pRemoveCue = new QPushButton(icon, "", this); m_pRemoveCue->setToolTip(tr("Remove this cue point")); m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); - m_pRemoveCue->setObjectName("RemoveCueButton"); + m_pRemoveCue->setObjectName("CueRemoveButton"); connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); QVBoxLayout* pMainLayout = new QVBoxLayout(); From 60f55f10522d044ec1c5e794db655845e518e223 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 12:10:22 +0100 Subject: [PATCH 11/45] widget/cuemenu: Move button icon setting to skin qss --- res/skins/Deere/style.qss | 4 ++++ res/skins/LateNight/style.qss | 3 +++ res/skins/Shade/style.qss | 4 ++++ res/skins/Tango/style.qss | 3 +++ src/widget/cuemenu.cpp | 3 +-- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index c89a5eca6b4..7a7e41db315 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -1742,6 +1742,10 @@ WPushButton[value="2"]:hover { border-radius: 3px; } +CueMenu #CueRemoveButton { + qproperty-icon: url(:/images/library/ic_library_cross.svg); +} + WRecordingDuration { font-weight: bold; } diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index b2101872d4e..e7d148339b6 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -577,6 +577,9 @@ WTime { font-size: 10px/10px; } +CueMenu #CueRemoveButton { + qproperty-icon: url(:/images/library/ic_library_cross.svg); +} /********************** Decks **********************/ diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 158e25eb970..0e603d74efc 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -597,3 +597,7 @@ QPushButton#pushButtonRepeatPlaylist { #HotcueButton[highlight="8"] { background-color: #f2f2ff; } + +CueMenu #CueRemoveButton { + qproperty-icon: url(:/images/library/ic_library_cross.svg); +} diff --git a/res/skins/Tango/style.qss b/res/skins/Tango/style.qss index dbde02e6c39..29313ea6051 100644 --- a/res/skins/Tango/style.qss +++ b/res/skins/Tango/style.qss @@ -94,6 +94,9 @@ WWidgetGroup { image: url(skin:/graphics/splitterVert_handle_pressed.svg); } +CueMenu #CueRemoveButton { + qproperty-icon: url(:/images/library/ic_library_cross.svg); +} /* ################################################################ ####### Colors ################################################## diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 5b485a5d418..9361e08edc0 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -21,8 +21,7 @@ CueMenu::CueMenu(QWidget* parent) m_pColorMenu->setObjectName("CueColorPicker"); connect(m_pColorMenu, &ColorMenu::colorPicked, this, &CueMenu::slotChangeCueColor); - QIcon icon(":/images/library/ic_library_cross.svg"); - m_pRemoveCue = new QPushButton(icon, "", this); + m_pRemoveCue = new QPushButton("", this); m_pRemoveCue->setToolTip(tr("Remove this cue point")); m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); m_pRemoveCue->setObjectName("CueRemoveButton"); From 56133d41c20bd9d48e202eba9b3181f12962a76d Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 13:12:04 +0100 Subject: [PATCH 12/45] widget/cuemenu: Fix code style with clang-format --- src/widget/cuemenu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index c59dc8b8376..b4de36e417d 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -30,7 +30,7 @@ class CueMenu : public QWidget { } } - void popup(const QPoint &p, QAction *atAction = nullptr) { + void popup(const QPoint& p, QAction* atAction = nullptr) { Q_UNUSED(atAction); qDebug() << "Showing menu at" << p; move(p); From f361f758face2853223b1e780d3fed792fbb6511 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 14:27:06 +0100 Subject: [PATCH 13/45] widget/colormenu: Highlight currently selected cue color --- src/widget/colormenu.cpp | 24 ++++++++++++++++++++++++ src/widget/colormenu.h | 2 ++ src/widget/cuemenu.cpp | 1 + src/widget/cuemenu.h | 3 +++ 4 files changed, 30 insertions(+) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index 4158117a1c5..a561a0b396e 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -30,6 +30,7 @@ ColorMenu::ColorMenu(QWidget* parent) palette.setColor(QPalette::Button, pColor->m_defaultRgba); pColorButton->setPalette(palette); pColorButton->setToolTip(pColor->m_sDisplayName); + m_pColorButtons.insert(pColor, pColorButton); pLayout->addWidget(pColorButton, row, column); column++; @@ -45,6 +46,29 @@ ColorMenu::ColorMenu(QWidget* parent) setLayout(pLayout); } +void ColorMenu::setSelectedColor(PredefinedColorPointer pColor) { + qDebug() << "setSelectedColor"; + if (m_pSelectedColor) { + qDebug() << "m_pSelectedColor"; + QMap::const_iterator it = m_pColorButtons.find(m_pSelectedColor); + if (it != m_pColorButtons.constEnd()) { + qDebug() << it.value() << "setDown(false)"; + it.value()->setDown(false); + } + } + + if (pColor) { + qDebug() << "m_pColor"; + QMap::const_iterator it = m_pColorButtons.find(pColor); + if (it != m_pColorButtons.constEnd()) { + qDebug() << it.value() << "setDown(true)"; + it.value()->setDown(true); + } + } + + m_pSelectedColor = pColor; +} + void ColorMenu::useColorSet(PredefinedColorsRepresentation* pColorRepresentation) { QMapIterator i(m_pColorButtons); while (i.hasNext()) { diff --git a/src/widget/colormenu.h b/src/widget/colormenu.h index 87b0b278df9..015df06f55f 100644 --- a/src/widget/colormenu.h +++ b/src/widget/colormenu.h @@ -11,6 +11,7 @@ class ColorMenu : public QWidget { public: ColorMenu(QWidget* parent = nullptr); + void setSelectedColor(PredefinedColorPointer pColor = nullptr); void useColorSet(PredefinedColorsRepresentation* pColorRepresentation); signals: @@ -18,4 +19,5 @@ class ColorMenu : public QWidget { private: QMap m_pColorButtons; + PredefinedColorPointer m_pSelectedColor; }; diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 9361e08edc0..a2fd64baf00 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -57,6 +57,7 @@ void CueMenu::slotChangeCueColor(PredefinedColorPointer pColor) { return; } m_pCue->setColor(pColor); + m_pColorMenu->setSelectedColor(pColor); hide(); } diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index b4de36e417d..3635fa1d3dd 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -17,6 +17,9 @@ class CueMenu : public QWidget { m_pCue = pCue; if (m_pCue) { m_pEditLabel->setText(m_pCue->getLabel()); + m_pColorMenu->setSelectedColor(m_pCue->getColor()); + } else { + m_pColorMenu->setSelectedColor(); } } From f724e03ba60e68cdc05a16b09aab7f439808d2e2 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 15:37:35 +0100 Subject: [PATCH 14/45] widget/cuemenu: Improve cue menu box layout --- src/widget/cuemenu.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index a2fd64baf00..d4b621cc742 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -27,12 +27,17 @@ CueMenu::CueMenu(QWidget* parent) m_pRemoveCue->setObjectName("CueRemoveButton"); connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); - QVBoxLayout* pMainLayout = new QVBoxLayout(); - QHBoxLayout* pTopLayout = new QHBoxLayout(); - pTopLayout->addWidget(m_pEditLabel); - pTopLayout->addWidget(m_pRemoveCue); - pMainLayout->addLayout(pTopLayout); - pMainLayout->addWidget(m_pColorMenu); + QVBoxLayout* pLeftLayout = new QVBoxLayout(); + pLeftLayout->addWidget(m_pEditLabel); + pLeftLayout->addWidget(m_pColorMenu); + + QVBoxLayout* pRightLayout = new QVBoxLayout(); + pRightLayout->addWidget(m_pRemoveCue); + pRightLayout->addStretch(1); + + QHBoxLayout* pMainLayout = new QHBoxLayout(); + pMainLayout->addLayout(pLeftLayout); + pMainLayout->addLayout(pRightLayout); setLayout(pMainLayout); } From 6f448053f87e23557ea0181d57fccc80e8627e27 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 19 Nov 2019 16:09:44 +0100 Subject: [PATCH 15/45] widget/cuemenu: Add space between label/colorpicker and remove button --- src/widget/cuemenu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index d4b621cc742..cdb4394222a 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -37,6 +37,7 @@ CueMenu::CueMenu(QWidget* parent) QHBoxLayout* pMainLayout = new QHBoxLayout(); pMainLayout->addLayout(pLeftLayout); + pMainLayout->addSpacing(5); pMainLayout->addLayout(pRightLayout); setLayout(pMainLayout); } From e71074a9ee5162ccb4f946526334ece14cb2facd Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 20 Nov 2019 00:25:34 +0100 Subject: [PATCH 16/45] widget/cuemenu: Merge setCue() and setTrack() to setTrackAndCue() --- src/widget/cuemenu.cpp | 14 ++++++++++++++ src/widget/cuemenu.h | 14 +------------- src/widget/woverview.cpp | 3 +-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index cdb4394222a..8338770a4d6 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -48,6 +48,20 @@ CueMenu::~CueMenu() { delete m_pRemoveCue; } +void CueMenu::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { + if (pTrack && pCue) { + m_pTrack = pTrack; + m_pCue = pCue; + m_pEditLabel->setText(m_pCue->getLabel()); + m_pColorMenu->setSelectedColor(m_pCue->getColor()); + } else { + m_pTrack.reset(); + m_pCue.reset(); + m_pEditLabel->setText(QString("")); + m_pColorMenu->setSelectedColor(); + } +} + void CueMenu::slotEditLabel() { VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { return; diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index 3635fa1d3dd..f5c70918bca 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -13,19 +13,7 @@ class CueMenu : public QWidget { CueMenu(QWidget* parent = nullptr); ~CueMenu() override; - void setCue(CuePointer pCue) { - m_pCue = pCue; - if (m_pCue) { - m_pEditLabel->setText(m_pCue->getLabel()); - m_pColorMenu->setSelectedColor(m_pCue->getColor()); - } else { - m_pColorMenu->setSelectedColor(); - } - } - - void setTrack(TrackPointer pTrack) { - m_pTrack = pTrack; - } + void setTrackAndCue(TrackPointer pTrack, CuePointer pCue); void useColorSet(PredefinedColorsRepresentation* pColorRepresentation) { if (m_pColorMenu != nullptr) { diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 0ec8c32effb..4c951c49e02 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -469,8 +469,7 @@ void WOverview::mousePressEvent(QMouseEvent* e) { } } if (pHoveredCue != nullptr) { - m_pCueMenu->setCue(pHoveredCue); - m_pCueMenu->setTrack(m_pCurrentTrack); + m_pCueMenu->setTrackAndCue(m_pCurrentTrack, pHoveredCue); m_pCueMenu->popup(e->globalPos()); m_bHotcueMenuShowing = true; } From 92d0e35cfb0e0a7c1ad221946ca3ca6959080d26 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 20 Nov 2019 01:06:47 +0100 Subject: [PATCH 17/45] widget/cuemenu: Add number and position as labels --- src/widget/cuemenu.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++ src/widget/cuemenu.h | 3 +++ 2 files changed, 47 insertions(+) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 8338770a4d6..9652123bde2 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -4,6 +4,7 @@ #include #include +#include "engine/engine.h" #include "util/color/color.h" CueMenu::CueMenu(QWidget* parent) @@ -12,6 +13,16 @@ CueMenu::CueMenu(QWidget* parent) setWindowFlags(Qt::Popup); setObjectName("CueMenu"); + m_pCueNumber = new QLabel(this); + m_pCueNumber->setToolTip(tr("cue number")); + m_pCueNumber->setObjectName("CueNumberLabel"); + m_pCueNumber->setAlignment(Qt::AlignLeft); + + m_pCuePosition = new QLabel(this); + m_pCuePosition->setToolTip(tr("Cue position")); + m_pCuePosition->setObjectName("CuePositionLabel"); + m_pCuePosition->setAlignment(Qt::AlignRight); + m_pEditLabel = new QLineEdit(this); m_pEditLabel->setToolTip(tr("Edit cue label")); m_pEditLabel->setObjectName("CueLabelEdit"); @@ -27,7 +38,13 @@ CueMenu::CueMenu(QWidget* parent) m_pRemoveCue->setObjectName("CueRemoveButton"); connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); + QHBoxLayout* pLabelLayout = new QHBoxLayout(); + pLabelLayout->addWidget(m_pCueNumber); + pLabelLayout->addStretch(1); + pLabelLayout->addWidget(m_pCuePosition); + QVBoxLayout* pLeftLayout = new QVBoxLayout(); + pLeftLayout->addLayout(pLabelLayout); pLeftLayout->addWidget(m_pEditLabel); pLeftLayout->addWidget(m_pColorMenu); @@ -43,6 +60,8 @@ CueMenu::CueMenu(QWidget* parent) } CueMenu::~CueMenu() { + delete m_pCueNumber; + delete m_pCuePosition; delete m_pEditLabel; delete m_pColorMenu; delete m_pRemoveCue; @@ -52,11 +71,36 @@ void CueMenu::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { if (pTrack && pCue) { m_pTrack = pTrack; m_pCue = pCue; + + int hotcueNumber = m_pCue->getHotCue(); + QString hotcueNumberText = ""; + if (hotcueNumber != Cue::kNoHotCue) { + // Programmers count from 0, but DJs count from 1 + hotcueNumberText = QString::number(hotcueNumber + 1); + } + m_pCueNumber->setText(hotcueNumberText); + + QString positionText = ""; + double startPosition = m_pCue->getPosition(); + double endPosition = m_pCue->getEndPosition(); + if (startPosition != Cue::kNoPosition) { + positionText = mixxx::Duration::formatTime(startPosition / m_pTrack->getSampleRate() / mixxx::kEngineChannelCount); + if (endPosition != Cue::kNoPosition) { + positionText = QString("%1 - %2").arg( + positionText, + mixxx::Duration::formatTime(endPosition / m_pTrack->getSampleRate() / mixxx::kEngineChannelCount) + ); + } + } + m_pCuePosition->setText(positionText); + m_pEditLabel->setText(m_pCue->getLabel()); m_pColorMenu->setSelectedColor(m_pCue->getColor()); } else { m_pTrack.reset(); m_pCue.reset(); + m_pCueNumber->setText(QString("")); + m_pCuePosition->setText(QString("")); m_pEditLabel->setText(QString("")); m_pColorMenu->setSelectedColor(); } diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index f5c70918bca..25a6c2c8263 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -51,6 +52,8 @@ class CueMenu : public QWidget { CuePointer m_pCue; TrackPointer m_pTrack; + QLabel* m_pCueNumber; + QLabel* m_pCuePosition; QLineEdit* m_pEditLabel; ColorMenu* m_pColorMenu; QPushButton* m_pRemoveCue; From 238dbc0ff1c5006cbb0d3f716f3248c92a3092ea Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 20 Nov 2019 01:13:21 +0100 Subject: [PATCH 18/45] widget/cuemenu: Move destructor to header file --- src/widget/cuemenu.cpp | 8 -------- src/widget/cuemenu.h | 9 ++++++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 9652123bde2..7a1aa9fbf5b 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -59,14 +59,6 @@ CueMenu::CueMenu(QWidget* parent) setLayout(pMainLayout); } -CueMenu::~CueMenu() { - delete m_pCueNumber; - delete m_pCuePosition; - delete m_pEditLabel; - delete m_pColorMenu; - delete m_pRemoveCue; -} - void CueMenu::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { if (pTrack && pCue) { m_pTrack = pTrack; diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index 25a6c2c8263..2a28bfabe04 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -12,7 +12,14 @@ class CueMenu : public QWidget { Q_OBJECT public: CueMenu(QWidget* parent = nullptr); - ~CueMenu() override; + + ~CueMenu() { + delete m_pCueNumber; + delete m_pCuePosition; + delete m_pEditLabel; + delete m_pColorMenu; + delete m_pRemoveCue; + } void setTrackAndCue(TrackPointer pTrack, CuePointer pCue); From 3a12d7abec8ca9b98649977c6813ea3bbf07fcef Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 11:29:46 +0100 Subject: [PATCH 19/45] widget/colormenu: Use background-color styled buttons instead of QPalette From the QPalette documentation: > Warning: Some styles do not use the palette for all drawing, for > instance, if they make use of native theme engines. This is the case > for both the Windows Vista and the macOS styles. This is probably the reason for the issue reported by @ronso0: https://github.com/mixxxdj/mixxx/pull/2362#issuecomment-555663533 --- src/widget/colormenu.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/widget/colormenu.cpp b/src/widget/colormenu.cpp index a561a0b396e..f5595b9037d 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/colormenu.cpp @@ -26,9 +26,10 @@ ColorMenu::ColorMenu(QWidget* parent) } parented_ptr pColorButton = make_parented("", this); - QPalette palette = pColorButton->palette(); - palette.setColor(QPalette::Button, pColor->m_defaultRgba); - pColorButton->setPalette(palette); + pColorButton->setStyleSheet(QString("background-color: #%1;").arg( + QString::number(pColor->m_defaultRgba.rgb(), 16) + )); + pColorButton->setToolTip(pColor->m_sDisplayName); m_pColorButtons.insert(pColor, pColorButton); @@ -75,13 +76,11 @@ void ColorMenu::useColorSet(PredefinedColorsRepresentation* pColorRepresentation i.next(); PredefinedColorPointer pColor = i.key(); QPushButton* pColorButton = i.value(); - QPalette palette = pColorButton->palette(); - if (pColorRepresentation == nullptr) { - palette.setColor(QPalette::Button, pColor->m_defaultRgba); - } else { - palette.setColor(QPalette::Button, pColorRepresentation->representationFor(pColor)); - } + QColor color = (pColorRepresentation == nullptr) ? pColor->m_defaultRgba : pColorRepresentation->representationFor(pColor); + pColorButton->setStyleSheet(QString("background-color: #%1;").arg( + QString::number(color.rgb(), 16) + )); + pColorButton->setToolTip(pColor->m_sDisplayName); - pColorButton->setPalette(palette); } } From 036de53eae3c26e7115016b73a61acc988f3e18c Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 11:42:35 +0100 Subject: [PATCH 20/45] widget: Rename ColorMenu widget to WColorPicker --- build/depends.py | 2 +- src/widget/cuemenu.cpp | 14 +++++++------- src/widget/cuemenu.h | 10 +++++----- src/widget/{colormenu.cpp => wcolorpicker.cpp} | 8 ++++---- src/widget/{colormenu.h => wcolorpicker.h} | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) rename src/widget/{colormenu.cpp => wcolorpicker.cpp} (91%) rename src/widget/{colormenu.h => wcolorpicker.h} (84%) diff --git a/build/depends.py b/build/depends.py index 5298cf87b73..90c2374b11f 100644 --- a/build/depends.py +++ b/build/depends.py @@ -930,7 +930,6 @@ def sources(self, build): "src/sources/soundsourceproviderregistry.cpp", "src/sources/soundsourceproxy.cpp", - "src/widget/colormenu.cpp", "src/widget/controlwidgetconnection.cpp", "src/widget/cuemenu.cpp", "src/widget/wbasewidget.cpp", @@ -983,6 +982,7 @@ def sources(self, build): "src/widget/wcoverart.cpp", "src/widget/wcoverartlabel.cpp", "src/widget/wcoverartmenu.cpp", + "src/widget/wcolorpicker.cpp", "src/widget/wsingletoncontainer.cpp", "src/widget/wmainmenubar.cpp", diff --git a/src/widget/cuemenu.cpp b/src/widget/cuemenu.cpp index 7a1aa9fbf5b..eb13749fe9e 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/cuemenu.cpp @@ -28,9 +28,9 @@ CueMenu::CueMenu(QWidget* parent) m_pEditLabel->setObjectName("CueLabelEdit"); connect(m_pEditLabel, &QLineEdit::textEdited, this, &CueMenu::slotEditLabel); - m_pColorMenu = new ColorMenu(this); - m_pColorMenu->setObjectName("CueColorPicker"); - connect(m_pColorMenu, &ColorMenu::colorPicked, this, &CueMenu::slotChangeCueColor); + m_pColorPicker = new WColorPicker(this); + m_pColorPicker->setObjectName("CueColorPicker"); + connect(m_pColorPicker, &WColorPicker::colorPicked, this, &CueMenu::slotChangeCueColor); m_pRemoveCue = new QPushButton("", this); m_pRemoveCue->setToolTip(tr("Remove this cue point")); @@ -46,7 +46,7 @@ CueMenu::CueMenu(QWidget* parent) QVBoxLayout* pLeftLayout = new QVBoxLayout(); pLeftLayout->addLayout(pLabelLayout); pLeftLayout->addWidget(m_pEditLabel); - pLeftLayout->addWidget(m_pColorMenu); + pLeftLayout->addWidget(m_pColorPicker); QVBoxLayout* pRightLayout = new QVBoxLayout(); pRightLayout->addWidget(m_pRemoveCue); @@ -87,14 +87,14 @@ void CueMenu::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { m_pCuePosition->setText(positionText); m_pEditLabel->setText(m_pCue->getLabel()); - m_pColorMenu->setSelectedColor(m_pCue->getColor()); + m_pColorPicker->setSelectedColor(m_pCue->getColor()); } else { m_pTrack.reset(); m_pCue.reset(); m_pCueNumber->setText(QString("")); m_pCuePosition->setText(QString("")); m_pEditLabel->setText(QString("")); - m_pColorMenu->setSelectedColor(); + m_pColorPicker->setSelectedColor(); } } @@ -113,7 +113,7 @@ void CueMenu::slotChangeCueColor(PredefinedColorPointer pColor) { return; } m_pCue->setColor(pColor); - m_pColorMenu->setSelectedColor(pColor); + m_pColorPicker->setSelectedColor(pColor); hide(); } diff --git a/src/widget/cuemenu.h b/src/widget/cuemenu.h index 2a28bfabe04..e47ef4410db 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/cuemenu.h @@ -6,7 +6,7 @@ #include "track/cue.h" #include "track/track.h" -#include "widget/colormenu.h" +#include "widget/wcolorpicker.h" class CueMenu : public QWidget { Q_OBJECT @@ -17,15 +17,15 @@ class CueMenu : public QWidget { delete m_pCueNumber; delete m_pCuePosition; delete m_pEditLabel; - delete m_pColorMenu; + delete m_pColorPicker; delete m_pRemoveCue; } void setTrackAndCue(TrackPointer pTrack, CuePointer pCue); void useColorSet(PredefinedColorsRepresentation* pColorRepresentation) { - if (m_pColorMenu != nullptr) { - m_pColorMenu->useColorSet(pColorRepresentation); + if (m_pColorPicker != nullptr) { + m_pColorPicker->useColorSet(pColorRepresentation); } } @@ -62,6 +62,6 @@ class CueMenu : public QWidget { QLabel* m_pCueNumber; QLabel* m_pCuePosition; QLineEdit* m_pEditLabel; - ColorMenu* m_pColorMenu; + WColorPicker* m_pColorPicker; QPushButton* m_pRemoveCue; }; diff --git a/src/widget/colormenu.cpp b/src/widget/wcolorpicker.cpp similarity index 91% rename from src/widget/colormenu.cpp rename to src/widget/wcolorpicker.cpp index f5595b9037d..037c0f159c2 100644 --- a/src/widget/colormenu.cpp +++ b/src/widget/wcolorpicker.cpp @@ -1,4 +1,4 @@ -#include "widget/colormenu.h" +#include "widget/wcolorpicker.h" #include #include @@ -11,7 +11,7 @@ namespace { const int kNumColumns = 4; } -ColorMenu::ColorMenu(QWidget* parent) +WColorPicker::WColorPicker(QWidget* parent) : QWidget(parent) { // If another title would be more appropriate in some context, setTitle // can be called again after construction. @@ -47,7 +47,7 @@ ColorMenu::ColorMenu(QWidget* parent) setLayout(pLayout); } -void ColorMenu::setSelectedColor(PredefinedColorPointer pColor) { +void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { qDebug() << "setSelectedColor"; if (m_pSelectedColor) { qDebug() << "m_pSelectedColor"; @@ -70,7 +70,7 @@ void ColorMenu::setSelectedColor(PredefinedColorPointer pColor) { m_pSelectedColor = pColor; } -void ColorMenu::useColorSet(PredefinedColorsRepresentation* pColorRepresentation) { +void WColorPicker::useColorSet(PredefinedColorsRepresentation* pColorRepresentation) { QMapIterator i(m_pColorButtons); while (i.hasNext()) { i.next(); diff --git a/src/widget/colormenu.h b/src/widget/wcolorpicker.h similarity index 84% rename from src/widget/colormenu.h rename to src/widget/wcolorpicker.h index 015df06f55f..f40d3c33b1b 100644 --- a/src/widget/colormenu.h +++ b/src/widget/wcolorpicker.h @@ -6,10 +6,10 @@ #include "util/color/color.h" -class ColorMenu : public QWidget { +class WColorPicker : public QWidget { Q_OBJECT public: - ColorMenu(QWidget* parent = nullptr); + WColorPicker(QWidget* parent = nullptr); void setSelectedColor(PredefinedColorPointer pColor = nullptr); void useColorSet(PredefinedColorsRepresentation* pColorRepresentation); From d26d6b4c057a520521e1aa4de426e72cfac791e8 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 11:51:38 +0100 Subject: [PATCH 21/45] widget: Rename CueMenu widget to WCueMenuPopup --- build/depends.py | 2 +- src/widget/{cuemenu.cpp => wcuemenupopup.cpp} | 20 +++++++++---------- src/widget/{cuemenu.h => wcuemenupopup.h} | 6 +++--- src/widget/woverview.cpp | 16 +++++++-------- src/widget/woverview.h | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) rename src/widget/{cuemenu.cpp => wcuemenupopup.cpp} (85%) rename src/widget/{cuemenu.h => wcuemenupopup.h} (92%) diff --git a/build/depends.py b/build/depends.py index 90c2374b11f..233ac86e1c9 100644 --- a/build/depends.py +++ b/build/depends.py @@ -931,7 +931,6 @@ def sources(self, build): "src/sources/soundsourceproxy.cpp", "src/widget/controlwidgetconnection.cpp", - "src/widget/cuemenu.cpp", "src/widget/wbasewidget.cpp", "src/widget/wwidget.cpp", "src/widget/wwidgetgroup.cpp", @@ -983,6 +982,7 @@ def sources(self, build): "src/widget/wcoverartlabel.cpp", "src/widget/wcoverartmenu.cpp", "src/widget/wcolorpicker.cpp", + "src/widget/wcuemenupopup.cpp", "src/widget/wsingletoncontainer.cpp", "src/widget/wmainmenubar.cpp", diff --git a/src/widget/cuemenu.cpp b/src/widget/wcuemenupopup.cpp similarity index 85% rename from src/widget/cuemenu.cpp rename to src/widget/wcuemenupopup.cpp index eb13749fe9e..89f1a482dd0 100644 --- a/src/widget/cuemenu.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -1,4 +1,4 @@ -#include "widget/cuemenu.h" +#include "widget/wcuemenupopup.h" #include #include @@ -7,11 +7,11 @@ #include "engine/engine.h" #include "util/color/color.h" -CueMenu::CueMenu(QWidget* parent) +WCueMenuPopup::WCueMenuPopup(QWidget* parent) : QWidget(parent) { QWidget::hide(); setWindowFlags(Qt::Popup); - setObjectName("CueMenu"); + setObjectName("WCueMenuPopup"); m_pCueNumber = new QLabel(this); m_pCueNumber->setToolTip(tr("cue number")); @@ -26,17 +26,17 @@ CueMenu::CueMenu(QWidget* parent) m_pEditLabel = new QLineEdit(this); m_pEditLabel->setToolTip(tr("Edit cue label")); m_pEditLabel->setObjectName("CueLabelEdit"); - connect(m_pEditLabel, &QLineEdit::textEdited, this, &CueMenu::slotEditLabel); + connect(m_pEditLabel, &QLineEdit::textEdited, this, &WCueMenuPopup::slotEditLabel); m_pColorPicker = new WColorPicker(this); m_pColorPicker->setObjectName("CueColorPicker"); - connect(m_pColorPicker, &WColorPicker::colorPicked, this, &CueMenu::slotChangeCueColor); + connect(m_pColorPicker, &WColorPicker::colorPicked, this, &WCueMenuPopup::slotChangeCueColor); m_pRemoveCue = new QPushButton("", this); m_pRemoveCue->setToolTip(tr("Remove this cue point")); m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); m_pRemoveCue->setObjectName("CueRemoveButton"); - connect(m_pRemoveCue, &QPushButton::clicked, this, &CueMenu::slotRemoveCue); + connect(m_pRemoveCue, &QPushButton::clicked, this, &WCueMenuPopup::slotRemoveCue); QHBoxLayout* pLabelLayout = new QHBoxLayout(); pLabelLayout->addWidget(m_pCueNumber); @@ -59,7 +59,7 @@ CueMenu::CueMenu(QWidget* parent) setLayout(pMainLayout); } -void CueMenu::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { +void WCueMenuPopup::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { if (pTrack && pCue) { m_pTrack = pTrack; m_pCue = pCue; @@ -98,14 +98,14 @@ void CueMenu::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { } } -void CueMenu::slotEditLabel() { +void WCueMenuPopup::slotEditLabel() { VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { return; } m_pCue->setLabel(m_pEditLabel->text()); } -void CueMenu::slotChangeCueColor(PredefinedColorPointer pColor) { +void WCueMenuPopup::slotChangeCueColor(PredefinedColorPointer pColor) { VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { return; } @@ -117,7 +117,7 @@ void CueMenu::slotChangeCueColor(PredefinedColorPointer pColor) { hide(); } -void CueMenu::slotRemoveCue() { +void WCueMenuPopup::slotRemoveCue() { VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { return; } diff --git a/src/widget/cuemenu.h b/src/widget/wcuemenupopup.h similarity index 92% rename from src/widget/cuemenu.h rename to src/widget/wcuemenupopup.h index e47ef4410db..04be43e085a 100644 --- a/src/widget/cuemenu.h +++ b/src/widget/wcuemenupopup.h @@ -8,12 +8,12 @@ #include "track/track.h" #include "widget/wcolorpicker.h" -class CueMenu : public QWidget { +class WCueMenuPopup : public QWidget { Q_OBJECT public: - CueMenu(QWidget* parent = nullptr); + WCueMenuPopup(QWidget* parent = nullptr); - ~CueMenu() { + ~WCueMenuPopup() { delete m_pCueNumber; delete m_pCuePosition; delete m_pEditLabel; diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 4c951c49e02..1580fee09ac 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -54,7 +54,7 @@ WOverview::WOverview( m_group(group), m_pConfig(pConfig), m_endOfTrack(false), - m_pCueMenu(std::make_unique(this)), + m_pCueMenuPopup(std::make_unique(this)), m_bShowCueTimes(true), m_iPosSeconds(0), m_iPos(0), @@ -87,7 +87,7 @@ WOverview::WOverview( connect(pPlayerManager, &PlayerManager::trackAnalyzerProgress, this, &WOverview::onTrackAnalyzerProgress); - connect(m_pCueMenu.get(), &CueMenu::aboutToHide, this, &WOverview::slotCueMenuAboutToHide); + connect(m_pCueMenuPopup.get(), &WCueMenuPopup::aboutToHide, this, &WOverview::slotCueMenuPopupAboutToHide); } void WOverview::setup(const QDomNode& node, const SkinContext& context) { @@ -136,7 +136,7 @@ void WOverview::setup(const QDomNode& node, const SkinContext& context) { ? defaultMark->fillColor() : m_signalColors.getAxesColor(); m_predefinedColorsRepresentation = context.getCueColorRepresentation(node, defaultColor); - m_pCueMenu->useColorSet(&m_predefinedColorsRepresentation); + m_pCueMenuPopup->useColorSet(&m_predefinedColorsRepresentation); for (const auto& pMark: m_marks) { if (pMark->isValid()) { @@ -398,8 +398,8 @@ void WOverview::mouseMoveEvent(QMouseEvent* e) { // before hotcues in m_marksToRender so if there is a hotcue in the same // location, the hotcue gets rendered on top. When right clicking, the // the hotcue rendered on top must be assigned to m_pHoveredMark to show - // the CueMenu. To accomplish this, m_marksToRender is iterated in reverse - // and the loop breaks as soon as m_pHoveredMark is set. + // the CueMenuPopup. To accomplish this, m_marksToRender is iterated in + // reverse and the loop breaks as soon as m_pHoveredMark is set. for (int i = m_marksToRender.size() - 1; i >= 0; --i) { WaveformMarkPointer pMark = m_marksToRender.at(i); int hoveredPosition; @@ -469,15 +469,15 @@ void WOverview::mousePressEvent(QMouseEvent* e) { } } if (pHoveredCue != nullptr) { - m_pCueMenu->setTrackAndCue(m_pCurrentTrack, pHoveredCue); - m_pCueMenu->popup(e->globalPos()); + m_pCueMenuPopup->setTrackAndCue(m_pCurrentTrack, pHoveredCue); + m_pCueMenuPopup->popup(e->globalPos()); m_bHotcueMenuShowing = true; } } } } -void WOverview::slotCueMenuAboutToHide() { +void WOverview::slotCueMenuPopupAboutToHide() { m_bHotcueMenuShowing = false; m_pHoveredMark.clear(); update(); diff --git a/src/widget/woverview.h b/src/widget/woverview.h index d5bcc4792ac..96ab55709e9 100644 --- a/src/widget/woverview.h +++ b/src/widget/woverview.h @@ -20,7 +20,7 @@ #include "analyzer/analyzerprogress.h" #include "track/track.h" -#include "widget/cuemenu.h" +#include "widget/wcuemenupopup.h" #include "widget/trackdroptarget.h" #include "widget/wwidget.h" @@ -101,7 +101,7 @@ class WOverview : public WWidget, public TrackDropTarget { void receiveCuesUpdated(); void slotWaveformSummaryUpdated(); - void slotCueMenuAboutToHide(); + void slotCueMenuPopupAboutToHide(); private: // Append the waveform overview pixmap according to available data @@ -143,7 +143,7 @@ class WOverview : public WWidget, public TrackDropTarget { TrackPointer m_pCurrentTrack; ConstWaveformPointer m_pWaveform; - std::unique_ptr m_pCueMenu; + std::unique_ptr m_pCueMenuPopup; bool m_bShowCueTimes; int m_iPosSeconds; From c126494c64806c50af950d727553ba54c9768c57 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 11:55:47 +0100 Subject: [PATCH 22/45] res/skins: Apply CueMenu -> WCueMenuPopup rename in style.qss files --- res/skins/Deere/style.qss | 2 +- res/skins/LateNight/style.qss | 2 +- res/skins/Shade/style.qss | 2 +- res/skins/Tango/style.qss | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index 7a7e41db315..dc29e8f7e01 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -1742,7 +1742,7 @@ WPushButton[value="2"]:hover { border-radius: 3px; } -CueMenu #CueRemoveButton { +WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index e7d148339b6..b9463859bdd 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -577,7 +577,7 @@ WTime { font-size: 10px/10px; } -CueMenu #CueRemoveButton { +WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 0e603d74efc..5c8004ebfcb 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -598,6 +598,6 @@ QPushButton#pushButtonRepeatPlaylist { background-color: #f2f2ff; } -CueMenu #CueRemoveButton { +WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/res/skins/Tango/style.qss b/res/skins/Tango/style.qss index 29313ea6051..588abcbb709 100644 --- a/res/skins/Tango/style.qss +++ b/res/skins/Tango/style.qss @@ -94,7 +94,7 @@ WWidgetGroup { image: url(skin:/graphics/splitterVert_handle_pressed.svg); } -CueMenu #CueRemoveButton { +WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } From ff4fc640bb1d8d410e37344be9de628fe71b5ce9 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 12:03:08 +0100 Subject: [PATCH 23/45] widget/wcolorpicker: Restrict background-color to QPushButton Without this, the background color of the tooltip will be changed as well. --- src/widget/wcolorpicker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 037c0f159c2..30fdd1a9452 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -26,7 +26,7 @@ WColorPicker::WColorPicker(QWidget* parent) } parented_ptr pColorButton = make_parented("", this); - pColorButton->setStyleSheet(QString("background-color: #%1;").arg( + pColorButton->setStyleSheet(QString("QPushButton { background-color: #%1; }").arg( QString::number(pColor->m_defaultRgba.rgb(), 16) )); @@ -77,7 +77,7 @@ void WColorPicker::useColorSet(PredefinedColorsRepresentation* pColorRepresentat PredefinedColorPointer pColor = i.key(); QPushButton* pColorButton = i.value(); QColor color = (pColorRepresentation == nullptr) ? pColor->m_defaultRgba : pColorRepresentation->representationFor(pColor); - pColorButton->setStyleSheet(QString("background-color: #%1;").arg( + pColorButton->setStyleSheet(QString("QPushButton { background-color: #%1; }").arg( QString::number(color.rgb(), 16) )); From af8af8b93e1ce1ced0b8f8e26940899cf8d56db3 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 12:04:36 +0100 Subject: [PATCH 24/45] widget/wcuemenupopup: Add nicer format for hotcue number in info bar --- src/widget/wcuemenupopup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 89f1a482dd0..22df8c0aa50 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -68,7 +68,7 @@ void WCueMenuPopup::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { QString hotcueNumberText = ""; if (hotcueNumber != Cue::kNoHotCue) { // Programmers count from 0, but DJs count from 1 - hotcueNumberText = QString::number(hotcueNumber + 1); + hotcueNumberText = QString(tr("Hotcue #%1")).arg(QString::number(hotcueNumber + 1)); } m_pCueNumber->setText(hotcueNumberText); From 1c92d8b00a5d54debdab19edb00b3c2cf78fd267 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 19:04:04 +0100 Subject: [PATCH 25/45] widget/wcolorpicker: Make sure that qss hex-color is 0-padded --- src/widget/wcolorpicker.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 30fdd1a9452..16f22ce17ee 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -26,9 +26,9 @@ WColorPicker::WColorPicker(QWidget* parent) } parented_ptr pColorButton = make_parented("", this); - pColorButton->setStyleSheet(QString("QPushButton { background-color: #%1; }").arg( - QString::number(pColor->m_defaultRgba.rgb(), 16) - )); + pColorButton->setStyleSheet( + QString("QPushButton { background-color: #%1; }").arg(pColor->m_defaultRgba.rgb(), 6, 16, QChar('0')) + ); pColorButton->setToolTip(pColor->m_sDisplayName); m_pColorButtons.insert(pColor, pColorButton); @@ -77,9 +77,9 @@ void WColorPicker::useColorSet(PredefinedColorsRepresentation* pColorRepresentat PredefinedColorPointer pColor = i.key(); QPushButton* pColorButton = i.value(); QColor color = (pColorRepresentation == nullptr) ? pColor->m_defaultRgba : pColorRepresentation->representationFor(pColor); - pColorButton->setStyleSheet(QString("QPushButton { background-color: #%1; }").arg( - QString::number(color.rgb(), 16) - )); + pColorButton->setStyleSheet( + QString("QPushButton { background-color: #%1; }").arg(color.rgb(), 6, 16, QChar('0')) + ); pColorButton->setToolTip(pColor->m_sDisplayName); } From 7390560695600ed0a514f743d985e7cbd7fe9033 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 22 Nov 2019 19:09:57 +0100 Subject: [PATCH 26/45] CMake: Update sources with renamed files --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2873b5bcdec..5d3f9e07f7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -617,19 +617,19 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/waveform/widgets/rgbwaveformwidget.cpp src/waveform/widgets/softwarewaveformwidget.cpp src/waveform/widgets/waveformwidgetabstract.cpp - src/widget/colormenu.cpp src/widget/controlwidgetconnection.cpp - src/widget/cuemenu.cpp src/widget/hexspinbox.cpp src/widget/paintable.cpp src/widget/wanalysislibrarytableview.cpp src/widget/wbasewidget.cpp src/widget/wbattery.cpp src/widget/wbeatspinbox.cpp + src/widget/wcolorpicker.cpp src/widget/wcombobox.cpp src/widget/wcoverart.cpp src/widget/wcoverartlabel.cpp src/widget/wcoverartmenu.cpp + src/widget/wcuemenupopup.cpp src/widget/wdisplay.cpp src/widget/weffect.cpp src/widget/weffectbuttonparameter.cpp From 28b15f0c4e754daf1fed57c75b849b0749c2729f Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 25 Nov 2019 20:02:17 +0100 Subject: [PATCH 27/45] widget/wcolorpicker: Force "Fusion" QStyle on QPushButtons --- src/widget/wcolorpicker.cpp | 5 +++++ src/widget/wcolorpicker.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 16f22ce17ee..b781dfd9e1d 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -18,6 +18,8 @@ WColorPicker::WColorPicker(QWidget* parent) QGridLayout* pLayout = new QGridLayout(); pLayout->setMargin(0); pLayout->setContentsMargins(0, 0, 0, 0); + + m_pStyle = QStyleFactory::create(QString("fusion")); int row = 0; int column = 0; for (const auto& pColor : Color::kPredefinedColorsSet.allColors) { @@ -26,6 +28,9 @@ WColorPicker::WColorPicker(QWidget* parent) } parented_ptr pColorButton = make_parented("", this); + if (m_pStyle) { + pColorButton->setStyle(m_pStyle); + } pColorButton->setStyleSheet( QString("QPushButton { background-color: #%1; }").arg(pColor->m_defaultRgba.rgb(), 6, 16, QChar('0')) ); diff --git a/src/widget/wcolorpicker.h b/src/widget/wcolorpicker.h index f40d3c33b1b..911cbc43a44 100644 --- a/src/widget/wcolorpicker.h +++ b/src/widget/wcolorpicker.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "util/color/color.h" @@ -20,4 +21,5 @@ class WColorPicker : public QWidget { private: QMap m_pColorButtons; PredefinedColorPointer m_pSelectedColor; + QStyle* m_pStyle; }; From 67fc1b9efb4a8bb8dd449ea13e309557f24d9687 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Sat, 30 Nov 2019 17:25:11 +0100 Subject: [PATCH 28/45] unstyle cue popup labels --- res/skins/Deere/style.qss | 2 +- res/skins/LateNight/style.qss | 17 ++++++----------- res/skins/Shade/style.qss | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index dc29e8f7e01..595e315103b 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -789,7 +789,7 @@ QAbstractScrollArea::corner { background-color: #222; } -WWidget, QLabel { +WWidget, WLibrary QLabel { font-family: "Open Sans"; font-size: 12px; text-transform: uppercase; diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index b9463859bdd..117ed9b92ce 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -5,8 +5,8 @@ } #Mixxx, WWidget, -WLabel, QLabel, -WPushButton, QPushButton, +WLabel, WLibrary QLabel, +WPushButton, WLibrary QPushButton, WEffect, WEffectSelector, WBeatSpinBox, QSpinBox { @@ -26,16 +26,11 @@ WBeatSpinBox, QSpinBox, /* Hotcue labels in the overview */ WOverview, -/* Edit label and pushbuttons in the hotcue label edit dialog */ -WOverview QLabel, -WOverview QPushButton { +/* 'Edit' label in the hotcue label edit dialog */ +WOverview QLabel { font-family: "Open Sans"; text-transform: none; } -WOverview QLabel, -WOverview QPushButton { - font-weight: normal; -} QToolTip { font-family: Ubuntu; @@ -47,7 +42,7 @@ QToolTip { border-radius: 2px; } -WPushButton, QPushButton { +WPushButton, WLibary QPushButton { font-size: 11px/12px; } @@ -477,7 +472,7 @@ WOverview { color: #0bd9d1; } -QLabel, QRadioButton, +WLibary QLabel, WLibary QRadioButton, WSearchLineEdit, #LibraryBPMSpinBox, #LibraryBPMButton::item, diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 5c8004ebfcb..659e17b4e32 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -442,10 +442,10 @@ QSplitter::handle:pressed { image: url(skin:/style/style_handle_checked.png); ba QSplitter::handle:horizontal { width: 6px; } QSplitter::handle:vertical { height: 6px;} -QPushButton { font-size: 10pt; +WLibrary QPushButton { font-size: 10pt; font-family: "Open Sans";} /* Extra declaration for QRadionButton otherwise it shows up with wrong colors in Linux with Gnome */ -QLabel, QRadioButton { +WLibrary QLabel, WLibrary QRadioButton { font-size: 10pt; background: transparent; color: #C1C1C1;} From b35863fe7a35365f0b45d0aa74ec1b6e17aab2db Mon Sep 17 00:00:00 2001 From: ronso0 Date: Sat, 30 Nov 2019 18:34:15 +0100 Subject: [PATCH 29/45] set checkmark icon in wcolorpicker.cpp --- res/images/ic_checkmark.svg | 3 +++ src/widget/wcolorpicker.cpp | 11 ++++++----- src/widget/wcolorpicker.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 res/images/ic_checkmark.svg diff --git a/res/images/ic_checkmark.svg b/res/images/ic_checkmark.svg new file mode 100644 index 00000000000..e2ebaa5bed3 --- /dev/null +++ b/res/images/ic_checkmark.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index b781dfd9e1d..a81c61ab716 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -12,7 +12,8 @@ const int kNumColumns = 4; } WColorPicker::WColorPicker(QWidget* parent) - : QWidget(parent) { + : QWidget(parent), + m_pCheckedIcon(":/images/ic_checkmark.svg") { // If another title would be more appropriate in some context, setTitle // can be called again after construction. QGridLayout* pLayout = new QGridLayout(); @@ -58,8 +59,8 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { qDebug() << "m_pSelectedColor"; QMap::const_iterator it = m_pColorButtons.find(m_pSelectedColor); if (it != m_pColorButtons.constEnd()) { - qDebug() << it.value() << "setDown(false)"; - it.value()->setDown(false); + qDebug() << it.value() << "clear icon"; + it.value()->setIcon(QIcon()); } } @@ -67,8 +68,8 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { qDebug() << "m_pColor"; QMap::const_iterator it = m_pColorButtons.find(pColor); if (it != m_pColorButtons.constEnd()) { - qDebug() << it.value() << "setDown(true)"; - it.value()->setDown(true); + qDebug() << it.value() << "set checkmark icon"; + it.value()->setIcon(m_pCheckedIcon); } } diff --git a/src/widget/wcolorpicker.h b/src/widget/wcolorpicker.h index 911cbc43a44..333f70a468f 100644 --- a/src/widget/wcolorpicker.h +++ b/src/widget/wcolorpicker.h @@ -22,4 +22,5 @@ class WColorPicker : public QWidget { QMap m_pColorButtons; PredefinedColorPointer m_pSelectedColor; QStyle* m_pStyle; + QIcon* m_pCheckedIcon; }; From 147a0ccf4eb3b23e33b85cae775cbc46af89df25 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 2 Dec 2019 21:27:48 +0100 Subject: [PATCH 30/45] mixxx.qrc: Add checkmark icon --- res/mixxx.qrc | 1 + 1 file changed, 1 insertion(+) diff --git a/res/mixxx.qrc b/res/mixxx.qrc index c4286344691..cebda2fe50c 100644 --- a/res/mixxx.qrc +++ b/res/mixxx.qrc @@ -30,6 +30,7 @@ images/mixxx_icon.svg images/mixxx-icon-logo-symbolic.svg images/skin_preview_placeholder.png + images/ic_checkmark.svg images/preferences/ic_preferences_autodj.svg images/preferences/ic_preferences_bpmdetect.svg images/preferences/ic_preferences_broadcast.svg From f32e6a89b1f9584d11fe1ee7eca93ff338868990 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 2 Dec 2019 21:30:05 +0100 Subject: [PATCH 31/45] widget/wcolorpicker: Use QPushButton "checked" property for selected color --- src/widget/wcolorpicker.cpp | 15 +++++++++------ src/widget/wcolorpicker.h | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index a81c61ab716..65b7b001217 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "util/color/color.h" #include "util/parented_ptr.h" @@ -12,8 +13,7 @@ const int kNumColumns = 4; } WColorPicker::WColorPicker(QWidget* parent) - : QWidget(parent), - m_pCheckedIcon(":/images/ic_checkmark.svg") { + : QWidget(parent) { // If another title would be more appropriate in some context, setTitle // can be called again after construction. QGridLayout* pLayout = new QGridLayout(); @@ -37,6 +37,7 @@ WColorPicker::WColorPicker(QWidget* parent) ); pColorButton->setToolTip(pColor->m_sDisplayName); + pColorButton->setCheckable(true); m_pColorButtons.insert(pColor, pColorButton); pLayout->addWidget(pColorButton, row, column); @@ -59,8 +60,9 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { qDebug() << "m_pSelectedColor"; QMap::const_iterator it = m_pColorButtons.find(m_pSelectedColor); if (it != m_pColorButtons.constEnd()) { - qDebug() << it.value() << "clear icon"; - it.value()->setIcon(QIcon()); + it.value()->setChecked(false); + it.value()->style()->unpolish(it.value()); + it.value()->style()->polish(it.value()); } } @@ -68,8 +70,9 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { qDebug() << "m_pColor"; QMap::const_iterator it = m_pColorButtons.find(pColor); if (it != m_pColorButtons.constEnd()) { - qDebug() << it.value() << "set checkmark icon"; - it.value()->setIcon(m_pCheckedIcon); + it.value()->setChecked(true); + it.value()->style()->unpolish(it.value()); + it.value()->style()->polish(it.value()); } } diff --git a/src/widget/wcolorpicker.h b/src/widget/wcolorpicker.h index 333f70a468f..911cbc43a44 100644 --- a/src/widget/wcolorpicker.h +++ b/src/widget/wcolorpicker.h @@ -22,5 +22,4 @@ class WColorPicker : public QWidget { QMap m_pColorButtons; PredefinedColorPointer m_pSelectedColor; QStyle* m_pStyle; - QIcon* m_pCheckedIcon; }; From b8b8f34afd886b42b9a3c5d79c16e3c1351bfd47 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 2 Dec 2019 21:31:24 +0100 Subject: [PATCH 32/45] skins: Add checkmark icon for selected hotcue color --- res/skins/Deere/style.qss | 8 ++++++++ res/skins/LateNight/style.qss | 7 +++++++ res/skins/Shade/style.qss | 8 ++++++++ res/skins/Tango/style.qss | 8 ++++++++ 4 files changed, 31 insertions(+) diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index 595e315103b..c7229fb3aca 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -1746,6 +1746,14 @@ WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } +WColorPicker QPushButton[checked="false"] { + qproperty-icon: none; +} + +WColorPicker QPushButton[checked="true"] { + qproperty-icon: url(:/images/ic_checkmark.svg); +} + WRecordingDuration { font-weight: bold; } diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index 117ed9b92ce..0fcf55eed31 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -576,6 +576,13 @@ WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } +WColorPicker QPushButton[checked="false"] { + qproperty-icon: none; +} + +WColorPicker QPushButton[checked="true"] { + qproperty-icon: url(:/images/ic_checkmark.svg); +} /********************** Decks **********************/ #DeckRow_1_KeyVinylFx { diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 659e17b4e32..4f3f71cbd5d 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -601,3 +601,11 @@ QPushButton#pushButtonRepeatPlaylist { WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } + +WColorPicker QPushButton[checked="false"] { + qproperty-icon: none; +} + +WColorPicker QPushButton[checked="true"] { + qproperty-icon: url(:/images/ic_checkmark.svg); +} diff --git a/res/skins/Tango/style.qss b/res/skins/Tango/style.qss index 588abcbb709..c5bf5b92427 100644 --- a/res/skins/Tango/style.qss +++ b/res/skins/Tango/style.qss @@ -98,6 +98,14 @@ WCueMenuPopup #CueRemoveButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } +WColorPicker QPushButton[checked="false"] { + qproperty-icon: none; +} + +WColorPicker QPushButton[checked="true"] { + qproperty-icon: url(:/images/ic_checkmark.svg); +} + /* ################################################################ ####### Colors ################################################## ###############################################################*/ From 65459f9d3a4318b1e981e1b66b027337c7c73fd8 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 3 Dec 2019 00:11:28 +0100 Subject: [PATCH 33/45] widget/wcuemenupopup: Always give focus to label QLineEdit on show() --- src/widget/wcuemenupopup.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget/wcuemenupopup.h b/src/widget/wcuemenupopup.h index 04be43e085a..30e96c00489 100644 --- a/src/widget/wcuemenupopup.h +++ b/src/widget/wcuemenupopup.h @@ -42,6 +42,7 @@ class WCueMenuPopup : public QWidget { } void show() { + m_pEditLabel->setFocus(); emit(aboutToShow()); QWidget::show(); } From 3e1e24a32bb946967dc584399dbfab4c883c6a63 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 3 Dec 2019 00:14:32 +0100 Subject: [PATCH 34/45] widget/wcuemenupopup: Hide popup on return press with label edit focused --- src/widget/wcuemenupopup.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 22df8c0aa50..90d7e0c1aec 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -27,6 +27,7 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent) m_pEditLabel->setToolTip(tr("Edit cue label")); m_pEditLabel->setObjectName("CueLabelEdit"); connect(m_pEditLabel, &QLineEdit::textEdited, this, &WCueMenuPopup::slotEditLabel); + connect(m_pEditLabel, &QLineEdit::returnPressed, this, &WCueMenuPopup::hide); m_pColorPicker = new WColorPicker(this); m_pColorPicker->setObjectName("CueColorPicker"); From 1635ebac7339c69a1d68cb0b0f42f04c3f8b337d Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 02:26:09 +0100 Subject: [PATCH 35/45] widget/wcuemenupopup: Fix indentation in namespace { } --- src/widget/wcolorpicker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 65b7b001217..7f1747c997a 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -9,7 +9,7 @@ #include "util/parented_ptr.h" namespace { -const int kNumColumns = 4; + const int kNumColumns = 4; } WColorPicker::WColorPicker(QWidget* parent) From b0188ae694058d44a68a79807b9a6a4ff4554466 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 02:26:56 +0100 Subject: [PATCH 36/45] widget/wcolorpicker: Remove useless comment and qDebug() calls --- src/widget/wcolorpicker.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 7f1747c997a..2fa2ee01bc0 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -14,8 +14,6 @@ namespace { WColorPicker::WColorPicker(QWidget* parent) : QWidget(parent) { - // If another title would be more appropriate in some context, setTitle - // can be called again after construction. QGridLayout* pLayout = new QGridLayout(); pLayout->setMargin(0); pLayout->setContentsMargins(0, 0, 0, 0); @@ -55,9 +53,7 @@ WColorPicker::WColorPicker(QWidget* parent) } void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { - qDebug() << "setSelectedColor"; if (m_pSelectedColor) { - qDebug() << "m_pSelectedColor"; QMap::const_iterator it = m_pColorButtons.find(m_pSelectedColor); if (it != m_pColorButtons.constEnd()) { it.value()->setChecked(false); @@ -67,7 +63,6 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { } if (pColor) { - qDebug() << "m_pColor"; QMap::const_iterator it = m_pColorButtons.find(pColor); if (it != m_pColorButtons.constEnd()) { it.value()->setChecked(true); From cb98b98b0331595a40d95aaa545af082155454bb Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 02:27:45 +0100 Subject: [PATCH 37/45] widget/wcuemenupopup: Fix tooltip for cue number label --- src/widget/wcuemenupopup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 90d7e0c1aec..768a193fe77 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -14,7 +14,7 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent) setObjectName("WCueMenuPopup"); m_pCueNumber = new QLabel(this); - m_pCueNumber->setToolTip(tr("cue number")); + m_pCueNumber->setToolTip(tr("Cue number")); m_pCueNumber->setObjectName("CueNumberLabel"); m_pCueNumber->setAlignment(Qt::AlignLeft); From a7c4787fca6fddb4bbf6bbf84f2a86f2be99ace2 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 02:28:21 +0100 Subject: [PATCH 38/45] widget/wcuemenupopup: Fix tooltip for remove cue button --- src/widget/wcuemenupopup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 768a193fe77..b8d1911cf12 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -34,8 +34,8 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent) connect(m_pColorPicker, &WColorPicker::colorPicked, this, &WCueMenuPopup::slotChangeCueColor); m_pRemoveCue = new QPushButton("", this); - m_pRemoveCue->setToolTip(tr("Remove this cue point")); m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); + m_pRemoveCue->setToolTip(tr("Delete this cue")); m_pRemoveCue->setObjectName("CueRemoveButton"); connect(m_pRemoveCue, &QPushButton::clicked, this, &WCueMenuPopup::slotRemoveCue); From 7265c85084aaae7dcd7d68d40caf05c50d03ba69 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 02:28:53 +0100 Subject: [PATCH 39/45] widget/wcuemenupopup: Do not force lineedit height for remove cue button --- src/widget/wcuemenupopup.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index b8d1911cf12..0c7734d0dad 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -34,7 +34,6 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent) connect(m_pColorPicker, &WColorPicker::colorPicked, this, &WCueMenuPopup::slotChangeCueColor); m_pRemoveCue = new QPushButton("", this); - m_pRemoveCue->setFixedHeight(m_pEditLabel->sizeHint().height()); m_pRemoveCue->setToolTip(tr("Delete this cue")); m_pRemoveCue->setObjectName("CueRemoveButton"); connect(m_pRemoveCue, &QPushButton::clicked, this, &WCueMenuPopup::slotRemoveCue); From 007a7752397e5be4b483a112fbed0642cc006fce Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 02:32:05 +0100 Subject: [PATCH 40/45] widget/wcuemenupopup: Use CueDelete instead of CueRemove for button name --- res/skins/Deere/style.qss | 2 +- res/skins/LateNight/style.qss | 2 +- res/skins/Shade/style.qss | 2 +- res/skins/Tango/style.qss | 2 +- src/widget/wcuemenupopup.cpp | 12 ++++++------ src/widget/wcuemenupopup.h | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index c7229fb3aca..5e3f3fa7589 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -1742,7 +1742,7 @@ WPushButton[value="2"]:hover { border-radius: 3px; } -WCueMenuPopup #CueRemoveButton { +WCueMenuPopup #CueDeleteButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index 0fcf55eed31..1b643c01fcd 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -572,7 +572,7 @@ WTime { font-size: 10px/10px; } -WCueMenuPopup #CueRemoveButton { +WCueMenuPopup #CueDeleteButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 4f3f71cbd5d..8e781b00bfc 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -598,7 +598,7 @@ QPushButton#pushButtonRepeatPlaylist { background-color: #f2f2ff; } -WCueMenuPopup #CueRemoveButton { +WCueMenuPopup #CueDeleteButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/res/skins/Tango/style.qss b/res/skins/Tango/style.qss index c5bf5b92427..b23ebc4c378 100644 --- a/res/skins/Tango/style.qss +++ b/res/skins/Tango/style.qss @@ -94,7 +94,7 @@ WWidgetGroup { image: url(skin:/graphics/splitterVert_handle_pressed.svg); } -WCueMenuPopup #CueRemoveButton { +WCueMenuPopup #CueDeleteButton { qproperty-icon: url(:/images/library/ic_library_cross.svg); } diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 0c7734d0dad..382dd4cefc3 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -33,10 +33,10 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent) m_pColorPicker->setObjectName("CueColorPicker"); connect(m_pColorPicker, &WColorPicker::colorPicked, this, &WCueMenuPopup::slotChangeCueColor); - m_pRemoveCue = new QPushButton("", this); - m_pRemoveCue->setToolTip(tr("Delete this cue")); - m_pRemoveCue->setObjectName("CueRemoveButton"); - connect(m_pRemoveCue, &QPushButton::clicked, this, &WCueMenuPopup::slotRemoveCue); + m_pDeleteCue = new QPushButton("", this); + m_pDeleteCue->setToolTip(tr("Delete this cue")); + m_pDeleteCue->setObjectName("CueDeleteButton"); + connect(m_pDeleteCue, &QPushButton::clicked, this, &WCueMenuPopup::slotDeleteCue); QHBoxLayout* pLabelLayout = new QHBoxLayout(); pLabelLayout->addWidget(m_pCueNumber); @@ -49,7 +49,7 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent) pLeftLayout->addWidget(m_pColorPicker); QVBoxLayout* pRightLayout = new QVBoxLayout(); - pRightLayout->addWidget(m_pRemoveCue); + pRightLayout->addWidget(m_pDeleteCue); pRightLayout->addStretch(1); QHBoxLayout* pMainLayout = new QHBoxLayout(); @@ -117,7 +117,7 @@ void WCueMenuPopup::slotChangeCueColor(PredefinedColorPointer pColor) { hide(); } -void WCueMenuPopup::slotRemoveCue() { +void WCueMenuPopup::slotDeleteCue() { VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { return; } diff --git a/src/widget/wcuemenupopup.h b/src/widget/wcuemenupopup.h index 30e96c00489..99d587bdeef 100644 --- a/src/widget/wcuemenupopup.h +++ b/src/widget/wcuemenupopup.h @@ -18,7 +18,7 @@ class WCueMenuPopup : public QWidget { delete m_pCuePosition; delete m_pEditLabel; delete m_pColorPicker; - delete m_pRemoveCue; + delete m_pDeleteCue; } void setTrackAndCue(TrackPointer pTrack, CuePointer pCue); @@ -53,7 +53,7 @@ class WCueMenuPopup : public QWidget { private slots: void slotEditLabel(); - void slotRemoveCue(); + void slotDeleteCue(); void slotChangeCueColor(PredefinedColorPointer pColor); private: @@ -64,5 +64,5 @@ class WCueMenuPopup : public QWidget { QLabel* m_pCuePosition; QLineEdit* m_pEditLabel; WColorPicker* m_pColorPicker; - QPushButton* m_pRemoveCue; + QPushButton* m_pDeleteCue; }; From 86a37c824f4345343e766de5a3fd90d671aa0e3f Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 12:55:33 +0100 Subject: [PATCH 41/45] widget/wcolorpicker: Add some code comments --- src/widget/wcolorpicker.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp index 2fa2ee01bc0..669cb7cad8f 100644 --- a/src/widget/wcolorpicker.cpp +++ b/src/widget/wcolorpicker.cpp @@ -18,7 +18,19 @@ WColorPicker::WColorPicker(QWidget* parent) pLayout->setMargin(0); pLayout->setContentsMargins(0, 0, 0, 0); + // Unfortunately, not all styles supported by Qt support setting a + // background color for QPushButtons (see + // https://bugreports.qt.io/browse/QTBUG-11089). For example, when using + // the gtk2 style all color buttons would be just grey. It's possible to + // work around this by modifing the button border with a QSS stylesheet, so + // that the QStyle will be overwritten, but as a sane default for skins + // without styles for WColorPicker, we're setting the platform-independent + // "Fusion" style here. This will make the buttons look slightly different + // from the rest of the application (when not styled via QSS), but that's + // better than having buttons without any colors (which would make the + // color picker unusable). m_pStyle = QStyleFactory::create(QString("fusion")); + int row = 0; int column = 0; for (const auto& pColor : Color::kPredefinedColorsSet.allColors) { @@ -30,6 +42,8 @@ WColorPicker::WColorPicker(QWidget* parent) if (m_pStyle) { pColorButton->setStyle(m_pStyle); } + + // Set the background color of the button. This can't be overridden in skin stylesheets. pColorButton->setStyleSheet( QString("QPushButton { background-color: #%1; }").arg(pColor->m_defaultRgba.rgb(), 6, 16, QChar('0')) ); @@ -57,6 +71,7 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { QMap::const_iterator it = m_pColorButtons.find(m_pSelectedColor); if (it != m_pColorButtons.constEnd()) { it.value()->setChecked(false); + // This is needed to re-apply skin styles (e.g. to show/hide a checkmark icon) it.value()->style()->unpolish(it.value()); it.value()->style()->polish(it.value()); } @@ -66,6 +81,7 @@ void WColorPicker::setSelectedColor(PredefinedColorPointer pColor) { QMap::const_iterator it = m_pColorButtons.find(pColor); if (it != m_pColorButtons.constEnd()) { it.value()->setChecked(true); + // This is needed to re-apply skin styles (e.g. to show/hide a checkmark icon) it.value()->style()->unpolish(it.value()); it.value()->style()->polish(it.value()); } @@ -81,6 +97,8 @@ void WColorPicker::useColorSet(PredefinedColorsRepresentation* pColorRepresentat PredefinedColorPointer pColor = i.key(); QPushButton* pColorButton = i.value(); QColor color = (pColorRepresentation == nullptr) ? pColor->m_defaultRgba : pColorRepresentation->representationFor(pColor); + + // Set the background color of the button. This can't be overridden in skin stylesheets. pColorButton->setStyleSheet( QString("QPushButton { background-color: #%1; }").arg(color.rgb(), 6, 16, QChar('0')) ); From 5649646eda50076839a80682645d88dad406edfa Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 12:59:03 +0100 Subject: [PATCH 42/45] mixxx: Load default.qss stylesheet that can be overwritten by skins --- res/mixxx.qrc | 1 + res/skins/default.qss | 11 +++++++++++ src/mixxx.cpp | 11 +++++++++++ 3 files changed, 23 insertions(+) create mode 100644 res/skins/default.qss diff --git a/res/mixxx.qrc b/res/mixxx.qrc index cebda2fe50c..a4ecadadda5 100644 --- a/res/mixxx.qrc +++ b/res/mixxx.qrc @@ -56,6 +56,7 @@ shaders/filteredsignal.frag shaders/passthrough.vert shaders/rgbsignal.frag + skins/default.qss translations/mixxx_ar.qm translations/mixxx_ast.qm translations/mixxx_bg.qm diff --git a/res/skins/default.qss b/res/skins/default.qss new file mode 100644 index 00000000000..fd0ab5c6d21 --- /dev/null +++ b/res/skins/default.qss @@ -0,0 +1,11 @@ +WCueMenuPopup #CueDeleteButton { + qproperty-icon: url(:/images/library/ic_library_cross.svg); +} + +WColorPicker QPushButton[checked="false"] { + qproperty-icon: none; +} + +WColorPicker QPushButton[checked="true"] { + qproperty-icon: url(:/images/ic_checkmark.svg); +} diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 83c40792071..73873c3329f 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -468,6 +468,17 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { QWidget* oldWidget = m_pWidgetParent; + // Load default styles that can be overridden by skins + QFile file(":/skins/default.qss"); + if (file.open(QIODevice::ReadOnly)) { + QByteArray fileBytes = file.readAll(); + QString style = QString::fromLocal8Bit(fileBytes.constData(), + fileBytes.length()); + setStyleSheet(style); + } else { + qWarning() << "Failed to load default skin styles!"; + } + // Load skin to a QWidget that we set as the central widget. Assignment // intentional in next line. if (!(m_pWidgetParent = m_pSkinLoader->loadConfiguredSkin(this, m_pKeyboard, From a9c4fe30c7ec68f9cbffad4c7e6a3c08b304ccdd Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 13:01:21 +0100 Subject: [PATCH 43/45] skins: Remove WCueMenuPopup/WColorPicker styles from skins --- res/skins/Deere/style.qss | 12 ------------ res/skins/LateNight/style.qss | 12 ------------ res/skins/Shade/style.qss | 12 ------------ res/skins/Tango/style.qss | 12 ------------ 4 files changed, 48 deletions(-) diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index 5e3f3fa7589..d73f7d60fff 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -1742,18 +1742,6 @@ WPushButton[value="2"]:hover { border-radius: 3px; } -WCueMenuPopup #CueDeleteButton { - qproperty-icon: url(:/images/library/ic_library_cross.svg); -} - -WColorPicker QPushButton[checked="false"] { - qproperty-icon: none; -} - -WColorPicker QPushButton[checked="true"] { - qproperty-icon: url(:/images/ic_checkmark.svg); -} - WRecordingDuration { font-weight: bold; } diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index 1b643c01fcd..9dfbf525112 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -572,18 +572,6 @@ WTime { font-size: 10px/10px; } -WCueMenuPopup #CueDeleteButton { - qproperty-icon: url(:/images/library/ic_library_cross.svg); -} - -WColorPicker QPushButton[checked="false"] { - qproperty-icon: none; -} - -WColorPicker QPushButton[checked="true"] { - qproperty-icon: url(:/images/ic_checkmark.svg); -} - /********************** Decks **********************/ #DeckRow_1_KeyVinylFx { qproperty-layoutAlignment: 'AlignLeft | AlignTop'; diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 8e781b00bfc..42cb266361e 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -597,15 +597,3 @@ QPushButton#pushButtonRepeatPlaylist { #HotcueButton[highlight="8"] { background-color: #f2f2ff; } - -WCueMenuPopup #CueDeleteButton { - qproperty-icon: url(:/images/library/ic_library_cross.svg); -} - -WColorPicker QPushButton[checked="false"] { - qproperty-icon: none; -} - -WColorPicker QPushButton[checked="true"] { - qproperty-icon: url(:/images/ic_checkmark.svg); -} diff --git a/res/skins/Tango/style.qss b/res/skins/Tango/style.qss index b23ebc4c378..baf80b4a2c3 100644 --- a/res/skins/Tango/style.qss +++ b/res/skins/Tango/style.qss @@ -94,18 +94,6 @@ WWidgetGroup { image: url(skin:/graphics/splitterVert_handle_pressed.svg); } -WCueMenuPopup #CueDeleteButton { - qproperty-icon: url(:/images/library/ic_library_cross.svg); -} - -WColorPicker QPushButton[checked="false"] { - qproperty-icon: none; -} - -WColorPicker QPushButton[checked="true"] { - qproperty-icon: url(:/images/ic_checkmark.svg); -} - /* ################################################################ ####### Colors ################################################## ###############################################################*/ From 8bb98fa345da84b8bb652a096f76908bcad788b7 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 15:00:04 +0100 Subject: [PATCH 44/45] res: Add ic_delete icon and use it for WCueMenuPopup --- res/images/ic_delete.svg | 80 ++++++++++++++++++++++++++++++++++++++++ res/mixxx.qrc | 1 + res/skins/default.qss | 2 +- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 res/images/ic_delete.svg diff --git a/res/images/ic_delete.svg b/res/images/ic_delete.svg new file mode 100644 index 00000000000..9f2b5ec79aa --- /dev/null +++ b/res/images/ic_delete.svg @@ -0,0 +1,80 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/res/mixxx.qrc b/res/mixxx.qrc index a4ecadadda5..a9719f9e5d3 100644 --- a/res/mixxx.qrc +++ b/res/mixxx.qrc @@ -31,6 +31,7 @@ images/mixxx-icon-logo-symbolic.svg images/skin_preview_placeholder.png images/ic_checkmark.svg + images/ic_delete.svg images/preferences/ic_preferences_autodj.svg images/preferences/ic_preferences_bpmdetect.svg images/preferences/ic_preferences_broadcast.svg diff --git a/res/skins/default.qss b/res/skins/default.qss index fd0ab5c6d21..667f25e1003 100644 --- a/res/skins/default.qss +++ b/res/skins/default.qss @@ -1,5 +1,5 @@ WCueMenuPopup #CueDeleteButton { - qproperty-icon: url(:/images/library/ic_library_cross.svg); + qproperty-icon: url(:/images/ic_delete.svg); } WColorPicker QPushButton[checked="false"] { From 9cefcfb1c3e1f794ebb70435f2324ac08134dca5 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 4 Dec 2019 15:13:28 +0100 Subject: [PATCH 45/45] widget/wcuemenupopup: Use centiseconds precision for cue position --- src/widget/wcuemenupopup.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 382dd4cefc3..215c6f4fd67 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -76,11 +76,13 @@ void WCueMenuPopup::setTrackAndCue(TrackPointer pTrack, CuePointer pCue) { double startPosition = m_pCue->getPosition(); double endPosition = m_pCue->getEndPosition(); if (startPosition != Cue::kNoPosition) { - positionText = mixxx::Duration::formatTime(startPosition / m_pTrack->getSampleRate() / mixxx::kEngineChannelCount); + double startPositionSeconds = startPosition / m_pTrack->getSampleRate() / mixxx::kEngineChannelCount; + positionText = mixxx::Duration::formatTime(startPositionSeconds, mixxx::Duration::Precision::CENTISECONDS); if (endPosition != Cue::kNoPosition) { + double endPositionSeconds = endPosition / m_pTrack->getSampleRate() / mixxx::kEngineChannelCount; positionText = QString("%1 - %2").arg( positionText, - mixxx::Duration::formatTime(endPosition / m_pTrack->getSampleRate() / mixxx::kEngineChannelCount) + mixxx::Duration::formatTime(endPositionSeconds, mixxx::Duration::Precision::CENTISECONDS) ); } }