Krita Source Code Documentation
Loading...
Searching...
No Matches
PaletteView.cpp
Go to the documentation of this file.
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
16
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(sigIndexSelected(QModelIndex)),
29 this, SLOT(fgSelected(QModelIndex)));
30}
31
33{
34 delete d->widget;
35 delete d->model;
36}
37
39{
40 d->model->setColorSet(palette->colorSet());
41 d->widget->setPaletteModel(d->model);
42}
43
45{
46 if (d->model->colorSet()) {
47 return d->widget->addEntryWithDialog(color->color());
48 }
49 return false;
50}
51
53{
54 if (d->model->colorSet()) {
55 return d->widget->addGroupWithDialog();
56 }
57 return false;
58}
59
61{
62 if (d->model->colorSet()) {
63 return d->widget->removeEntryWithDialog(d->widget->currentIndex());
64 }
65 return false;
66}
67
69{
70 d->widget->selectClosestColor(color->color());
71}
72
73void PaletteView::fgSelected(QModelIndex index)
74{
75 KisSwatch swatch = d->model->getSwatch(index);
76 Q_EMIT entrySelectedForeGround(Swatch(swatch));
77}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisPaletteModel class This, together with KisPaletteView and KisPaletteDelegate forms a mvc way t...
The ManagedColor class is a class to handle colors that are color managed. A managed color is a color...
KoColor color() const
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,...
PaletteView(QWidget *parent=0)
bool removeSelectedEntryWithDialog()
removeSelectedEntryWithDialog removes the selected entry. If it is a group, it pop up a dialog asking...
void setPalette(Palette *palette)
setPalette Set a new palette.
void trySelectClosestColor(ManagedColor *color)
trySelectClosestColor tries to select the closest color to the one given. It does not force a change ...
bool addGroupWithDialog()
addGroupWithDialog gives a little dialog to ask for the desired groupname.
void fgSelected(QModelIndex index)
const QScopedPointer< Private > d
Definition PaletteView.h:94
The Palette class Palette is a resource object that stores organised color data. It's purpose is to a...
Definition Palette.h:44
The Swatch class is a thin wrapper around the KisSwatch class.
Definition Swatch.h:22
rgba palette[MAX_PALETTE]
Definition palette.c:35