summaryrefslogtreecommitdiffstats
path: root/src/widget/wcolorpickeraction.cpp
blob: 642a2f20fb0fa21aed46a6dbcf7b74dde9d60dd9 (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
#include "widget/wcolorpickeraction.h"

#include "moc_wcolorpickeraction.cpp"

WColorPickerAction::WColorPickerAction(WColorPicker::Options options, const ColorPalette& palette, QWidget* parent)
        : QWidgetAction(parent),
          m_pColorPicker(make_parented<WColorPicker>(options, palette)) {
    connect(m_pColorPicker.get(), &WColorPicker::colorPicked, this, &WColorPickerAction::colorPicked);

    QHBoxLayout* pLayout = new QHBoxLayout();
    pLayout->addWidget(m_pColorPicker);
    pLayout->setSizeConstraint(QLayout::SetFixedSize);

    QWidget* pWidget = new QWidget();
    pWidget->setLayout(pLayout);
    pWidget->setSizePolicy(QSizePolicy());
    setDefaultWidget(pWidget);
}

void WColorPickerAction::resetSelectedColor() {
    m_pColorPicker->resetSelectedColor();
}

void WColorPickerAction::setSelectedColor(const mixxx::RgbColor::optional_t& color) {
    m_pColorPicker->setSelectedColor(color);
}

void WColorPickerAction::setColorPalette(const ColorPalette& palette) {
    m_pColorPicker->setColorPalette(palette);
    QWidget* pWidget = defaultWidget();
    VERIFY_OR_DEBUG_ASSERT(pWidget) {
        return;
    }
    pWidget->adjustSize();
}