Krita

PaletteView.cpp
1/*
2 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#include <PaletteView.h>
8#include <QVBoxLayout>
9
10struct PaletteView::Private
11{
12 KisPaletteModel *model = 0;
13 KisPaletteView *widget = 0;
14 bool allowPaletteModification = true;
15};
16
17PaletteView::PaletteView(QWidget *parent)
18 : QWidget(parent), d(new Private)
19{
20 d->widget = new KisPaletteView();
21 d->model = new KisPaletteModel();
22 d->widget->setPaletteModel(d->model);
23
24 QVBoxLayout *layout = new QVBoxLayout(this);
25 layout->addWidget(d->widget);
26
27 //forward signals.
28 connect(d->widget, SIGNAL(entrySelected(KisSwatch)),
29 this, SLOT(fgSelected(KisSwatch)));
30 connect(d->widget, SIGNAL(entrySelectedBackGround(KisSwatch)),
31 this, SLOT(bgSelected(KisSwatch)));
32}
33
34PaletteView::~PaletteView()
35{
36 delete d->model;
37}
38
40{
41 d->model->setColorSet(palette->colorSet());
42 d->widget->setPaletteModel(d->model);
43}
44
46{
47 if (d->model->colorSet()) {
48 return d->widget->addEntryWithDialog(color->color());
49 }
50 return false;
51}
52
54{
55 if (d->model->colorSet()) {
56 return d->widget->addGroupWithDialog();
57 }
58 return false;
59}
60
62{
63 if (d->model->colorSet()) {
64 return d->widget->removeEntryWithDialog(d->widget->currentIndex());
65 }
66 return false;
67}
68
70{
71 d->widget->selectClosestColor(color->color());
72}
73
74void PaletteView::fgSelected(KisSwatch swatch)
75{
77}
78
79void PaletteView::bgSelected(KisSwatch swatch)
80{
82}
The ManagedColor class is a class to handle colors that are color managed.
void entrySelectedForeGround(Swatch entry)
entrySelectedForeGround fires when a swatch is selected with leftclick.
bool addEntryWithDialog(ManagedColor *color)
addEntryWithDialog This gives a simple dialog for adding colors, with options like adding name,...
bool removeSelectedEntryWithDialog()
removeSelectedEntryWithDialog removes the selected entry.
void setPalette(Palette *palette)
setPalette Set a new palette.
void trySelectClosestColor(ManagedColor *color)
trySelectClosestColor tries to select the closest color to the one given.
void entrySelectedBackGround(Swatch entry)
entrySelectedBackGround fires when a swatch is selected with rightclick.
bool addGroupWithDialog()
addGroupWithDialog gives a little dialog to ask for the desired groupname.
The Palette class Palette is a resource object that stores organised color data.
Definition Palette.h:45
The Swatch class is a thin wrapper around the KisSwatch class.
Definition Swatch.h:22
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
Q_EMITQ_EMIT
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.