Krita Source Code Documentation
Loading...
Searching...
No Matches
PaletteView Class Reference

The PaletteView class is a wrapper around a MVC method for handling palettes. This class shows a nice widget that can drag and drop, edit colors in a colorset and will handle adding and removing entries if you'd like it to. More...

#include <PaletteView.h>

+ Inheritance diagram for PaletteView:

Public Slots

bool addEntryWithDialog (ManagedColor *color)
 addEntryWithDialog This gives a simple dialog for adding colors, with options like adding name, id, and to which group the color should be added.
 
bool addGroupWithDialog ()
 addGroupWithDialog gives a little dialog to ask for the desired groupname.
 
bool removeSelectedEntryWithDialog ()
 removeSelectedEntryWithDialog removes the selected entry. If it is a group, it pop up a dialog asking whether the colors should also be removed.
 
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 on the active color.
 

Signals

void entrySelectedBackGround (Swatch entry)
 entrySelectedBackGround fires when a swatch is selected with rightclick.
 
void entrySelectedForeGround (Swatch entry)
 entrySelectedForeGround fires when a swatch is selected with leftclick.
 

Public Member Functions

 PaletteView (QWidget *parent=0)
 
 ~PaletteView ()
 

Private Slots

void fgSelected (QModelIndex index)
 

Private Attributes

const QScopedPointer< Privated
 

Detailed Description

The PaletteView class is a wrapper around a MVC method for handling palettes. This class shows a nice widget that can drag and drop, edit colors in a colorset and will handle adding and removing entries if you'd like it to.

Definition at line 30 of file PaletteView.h.

Constructor & Destructor Documentation

◆ PaletteView()

PaletteView::PaletteView ( QWidget * parent = 0)

Definition at line 17 of file PaletteView.cpp.

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}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisPaletteModel class This, together with KisPaletteView and KisPaletteDelegate forms a mvc way t...
void fgSelected(QModelIndex index)
const QScopedPointer< Private > d
Definition PaletteView.h:94

References connect(), d, and fgSelected().

◆ ~PaletteView()

PaletteView::~PaletteView ( )

Definition at line 32 of file PaletteView.cpp.

33{
34 delete d->widget;
35 delete d->model;
36}

References d.

Member Function Documentation

◆ addEntryWithDialog

bool PaletteView::addEntryWithDialog ( ManagedColor * color)
slot

addEntryWithDialog This gives a simple dialog for adding colors, with options like adding name, id, and to which group the color should be added.

Parameters
colorthe default color to add
Returns
whether it was successful.

Definition at line 44 of file PaletteView.cpp.

45{
46 if (d->model->colorSet()) {
47 return d->widget->addEntryWithDialog(color->color());
48 }
49 return false;
50}
KoColor color() const

References ManagedColor::color(), and d.

◆ addGroupWithDialog

bool PaletteView::addGroupWithDialog ( )
slot

addGroupWithDialog gives a little dialog to ask for the desired groupname.

Returns
whether this was successful.

Definition at line 52 of file PaletteView.cpp.

53{
54 if (d->model->colorSet()) {
55 return d->widget->addGroupWithDialog();
56 }
57 return false;
58}

References d.

◆ entrySelectedBackGround

void PaletteView::entrySelectedBackGround ( Swatch entry)
signal

entrySelectedBackGround fires when a swatch is selected with rightclick.

Parameters
entry

◆ entrySelectedForeGround

void PaletteView::entrySelectedForeGround ( Swatch entry)
signal

entrySelectedForeGround fires when a swatch is selected with leftclick.

Parameters
entry

◆ fgSelected

void PaletteView::fgSelected ( QModelIndex index)
privateslot

Definition at line 73 of file PaletteView.cpp.

74{
75 KisSwatch swatch = d->model->getSwatch(index);
76 Q_EMIT entrySelectedForeGround(Swatch(swatch));
77}
void entrySelectedForeGround(Swatch entry)
entrySelectedForeGround fires when a swatch is selected with leftclick.
The Swatch class is a thin wrapper around the KisSwatch class.
Definition Swatch.h:22

References d, and entrySelectedForeGround().

◆ removeSelectedEntryWithDialog

bool PaletteView::removeSelectedEntryWithDialog ( )
slot

removeSelectedEntryWithDialog removes the selected entry. If it is a group, it pop up a dialog asking whether the colors should also be removed.

Returns
whether this was successful

Definition at line 60 of file PaletteView.cpp.

61{
62 if (d->model->colorSet()) {
63 return d->widget->removeEntryWithDialog(d->widget->currentIndex());
64 }
65 return false;
66}

References d.

◆ setPalette

void PaletteView::setPalette ( Palette * palette)
slot

setPalette Set a new palette.

Parameters
palette

Definition at line 38 of file PaletteView.cpp.

39{
40 d->model->setColorSet(palette->colorSet());
41 d->widget->setPaletteModel(d->model);
42}
rgba palette[MAX_PALETTE]
Definition palette.c:35

References d, and palette.

◆ trySelectClosestColor

void PaletteView::trySelectClosestColor ( ManagedColor * color)
slot

trySelectClosestColor tries to select the closest color to the one given. It does not force a change on the active color.

Parameters
colorthe color to compare to.

Definition at line 68 of file PaletteView.cpp.

69{
70 d->widget->selectClosestColor(color->color());
71}

References ManagedColor::color(), and d.

Member Data Documentation

◆ d

const QScopedPointer<Private> PaletteView::d
private

Definition at line 94 of file PaletteView.h.


The documentation for this class was generated from the following files: