summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-02-12 12:35:03 +0100
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-02-12 12:35:39 +0100
commit49bd30ea7fc768675961e6f2c2f2656acffa4698 (patch)
treefd395333bb8737f58ba076db9109931d4bf00064 /src
parent1f4a6e5269fa04204ce5621244f214ba40b13c97 (diff)
widget: Use enum class for color picker options
Diffstat (limited to 'src')
-rw-r--r--src/widget/wcolorpicker.cpp5
-rw-r--r--src/widget/wcolorpicker.h7
-rw-r--r--src/widget/wcolorpickeraction.cpp4
-rw-r--r--src/widget/wcolorpickeraction.h4
-rw-r--r--src/widget/wcuemenupopup.cpp2
-rw-r--r--src/widget/wtracktableview.cpp2
6 files changed, 16 insertions, 8 deletions
diff --git a/src/widget/wcolorpicker.cpp b/src/widget/wcolorpicker.cpp
index 135ee2c357..85110cac62 100644
--- a/src/widget/wcolorpicker.cpp
+++ b/src/widget/wcolorpicker.cpp
@@ -12,7 +12,7 @@ namespace {
const int kNumColumns = 4;
}
-WColorPicker::WColorPicker(bool allowNoColor, QWidget* parent)
+WColorPicker::WColorPicker(ColorPickerOption option, QWidget* parent)
: QWidget(parent) {
QGridLayout* pLayout = new QGridLayout();
pLayout->setMargin(0);
@@ -34,7 +34,8 @@ WColorPicker::WColorPicker(bool allowNoColor, QWidget* parent)
int row = 0;
int column = 0;
for (const auto& pColor : Color::kPredefinedColorsSet.allColors) {
- if (!allowNoColor && pColor == Color::kPredefinedColorsSet.noColor) {
+ if (option != ColorPickerOption::AllowNoColor &&
+ pColor == Color::kPredefinedColorsSet.noColor) {
continue;
}
diff --git a/src/widget/wcolorpicker.h b/src/widget/wcolorpicker.h
index d10d7591bd..6511172ede 100644
--- a/src/widget/wcolorpicker.h
+++ b/src/widget/wcolorpicker.h
@@ -7,10 +7,15 @@
#include "util/color/color.h"
+enum class ColorPickerOption {
+ DenyNoColor,
+ AllowNoColor,
+};
+
class WColorPicker : public QWidget {
Q_OBJECT
public:
- explicit WColorPicker(bool allowNoColor = false, QWidget* parent = nullptr);
+ explicit WColorPicker(ColorPickerOption option = ColorPickerOption::DenyNoColor, QWidget* parent = nullptr);
void setSelectedColor(PredefinedColorPointer pColor = nullptr);
void useColorSet(PredefinedColorsRepresentation* pColorRepresentation);
diff --git a/src/widget/wcolorpickeraction.cpp b/src/widget/wcolorpickeraction.cpp
index 66f3bb5850..2b38d40b81 100644
--- a/src/widget/wcolorpickeraction.cpp
+++ b/src/widget/wcolorpickeraction.cpp
@@ -1,8 +1,8 @@
#include "widget/wcolorpickeraction.h"
-WColorPickerAction::WColorPickerAction(QWidget* parent)
+WColorPickerAction::WColorPickerAction(ColorPickerOption option, QWidget* parent)
: QWidgetAction(parent) {
- m_pColorPicker = make_parented<WColorPicker>(true);
+ m_pColorPicker = make_parented<WColorPicker>(option);
connect(m_pColorPicker.get(), &WColorPicker::colorPicked, this, &WColorPickerAction::colorPicked);
QHBoxLayout* pLayout = new QHBoxLayout();
diff --git a/src/widget/wcolorpickeraction.h b/src/widget/wcolorpickeraction.h
index fc93846eda..c260c6bdcb 100644
--- a/src/widget/wcolorpickeraction.h
+++ b/src/widget/wcolorpickeraction.h
@@ -10,7 +10,9 @@
class WColorPickerAction : public QWidgetAction {
Q_OBJECT
public:
- explicit WColorPickerAction(QWidget* parent);
+ explicit WColorPickerAction(
+ ColorPickerOption option = ColorPickerOption::DenyNoColor,
+ QWidget* parent = nullptr);
void setSelectedColor(PredefinedColorPointer pColor = nullptr);
diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp
index 368b55d8ad..455f912195 100644
--- a/src/widget/wcuemenupopup.cpp
+++ b/src/widget/wcuemenupopup.cpp
@@ -29,7 +29,7 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent)
connect(m_pEditLabel, &QLineEdit::textEdited, this, &WCueMenuPopup::slotEditLabel);
connect(m_pEditLabel, &QLineEdit::returnPressed, this, &WCueMenuPopup::hide);
- m_pColorPicker = new WColorPicker(false, this);
+ m_pColorPicker = new WColorPicker(ColorPickerOption::DenyNoColor, this);
m_pColorPicker->setObjectName("CueColorPicker");
connect(m_pColorPicker, &WColorPicker::colorPicked, this, &WCueMenuPopup::slotChangeCueColor);
diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp
index 5c55ba4c29..1422be784f 100644
--- a/src/widget/wtracktableview.cpp
+++ b/src/widget/wtracktableview.cpp
@@ -574,7 +574,7 @@ void WTrackTableView::createActions() {
connect(m_pBpmThreeHalvesAction, &QAction::triggered,
this, [this] { slotScaleBpm(Beats::THREEHALVES); });
- m_pColorPickerAction = new WColorPickerAction(this);
+ m_pColorPickerAction = new WColorPickerAction(ColorPickerOption::AllowNoColor, this);
m_pColorPickerAction->setObjectName("TrackColorPickerAction");
connect(m_pColorPickerAction, &WColorPickerAction::colorPicked, this, &WTrackTableView::slotColorPicked);
}