57 : QDockWidget(i18n(
"Palette"))
58 , m_ui(new Ui_WdgPaletteDock())
62 , m_resourceProvider(0)
66 , m_actAdd(new QAction(
KisIconUtils::loadIcon(
"list-add"), i18n(
"Add a new color swatch")))
67 , m_actRemove(new QAction(
KisIconUtils::loadIcon(
"edit-delete"), i18n(
"Remove swatch or group")))
68 , m_actModify(new QAction(
KisIconUtils::loadIcon(
"document-edit"), i18n(
"Edit swatch or group")))
69 , m_actEditPalette(new QAction(
KisIconUtils::loadIcon(
"palette-edit"), i18n(
"Edit current palette")))
70 , m_actSavePalette(new QAction(
KisIconUtils::loadIcon(
"document-save-16"), i18n(
"Save current palette")))
71 , m_colorSelfUpdate(false)
73 QWidget *mainWidget =
new QWidget(
this);
74 setWidget(mainWidget);
75 m_ui->setupUi(mainWidget);
79 m_ui->bnAdd->setDefaultAction(
m_actAdd.data());
80 m_ui->bnRemove->setDefaultAction(
m_actRemove.data());
81 m_ui->bnRename->setDefaultAction(
m_actModify.data());
86 m_ui->bnRemove->setIconSize(QSize(16, 16));
87 m_ui->bnRename->setIconSize(QSize(16, 16));
88 m_ui->bnAdd->setIconSize(QSize(16, 16));
89 m_ui->bnEditPalette->setIconSize(QSize(16, 16));
90 m_ui->bnSavePalette->setIconSize(QSize(16, 16));
93 m_ui->paletteView->setPaletteModel(
m_model);
94 m_ui->paletteView->setAllowModification(
true);
95 m_ui->cmbNameList->setCompanionView(m_ui->paletteView);
106 connect(m_ui->paletteView, SIGNAL(doubleClicked(QModelIndex)),
123 m_ui->bnColorSets->setToolTip(i18n(
"Load a palette"));
129 if (defaultPalette) {
133 m_ui->bnAdd->setEnabled(
false);
134 m_ui->bnUndo->setEnabled(
false);
135 m_ui->bnRedo->setEnabled(
false);
136 m_ui->bnRename->setEnabled(
false);
137 m_ui->bnRemove->setEnabled(
false);
138 m_ui->bnEditPalette->setEnabled(
false);
139 m_ui->bnSavePalette->setEnabled(
false);
140 m_ui->bnLock->setEnabled(
false);
142 m_ui->paletteView->setAllowModification(
false);
292 m_ui->bnUndo->setEnabled(colorSet->undoStack()->canUndo() && !colorSet->isLocked());
293 connect(colorSet->undoStack(), SIGNAL(canUndoChanged(
bool)), m_ui->bnUndo, SLOT(setEnabled(
bool)));
294 connect(colorSet->undoStack(), SIGNAL(undoTextChanged(QString)),
this, SLOT(
setUndoToolTip(QString)));
296 m_ui->bnRedo->setEnabled(colorSet->undoStack()->canRedo() && colorSet->isLocked());
297 connect(colorSet->undoStack(), SIGNAL(canRedoChanged(
bool)), m_ui->bnRedo, SLOT(setEnabled(
bool)));
298 connect(colorSet->undoStack(), SIGNAL(redoTextChanged(QString)),
this, SLOT(
setRedoToolTip(QString)));
300 connect(m_ui->bnUndo, SIGNAL(clicked()),
this, SLOT(
undo()));
301 connect(m_ui->bnRedo, SIGNAL(clicked()),
this, SLOT(
redo()));
303 m_ui->bnLock->setChecked(colorSet->isLocked());
305 bool state = (bool)colorSet;
307 m_ui->bnAdd->setEnabled(state);
308 m_ui->bnRename->setEnabled(state);
309 m_ui->bnRemove->setEnabled(state);
310 m_ui->bnEditPalette->setEnabled(state);
311 m_ui->bnSavePalette->setEnabled(state);
312 m_ui->paletteView->setAllowModification(state);
313 m_ui->bnLock->setEnabled(state);
321 m_ui->lblPaletteName->setTextElideMode(Qt::ElideMiddle);
322 m_ui->lblPaletteName->setText(colorSet->name());
325 m_ui->lblPaletteName->setText(
"");
380 m_ui->lblPaletteName->setTextElideMode(Qt::ElideLeft);
383 bool isGlobal =
true;
386 if (index.isValid()) {
397 m_actSavePalette.data()->setToolTip(i18nc(
"@tooltip",
"Save palette explicitly, will also happen automatically on exiting Krita."));
400 m_actSavePalette.data()->setToolTip(i18nc(
"@tooltip",
"Saving for document palettes is done by saving the document."));
406 QFont font = m_ui->lblPaletteName->font();
407 font.setItalic(
true);
408 m_ui->lblPaletteName->setFont(font);
411 QFont font = m_ui->lblPaletteName->font();
412 font.setItalic(
false);
413 m_ui->lblPaletteName->setFont(font);
416 m_ui->lblPaletteName->setText(name);
419 m_ui->lblPaletteName->setText(
"");