10#include <QApplication>
17#include <QWidgetAction>
23#include <klocalizedstring.h>
24#include <ksharedconfig.h>
37void KoColorSetWidget::KoColorSetWidgetPrivate::addRecent(
const KoColor &color)
41 recentPatches[numRecents]->setFrameShape(QFrame::StyledPanel);
42 recentPatches[numRecents]->setDisplayRenderer(displayRenderer);
43 recentsLayout->insertWidget(numRecents + 1, recentPatches[numRecents]);
48 for (
int i = numRecents- 1; i >0; i--) {
49 recentPatches[i]->setColor(recentPatches[i-1]->color());
53 recentPatches[0]->setColor(color);
56void KoColorSetWidget::KoColorSetWidgetPrivate::activateRecent(
int i)
58 KoColor color = recentPatches[i]->color();
61 recentPatches[i]->
setColor(recentPatches[i-1]->color());
64 recentPatches[0]->setColor(color);
69 , d(new KoColorSetWidgetPrivate())
74 d->recentsLayout =
new QHBoxLayout;
75 d->recentsLayout->setContentsMargins(0, 0, 0, 0);
76 d->recentsLayout->addWidget(
new QLabel(i18n(
"Recent:")));
77 d->recentsLayout->addStretch(1);
85 d->paletteView->setPaletteModel(paletteModel);
86 d->paletteView->setDisplayRenderer(
d->displayRenderer);
90 d->paletteChooserButton->setPopupWidget(
d->paletteChooser);
92 d->paletteChooserButton->setToolTip(i18n(
"Choose palette"));
95 d->colorNameCmb->setCompanionView(
d->paletteView);
97 d->bottomLayout =
new QHBoxLayout;
98 d->bottomLayout->addWidget(
d->paletteChooserButton);
99 d->bottomLayout->addWidget(
d->colorNameCmb);
100 d->bottomLayout->setStretch(0, 0);
101 d->bottomLayout->setStretch(1, 1);
103 d->mainLayout =
new QVBoxLayout(
this);
104 d->mainLayout->setContentsMargins(4, 4, 4, 4);
105 d->mainLayout->setSpacing(2);
106 d->mainLayout->addLayout(
d->recentsLayout);
107 d->mainLayout->addWidget(
d->paletteView);
108 d->mainLayout->addLayout(
d->bottomLayout);
115 KoColorSetSP defaultColorSet =
d->rServer->resource(
"",
"",
"Default");
116 if (!defaultColorSet &&
d->rServer->resourceCount() > 0) {
117 defaultColorSet =
d->rServer->firstResource();
132 d->paletteView->paletteModel()->setColorSet(
colorSet);
145 for (
int i=0; i<6; i++) {
146 if (
d->recentPatches[i]) {
156 QFrame::resizeEvent(event);
171 for (i = 0; i <
d->numRecents; i++) {
172 if(patch ==
d->recentPatches[i]) {
173 d->activateRecent(i);
178 if (i ==
d->numRecents) {
179 d->addRecent(patch->
color());
186 d->paletteView->paletteModel()->setColorSet(
colorSet);
195#include "moc_KoColorSetWidget.cpp"
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisPaletteComboBox class A combobox used with KisPaletteView.
The KisPaletteModel class This, together with KisPaletteView and KisPaletteDelegate forms a mvc way t...
void setColor(const quint8 *data, const KoColorSpace *colorSpace=0)
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
QIcon loadIcon(const QString &name)
static KoColorSpaceRegistry * instance()
static KoResourceServerProvider * instance()
KoResourceServer< KoColorSet > * paletteServer