diff --git a/libs/widgets/KoColorSetWidget.cpp b/libs/widgets/KoColorSetWidget.cpp index 5c3e4405ba..4fcaf470e3 100644 --- a/libs/widgets/KoColorSetWidget.cpp +++ b/libs/widgets/KoColorSetWidget.cpp @@ -1,268 +1,266 @@ /* This file is part of the KDE project Copyright (c) 2007, 2012 C. Boemann Copyright (c) 2007-2008 Fredy Yanardi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KoColorSetWidget.h" #include "KoColorSetWidget_p.h" -#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include - -void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors() -{ - if (colorSetContainer) { - delete colorSetContainer; - } - colorSetContainer = new QWidget(); - colorSetLayout = new QVBoxLayout(colorSetContainer); - colorSetLayout->setMargin(3); - colorSetLayout->setSpacing(0); // otherwise the use can click where there is none - colorSetContainer->setBackgroundRole(QPalette::Dark); - - colorSetContainer->setLayout(colorSetLayout); - colornames.clear(); - colorNameCmb->clear(); - - connect(paletteView, SIGNAL(sigEntrySelected(KisSwatch)), thePublic, SLOT(slotEntrySelected(KisSwatch))); - connect(colorNameCmb, SIGNAL(activated(QString)), thePublic, SLOT(setColorFromString(QString)), Qt::UniqueConnection); -} +#include void KoColorSetWidget::KoColorSetWidgetPrivate::addRemoveColors() { QList palettes = rServer->resources(); Q_ASSERT(colorSet); KoEditColorSetDialog *dlg = new KoEditColorSetDialog(palettes, colorSet->name(), thePublic); if (dlg->exec() == KoDialog::Accepted ) { // always reload the color set KoColorSet *cs = dlg->activeColorSet(); // check if the selected colorset is predefined if( cs && !palettes.contains( cs ) ) { int i = 1; QFileInfo fileInfo; QString savePath = rServer->saveLocation(); do { fileInfo.setFile(savePath + QString("%1.%2").arg(i++, 4, 10, QChar('0')).arg(colorSet->defaultFileExtension())); } while (fileInfo.exists()); cs->setFilename( fileInfo.filePath() ); cs->setValid( true ); // add new colorset to predefined colorsets if (!rServer->addResource(cs)) { delete cs; cs = 0; } } if (cs) { thePublic->setColorSet(cs); } } delete dlg; } void KoColorSetWidget::KoColorSetWidgetPrivate::addRecent(const KoColor &color) { if(numRecents < 6) { recentPatches[numRecents] = new KoColorPatch(thePublic); recentPatches[numRecents]->setFrameShape(QFrame::StyledPanel); recentPatches[numRecents]->setDisplayRenderer(displayRenderer); recentsLayout->insertWidget(numRecents + 1, recentPatches[numRecents]); connect(recentPatches[numRecents], SIGNAL(triggered(KoColorPatch *)), thePublic, SLOT(slotPatchTriggered(KoColorPatch *))); numRecents++; } // shift colors to the right for (int i = numRecents- 1; i >0; i--) { recentPatches[i]->setColor(recentPatches[i-1]->color()); } //Finally set the recent color recentPatches[0]->setColor(color); } void KoColorSetWidget::KoColorSetWidgetPrivate::activateRecent(int i) { KoColor color = recentPatches[i]->color(); while (i >0) { recentPatches[i]->setColor(recentPatches[i-1]->color()); i--; } recentPatches[0]->setColor(color); } KoColorSetWidget::KoColorSetWidget(QWidget *parent) : QFrame(parent) - ,d(new KoColorSetWidgetPrivate()) + , d(new KoColorSetWidgetPrivate()) { d->thePublic = this; - d->firstShowOfContainer = true; - - d->mainLayout = new QVBoxLayout(this); - d->mainLayout->setMargin(4); - d->mainLayout->setSpacing(2); - d->numRecents = 0; - d->recentsLayout = new QHBoxLayout(); - d->mainLayout->addLayout(d->recentsLayout); + d->recentsLayout = new QHBoxLayout; d->recentsLayout->setMargin(0); d->recentsLayout->addWidget(new QLabel(i18n("Recent:"))); d->recentsLayout->addStretch(1); KoColor color(KoColorSpaceRegistry::instance()->rgb8()); color.fromQColor(QColor(128,0,0)); d->addRecent(color); d->paletteView = new KisPaletteView(this); KisPaletteModel *paletteModel = new KisPaletteModel(d->paletteView); - paletteModel->setDisplayRenderer(d->displayRenderer); d->paletteView->setPaletteModel(paletteModel); - d->mainLayout->addWidget(d->paletteView); - connect(d->paletteView, SIGNAL(sigEntrySelected(KisSwatch)), SLOT(slotEntrySelected(KisSwatch))); + paletteModel->setDisplayRenderer(d->displayRenderer); - d->rServer = KoResourceServerProvider::instance()->paletteServer(); - QPointer defaultColorSet = d->rServer->resourceByName("Default"); - if (!defaultColorSet && d->rServer->resources().count() > 0) { - defaultColorSet = d->rServer->resources().first(); - } - setColorSet(defaultColorSet); + d->paletteChooser = new KisPaletteListWidget(this); + d->paletteChooserButton = new KisPopupButton(this); + d->paletteChooserButton->setPopupWidget(d->paletteChooser); + d->paletteChooserButton->setIcon(KisIconUtils::loadIcon("hi16-palette_library")); + d->paletteChooserButton->setToolTip(i18n("Choose palette")); d->colorNameCmb = new QComboBox(this); d->colorNameCmb->setEditable(true); d->colorNameCmb->setInsertPolicy(QComboBox::NoInsert); - d->mainLayout->addWidget(d->colorNameCmb); + + d->bottomLayout = new QHBoxLayout; + d->bottomLayout->addWidget(d->paletteChooserButton); + d->bottomLayout->addWidget(d->colorNameCmb); + d->bottomLayout->setStretch(0, 0); // minimize chooser button + d->bottomLayout->setStretch(1, 1); // maximize color name cmb d->addRemoveButton = new QToolButton(this); d->addRemoveButton->setText(i18n("Add / Remove Colors...")); d->addRemoveButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - connect(d->addRemoveButton, SIGNAL(clicked()), SLOT(addRemoveColors())); + + d->mainLayout = new QVBoxLayout(this); + d->mainLayout->setMargin(4); + d->mainLayout->setSpacing(2); + d->mainLayout->addLayout(d->recentsLayout); + d->mainLayout->addWidget(d->paletteView); + d->mainLayout->addLayout(d->bottomLayout); d->mainLayout->addWidget(d->addRemoveButton); setLayout(d->mainLayout); + connect(d->paletteChooser, SIGNAL(sigPaletteSelected(KoColorSet*)), SLOT(slotPaletteChoosen(KoColorSet*))); + connect(d->paletteView, SIGNAL(sigEntrySelected(KisSwatch)), SLOT(slotEntrySelected(KisSwatch))); + connect(d->addRemoveButton, SIGNAL(clicked()), SLOT(addRemoveColors())); connect(d->colorNameCmb, SIGNAL(activated(QString)), SLOT(setColorFromString(QString)), Qt::UniqueConnection); + + d->rServer = KoResourceServerProvider::instance()->paletteServer(); + QPointer defaultColorSet = d->rServer->resourceByName("Default"); + if (!defaultColorSet && d->rServer->resources().count() > 0) { + defaultColorSet = d->rServer->resources().first(); + } + setColorSet(defaultColorSet); } KoColorSetWidget::~KoColorSetWidget() { delete d; } void KoColorSetWidget::KoColorSetWidgetPrivate::setColorFromString(QString s) { /* int i = colornames.indexOf(QRegExp(s+"|Fixed")); i = qMax(i,0); colorTriggered(patchWidgetList.at(i)); */ } void KoColorSetWidget::setColorSet(QPointer colorSet) { if (!colorSet) return; if (colorSet == d->colorSet) return; d->paletteView->paletteModel()->setColorSet(colorSet.data()); d->colorSet = colorSet; } KoColorSet* KoColorSetWidget::colorSet() { return d->colorSet; } void KoColorSetWidget::setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer) { if (displayRenderer) { d->displayRenderer = displayRenderer; for (int i=0; i<6; i++) { if (d->recentPatches[i]) { d->recentPatches[i]->setDisplayRenderer(displayRenderer); } } } } void KoColorSetWidget::resizeEvent(QResizeEvent *event) { emit widgetSizeChanged(event->size()); QFrame::resizeEvent(event); } void KoColorSetWidget::slotEntrySelected(const KisSwatch &entry) { emit colorChanged(entry.color(), true); - d->colorNameCmb->setCurrentIndex(d->colornames.indexOf(QRegExp(entry.name()+"|Fixed"))); + // d->colorNameCmb->setCurrentIndex(d->colornames.indexOf(QRegExp(entry.name()+"|Fixed"))); } void KoColorSetWidget::slotPatchTriggered(KoColorPatch *patch) { emit colorChanged(patch->color(), true); int i; for (i = 0; i < d->numRecents; i++) { if(patch == d->recentPatches[i]) { d->activateRecent(i); break; } } if (i == d->numRecents) { // we didn't find it above d->addRecent(patch->color()); } - d->colorNameCmb->setCurrentIndex(d->colornames.indexOf(QRegExp(patch->toolTip()+"|Fixed"))); + // d->colorNameCmb->setCurrentIndex(d->colornames.indexOf(QRegExp(patch->toolTip()+"|Fixed"))); +} + +void KoColorSetWidget::slotPaletteChoosen(KoColorSet *colorSet) +{ + d->colorSet = colorSet; + d->paletteView->paletteModel()->setColorSet(colorSet); } //have to include this because of Q_PRIVATE_SLOT #include "moc_KoColorSetWidget.cpp" diff --git a/libs/widgets/KoColorSetWidget.h b/libs/widgets/KoColorSetWidget.h index 7a716ecd20..a557e1f3eb 100644 --- a/libs/widgets/KoColorSetWidget.h +++ b/libs/widgets/KoColorSetWidget.h @@ -1,121 +1,122 @@ /* This file is part of the KDE project Copyright (c) 2007 C. Boemann Copyright (c) 2007 Fredy Yanardi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KOCOLORSETWIDGET_H_ #define KOCOLORSETWIDGET_H_ #include #include #include #include #include "kritawidgets_export.h" class KoColor; class KoColorSet; class KoColorPatch; /** * @short A colormanaged widget for choosing a color from a colorset * * KoColorSetWidget is a widget for choosing a color (colormanaged via pigment). It shows a color * set plus optionally a checkbox to filter away bad matching colors. */ class KRITAWIDGETS_EXPORT KoColorSetWidget : public QFrame { Q_OBJECT public: /** * Constructor for the widget, where color is initially blackpoint of sRGB * * @param parent parent QWidget */ explicit KoColorSetWidget(QWidget *parent=0); /** * Destructor */ ~KoColorSetWidget() override; /** * Sets the color set that this widget shows. * @param colorSet pointer to the color set */ void setColorSet(QPointer colorSet); /** * @brief setDisplayRenderer * Set the display renderer of this object. * @param displayRenderer */ void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer); /** * Gets the current color set * @returns current color set,, 0 if none set */ KoColorSet* colorSet(); protected: void resizeEvent(QResizeEvent *event) override; ///< reimplemented from QFrame Q_SIGNALS: /** * Emitted every time the color changes (by calling setColor() or * by user interaction. * @param color the new color * @param final if the value is final (ie not produced by the pointer moving over around) */ void colorChanged(const KoColor &color, bool final); /** * Emitted every time the size of this widget changes because of new colorset with * different number of colors is loaded. This is useful for KoColorSetAction to update * correct size of the menu showing this widget. * @param size the new size */ void widgetSizeChanged(const QSize &size); private Q_SLOTS: /** * @brief slotPatchTriggered * Triggered when a recent patch is triggered */ void slotPatchTriggered(KoColorPatch *); /** * @brief slotEntrySelected * Triggered when a color is choose from the palette view */ void slotEntrySelected(const KisSwatch &); + void slotPaletteChoosen(KoColorSet *); private: Q_PRIVATE_SLOT(d, void addRemoveColors()) Q_PRIVATE_SLOT(d, void setColorFromString(QString s)) class KoColorSetWidgetPrivate; KoColorSetWidgetPrivate * const d; }; #endif diff --git a/libs/widgets/KoColorSetWidget_p.h b/libs/widgets/KoColorSetWidget_p.h index 8d51e98dfe..3268b67350 100644 --- a/libs/widgets/KoColorSetWidget_p.h +++ b/libs/widgets/KoColorSetWidget_p.h @@ -1,78 +1,81 @@ /* This file is part of the KDE project Copyright (c) 2007, 2012 C. Boemann Copyright (c) 2007-2008 Fredy Yanardi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KoColorSetWidget_p_h #define KoColorSetWidget_p_h #include "KoColorSetWidget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include +#include #include #include class KoColorPatch; class KisPaletteView; class Q_DECL_HIDDEN KoColorSetWidget::KoColorSetWidgetPrivate { public: KoColorSetWidget *thePublic; QPointer colorSet; - QTimer m_timer; - QVBoxLayout *mainLayout; - bool firstShowOfContainer; - QWidget *colorSetContainer; + KisPaletteView *paletteView; + KisPaletteListWidget *paletteChooser; + KisPopupButton *paletteChooserButton; + + QVBoxLayout *mainLayout; QVBoxLayout *colorSetLayout; QHBoxLayout *recentsLayout; + QHBoxLayout *bottomLayout; + KoColorPatch *recentPatches[6]; QToolButton *addRemoveButton; QComboBox *colorNameCmb; - QStringList colornames; int numRecents; + const KoColorDisplayRendererInterface *displayRenderer; + KoResourceServer *rServer; + void addRecent(const KoColor &); void activateRecent(int i); - void fillColors(); void addRemoveColors(); void setColorFromString(QString s); - - const KoColorDisplayRendererInterface *displayRenderer; - KoResourceServer* rServer; }; #endif diff --git a/plugins/dockers/palettedocker/palettedocker_dock.cpp b/plugins/dockers/palettedocker/palettedocker_dock.cpp index 177f7b95be..349933aeaa 100644 --- a/plugins/dockers/palettedocker/palettedocker_dock.cpp +++ b/plugins/dockers/palettedocker/palettedocker_dock.cpp @@ -1,313 +1,314 @@ /* * Copyright (c) 2013 Sven Langkamp * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "palettedocker_dock.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "KisPaletteModel.h" #include "KisPaletteDelegate.h" #include "kis_palette_view.h" #include #include "ui_wdgpalettedock.h" PaletteDockerDock::PaletteDockerDock( ) : QDockWidget(i18n("Palette")) , m_wdgPaletteDock(new Ui_WdgPaletteDock()) , m_currentColorSet(0) , m_resourceProvider(0) , m_canvas(0) { QWidget* mainWidget = new QWidget(this); setWidget(mainWidget); m_wdgPaletteDock->setupUi(mainWidget); m_wdgPaletteDock->bnAdd->setIcon(KisIconUtils::loadIcon("list-add")); m_wdgPaletteDock->bnAdd->setIconSize(QSize(16, 16)); m_wdgPaletteDock->bnRemove->setIcon(KisIconUtils::loadIcon("edit-delete")); m_wdgPaletteDock->bnRemove->setIconSize(QSize(16, 16)); m_wdgPaletteDock->bnAdd->setEnabled(false); m_wdgPaletteDock->bnRemove->setEnabled(false); // m_wdgPaletteDock->bnAddGroup->setIcon(KisIconUtils::loadIcon("groupLayer")); m_model = new KisPaletteModel(this); m_wdgPaletteDock->paletteView->setPaletteModel(m_model); connect(m_wdgPaletteDock->bnAdd, SIGNAL(clicked(bool)), this, SLOT(slotAddColor())); connect(m_wdgPaletteDock->bnRemove, SIGNAL(clicked(bool)), this, SLOT(slotRemoveColor())); connect(m_wdgPaletteDock->bnRename, SIGNAL(clicked(bool)), this, SLOT(slotEditEntry())); connect(m_wdgPaletteDock->paletteView, SIGNAL(sigEntrySelected(const KisSwatch &)), this, SLOT(slotSetForegroundColor(const KisSwatch &))); connect(m_wdgPaletteDock->paletteView, SIGNAL(entrySelectedBackGround(const KisSwatch &)), this, SLOT(entrySelectedBack(const KisSwatch &))); connect(m_wdgPaletteDock->paletteView, SIGNAL(sigSetEntry(QModelIndex)), this, SLOT(slotSetEntryByForeground(QModelIndex))); KoResourceServer* rServer = KoResourceServerProvider::instance()->paletteServer(); m_serverAdapter = QSharedPointer(new KoResourceServerAdapter(rServer)); m_serverAdapter->connectToResourceServer(); rServer->addObserver(this); m_paletteChooser = new KisPaletteListWidget(this); connect(m_paletteChooser, SIGNAL(sigPaletteSelected(KoColorSet*)), this, SLOT(slotSetColorSet(KoColorSet*))); m_wdgPaletteDock->bnColorSets->setIcon(KisIconUtils::loadIcon("hi16-palette_library")); m_wdgPaletteDock->bnColorSets->setToolTip(i18n("Choose palette")); m_wdgPaletteDock->bnColorSets->setPopupWidget(m_paletteChooser); connect(m_wdgPaletteDock->cmbNameList, SIGNAL(currentIndexChanged(int)), this, SLOT(slotNameListSelection(int))); + KisConfig cfg(true); QString defaultPaletteName = cfg.defaultPalette(); KoColorSet* defaultPalette = rServer->resourceByName(defaultPaletteName); if (defaultPalette) { slotSetColorSet(defaultPalette); } } PaletteDockerDock::~PaletteDockerDock() { KoResourceServer* rServer = KoResourceServerProvider::instance()->paletteServer(); rServer->removeObserver(this); if (m_currentColorSet) { KisConfig cfg(true); cfg.setDefaultPalette(m_currentColorSet->name()); } delete m_wdgPaletteDock->paletteView->itemDelegate(); delete m_wdgPaletteDock; } void PaletteDockerDock::setViewManager(KisViewManager* kisview) { m_resourceProvider = kisview->resourceProvider(); connect(m_resourceProvider, SIGNAL(sigSavingWorkspace(KisWorkspaceResource*)), SLOT(saveToWorkspace(KisWorkspaceResource*))); connect(m_resourceProvider, SIGNAL(sigLoadingWorkspace(KisWorkspaceResource*)), SLOT(loadFromWorkspace(KisWorkspaceResource*))); connect(m_resourceProvider, SIGNAL(sigFGColorChanged(KoColor)),m_wdgPaletteDock->paletteView, SLOT(trySelectClosestColor(KoColor))); kisview->nodeManager()->disconnect(m_model); } void PaletteDockerDock::setCanvas(KoCanvasBase *canvas) { setEnabled(canvas != 0); if (canvas) { KisCanvas2 *cv = qobject_cast(canvas); m_model->setDisplayRenderer(cv->displayColorConverter()->displayRendererInterface()); } m_canvas = static_cast(canvas); } void PaletteDockerDock::unsetCanvas() { setEnabled(false); m_model->setDisplayRenderer(0); m_canvas = 0; } void PaletteDockerDock::unsetResourceServer() { KoResourceServer* rServer = KoResourceServerProvider::instance()->paletteServer(); rServer->removeObserver(this); } void PaletteDockerDock::removingResource(KoColorSet *resource) { if (resource == m_currentColorSet) { slotSetColorSet(0); } } void PaletteDockerDock::resourceChanged(KoColorSet *resource) { slotSetColorSet(resource); } void PaletteDockerDock::slotSetColorSet(KoColorSet* colorSet) { m_currentColorSet = colorSet; m_model->setColorSet(colorSet); m_wdgPaletteDock->bnColorSets->setText(colorSet->name()); resetNameList(colorSet); } void PaletteDockerDock::resetNameList(const KoColorSet *colorSet) { m_wdgPaletteDock->cmbNameList->clear(); m_indexList.clear(); if (!colorSet || !(colorSet->colorCount()>0)) { return; } for (int x = 0; x < colorSet->columnCount(); x++) { for (int y = 0; y < colorSet->rowCount(); y++) { KisSwatch entry = colorSet->getColorGlobal(x, y); QPixmap colorSquare = QPixmap(32, 32); if (entry.spotColor()) { QImage img = QImage(32, 32, QImage::Format_ARGB32); QPainter circlePainter; img.fill(Qt::transparent); circlePainter.begin(&img); QBrush brush = QBrush(Qt::SolidPattern); brush.setColor(entry.color().toQColor()); circlePainter.setBrush(brush); QPen pen = circlePainter.pen(); pen.setColor(Qt::transparent); pen.setWidth(0); circlePainter.setPen(pen); circlePainter.drawEllipse(0, 0, 32, 32); circlePainter.end(); colorSquare = QPixmap::fromImage(img); } else { colorSquare.fill(entry.color().toQColor()); } QString name = entry.name(); if (!entry.id().isEmpty()){ name = entry.id() + " - " + entry.name(); } m_wdgPaletteDock->cmbNameList->addSqueezedItem(QIcon(colorSquare), name); m_indexList.append(QPair(x, y)); } } QCompleter *completer = new QCompleter(m_wdgPaletteDock->cmbNameList->model()); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setFilterMode(Qt::MatchContains); m_wdgPaletteDock->cmbNameList->setCompleter(completer); if (colorSet && colorSet->removable()) { m_wdgPaletteDock->bnAdd->setEnabled(true); m_wdgPaletteDock->bnRemove->setEnabled(true); } else { m_wdgPaletteDock->bnAdd->setEnabled(false); m_wdgPaletteDock->bnRemove->setEnabled(false); } } void PaletteDockerDock::slotNameListSelection(int index) { /* if (m_model && m_currentColorSet) { KisPaletteView *view = m_wdgPaletteDock->paletteView; view->blockSignals(true); m_wdgPaletteDock->cmbNameList->blockSignals(true); m_wdgPaletteDock->cmbNameList->setCurrentIndex(index); view->selectionModel()->clearSelection(); view->selectionModel()->setCurrentIndex(QModelIndex(m_indexList[index].first, m_indexList[index].second), QItemSelectionModel::Select); view->blockSignals(false); m_wdgPaletteDock->cmbNameList->blockSignals(false); } */ } void PaletteDockerDock::slotAddColor() { if (m_resourceProvider) { m_wdgPaletteDock->paletteView->addEntryWithDialog(m_resourceProvider->fgColor()); } } void PaletteDockerDock::slotRemoveColor() { QModelIndex index = m_wdgPaletteDock->paletteView->currentIndex(); if (!index.isValid()) { return; } m_wdgPaletteDock->paletteView->removeEntryWithDialog(index); } void PaletteDockerDock::slotSetForegroundColor(const KisSwatch &entry) { if (m_resourceProvider) { m_resourceProvider->setFGColor(entry.color()); } } void PaletteDockerDock::saveToWorkspace(KisWorkspaceResource* workspace) { if (m_currentColorSet) { workspace->setProperty("palette", m_currentColorSet->name()); } } void PaletteDockerDock::loadFromWorkspace(KisWorkspaceResource* workspace) { if (workspace->hasProperty("palette")) { KoResourceServer* rServer = KoResourceServerProvider::instance()->paletteServer(); KoColorSet* colorSet = rServer->resourceByName(workspace->getString("palette")); if (colorSet) { slotSetColorSet(colorSet); } } } void PaletteDockerDock::slotSetEntryByForeground(const QModelIndex &index) { m_model->setEntry(KisSwatch(m_resourceProvider->fgColor()), index); if (m_currentColorSet->removable()) { m_wdgPaletteDock->bnRemove->setEnabled(true); } } void PaletteDockerDock::slotEditEntry() { QModelIndex index = m_wdgPaletteDock->paletteView->currentIndex(); if (!index.isValid()) { return; } m_wdgPaletteDock->paletteView->modifyEntry(index); }