summaryrefslogtreecommitdiffstats
path: root/src/widget/wcolorpickeraction.h
blob: 29566343785f633b1f333f09f0d7748ad0c62088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include <QHBoxLayout>
#include <QWidget>
#include <QWidgetAction>

#include "util/parented_ptr.h"
#include "widget/wcolorpicker.h"

class WColorPickerAction : public QWidgetAction {
    Q_OBJECT
  public:
    explicit WColorPickerAction(
            WColorPicker::Options options,
            const ColorPalette& palette,
            QWidget* parent = nullptr);

    void resetSelectedColor();
    void setSelectedColor(mixxx::RgbColor::optional_t color);

    /// Set a new color palette for the underlying color picker.
    ///
    /// After calling this, your need to tell Qt that the menu size needs to be
    /// recalculated, e.g.:
    ///
    ///     m_pColorPickerAction->setColorPalette(palette);
    ///     QResizeEvent resizeEvent(QSize(), m_pMenu->size());
    ///     qApp->sendEvent(m_pMenu, &resizeEvent);
    void setColorPalette(const ColorPalette& palette);

  signals:
    void colorPicked(mixxx::RgbColor::optional_t color);

  private:
    parented_ptr<WColorPicker> m_pColorPicker;
};