Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/kis_palette_view.cpp
Context not available. | |||||
30 | #include <KConfigGroup> | 30 | #include <KConfigGroup> | ||
---|---|---|---|---|---|
31 | #include <KSharedConfig> | 31 | #include <KSharedConfig> | ||
32 | #include <KLocalizedString> | 32 | #include <KLocalizedString> | ||
33 | 33 | #include <kis_icon_utils.h> | |||
34 | #include <KoDialog.h> | 34 | #include <KoDialog.h> | ||
35 | #include <KoColorDisplayRendererInterface.h> | ||||
35 | 36 | | |||
36 | #include "kis_palette_delegate.h" | 37 | #include "KisPaletteDelegate.h" | ||
37 | #include "KisPaletteModel.h" | 38 | #include "KisPaletteModel.h" | ||
38 | #include "kis_color_button.h" | 39 | #include "kis_color_button.h" | ||
40 | #include <KisSwatch.h> | ||||
41 | | ||||
42 | int KisPaletteView::MININUM_ROW_HEIGHT = 10; | ||||
39 | 43 | | |||
40 | struct KisPaletteView::Private | 44 | struct KisPaletteView::Private | ||
41 | { | 45 | { | ||
42 | KisPaletteModel *model = nullptr; | 46 | QPointer<KisPaletteModel> model; | ||
43 | bool allowPaletteModification = true; | 47 | bool allowPaletteModification; // if modification is allowed from this widget | ||
44 | }; | 48 | }; | ||
45 | 49 | | |||
46 | KisPaletteView::KisPaletteView(QWidget *parent) | 50 | KisPaletteView::KisPaletteView(QWidget *parent) | ||
47 | : KoTableView(parent) | 51 | : QTableView(parent) | ||
48 | , m_d(new Private) | 52 | , m_d(new Private) | ||
49 | { | 53 | { | ||
50 | setShowGrid(false); | 54 | m_d->allowPaletteModification = false; | ||
51 | horizontalHeader()->setVisible(false); | | |||
52 | verticalHeader()->setVisible(false); | | |||
53 | setItemDelegate(new KisPaletteDelegate()); | | |||
54 | | ||||
55 | // setDragEnabled(true); | | |||
56 | // setDragDropMode(QAbstractItemView::InternalMove); | | |||
57 | setDropIndicatorShown(true); | | |||
58 | 55 | | |||
59 | KConfigGroup cfg(KSharedConfig::openConfig()->group("")); | 56 | setItemDelegate(new KisPaletteDelegate(this)); | ||
60 | //QPalette pal(palette()); | | |||
61 | //pal.setColor(QPalette::Base, cfg.getMDIBackgroundColor()); | | |||
62 | //setAutoFillBackground(true); | | |||
63 | //setPalette(pal); | | |||
64 | 57 | | |||
65 | int defaultSectionSize = cfg.readEntry("paletteDockerPaletteViewSectionSize", 12); | 58 | setShowGrid(true); | ||
66 | horizontalHeader()->setDefaultSectionSize(defaultSectionSize); | 59 | setDropIndicatorShown(true); | ||
67 | verticalHeader()->setDefaultSectionSize(defaultSectionSize); | 60 | setDragDropMode(QAbstractItemView::InternalMove); | ||
68 | connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(modifyEntry(QModelIndex))); | 61 | setSelectionMode(QAbstractItemView::SingleSelection); | ||
62 | setDragEnabled(false); | ||||
63 | setAcceptDrops(false); | ||||
64 | | ||||
65 | /* | ||||
66 | * without this, a cycle might be created: | ||||
67 | * the view streches to right border, and this make it need a scroll bar; | ||||
68 | * after the bar is added, the view shrinks to the bar, and this makes it | ||||
69 | * no longer need the bar any more, and the bar is removed again | ||||
70 | */ | ||||
71 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | ||||
72 | | ||||
73 | // set the size of swatches | ||||
74 | horizontalHeader()->setVisible(false); | ||||
75 | verticalHeader()->setVisible(false); | ||||
76 | horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | ||||
77 | horizontalHeader()->setMinimumSectionSize(MININUM_ROW_HEIGHT); | ||||
78 | verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); | ||||
79 | verticalHeader()->setMinimumSectionSize(MININUM_ROW_HEIGHT); | ||||
80 | | ||||
81 | connect(horizontalHeader(), SIGNAL(sectionResized(int,int,int)), | ||||
82 | SLOT(slotHorizontalHeaderResized(int,int,int))); | ||||
83 | setAutoFillBackground(true); | ||||
69 | } | 84 | } | ||
70 | 85 | | |||
71 | KisPaletteView::~KisPaletteView() | 86 | KisPaletteView::~KisPaletteView() | ||
Context not available. | |||||
83 | 98 | | |||
84 | bool KisPaletteView::addEntryWithDialog(KoColor color) | 99 | bool KisPaletteView::addEntryWithDialog(KoColor color) | ||
85 | { | 100 | { | ||
86 | KoDialog *window = new KoDialog(this); | 101 | QScopedPointer<KoDialog> window(new KoDialog(this)); | ||
87 | window->setWindowTitle(i18nc("@title:window", "Add a new Colorset Entry")); | 102 | window->setWindowTitle(i18nc("@title:window", "Add a new Colorset Entry")); | ||
88 | QFormLayout *editableItems = new QFormLayout(window); | 103 | QFormLayout *editableItems = new QFormLayout(window.data()); | ||
89 | window->mainWidget()->setLayout(editableItems); | 104 | window->mainWidget()->setLayout(editableItems); | ||
90 | QComboBox *cmbGroups = new QComboBox(window); | 105 | QComboBox *cmbGroups = new QComboBox(window.data()); | ||
91 | QString defaultGroupName = i18nc("Name for default group", "Default"); | 106 | QString defaultGroupName = i18nc("Name for default group", "Default"); | ||
92 | cmbGroups->addItem(defaultGroupName); | 107 | cmbGroups->addItem(defaultGroupName); | ||
93 | cmbGroups->addItems(m_d->model->colorSet()->getGroupNames()); | 108 | cmbGroups->addItems(m_d->model->colorSet()->getGroupNames()); | ||
94 | QLineEdit *lnIDName = new QLineEdit(window); | 109 | QLineEdit *lnIDName = new QLineEdit(window.data()); | ||
95 | QLineEdit *lnName = new QLineEdit(window); | 110 | QLineEdit *lnName = new QLineEdit(window.data()); | ||
96 | KisColorButton *bnColor = new KisColorButton(window); | 111 | KisColorButton *bnColor = new KisColorButton(window.data()); | ||
97 | QCheckBox *chkSpot = new QCheckBox(window); | 112 | QCheckBox *chkSpot = new QCheckBox(window.data()); | ||
98 | chkSpot->setToolTip(i18nc("@info:tooltip", "A spot color is a color that the printer is able to print without mixing the paints it has available to it. The opposite is called a process color.")); | 113 | chkSpot->setToolTip(i18nc("@info:tooltip", "A spot color is a color that the printer is able to print without mixing the paints it has available to it. The opposite is called a process color.")); | ||
99 | editableItems->addRow(i18n("Group"), cmbGroups); | 114 | editableItems->addRow(i18n("Group"), cmbGroups); | ||
100 | editableItems->addRow(i18n("ID"), lnIDName); | 115 | editableItems->addRow(i18n("ID"), lnIDName); | ||
Context not available. | |||||
102 | editableItems->addRow(i18n("Color"), bnColor); | 117 | editableItems->addRow(i18n("Color"), bnColor); | ||
103 | editableItems->addRow(i18nc("Spot color", "Spot"), chkSpot); | 118 | editableItems->addRow(i18nc("Spot color", "Spot"), chkSpot); | ||
104 | cmbGroups->setCurrentIndex(0); | 119 | cmbGroups->setCurrentIndex(0); | ||
105 | lnName->setText(i18nc("Part of a default name for a color","Color")+" "+QString::number(m_d->model->colorSet()->nColors()+1)); | 120 | lnName->setText(i18nc("Part of a default name for a color","Color")+" " + QString::number(m_d->model->colorSet()->colorCount()+1)); | ||
106 | lnIDName->setText(QString::number(m_d->model->colorSet()->nColors()+1)); | 121 | lnIDName->setText(QString::number(m_d->model->colorSet()->colorCount() + 1)); | ||
107 | bnColor->setColor(color); | 122 | bnColor->setColor(color); | ||
108 | chkSpot->setChecked(false); | 123 | chkSpot->setChecked(false); | ||
109 | 124 | | |||
Context not available. | |||||
112 | if (groupName == defaultGroupName) { | 127 | if (groupName == defaultGroupName) { | ||
113 | groupName = QString(); | 128 | groupName = QString(); | ||
114 | } | 129 | } | ||
115 | KoColorSetEntry newEntry; | 130 | KisSwatch newEntry; | ||
116 | newEntry.setColor(bnColor->color()); | 131 | newEntry.setColor(bnColor->color()); | ||
117 | newEntry.setName(lnName->text()); | 132 | newEntry.setName(lnName->text()); | ||
118 | newEntry.setId(lnIDName->text()); | 133 | newEntry.setId(lnIDName->text()); | ||
119 | newEntry.setSpotColor(chkSpot->isChecked()); | 134 | newEntry.setSpotColor(chkSpot->isChecked()); | ||
120 | m_d->model->addColorSetEntry(newEntry, groupName); | 135 | m_d->model->addEntry(newEntry, groupName); | ||
121 | m_d->model->colorSet()->save(); | | |||
122 | return true; | 136 | return true; | ||
123 | } | 137 | } | ||
138 | | ||||
124 | return false; | 139 | return false; | ||
125 | } | 140 | } | ||
126 | 141 | | |||
127 | // should be move to colorSetChooser | | |||
128 | bool KisPaletteView::addGroupWithDialog() | 142 | bool KisPaletteView::addGroupWithDialog() | ||
129 | { | 143 | { | ||
130 | KoDialog *window = new KoDialog(); | 144 | KoDialog *window = new KoDialog(); | ||
Context not available. | |||||
135 | editableItems->addRow(i18nc("Name for a group", "Name"), lnName); | 149 | editableItems->addRow(i18nc("Name for a group", "Name"), lnName); | ||
136 | lnName->setText(i18nc("Part of default name for a new group", "Color Group")+""+QString::number(m_d->model->colorSet()->getGroupNames().size()+1)); | 150 | lnName->setText(i18nc("Part of default name for a new group", "Color Group")+""+QString::number(m_d->model->colorSet()->getGroupNames().size()+1)); | ||
137 | if (window->exec() == KoDialog::Accepted) { | 151 | if (window->exec() == KoDialog::Accepted) { | ||
138 | QString groupName = lnName->text(); | 152 | KisSwatchGroup group; | ||
139 | m_d->model->addGroup(groupName); | 153 | group.setName(lnName->text()); | ||
154 | m_d->model->addGroup(group); | ||||
140 | m_d->model->colorSet()->save(); | 155 | m_d->model->colorSet()->save(); | ||
141 | return true; | 156 | return true; | ||
142 | } | 157 | } | ||
Context not available. | |||||
145 | 160 | | |||
146 | bool KisPaletteView::removeEntryWithDialog(QModelIndex index) | 161 | bool KisPaletteView::removeEntryWithDialog(QModelIndex index) | ||
147 | { | 162 | { | ||
148 | bool keepColors = true; | 163 | bool keepColors = false; | ||
149 | if (qvariant_cast<bool>(index.data(KisPaletteModel::IsHeaderRole))) { | 164 | if (qvariant_cast<bool>(index.data(KisPaletteModel::IsGroupNameRole))) { | ||
150 | KoDialog *window = new KoDialog(); | 165 | QScopedPointer<KoDialog> window(new KoDialog(this)); | ||
151 | window->setWindowTitle(i18nc("@title:window","Removing Group")); | 166 | window->setWindowTitle(i18nc("@title:window","Removing Group")); | ||
152 | QFormLayout *editableItems = new QFormLayout(); | 167 | QFormLayout *editableItems = new QFormLayout(window.data()); | ||
153 | QCheckBox *chkKeep = new QCheckBox(); | 168 | QCheckBox *chkKeep = new QCheckBox(window.data()); | ||
154 | window->mainWidget()->setLayout(editableItems); | 169 | window->mainWidget()->setLayout(editableItems); | ||
155 | editableItems->addRow(i18nc("Shows up when deleting a group","Keep the Colors"), chkKeep); | 170 | editableItems->addRow(i18nc("Shows up when deleting a swatch group", "Keep the Colors"), chkKeep); | ||
156 | chkKeep->setChecked(keepColors); | 171 | if (window->exec() != KoDialog::Accepted) { return false; } | ||
157 | if (window->exec() == KoDialog::Accepted) { | 172 | keepColors = chkKeep->isChecked(); | ||
158 | keepColors = chkKeep->isChecked(); | 173 | } | ||
159 | m_d->model->removeEntry(index, keepColors); | 174 | m_d->model->removeEntry(index, keepColors); | ||
160 | m_d->model->colorSet()->save(); | 175 | if (m_d->model->colorSet()->isGlobal()) { | ||
161 | } | | |||
162 | } else { | | |||
163 | m_d->model->removeEntry(index, keepColors); | | |||
164 | m_d->model->colorSet()->save(); | 176 | m_d->model->colorSet()->save(); | ||
165 | } | 177 | } | ||
166 | return true; | 178 | return true; | ||
167 | } | 179 | } | ||
168 | 180 | | |||
169 | void KisPaletteView::trySelectClosestColor(KoColor color) | 181 | void KisPaletteView::selectClosestColor(const KoColor &color) | ||
170 | { | 182 | { | ||
171 | KoColorSet* color_set = m_d->model->colorSet(); | 183 | KoColorSet* color_set = m_d->model->colorSet(); | ||
172 | if (!color_set) | 184 | if (!color_set) { | ||
173 | return; | 185 | return; | ||
186 | } | ||||
174 | //also don't select if the color is the same as the current selection | 187 | //also don't select if the color is the same as the current selection | ||
175 | if (selectedIndexes().size()>0) { | 188 | if (m_d->model->getEntry(currentIndex()).color() == color) { | ||
176 | QModelIndex currentI = currentIndex(); | 189 | return; | ||
177 | if (!currentI.isValid()) { | | |||
178 | currentI = selectedIndexes().last(); | | |||
179 | } | | |||
180 | if (!currentI.isValid()) { | | |||
181 | currentI = selectedIndexes().first(); | | |||
182 | } | | |||
183 | if (currentI.isValid()) { | | |||
184 | if (m_d->model->colorSetEntryFromIndex(currentI).color()==color) { | | |||
185 | return; | | |||
186 | } | | |||
187 | } | | |||
188 | } | 190 | } | ||
189 | quint32 i = color_set->getIndexClosestColor(color); | | |||
190 | QModelIndex index = m_d->model->indexFromId(i); | | |||
191 | this->selectionModel()->clearSelection(); | | |||
192 | this->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select); | | |||
193 | } | | |||
194 | 191 | | |||
195 | void KisPaletteView::mouseReleaseEvent(QMouseEvent *event) | 192 | selectionModel()->clearSelection(); | ||
196 | { | 193 | QModelIndex index = m_d->model->indexForClosest(color); | ||
197 | bool foreground = false; | 194 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select); | ||
198 | if (event->button()== Qt::LeftButton) { | | |||
199 | foreground = true; | | |||
200 | } | | |||
201 | entrySelection(foreground); | | |||
202 | } | 195 | } | ||
203 | 196 | | |||
204 | void KisPaletteView::paletteModelChanged() | 197 | void KisPaletteView::slotFGColorChanged(const KoColor &color) | ||
205 | { | 198 | { | ||
206 | updateView(); | 199 | selectClosestColor(color); | ||
207 | updateRows(); | | |||
208 | } | 200 | } | ||
209 | 201 | | |||
210 | void KisPaletteView::setPaletteModel(KisPaletteModel *model) | 202 | void KisPaletteView::setPaletteModel(KisPaletteModel *model) | ||
211 | { | 203 | { | ||
212 | if (m_d->model) { | 204 | if (m_d->model) { | ||
213 | disconnect(m_d->model, 0, this, 0); | 205 | disconnect(m_d->model, Q_NULLPTR, this, Q_NULLPTR); | ||
214 | } | 206 | } | ||
215 | m_d->model = model; | 207 | m_d->model = model; | ||
216 | setModel(model); | 208 | setModel(model); | ||
217 | paletteModelChanged(); | 209 | slotAdditionalGuiUpdate(); | ||
218 | connect(m_d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), this, SLOT(paletteModelChanged())); | 210 | connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), | ||
219 | connect(m_d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(paletteModelChanged())); | 211 | SLOT(slotAdditionalGuiUpdate())); | ||
220 | connect(m_d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(paletteModelChanged())); | 212 | connect(model, SIGNAL(modelReset()), | ||
221 | connect(m_d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(paletteModelChanged())); | 213 | SLOT(slotAdditionalGuiUpdate())); | ||
222 | connect(m_d->model, SIGNAL(modelReset()), this, SLOT(paletteModelChanged())); | 214 | | ||
223 | 215 | connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), | |||
216 | SLOT(slotCurrentSelectionChanged(QModelIndex))); | ||||
224 | } | 217 | } | ||
225 | 218 | | |||
226 | KisPaletteModel* KisPaletteView::paletteModel() const | 219 | KisPaletteModel* KisPaletteView::paletteModel() const | ||
Context not available. | |||||
228 | return m_d->model; | 221 | return m_d->model; | ||
229 | } | 222 | } | ||
230 | 223 | | |||
231 | void KisPaletteView::updateRows() | | |||
232 | { | | |||
233 | this->clearSpans(); | | |||
234 | if (m_d->model) { | | |||
235 | for (int r=0; r<=m_d->model->rowCount(); r++) { | | |||
236 | QModelIndex index = m_d->model->index(r, 0); | | |||
237 | if (qvariant_cast<bool>(index.data(KisPaletteModel::IsHeaderRole))) { | | |||
238 | setSpan(r, 0, 1, m_d->model->columnCount()); | | |||
239 | setRowHeight(r, this->fontMetrics().lineSpacing()+6); | | |||
240 | } else { | | |||
241 | this->setRowHeight(r, this->columnWidth(0)); | | |||
242 | } | | |||
243 | } | | |||
244 | } | | |||
245 | } | | |||
246 | | ||||
247 | void KisPaletteView::setAllowModification(bool allow) | 224 | void KisPaletteView::setAllowModification(bool allow) | ||
248 | { | 225 | { | ||
249 | m_d->allowPaletteModification = allow; | 226 | m_d->allowPaletteModification = allow; | ||
227 | setDragEnabled(allow); | ||||
228 | setAcceptDrops(allow); | ||||
250 | } | 229 | } | ||
251 | 230 | | |||
231 | void KisPaletteView::slotHorizontalHeaderResized(int, int, int newSize) | ||||
232 | { | ||||
233 | resizeRows(newSize); | ||||
234 | slotAdditionalGuiUpdate(); | ||||
235 | } | ||||
252 | 236 | | |||
253 | void KisPaletteView::wheelEvent(QWheelEvent *event) | 237 | void KisPaletteView::resizeRows(int newSize) | ||
254 | { | 238 | { | ||
255 | if (event->modifiers() & Qt::ControlModifier) { | 239 | verticalHeader()->setDefaultSectionSize(newSize); | ||
256 | int numDegrees = event->delta() / 8; | 240 | verticalHeader()->resizeSections(QHeaderView::Fixed); | ||
257 | int numSteps = numDegrees / 7; | | |||
258 | int curSize = horizontalHeader()->sectionSize(0); | | |||
259 | int setSize = numSteps + curSize; | | |||
260 | | ||||
261 | if ( (event->delta() <= 0) && (setSize <= 8) ) { | | |||
262 | // Ignore scroll-zooming down below a certain size | | |||
263 | } else { | | |||
264 | horizontalHeader()->setDefaultSectionSize(setSize); | | |||
265 | verticalHeader()->setDefaultSectionSize(setSize); | | |||
266 | KConfigGroup cfg(KSharedConfig::openConfig()->group("")); | | |||
267 | cfg.writeEntry("paletteDockerPaletteViewSectionSize", setSize); | | |||
268 | } | | |||
269 | | ||||
270 | event->accept(); | | |||
271 | } else { | | |||
272 | KoTableView::wheelEvent(event); | | |||
273 | } | | |||
274 | } | 241 | } | ||
275 | 242 | | |||
276 | void KisPaletteView::entrySelection(bool foreground) { | 243 | void KisPaletteView::removeSelectedEntry() | ||
277 | QModelIndex index; | 244 | { | ||
278 | if (selectedIndexes().size()<=0) { | 245 | if (selectedIndexes().size() <= 0) { | ||
279 | return; | | |||
280 | } | | |||
281 | if (selectedIndexes().last().isValid()) { | | |||
282 | index = selectedIndexes().last(); | | |||
283 | } else if (selectedIndexes().first().isValid()) { | | |||
284 | index = selectedIndexes().first(); | | |||
285 | } else { | | |||
286 | return; | 246 | return; | ||
287 | } | 247 | } | ||
288 | if (qvariant_cast<bool>(index.data(KisPaletteModel::IsHeaderRole))==false) { | 248 | m_d->model->removeEntry(currentIndex()); | ||
289 | KoColorSetEntry entry = m_d->model->colorSetEntryFromIndex(index); | 249 | } | ||
290 | if (foreground) { | 250 | | ||
291 | emit(entrySelected(entry)); | 251 | void KisPaletteView::slotAdditionalGuiUpdate() | ||
292 | emit(indexEntrySelected(index)); | 252 | { | ||
293 | } else { | 253 | clearSpans(); | ||
294 | emit(entrySelectedBackGround(entry)); | 254 | resizeRows(verticalHeader()->defaultSectionSize()); | ||
295 | emit(indexEntrySelected(index)); | 255 | for (int groupNameRowNumber : m_d->model->m_groupNameRows.keys()) { | ||
296 | } | 256 | if (groupNameRowNumber == -1) { continue; } | ||
257 | setSpan(groupNameRowNumber, 0, 1, m_d->model->columnCount()); | ||||
258 | setRowHeight(groupNameRowNumber, fontMetrics().lineSpacing() + 6); | ||||
259 | verticalHeader()->resizeSection(groupNameRowNumber, fontMetrics().lineSpacing() + 6); | ||||
297 | } | 260 | } | ||
298 | } | 261 | } | ||
299 | 262 | | |||
300 | void KisPaletteView::modifyEntry(QModelIndex index) { | 263 | void KisPaletteView::slotCurrentSelectionChanged(const QModelIndex &newCurrent) | ||
301 | if (m_d->allowPaletteModification) { | 264 | { | ||
302 | KoDialog *group = new KoDialog(this); | 265 | if (!newCurrent.isValid()) { return; } | ||
303 | QFormLayout *editableItems = new QFormLayout(group); | 266 | | ||
304 | group->mainWidget()->setLayout(editableItems); | 267 | if (qvariant_cast<bool>(newCurrent.data(KisPaletteModel::IsGroupNameRole)) == false) { | ||
305 | QLineEdit *lnIDName = new QLineEdit(group); | 268 | emit sigIndexSelected(newCurrent); | ||
306 | QLineEdit *lnGroupName = new QLineEdit(group); | 269 | KisSwatch entry = m_d->model->getEntry(newCurrent); | ||
307 | KisColorButton *bnColor = new KisColorButton(group); | 270 | emit sigColorSelected(entry.color()); | ||
308 | QCheckBox *chkSpot = new QCheckBox(group); | | |||
309 | | ||||
310 | if (qvariant_cast<bool>(index.data(KisPaletteModel::IsHeaderRole))) { | | |||
311 | QString groupName = qvariant_cast<QString>(index.data(Qt::DisplayRole)); | | |||
312 | editableItems->addRow(i18nc("Name for a colorgroup","Name"), lnGroupName); | | |||
313 | lnGroupName->setText(groupName); | | |||
314 | if (group->exec() == KoDialog::Accepted) { | | |||
315 | m_d->model->colorSet()->changeGroupName(groupName, lnGroupName->text()); | | |||
316 | m_d->model->colorSet()->save(); | | |||
317 | updateRows(); | | |||
318 | } | | |||
319 | //rename the group. | | |||
320 | } else { | | |||
321 | KoColorSetEntry entry = m_d->model->colorSetEntryFromIndex(index); | | |||
322 | QStringList entryList = qvariant_cast<QStringList>(index.data(KisPaletteModel::RetrieveEntryRole)); | | |||
323 | chkSpot->setToolTip(i18nc("@info:tooltip", "A spot color is a color that the printer is able to print without mixing the paints it has available to it. The opposite is called a process color.")); | | |||
324 | editableItems->addRow(i18n("ID"), lnIDName); | | |||
325 | editableItems->addRow(i18n("Name"), lnGroupName); | | |||
326 | editableItems->addRow(i18n("Color"), bnColor); | | |||
327 | editableItems->addRow(i18n("Spot"), chkSpot); | | |||
328 | lnGroupName->setText(entry.name()); | | |||
329 | lnIDName->setText(entry.id()); | | |||
330 | bnColor->setColor(entry.color()); | | |||
331 | chkSpot->setChecked(entry.spotColor()); | | |||
332 | if (group->exec() == KoDialog::Accepted) { | | |||
333 | entry.setName(lnGroupName->text()); | | |||
334 | entry.setId(lnIDName->text()); | | |||
335 | entry.setColor(bnColor->color()); | | |||
336 | entry.setSpotColor(chkSpot->isChecked()); | | |||
337 | m_d->model->colorSet()->changeColorSetEntry(entry, entryList.at(0), entryList.at(1).toUInt()); | | |||
338 | m_d->model->colorSet()->save(); | | |||
339 | } | | |||
340 | } | | |||
341 | } | 271 | } | ||
342 | } | 272 | } | ||
273 | | ||||
274 | void KisPaletteView::setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer) | ||||
275 | { | ||||
276 | Q_ASSERT(m_d->model); | ||||
277 | m_d->model->setDisplayRenderer(displayRenderer); | ||||
278 | } | ||||
Context not available. |