diff --git a/libs/widgets/KisPaletteListWidget.cpp b/libs/widgets/KisPaletteListWidget.cpp index 2e5519a4de..0130369d59 100644 --- a/libs/widgets/KisPaletteListWidget.cpp +++ b/libs/widgets/KisPaletteListWidget.cpp @@ -1,294 +1,316 @@ #include #include #include #include #include #include #include #include +#include #include +#include #include "KisDlgPaletteEditor.h" #include #include "KisPaletteListWidget.h" #include "KisPaletteListWidget_p.h" /* bool KisPaletteView::addGroupWithDialog() { KoDialog *window = new KoDialog(); window->setWindowTitle(i18nc("@title:window","Add a new group")); QFormLayout *editableItems = new QFormLayout(); window->mainWidget()->setLayout(editableItems); QLineEdit *lnName = new QLineEdit(); editableItems->addRow(i18nc("Name for a group", "Name"), lnName); lnName->setText(i18nc("Part of default name for a new group", "Color Group")+""+QString::number(m_d->model->colorSet()->getGroupNames().size()+1)); if (window->exec() == KoDialog::Accepted) { QString groupName = lnName->text(); m_d->model->addGroup(groupName); m_d->model->colorSet()->save(); return true; } return false; } */ KisPaletteListWidget::KisPaletteListWidget(QWidget *parent) : QWidget(parent) , m_ui(new Ui_WdgPaletteListWidget) , m_d(new KisPaletteListWidgetPrivate(this)) { m_d->allowModification = false; m_d->actAdd.reset(new QAction(KisIconUtils::loadIcon("list-add"), i18n("Add a new palette"))); m_d->actRemove.reset(new QAction(KisIconUtils::loadIcon("list-remove"), i18n("Remove current palette"))); m_d->actModify.reset(new QAction(KisIconUtils::loadIcon("edit-rename"), i18n("Rename choosen palette"))); m_d->actImport.reset(new QAction(KisIconUtils::loadIcon("document-import"), i18n("Import a new palette from file"))); m_d->actExport.reset(new QAction(KisIconUtils::loadIcon("document-export"), i18n("Export current palette to file"))); m_d->model->setColumnCount(1); m_ui->setupUi(this); m_ui->bnAdd->setDefaultAction(m_d->actAdd.data()); m_ui->bnRemove->setDefaultAction(m_d->actRemove.data()); m_ui->bnEdit->setDefaultAction(m_d->actModify.data()); m_ui->bnImport->setDefaultAction(m_d->actImport.data()); m_ui->bnExport->setDefaultAction(m_d->actExport.data()); connect(m_d->actAdd.data(), SIGNAL(triggered()), SLOT(slotAdd())); connect(m_d->actRemove.data(), SIGNAL(triggered()), SLOT(slotRemove())); connect(m_d->actModify.data(), SIGNAL(triggered()), SLOT(slotModify())); connect(m_d->actImport.data(), SIGNAL(triggered()), SLOT(slotImport())); connect(m_d->actExport.data(), SIGNAL(triggered()), SLOT(slotExport())); m_d->itemChooser->setItemDelegate(m_d->delegate.data()); m_d->itemChooser->setRowHeight(40); m_d->itemChooser->setColumnCount(1); m_d->itemChooser->showButtons(false); m_d->itemChooser->showTaggingBar(true); m_ui->viewPalette->setLayout(new QHBoxLayout(m_ui->viewPalette)); m_ui->viewPalette->layout()->addWidget(m_d->itemChooser.data()); connect(m_d->itemChooser.data(), SIGNAL(resourceSelected(KoResource *)), SLOT(slotPaletteResourceSelected(KoResource*))); m_d->itemChooser->setCurrentItem(0, 0); } KisPaletteListWidget::~KisPaletteListWidget() { } void KisPaletteListWidget::slotPaletteResourceSelected(KoResource *r) { KoColorSet *g = static_cast(r); - if (g->isEditable() && m_d->allowModification) { + if (g->isEditable()) { m_ui->bnAdd->setEnabled(true); m_ui->bnRemove->setEnabled(true); m_ui->bnEdit->setEnabled(true); - m_ui->bnImport->setEnabled(true); - m_ui->bnExport->setEnabled(true); } else { m_ui->bnAdd->setEnabled(false); m_ui->bnRemove->setEnabled(false); m_ui->bnEdit->setEnabled(false); - m_ui->bnImport->setEnabled(false); - m_ui->bnExport->setEnabled(false); } emit sigPaletteSelected(g); } void KisPaletteListWidget::slotAdd() { KoColorSet *newColorSet = new KoColorSet(newPaletteFileName()); newColorSet->setPaletteType(KoColorSet::KPL); newColorSet->setIsGlobal(false); newColorSet->setIsEditable(true); newColorSet->setName("New Palette"); m_d->rAdapter->addResource(newColorSet); m_d->itemChooser->setCurrentResource(newColorSet); emit sigPaletteListChanged(); } void KisPaletteListWidget::slotRemove() { if (m_d->itemChooser->currentResource()) { KoColorSet *cs = static_cast(m_d->itemChooser->currentResource()); if (!cs || !cs->isEditable()) { return; } if (cs->isGlobal()) { QFile::remove(cs->filename()); } m_d->rAdapter->removeResource(cs); } m_d->itemChooser->setCurrentItem(0, 0); emit sigPaletteListChanged(); } void KisPaletteListWidget::slotModify() { KisDlgPaletteEditor dlg; KoColorSet *colorSet = static_cast(m_d->itemChooser->currentResource()); if (!colorSet) { return; } dlg.setPalette(colorSet); if (dlg.exec() != QDialog::Accepted){ return; } if (!dlg.isModified()) { return; } colorSet->setName(dlg.name()); colorSet->setColumnCount(dlg.columnCount()); if (dlg.isGlobal()) { setPaletteGlobal(colorSet); } else { setPaletteNonGlobal(colorSet); } for (const QString &newGroupName : dlg.newGroupNames()) { colorSet->addGroup(newGroupName); colorSet->getGroup(newGroupName)->setRowCount(dlg.groupRowNumber(newGroupName)); } for (const QString &groupName : colorSet->getGroupNames()) { if (groupName == KoColorSet::GLOBAL_GROUP_NAME) { continue; } if (dlg.groupRemoved(groupName)) { colorSet->removeGroup(groupName, dlg.groupKeelColors(groupName)); continue; } colorSet->getGroup(groupName)->setRowCount(dlg.groupRowNumber(groupName)); if (!dlg.groupRenamedTo(groupName).isEmpty()) { colorSet->changeGroupName(groupName, dlg.groupRenamedTo(groupName)); } } for (const KoResource *r : m_d->rAdapter->resources()) { if (r != colorSet && r->filename() == dlg.filename()) { QMessageBox msgFilenameDuplicate; msgFilenameDuplicate.setWindowTitle(i18n("Duplicate filename")); msgFilenameDuplicate.setText(i18n("Duplicate filename! Palette not saved.")); msgFilenameDuplicate.exec(); return; } } colorSet->setFilename(dlg.filename()); emit sigPaletteSelected(colorSet); // to update elements in the docker emit sigPaletteListChanged(); } void KisPaletteListWidget::slotImport() { + KoFileDialog dialog(this, KoFileDialog::OpenFile, "Open Palette"); + dialog.setDefaultDir(QDir::homePath()); + dialog.setMimeTypeFilters(QStringList() << "krita/x-colorsetentry" << "application/x-gimp-color-palette"); + QString fileName = dialog.filename(); + if (fileName.isEmpty()) { return; } + KoColorSet *colorSet = new KoColorSet(fileName); + colorSet->load(); + m_d->rAdapter->addResource(colorSet); + m_d->itemChooser->setCurrentResource(colorSet); emit sigPaletteListChanged(); } void KisPaletteListWidget::slotExport() { - + KoColorSet *r = static_cast(m_d->itemChooser->currentResource()); + KoFileDialog dialog(this, KoFileDialog::SaveFile, "Save Palette"); + dialog.setDefaultDir(r->filename()); + dialog.setMimeTypeFilters(QStringList() << "krita/x-colorsetentry" << "application/x-gimp-color-palette"); + QString newPath; + bool isStandAlone = r->isGlobal(); + QString oriPath = r->filename(); + if ((newPath = dialog.filename()).isEmpty()) { return; } + qDebug() << newPath; + r->setFilename(newPath); + r->setIsGlobal(true); + r->save(); + r->setFilename(oriPath); + r->setIsGlobal(isStandAlone); } void KisPaletteListWidget::setPaletteGlobal(KoColorSet *colorSet) { if (QPointer(colorSet).isNull()) { return; } KoResourceServer *rserver = KoResourceServerProvider::instance()->paletteServer(); QString saveLocation = rserver->saveLocation(); QString name = colorSet->filename(); QFileInfo fileInfo(saveLocation + name); colorSet->setFilename(fileInfo.filePath()); colorSet->setIsGlobal(true); } void KisPaletteListWidget::setPaletteNonGlobal(KoColorSet *colorSet) { if (QPointer(colorSet).isNull()) { return; } QString filename = newPaletteFileName(); QFile::remove(colorSet->filename()); colorSet->setFilename(filename); colorSet->setIsGlobal(false); } void KisPaletteListWidget::setAllowModification(bool allowModification) { m_d->allowModification = allowModification; + m_ui->bnImport->setEnabled(allowModification); + m_ui->bnExport->setEnabled(allowModification); } QString KisPaletteListWidget::newPaletteFileName() { KoColorSet tmpColorSet; QString result = "new_palette_"; QSet nameSet; QList rlist = m_d->rAdapter->resources(); for (const KoResource *r : rlist) { nameSet.insert(r->filename()); } int i = 0; while (nameSet.contains(result + QString::number(i) + tmpColorSet.defaultFileExtension())) { i++; } result = result + QString::number(i) + tmpColorSet.defaultFileExtension(); return result; } /************************* KisPaletteListWidgetPrivate **********************/ KisPaletteListWidgetPrivate::KisPaletteListWidgetPrivate(KisPaletteListWidget *a_c) : c(a_c) , rAdapter(new KoResourceServerAdapter(KoResourceServerProvider::instance()->paletteServer())) , itemChooser(new KoResourceItemChooser(rAdapter, a_c)) , model(new Model(rAdapter, a_c)) , delegate(new Delegate(a_c)) { } KisPaletteListWidgetPrivate::~KisPaletteListWidgetPrivate() { } /******************* KisPaletteListWidgetPrivate::Delegate ******************/ KisPaletteListWidgetPrivate::Delegate::Delegate(QObject *parent) : QAbstractItemDelegate(parent) { } KisPaletteListWidgetPrivate::Delegate::~Delegate() { } void KisPaletteListWidgetPrivate::Delegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { painter->save(); if (!index.isValid()) return; KoResource* resource = static_cast(index.internalPointer()); KoColorSet* colorSet = static_cast(resource); QRect previewRect(option.rect.x() + 2, option.rect.y() + 2, option.rect.height() - 4, option.rect.height() - 4); painter->drawImage(previewRect, colorSet->image()); if (option.state & QStyle::State_Selected) { painter->fillRect(option.rect, option.palette.highlight()); painter->drawImage(previewRect, colorSet->image()); painter->setPen(option.palette.highlightedText().color()); } else { painter->setBrush(option.palette.text().color()); } painter->drawText(option.rect.x() + previewRect.width() + 10, option.rect.y() + painter->fontMetrics().ascent() + 5, colorSet->name()); painter->restore(); } inline QSize KisPaletteListWidgetPrivate::Delegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex &) const { return option.decorationSize; } diff --git a/plugins/dockers/palettedocker/palettedocker_dock.cpp b/plugins/dockers/palettedocker/palettedocker_dock.cpp index 4018a30419..683af0fcf7 100644 --- a/plugins/dockers/palettedocker/palettedocker_dock.cpp +++ b/plugins/dockers/palettedocker/palettedocker_dock.cpp @@ -1,294 +1,313 @@ /* * 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 #include +#include #include "KisPaletteModel.h" #include "KisPaletteDelegate.h" #include "kis_palette_view.h" #include #include "ui_wdgpalettedock.h" PaletteDockerDock::PaletteDockerDock( ) : QDockWidget(i18n("Palette")) , m_ui(new Ui_WdgPaletteDock()) , m_model(new KisPaletteModel(this)) , m_paletteChooser(new KisPaletteListWidget(this)) , m_view(Q_NULLPTR) , m_resourceProvider(Q_NULLPTR) , m_rAdapter(new KoResourceServerAdapter(KoResourceServerProvider::instance()->paletteServer())) , m_activeDocument(Q_NULLPTR) , m_saver(new PaletteListSaver(this)) , m_actAdd(new QAction(KisIconUtils::loadIcon("list-add"), i18n("Add foreground color"))) , m_actRemove(new QAction(KisIconUtils::loadIcon("edit-delete"), i18n("Delete color"))) , m_actModify(new QAction(KisIconUtils::loadIcon("edit-rename"), i18n("Modify this spot"))) { QWidget *mainWidget = new QWidget(this); setWidget(mainWidget); m_ui->setupUi(mainWidget); m_ui->bnAdd->setDefaultAction(m_actAdd.data()); m_ui->bnRemove->setDefaultAction(m_actRemove.data()); m_ui->bnRename->setDefaultAction(m_actModify.data()); // to make sure their icons have the same size m_ui->bnRemove->setIconSize(QSize(16, 16)); m_ui->bnRename->setIconSize(QSize(16, 16)); m_ui->bnAdd->setIconSize(QSize(16, 16)); // m_wdgPaletteDock->bnAddGroup->setIcon(KisIconUtils::loadIcon("groupLayer")); m_ui->paletteView->setPaletteModel(m_model); m_ui->paletteView->setAllowModification(true); m_ui->cmbNameList->setPaletteModel(m_model); connect(m_actAdd.data(), SIGNAL(triggered()), SLOT(slotAddColor())); connect(m_actRemove.data(), SIGNAL(triggered()), SLOT(slotRemoveColor())); connect(m_actModify.data(), SIGNAL(triggered()), SLOT(slotEditEntry())); connect(m_ui->paletteView, SIGNAL(sigIndexSelected(QModelIndex)), SLOT(slotPaletteIndexSelected(QModelIndex))); connect(m_ui->paletteView, SIGNAL(sigIndexSelected(QModelIndex)), m_ui->cmbNameList, SLOT(slotSwatchSelected(QModelIndex))); connect(m_ui->cmbNameList, SIGNAL(sigColorSelected(KoColor)), SLOT(slotNameListSelection(KoColor))); m_viewContextMenu.addAction(m_actRemove.data()); m_viewContextMenu.addAction(m_actModify.data()); m_paletteChooser->setAllowModification(true); connect(m_paletteChooser, SIGNAL(sigPaletteSelected(KoColorSet*)), SLOT(slotSetColorSet(KoColorSet*))); m_ui->bnColorSets->setIcon(KisIconUtils::loadIcon("hi16-palette_library")); m_ui->bnColorSets->setToolTip(i18n("Choose palette")); m_ui->bnColorSets->setPopupWidget(m_paletteChooser); KisConfig cfg(true); QString defaultPaletteName = cfg.defaultPalette(); KoResourceServer* rServer = KoResourceServerProvider::instance()->paletteServer(); KoColorSet* defaultPalette = rServer->resourceByName(defaultPaletteName); if (defaultPalette) { slotSetColorSet(defaultPalette); } else { m_ui->bnAdd->setEnabled(false); m_ui->bnRename->setEnabled(false); m_ui->bnRemove->setEnabled(false); m_ui->paletteView->setAllowModification(false); } } PaletteDockerDock::~PaletteDockerDock() { } void PaletteDockerDock::setViewManager(KisViewManager* kisview) { m_view = 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_ui->paletteView, SLOT(slotFGColorChanged(KoColor))); connect(m_view->mainWindow(), SIGNAL(sigActiveDocumentChanged()), SLOT(slotViewChanged())); kisview->nodeManager()->disconnect(m_model); } void PaletteDockerDock::setCanvas(KoCanvasBase *canvas) { setEnabled(canvas != 0); if (canvas) { KisCanvas2 *cv = qobject_cast(canvas); m_ui->paletteView->setDisplayRenderer(cv->displayColorConverter()->displayRendererInterface()); } } void PaletteDockerDock::unsetCanvas() { setEnabled(false); m_ui->paletteView->setDisplayRenderer(Q_NULLPTR); } void PaletteDockerDock::slotSetColorSet(KoColorSet* colorSet) { if (colorSet && colorSet->isEditable()) { m_ui->bnAdd->setEnabled(true); m_ui->bnRename->setEnabled(true); m_ui->bnRemove->setEnabled(true); m_ui->paletteView->setAllowModification(true); } else { m_ui->bnAdd->setEnabled(false); m_ui->bnRename->setEnabled(false); m_ui->bnRemove->setEnabled(false); m_ui->paletteView->setAllowModification(false); } m_currentColorSet = colorSet; m_model->setColorSet(colorSet); if (colorSet) { KisConfig cfg(true); cfg.setDefaultPalette(colorSet->name()); m_ui->bnColorSets->setText(colorSet->name()); + } else { + m_ui->bnColorSets->setText(""); } } void PaletteDockerDock::slotViewChanged() { - if (m_view && m_view->document()) { - if (m_activeDocument) { - for (KoColorSet * &cs : m_activeDocument->paletteList()) { - KoColorSet *tmpAddr = cs; - cs = new KoColorSet(*cs); - m_rAdapter->removeResource(tmpAddr); + // for some reason rAdapter's resources gives only an empty list + KoResourceServer* rServer = KoResourceServerProvider::instance()->paletteServer(); + if (m_activeDocument) { + for (KoColorSet * &cs : m_activeDocument->paletteList()) { + KoColorSet *tmpAddr = cs; + cs = new KoColorSet(*cs); + m_rAdapter->removeResource(tmpAddr); + } + m_activaDocObjName = QString(); + } else { // all files was closed + for (KoResource *r : rServer->resources()) { + KoColorSet *g = static_cast(r); + if (!g->isGlobal()) { + m_rAdapter->removeResource(r); } } - + } + if (m_view && m_view->document()) { m_activeDocument = m_view->document(); + m_activaDocObjName = m_activeDocument->objectName(); for (KoColorSet *cs : m_activeDocument->paletteList()) { m_rAdapter->addResource(cs); } } - if (!m_currentColorSet || !m_currentColorSet->isGlobal()) { + if (!m_currentColorSet || (m_currentColorSet && !m_currentColorSet->isGlobal())) { slotSetColorSet(Q_NULLPTR); } } +void PaletteDockerDock::slotDocRemoved(const QString &objName) +{ + qDebug() << objName << "is removed"; +} + + void PaletteDockerDock::slotAddColor() { if (m_currentColorSet->isEditable()) { if (m_resourceProvider) { m_ui->paletteView->addEntryWithDialog(m_resourceProvider->fgColor()); } } } void PaletteDockerDock::slotRemoveColor() { if (m_currentColorSet->isEditable()) { QModelIndex index = m_ui->paletteView->currentIndex(); if (!index.isValid()) { return; } m_ui->paletteView->removeEntryWithDialog(index); m_ui->bnRemove->setEnabled(false); } } void PaletteDockerDock::setFGColorByPalette(const KisSwatch &entry) { if (m_resourceProvider) { m_resourceProvider->setFGColor(entry.color()); } } void PaletteDockerDock::saveToWorkspace(KisWorkspaceResource* workspace) { if (!m_currentColorSet.isNull()) { 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::slotPaletteIndexSelected(const QModelIndex &index) { bool slotEmpty = !(qvariant_cast(index.data(KisPaletteModel::CheckSlotRole))); if (slotEmpty) { if (!m_currentColorSet->isEditable()) { return; } setEntryByForeground(index); } else { m_ui->bnRemove->setEnabled(true); KisSwatch entry = m_model->getEntry(index); setFGColorByPalette(entry); } } void PaletteDockerDock::setEntryByForeground(const QModelIndex &index) { m_model->setEntry(KisSwatch(m_resourceProvider->fgColor()), index); if (m_currentColorSet->isEditable()) { m_ui->bnRemove->setEnabled(true); } } void PaletteDockerDock::slotEditEntry() { if (m_currentColorSet->isEditable()) { QModelIndex index = m_ui->paletteView->currentIndex(); if (!index.isValid()) { return; } m_ui->paletteView->modifyEntry(index); } } void PaletteDockerDock::slotImportPalette() { KoFileDialog dialog(this, KoFileDialog::OpenFile, "OpenColorSet"); dialog.setDefaultDir(m_currentColorSet->filename()); dialog.setMimeTypeFilters(QStringList() << "application/x-gimp-color-palette"); QString fileName = dialog.filename(); KoColorSet *colorSet = new KoColorSet(fileName); colorSet->load(); } void PaletteDockerDock::slotNameListSelection(const KoColor &color) { m_resourceProvider->setFGColor(color); } diff --git a/plugins/dockers/palettedocker/palettedocker_dock.h b/plugins/dockers/palettedocker/palettedocker_dock.h index 88657ca3af..115037b3fc 100644 --- a/plugins/dockers/palettedocker/palettedocker_dock.h +++ b/plugins/dockers/palettedocker/palettedocker_dock.h @@ -1,114 +1,116 @@ /* * 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. */ #ifndef PALETTEDOCKER_DOCK_H #define PALETTEDOCKER_DOCK_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "PaletteListSaver.h" class KisViewManager; class KisCanvasResourceProvider; class KisWorkspaceResource; class KisPaletteListWidget; class KisPaletteModel; class Ui_WdgPaletteDock; class PaletteDockerDock : public QDockWidget, public KisMainwindowObserver { Q_OBJECT public: PaletteDockerDock(); ~PaletteDockerDock() override; public: // QDockWidget void setCanvas(KoCanvasBase *canvas) override; void unsetCanvas() override; public: // KisMainWindowObserver void setViewManager(KisViewManager* kisview) override; private Q_SLOTS: void slotImportPalette(); void slotAddColor(); void slotRemoveColor(); void slotEditEntry(); void slotPaletteIndexSelected(const QModelIndex &index); void slotNameListSelection(const KoColor &color); void slotSetColorSet(KoColorSet* colorSet); void slotViewChanged(); + void slotDocRemoved(const QString &objName); void saveToWorkspace(KisWorkspaceResource* workspace); void loadFromWorkspace(KisWorkspaceResource* workspace); private: void setEntryByForeground(const QModelIndex &index); void setFGColorByPalette(const KisSwatch &entry); private /* friends */: /** * @brief PaletteListSaver * saves non-global palette list to KisDocument. * Actually, this should be implemented in * KisPaletteListWidget, but that class is in the * library kritawidgets, while KisDocument is in * kritaui, which depends on kritawidgets... * * Hope one day kritaui can finally be cleaned up... */ friend class PaletteListSaver; private /* member variables */: QScopedPointer m_ui; KisPaletteModel *m_model; KisPaletteListWidget *m_paletteChooser; - KisViewManager *m_view; + QPointer m_view; KisCanvasResourceProvider *m_resourceProvider; QScopedPointer > m_rAdapter; - KisDocument *m_activeDocument; + QPointer m_activeDocument; + QString m_activaDocObjName; QPointer m_currentColorSet; QScopedPointer m_saver; QScopedPointer m_actAdd; QScopedPointer m_actRemove; QScopedPointer m_actModify; QMenu m_viewContextMenu; }; #endif