1 | /* KDE Display color scheme setup module |
2 | * Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> |
3 | * Copyright (C) 2007 Jeremy Whiting <jpwhiting@kde.org> |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; see the file COPYING. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "colorscm.h" |
22 | |
23 | #include "../krdb/krdb.h" |
24 | |
25 | #include <QtCore/QFileInfo> |
26 | #include <QtCore/QTimer> |
27 | #include <QtGui/QHeaderView> |
28 | #include <QtGui/QStackedWidget> |
29 | #include <QtGui/QPainter> |
30 | #include <QtGui/QBitmap> |
31 | #include <QtDBus/QtDBus> |
32 | |
33 | #include <KAboutData> |
34 | #include <KColorButton> |
35 | #include <KColorDialog> |
36 | #include <KDebug> |
37 | #include <KFileDialog> |
38 | #include <KGlobal> |
39 | #include <KGlobalSettings> |
40 | #include <KColorUtils> |
41 | #include <KInputDialog> |
42 | #include <KMessageBox> |
43 | #include <KPluginFactory> |
44 | #include <KStandardDirs> |
45 | #include <kio/netaccess.h> |
46 | #include <knewstuff3/downloaddialog.h> |
47 | #include <knewstuff3/uploaddialog.h> |
48 | |
49 | K_PLUGIN_FACTORY( KolorFactory, registerPlugin<KColorCm>(); ) |
50 | K_EXPORT_PLUGIN( KolorFactory("kcmcolors" ) ) |
51 | |
52 | //BEGIN WindecoColors |
53 | KColorCm::WindecoColors::WindecoColors(const KSharedConfigPtr &config) |
54 | { |
55 | load(config); |
56 | } |
57 | |
58 | void KColorCm::WindecoColors::load(const KSharedConfigPtr &config) |
59 | { |
60 | // NOTE: keep this in sync with kdelibs/kdeui/kernel/kglobalsettings.cpp |
61 | KConfigGroup group(config, "WM" ); |
62 | m_colors[ActiveBackground] = group.readEntry("activeBackground" , QColor(48, 174, 232)); |
63 | m_colors[ActiveForeground] = group.readEntry("activeForeground" , QColor(255, 255, 255)); |
64 | m_colors[InactiveBackground] = group.readEntry("inactiveBackground" , QColor(224, 223, 222)); |
65 | m_colors[InactiveForeground] = group.readEntry("inactiveForeground" , QColor(75, 71, 67)); |
66 | m_colors[ActiveBlend] = group.readEntry("activeBlend" , m_colors[ActiveForeground]); |
67 | m_colors[InactiveBlend] = group.readEntry("inactiveBlend" , m_colors[InactiveForeground]); |
68 | } |
69 | |
70 | QColor KColorCm::WindecoColors::color(WindecoColors::Role role) const |
71 | { |
72 | return m_colors[role]; |
73 | } |
74 | //END WindecoColors |
75 | |
76 | KColorCm::KColorCm(QWidget *parent, const QVariantList &) |
77 | : KCModule( KolorFactory::componentData(), parent ), m_disableUpdates(false), |
78 | m_loadedSchemeHasUnsavedChanges(false), m_dontLoadSelectedScheme(false), |
79 | m_previousSchemeItem(0) |
80 | { |
81 | KAboutData* about = new KAboutData( |
82 | "kcmcolors" , 0, ki18n("Colors" ), 0, KLocalizedString(), |
83 | KAboutData::License_GPL, |
84 | ki18n("(c) 2007 Matthew Woehlke" ) |
85 | ); |
86 | about->addAuthor( ki18n("Matthew Woehlke" ), KLocalizedString(), |
87 | "mw_triad@users.sourceforge.net" ); |
88 | about->addAuthor( ki18n("Jeremy Whiting" ), KLocalizedString(), "jpwhiting@kde.org" ); |
89 | setAboutData( about ); |
90 | |
91 | m_config = KSharedConfig::openConfig("kdeglobals" ); |
92 | |
93 | setupUi(this); |
94 | schemeKnsButton->setIcon( KIcon("get-hot-new-stuff" ) ); |
95 | schemeKnsUploadButton->setIcon( KIcon("get-hot-new-stuff" ) ); |
96 | connect(colorSet, SIGNAL(currentIndexChanged(int)), this, SLOT(updateColorTable())); |
97 | connect(schemeList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), |
98 | this, SLOT(loadScheme(QListWidgetItem*,QListWidgetItem*))); |
99 | connect(applyToAlien, SIGNAL(toggled(bool)), this, SLOT(emitChanged())); |
100 | |
101 | // only needs to be called once |
102 | setupColorTable(); |
103 | } |
104 | |
105 | KColorCm::~KColorCm() |
106 | { |
107 | m_config->markAsClean(); |
108 | } |
109 | |
110 | void KColorCm::populateSchemeList() |
111 | { |
112 | // clear the list in case this is being called from reset button click |
113 | schemeList->clear(); |
114 | |
115 | // add entries |
116 | QIcon icon; |
117 | const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data" , "color-schemes/*.colors" , KStandardDirs::NoDuplicates); |
118 | for (int i = 0; i < schemeFiles.size(); ++i) |
119 | { |
120 | // get the file name |
121 | const QString filename = schemeFiles.at(i); |
122 | const QFileInfo info(filename); |
123 | |
124 | // add the entry |
125 | KSharedConfigPtr config = KSharedConfig::openConfig(filename); |
126 | icon = createSchemePreviewIcon(config); |
127 | KConfigGroup group(config, "General" ); |
128 | const QString name = group.readEntry("Name" , info.baseName()); |
129 | QListWidgetItem * newItem = new QListWidgetItem(icon, name); |
130 | // stash the file basename for use later |
131 | newItem->setData(Qt::UserRole, info.baseName()); |
132 | schemeList->addItem(newItem); |
133 | } |
134 | schemeList->sortItems(); |
135 | |
136 | // add default entry (do this here so that the current and default entry appear at the top) |
137 | m_config->setReadDefaults(true); |
138 | icon = createSchemePreviewIcon(m_config); |
139 | schemeList->insertItem(0, new QListWidgetItem(icon, i18nc("Default color scheme" , "Default" ))); |
140 | m_config->setReadDefaults(false); |
141 | |
142 | // add current scheme entry |
143 | icon = createSchemePreviewIcon(m_config); |
144 | QListWidgetItem *currentitem = new QListWidgetItem(icon, i18nc("Current color scheme" , "Current" )); |
145 | schemeList->insertItem(0, currentitem); |
146 | schemeList->blockSignals(true); // don't emit changed signals |
147 | schemeList->setCurrentItem(currentitem); |
148 | schemeList->blockSignals(false); |
149 | } |
150 | |
151 | void KColorCm::updatePreviews() |
152 | { |
153 | schemePreview->setPalette(m_config); |
154 | colorPreview->setPalette(m_config); |
155 | setPreview->setPalette(m_config, (KColorScheme::ColorSet)(colorSet->currentIndex() - 1)); |
156 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
157 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
158 | } |
159 | |
160 | void KColorCm::updateEffectsPage() |
161 | { |
162 | m_disableUpdates = true; |
163 | |
164 | // NOTE: keep this in sync with kdelibs/kdeui/colors/kcolorscheme.cpp |
165 | KConfigGroup groupI(m_config, "ColorEffects:Inactive" ); |
166 | inactiveIntensityBox->setCurrentIndex(abs(groupI.readEntry("IntensityEffect" , 0))); |
167 | inactiveIntensitySlider->setValue(int(groupI.readEntry("IntensityAmount" , 0.0) * 20.0) + 20); |
168 | inactiveColorBox->setCurrentIndex(abs(groupI.readEntry("ColorEffect" , 2))); |
169 | if (inactiveColorBox->currentIndex() > 1) |
170 | { |
171 | inactiveColorSlider->setValue(int(groupI.readEntry("ColorAmount" , 0.025) * 40.0)); |
172 | } |
173 | else |
174 | { |
175 | inactiveColorSlider->setValue(int(groupI.readEntry("ColorAmount" , 0.05) * 20.0) + 20); |
176 | } |
177 | inactiveColorButton->setColor(groupI.readEntry("Color" , QColor(112, 111, 110))); |
178 | inactiveContrastBox->setCurrentIndex(abs(groupI.readEntry("ContrastEffect" , 2))); |
179 | inactiveContrastSlider->setValue(int(groupI.readEntry("ContrastAmount" , 0.1) * 20.0)); |
180 | |
181 | // NOTE: keep this in sync with kdelibs/kdeui/colors/kcolorscheme.cpp |
182 | KConfigGroup groupD(m_config, "ColorEffects:Disabled" ); |
183 | disabledIntensityBox->setCurrentIndex(groupD.readEntry("IntensityEffect" , 2)); |
184 | disabledIntensitySlider->setValue(int(groupD.readEntry("IntensityAmount" , 0.1) * 20.0) + 20); |
185 | disabledColorBox->setCurrentIndex(groupD.readEntry("ColorEffect" , 0)); |
186 | if (disabledColorBox->currentIndex() > 1) |
187 | { |
188 | disabledColorSlider->setValue(int(groupD.readEntry("ColorAmount" , 0.0) * 40.0)); |
189 | } |
190 | else |
191 | { |
192 | disabledColorSlider->setValue(int(groupD.readEntry("ColorAmount" , 0.0) * 20.0) + 20); |
193 | } |
194 | disabledColorButton->setColor(groupD.readEntry("Color" , QColor(56, 56, 56))); |
195 | disabledContrastBox->setCurrentIndex(groupD.readEntry("ContrastEffect" , 1)); |
196 | disabledContrastSlider->setValue(int(groupD.readEntry("ContrastAmount" , 0.65) * 20.0)); |
197 | |
198 | m_disableUpdates = false; |
199 | |
200 | // enable/disable controls |
201 | inactiveIntensitySlider->setDisabled(inactiveIntensityBox->currentIndex() == 0); |
202 | disabledIntensitySlider->setDisabled(disabledIntensityBox->currentIndex() == 0); |
203 | inactiveColorSlider->setDisabled(inactiveColorBox->currentIndex() == 0); |
204 | disabledColorSlider->setDisabled(disabledColorBox->currentIndex() == 0); |
205 | inactiveColorButton->setDisabled(inactiveColorBox->currentIndex() < 2); |
206 | disabledColorButton->setDisabled(disabledColorBox->currentIndex() < 2); |
207 | inactiveContrastSlider->setDisabled(inactiveContrastBox->currentIndex() == 0); |
208 | disabledContrastSlider->setDisabled(disabledContrastBox->currentIndex() == 0); |
209 | } |
210 | |
211 | void KColorCm::loadScheme(KSharedConfigPtr config) // const QString &path) |
212 | { |
213 | KSharedConfigPtr temp = m_config; |
214 | m_config = config; |
215 | |
216 | updateColorSchemes(); |
217 | updateEffectsPage(); // intentionally before swapping back m_config |
218 | updatePreviews(); |
219 | |
220 | m_config = temp; |
221 | updateFromColorSchemes(); |
222 | updateFromEffectsPage(); |
223 | updateFromOptions(); |
224 | updateColorTable(); |
225 | |
226 | m_loadedSchemeHasUnsavedChanges = false; |
227 | //m_changed = false; |
228 | } |
229 | |
230 | void KColorCm::selectPreviousSchemeAgain() |
231 | { |
232 | m_dontLoadSelectedScheme = true; |
233 | schemeList->setCurrentItem(m_previousSchemeItem); |
234 | m_dontLoadSelectedScheme = false; |
235 | } |
236 | |
237 | void KColorCm::loadScheme(QListWidgetItem *currentItem, QListWidgetItem *previousItem) |
238 | { |
239 | m_previousSchemeItem = previousItem; |
240 | |
241 | if (m_dontLoadSelectedScheme) |
242 | { |
243 | return; |
244 | } |
245 | |
246 | if (currentItem != NULL) |
247 | { |
248 | if (m_loadedSchemeHasUnsavedChanges) // if changes made to loaded scheme |
249 | { |
250 | if (KMessageBox::Continue != KMessageBox::warningContinueCancel(this, |
251 | i18n("Selecting another scheme will discard any changes you have made" ), |
252 | i18n("Are you sure?" ), |
253 | KStandardGuiItem::cont(), |
254 | KStandardGuiItem::cancel(), |
255 | "noDiscardWarning" )) // if the user decides to cancel |
256 | { |
257 | QTimer::singleShot(0, this, SLOT(selectPreviousSchemeAgain())); |
258 | return; |
259 | } |
260 | } |
261 | |
262 | // load it |
263 | |
264 | const QString name = currentItem->text(); |
265 | m_currentColorScheme = name; |
266 | const QString fileBaseName = currentItem->data(Qt::UserRole).toString(); |
267 | if (name == i18nc("Default color scheme" , "Default" )) |
268 | { |
269 | schemeRemoveButton->setEnabled(false); |
270 | schemeKnsUploadButton->setEnabled(false); |
271 | |
272 | KSharedConfigPtr config = m_config; |
273 | config->setReadDefaults(true); |
274 | loadScheme(config); |
275 | config->setReadDefaults(false); |
276 | // load the default scheme |
277 | emit changed(true); |
278 | } |
279 | else if (name == i18nc("Current color scheme" , "Current" )) |
280 | { |
281 | schemeRemoveButton->setEnabled(false); |
282 | schemeKnsUploadButton->setEnabled(false); |
283 | loadInternal(false); |
284 | } |
285 | else |
286 | { |
287 | const QString path = KGlobal::dirs()->findResource("data" , |
288 | "color-schemes/" + fileBaseName + ".colors" ); |
289 | |
290 | const int permissions = QFile(path).permissions(); |
291 | const bool canWrite = (permissions & QFile::WriteUser); |
292 | kDebug() << "checking permissions of " << path; |
293 | schemeRemoveButton->setEnabled(canWrite); |
294 | schemeKnsUploadButton->setEnabled(true); |
295 | |
296 | KSharedConfigPtr config = KSharedConfig::openConfig(path); |
297 | loadScheme(config); |
298 | |
299 | emit changed(true); |
300 | } |
301 | } |
302 | } |
303 | |
304 | void KColorCm::on_schemeRemoveButton_clicked() |
305 | { |
306 | if (schemeList->currentItem() != NULL) |
307 | { |
308 | const QString path = KGlobal::dirs()->findResource("data" , |
309 | "color-schemes/" + schemeList->currentItem()->data(Qt::UserRole).toString() + |
310 | ".colors" ); |
311 | if (KIO::NetAccess::del(path, this)) |
312 | { |
313 | delete schemeList->takeItem(schemeList->currentRow()); |
314 | } |
315 | else |
316 | { |
317 | // deletion failed, so show an error message |
318 | KMessageBox::error(this, i18n("You do not have permission to delete that scheme" ), i18n("Error" )); |
319 | } |
320 | } |
321 | } |
322 | |
323 | void KColorCm::on_schemeImportButton_clicked() |
324 | { |
325 | // get the path to the scheme to import |
326 | KUrl url = KFileDialog::getOpenUrl(KUrl(), QString(), this, i18n("Import Color Scheme" )); |
327 | |
328 | if(url.isValid()) |
329 | { |
330 | // TODO: possibly untar or uncompress it |
331 | // open it |
332 | |
333 | // load the scheme |
334 | KSharedConfigPtr config = KSharedConfig::openConfig(url.path()); |
335 | |
336 | if (config->groupList().contains("Color Scheme" )) |
337 | { |
338 | if (KMessageBox::Continue != KMessageBox::warningContinueCancel(this, |
339 | i18n("The scheme you have selected appears to be a KDE3 scheme.\n\n" |
340 | "KDE will attempt to import this scheme, however many color roles have been added since KDE3. " |
341 | "Some manual work will likely be required.\n\n" |
342 | "This scheme will not be saved automatically." ), |
343 | i18n("Notice" ))) |
344 | { |
345 | return; |
346 | } |
347 | |
348 | // convert KDE3 scheme to KDE4 scheme |
349 | KConfigGroup g(config, "Color Scheme" ); |
350 | |
351 | colorSet->setCurrentIndex(0); |
352 | contrastSlider->setValue(g.readEntry("contrast" , KGlobalSettings::contrast())); |
353 | shadeSortedColumn->setChecked(g.readEntry("shadeSortColumn" , KGlobalSettings::shadeSortColumn())); |
354 | |
355 | m_commonColorButtons[0]->setColor(g.readEntry("windowBackground" , m_colorSchemes[KColorScheme::View].background().color())); |
356 | m_commonColorButtons[1]->setColor(g.readEntry("windowForeground" , m_colorSchemes[KColorScheme::View].foreground().color())); |
357 | m_commonColorButtons[2]->setColor(g.readEntry("background" , m_colorSchemes[KColorScheme::Window].background().color())); |
358 | m_commonColorButtons[3]->setColor(g.readEntry("foreground" , m_colorSchemes[KColorScheme::Window].foreground().color())); |
359 | m_commonColorButtons[4]->setColor(g.readEntry("buttonBackground" , m_colorSchemes[KColorScheme::Button].background().color())); |
360 | m_commonColorButtons[5]->setColor(g.readEntry("buttonForeground" , m_colorSchemes[KColorScheme::Button].foreground().color())); |
361 | m_commonColorButtons[6]->setColor(g.readEntry("selectBackground" , m_colorSchemes[KColorScheme::Selection].background().color())); |
362 | m_commonColorButtons[7]->setColor(g.readEntry("selectForeground" , m_colorSchemes[KColorScheme::Selection].foreground().color())); |
363 | m_commonColorButtons[8]->setColor(KColorUtils::mix(m_colorSchemes[KColorScheme::Selection].foreground().color(), |
364 | m_colorSchemes[KColorScheme::Selection].background().color())); |
365 | m_commonColorButtons[9]->setColor(KColorUtils::mix(m_colorSchemes[KColorScheme::View].foreground().color(), |
366 | m_colorSchemes[KColorScheme::View].background().color())); |
367 | // doesn't exist in KDE3: 10 ActiveText |
368 | m_commonColorButtons[11]->setColor(g.readEntry("linkColor" , m_colorSchemes[KColorScheme::View].foreground(KColorScheme::LinkText).color())); |
369 | m_commonColorButtons[12]->setColor(g.readEntry("visitedLinkColor" , m_colorSchemes[KColorScheme::View].foreground(KColorScheme::VisitedText).color())); |
370 | // doesn't exist in KDE3: 13-15 PositiveText, NeutralText, NegativeText |
371 | m_commonColorButtons[16]->setColor(g.readEntry("windowForeground" , m_colorSchemes[KColorScheme::View].decoration(KColorScheme::FocusColor).color())); |
372 | m_commonColorButtons[17]->setColor(g.readEntry("selectBackground" , m_colorSchemes[KColorScheme::View].decoration(KColorScheme::HoverColor).color())); |
373 | m_commonColorButtons[18]->setColor(g.readEntry("windowBackground" , m_colorSchemes[KColorScheme::Tooltip].background().color())); |
374 | m_commonColorButtons[19]->setColor(g.readEntry("windowForeground" , m_colorSchemes[KColorScheme::Tooltip].foreground().color())); |
375 | m_commonColorButtons[20]->setColor(g.readEntry("activeBackground" , m_wmColors.color(WindecoColors::ActiveBackground))); |
376 | m_commonColorButtons[21]->setColor(g.readEntry("activeForeground" , m_wmColors.color(WindecoColors::ActiveForeground))); |
377 | m_commonColorButtons[22]->setColor(g.readEntry("activeBlend" , m_wmColors.color(WindecoColors::ActiveBlend))); |
378 | m_commonColorButtons[23]->setColor(g.readEntry("inactiveBackground" , m_wmColors.color(WindecoColors::InactiveBackground))); |
379 | m_commonColorButtons[24]->setColor(g.readEntry("inactiveForeground" , m_wmColors.color(WindecoColors::InactiveForeground))); |
380 | m_commonColorButtons[25]->setColor(g.readEntry("inactiveBlend" , m_wmColors.color(WindecoColors::InactiveBlend))); |
381 | |
382 | colorSet->setCurrentIndex(1); |
383 | m_backgroundButtons[KColorScheme::AlternateBackground]->setColor(g.readEntry("alternateBackground" , |
384 | m_colorSchemes[KColorScheme::View].background(KColorScheme::AlternateBackground).color())); |
385 | colorSet->setCurrentIndex(0); |
386 | } |
387 | else |
388 | { |
389 | // load KDE4 scheme |
390 | loadScheme(config); |
391 | |
392 | // save it |
393 | saveScheme(url.fileName()); |
394 | } |
395 | } |
396 | } |
397 | |
398 | void KColorCm::on_schemeKnsButton_clicked() |
399 | { |
400 | KNS3::DownloadDialog dialog("colorschemes.knsrc" , this); |
401 | dialog.exec(); |
402 | if ( ! dialog.changedEntries().isEmpty() ) |
403 | { |
404 | populateSchemeList(); |
405 | } |
406 | } |
407 | |
408 | void KColorCm::on_schemeKnsUploadButton_clicked() |
409 | { |
410 | if (schemeList->currentItem() != NULL) |
411 | { |
412 | // check if the currently loaded scheme has unsaved changes |
413 | if (m_loadedSchemeHasUnsavedChanges) |
414 | { |
415 | KMessageBox::sorry(this, i18n("Please save the color scheme before uploading it." ), |
416 | i18n("Please save" )); |
417 | return; |
418 | } |
419 | |
420 | // find path |
421 | const QString basename = schemeList->currentItem()->data(Qt::UserRole).toString(); |
422 | const QString path = KGlobal::dirs()->findResource("data" , |
423 | "color-schemes/" + basename + ".colors" ); |
424 | if (path.isEmpty() ) // if the color scheme file wasn't found |
425 | { |
426 | kDebug() << "path for color scheme " << basename << " couldn't be found" ; |
427 | return; |
428 | } |
429 | |
430 | // upload |
431 | KNS3::UploadDialog dialog("colorschemes.knsrc" , this); |
432 | dialog.setUploadFile(KUrl(path) ); |
433 | dialog.exec(); |
434 | } |
435 | } |
436 | |
437 | void KColorCm::on_schemeSaveButton_clicked() |
438 | { |
439 | QString previousName; |
440 | if (schemeList->currentItem() != NULL && schemeList->currentRow() > 1) |
441 | { |
442 | previousName = schemeList->currentItem()->data(Qt::DisplayRole).toString(); |
443 | } |
444 | // prompt for the name to save as |
445 | bool ok; |
446 | QString name = KInputDialog::getText(i18n("Save Color Scheme" ), |
447 | i18n("&Enter a name for the color scheme:" ), previousName, &ok, this); |
448 | if (ok) |
449 | { |
450 | saveScheme(name); |
451 | } |
452 | } |
453 | |
454 | void KColorCm::saveScheme(const QString &name) |
455 | { |
456 | QString filename = name; |
457 | filename.remove('\''); // So Foo's does not become FooS |
458 | QRegExp fixer("[\\W,.-]+(.?)" ); |
459 | int offset; |
460 | while ((offset = fixer.indexIn(filename)) >= 0) |
461 | filename.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper()); |
462 | filename.replace(0, 1, filename.at(0).toUpper()); |
463 | |
464 | // check if that name is already in the list |
465 | const QString path = KGlobal::dirs()->saveLocation("data" , "color-schemes/" ) + |
466 | filename + ".colors" ; |
467 | |
468 | QFile file(path); |
469 | const int permissions = file.permissions(); |
470 | const bool canWrite = (permissions & QFile::WriteUser); |
471 | // or if we can overwrite it if it exists |
472 | if (path.isEmpty() || !file.exists() || canWrite) |
473 | { |
474 | if(canWrite){ |
475 | int ret = KMessageBox::questionYesNo(this, |
476 | i18n("A color scheme with that name already exists.\nDo you want to overwrite it?" ), |
477 | i18n("Save Color Scheme" ), |
478 | KStandardGuiItem::overwrite(), |
479 | KStandardGuiItem::cancel()); |
480 | //on don't overwrite, select the already existing name. |
481 | if(ret == KMessageBox::No){ |
482 | QList<QListWidgetItem*> foundItems = schemeList->findItems(name, Qt::MatchExactly); |
483 | if (foundItems.size() == 1) |
484 | schemeList->setCurrentRow(schemeList->row(foundItems[0])); |
485 | return; |
486 | } |
487 | } |
488 | |
489 | // go ahead and save it |
490 | QString newpath = KGlobal::dirs()->saveLocation("data" , "color-schemes/" ); |
491 | newpath += filename + ".colors" ; |
492 | KSharedConfigPtr temp = m_config; |
493 | m_config = KSharedConfig::openConfig(newpath); |
494 | // then copy current colors into new config |
495 | updateFromColorSchemes(); |
496 | updateFromEffectsPage(); |
497 | KConfigGroup group(m_config, "General" ); |
498 | group.writeEntry("Name" , name); |
499 | // sync it |
500 | m_config->sync(); |
501 | |
502 | m_loadedSchemeHasUnsavedChanges = false; |
503 | |
504 | QList<QListWidgetItem*> foundItems = schemeList->findItems(name, Qt::MatchExactly); |
505 | QIcon icon = createSchemePreviewIcon(m_config); |
506 | if (foundItems.size() < 1) |
507 | { |
508 | // add it to the list since it's not in there already |
509 | populateSchemeList(); |
510 | |
511 | // then select the new item |
512 | schemeList->setCurrentItem(schemeList->findItems(name, Qt::MatchExactly).at(0)); |
513 | } |
514 | else |
515 | { |
516 | // update the icon of the one that's in the list |
517 | foundItems[0]->setIcon(icon); |
518 | schemeList->setCurrentRow(schemeList->row(foundItems[0])); |
519 | } |
520 | |
521 | // set m_config back to the system one |
522 | m_config = temp; |
523 | |
524 | // store colorscheme name in global settings |
525 | m_currentColorScheme = name; |
526 | group = KConfigGroup(m_config, "General" ); |
527 | group.writeEntry("ColorScheme" , m_currentColorScheme); |
528 | |
529 | emit changed(true); |
530 | } |
531 | else if (!canWrite && file.exists()) |
532 | { |
533 | // give error message if !canWrite && file.exists() |
534 | KMessageBox::error(this, i18n("You do not have permission to overwrite that scheme" ), i18n("Error" )); |
535 | } |
536 | } |
537 | |
538 | void KColorCm::createColorEntry(const QString &text, const QString &key, QList<KColorButton *> &list, int index) |
539 | { |
540 | KColorButton *button = new KColorButton(this); |
541 | button->setObjectName(QString::number(index)); |
542 | connect(button, SIGNAL(changed(QColor)), this, SLOT(colorChanged(QColor))); |
543 | list.append(button); |
544 | |
545 | m_colorKeys.insert(index, key); |
546 | |
547 | QTableWidgetItem *label = new QTableWidgetItem(text); |
548 | colorTable->setItem(index, 0, label); |
549 | colorTable->setCellWidget(index, 1, button); |
550 | colorTable->setRowHeight(index, button->sizeHint().height()); |
551 | } |
552 | |
553 | void KColorCm::variesClicked() |
554 | { |
555 | // find which button was changed |
556 | const int row = sender()->objectName().toInt(); |
557 | |
558 | QColor color; |
559 | if(KColorDialog::getColor(color, this ) != QDialog::Rejected ) |
560 | { |
561 | changeColor(row, color); |
562 | m_stackedWidgets[row - 9]->setCurrentIndex(0); |
563 | } |
564 | } |
565 | |
566 | QPixmap KColorCm::createSchemePreviewIcon(const KSharedConfigPtr &config) |
567 | { |
568 | const WindecoColors wm(config); |
569 | const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b }; |
570 | const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff }; |
571 | const QSize bitsSize(24,2); |
572 | const QBitmap b1 = QBitmap::fromData(bitsSize, bits1); |
573 | const QBitmap b2 = QBitmap::fromData(bitsSize, bits2); |
574 | |
575 | QPixmap pixmap(23, 16); |
576 | pixmap.fill(Qt::black); // ### use some color other than black for borders? |
577 | |
578 | QPainter p(&pixmap); |
579 | |
580 | KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config); |
581 | p.fillRect( 1, 1, 7, 7, windowScheme.background()); |
582 | p.fillRect( 2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1)); |
583 | |
584 | KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config); |
585 | p.fillRect( 8, 1, 7, 7, buttonScheme.background()); |
586 | p.fillRect( 9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1)); |
587 | |
588 | p.fillRect(15, 1, 7, 7, wm.color(WindecoColors::ActiveBackground)); |
589 | p.fillRect(16, 2, 5, 2, QBrush(wm.color(WindecoColors::ActiveForeground), b1)); |
590 | |
591 | KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config); |
592 | p.fillRect( 1, 8, 7, 7, viewScheme.background()); |
593 | p.fillRect( 2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2)); |
594 | |
595 | KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config); |
596 | p.fillRect( 8, 8, 7, 7, selectionScheme.background()); |
597 | p.fillRect( 9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2)); |
598 | |
599 | p.fillRect(15, 8, 7, 7, wm.color(WindecoColors::InactiveBackground)); |
600 | p.fillRect(16, 12, 5, 2, QBrush(wm.color(WindecoColors::InactiveForeground), b2)); |
601 | |
602 | p.end(); |
603 | |
604 | return pixmap; |
605 | } |
606 | |
607 | void KColorCm::updateColorSchemes() |
608 | { |
609 | m_colorSchemes.clear(); |
610 | |
611 | m_colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::View, m_config)); |
612 | m_colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Window, m_config)); |
613 | m_colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Button, m_config)); |
614 | m_colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Selection, m_config)); |
615 | m_colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Tooltip, m_config)); |
616 | |
617 | m_wmColors.load(m_config); |
618 | } |
619 | |
620 | void KColorCm::updateFromColorSchemes() |
621 | { |
622 | // store colorscheme name in global settings |
623 | KConfigGroup group(m_config, "General" ); |
624 | group.writeEntry("ColorScheme" , m_currentColorScheme); |
625 | |
626 | for (int i = KColorScheme::View; i <= KColorScheme::Tooltip; ++i) |
627 | { |
628 | KConfigGroup group(m_config, colorSetGroupKey(i)); |
629 | group.writeEntry("BackgroundNormal" , m_colorSchemes[i].background(KColorScheme::NormalBackground).color()); |
630 | group.writeEntry("BackgroundAlternate" , m_colorSchemes[i].background(KColorScheme::AlternateBackground).color()); |
631 | group.writeEntry("ForegroundNormal" , m_colorSchemes[i].foreground(KColorScheme::NormalText).color()); |
632 | group.writeEntry("ForegroundInactive" , m_colorSchemes[i].foreground(KColorScheme::InactiveText).color()); |
633 | group.writeEntry("ForegroundActive" , m_colorSchemes[i].foreground(KColorScheme::ActiveText).color()); |
634 | group.writeEntry("ForegroundLink" , m_colorSchemes[i].foreground(KColorScheme::LinkText).color()); |
635 | group.writeEntry("ForegroundVisited" , m_colorSchemes[i].foreground(KColorScheme::VisitedText).color()); |
636 | group.writeEntry("ForegroundNegative" , m_colorSchemes[i].foreground(KColorScheme::NegativeText).color()); |
637 | group.writeEntry("ForegroundNeutral" , m_colorSchemes[i].foreground(KColorScheme::NeutralText).color()); |
638 | group.writeEntry("ForegroundPositive" , m_colorSchemes[i].foreground(KColorScheme::PositiveText).color()); |
639 | group.writeEntry("DecorationFocus" , m_colorSchemes[i].decoration(KColorScheme::FocusColor).color()); |
640 | group.writeEntry("DecorationHover" , m_colorSchemes[i].decoration(KColorScheme::HoverColor).color()); |
641 | } |
642 | |
643 | KConfigGroup WMGroup(m_config, "WM" ); |
644 | WMGroup.writeEntry("activeBackground" , m_wmColors.color(WindecoColors::ActiveBackground)); |
645 | WMGroup.writeEntry("activeForeground" , m_wmColors.color(WindecoColors::ActiveForeground)); |
646 | WMGroup.writeEntry("inactiveBackground" , m_wmColors.color(WindecoColors::InactiveBackground)); |
647 | WMGroup.writeEntry("inactiveForeground" , m_wmColors.color(WindecoColors::InactiveForeground)); |
648 | WMGroup.writeEntry("activeBlend" , m_wmColors.color(WindecoColors::ActiveBlend)); |
649 | WMGroup.writeEntry("inactiveBlend" , m_wmColors.color(WindecoColors::InactiveBlend)); |
650 | } |
651 | |
652 | void KColorCm::updateFromOptions() |
653 | { |
654 | KConfigGroup groupK(m_config, "KDE" ); |
655 | groupK.writeEntry("contrast" , contrastSlider->value()); |
656 | |
657 | KConfigGroup groupG(m_config, "General" ); |
658 | groupG.writeEntry("shadeSortColumn" , shadeSortedColumn->isChecked()); |
659 | |
660 | KConfigGroup groupI(m_config, "ColorEffects:Inactive" ); |
661 | groupI.writeEntry("Enable" , useInactiveEffects->isChecked()); |
662 | // only write this setting if it is not the default; this way we can change the default more easily in later KDE |
663 | // the setting will still written by explicitly checking/unchecking the box |
664 | if (inactiveSelectionEffect->isChecked()) |
665 | { |
666 | groupI.writeEntry("ChangeSelectionColor" , true); |
667 | } |
668 | else |
669 | { |
670 | groupI.deleteEntry("ChangeSelectionColor" ); |
671 | } |
672 | } |
673 | |
674 | void KColorCm::updateFromEffectsPage() |
675 | { |
676 | if (m_disableUpdates) |
677 | { |
678 | // don't write the config as we are reading it! |
679 | return; |
680 | } |
681 | |
682 | KConfigGroup groupI(m_config, "ColorEffects:Inactive" ); |
683 | KConfigGroup groupD(m_config, "ColorEffects:Disabled" ); |
684 | |
685 | // intensity |
686 | groupI.writeEntry("IntensityEffect" , inactiveIntensityBox->currentIndex()); |
687 | groupD.writeEntry("IntensityEffect" , disabledIntensityBox->currentIndex()); |
688 | groupI.writeEntry("IntensityAmount" , qreal(inactiveIntensitySlider->value() - 20) * 0.05); |
689 | groupD.writeEntry("IntensityAmount" , qreal(disabledIntensitySlider->value() - 20) * 0.05); |
690 | |
691 | // color |
692 | groupI.writeEntry("ColorEffect" , inactiveColorBox->currentIndex()); |
693 | groupD.writeEntry("ColorEffect" , disabledColorBox->currentIndex()); |
694 | if (inactiveColorBox->currentIndex() > 1) |
695 | { |
696 | groupI.writeEntry("ColorAmount" , qreal(inactiveColorSlider->value()) * 0.025); |
697 | } |
698 | else |
699 | { |
700 | groupI.writeEntry("ColorAmount" , qreal(inactiveColorSlider->value() - 20) * 0.05); |
701 | } |
702 | if (disabledColorBox->currentIndex() > 1) |
703 | { |
704 | groupD.writeEntry("ColorAmount" , qreal(disabledColorSlider->value()) * 0.025); |
705 | } |
706 | else |
707 | { |
708 | groupD.writeEntry("ColorAmount" , qreal(disabledColorSlider->value() - 20) * 0.05); |
709 | } |
710 | groupI.writeEntry("Color" , inactiveColorButton->color()); |
711 | groupD.writeEntry("Color" , disabledColorButton->color()); |
712 | |
713 | // contrast |
714 | groupI.writeEntry("ContrastEffect" , inactiveContrastBox->currentIndex()); |
715 | groupD.writeEntry("ContrastEffect" , disabledContrastBox->currentIndex()); |
716 | groupI.writeEntry("ContrastAmount" , qreal(inactiveContrastSlider->value()) * 0.05); |
717 | groupD.writeEntry("ContrastAmount" , qreal(disabledContrastSlider->value()) * 0.05); |
718 | |
719 | // enable/disable controls |
720 | inactiveIntensitySlider->setDisabled(inactiveIntensityBox->currentIndex() == 0); |
721 | disabledIntensitySlider->setDisabled(disabledIntensityBox->currentIndex() == 0); |
722 | inactiveColorSlider->setDisabled(inactiveColorBox->currentIndex() == 0); |
723 | disabledColorSlider->setDisabled(disabledColorBox->currentIndex() == 0); |
724 | inactiveColorButton->setDisabled(inactiveColorBox->currentIndex() < 2); |
725 | disabledColorButton->setDisabled(disabledColorBox->currentIndex() < 2); |
726 | inactiveContrastSlider->setDisabled(inactiveContrastBox->currentIndex() == 0); |
727 | disabledContrastSlider->setDisabled(disabledContrastBox->currentIndex() == 0); |
728 | } |
729 | |
730 | void KColorCm::setupColorTable() |
731 | { |
732 | // first setup the common colors table |
733 | commonColorTable->verticalHeader()->hide(); |
734 | commonColorTable->horizontalHeader()->hide(); |
735 | commonColorTable->setShowGrid(false); |
736 | commonColorTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
737 | int minWidth = QPushButton(i18n("Varies" )).minimumSizeHint().width(); |
738 | commonColorTable->horizontalHeader()->setMinimumSectionSize(minWidth); |
739 | commonColorTable->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); |
740 | |
741 | for (int i = 0; i < 26; ++i) |
742 | { |
743 | KColorButton * button = new KColorButton(this); |
744 | commonColorTable->setRowHeight(i, button->sizeHint().height()); |
745 | button->setObjectName(QString::number(i)); |
746 | connect(button, SIGNAL(changed(QColor)), this, SLOT(colorChanged(QColor))); |
747 | m_commonColorButtons << button; |
748 | |
749 | if (i > 8 && i < 18) |
750 | { |
751 | // Inactive Text row through Positive Text role all need a varies button |
752 | KPushButton * variesButton = new KPushButton(NULL); |
753 | variesButton->setText(i18n("Varies" )); |
754 | variesButton->setObjectName(QString::number(i)); |
755 | connect(variesButton, SIGNAL(clicked()), this, SLOT(variesClicked())); |
756 | |
757 | QStackedWidget * widget = new QStackedWidget(this); |
758 | widget->addWidget(button); |
759 | widget->addWidget(variesButton); |
760 | m_stackedWidgets.append(widget); |
761 | |
762 | commonColorTable->setCellWidget(i, 1, widget); |
763 | } |
764 | else |
765 | { |
766 | commonColorTable->setCellWidget(i, 1, button); |
767 | } |
768 | } |
769 | |
770 | // then the colorTable that the colorSets will use |
771 | colorTable->verticalHeader()->hide(); |
772 | colorTable->horizontalHeader()->hide(); |
773 | colorTable->setShowGrid(false); |
774 | colorTable->setRowCount(12); |
775 | colorTable->horizontalHeader()->setMinimumSectionSize(minWidth); |
776 | colorTable->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); |
777 | |
778 | createColorEntry(i18n("Normal Background" ), "BackgroundNormal" , m_backgroundButtons, 0); |
779 | createColorEntry(i18n("Alternate Background" ), "BackgroundAlternate" , m_backgroundButtons, 1); |
780 | createColorEntry(i18n("Normal Text" ), "ForegroundNormal" , m_foregroundButtons, 2); |
781 | createColorEntry(i18n("Inactive Text" ), "ForegroundInactive" , m_foregroundButtons, 3); |
782 | createColorEntry(i18n("Active Text" ), "ForegroundActive" , m_foregroundButtons, 4); |
783 | createColorEntry(i18n("Link Text" ), "ForegroundLink" , m_foregroundButtons, 5); |
784 | createColorEntry(i18n("Visited Text" ), "ForegroundVisited" , m_foregroundButtons, 6); |
785 | createColorEntry(i18n("Negative Text" ), "ForegroundNegative" , m_foregroundButtons, 7); |
786 | createColorEntry(i18n("Neutral Text" ), "ForegroundNeutral" , m_foregroundButtons, 8); |
787 | createColorEntry(i18n("Positive Text" ), "ForegroundPositive" , m_foregroundButtons, 9); |
788 | createColorEntry(i18n("Focus Decoration" ), "DecorationFocus" , m_decorationButtons, 10); |
789 | createColorEntry(i18n("Hover Decoration" ), "DecorationHover" , m_decorationButtons, 11); |
790 | |
791 | colorTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
792 | colorTable->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); |
793 | |
794 | updateColorSchemes(); |
795 | updateColorTable(); |
796 | } |
797 | |
798 | void KColorCm::setCommonForeground(KColorScheme::ForegroundRole role, int stackIndex, |
799 | int buttonIndex) |
800 | { |
801 | QColor color = m_colorSchemes[KColorScheme::View].foreground(role).color(); |
802 | for (int i = KColorScheme::Window; i < KColorScheme::Tooltip; ++i) |
803 | { |
804 | if (i == KColorScheme::Selection && role == KColorScheme::InactiveText) |
805 | break; |
806 | |
807 | if (m_colorSchemes[i].foreground(role).color() != color) |
808 | { |
809 | m_stackedWidgets[stackIndex]->setCurrentIndex(1); |
810 | return; |
811 | } |
812 | } |
813 | |
814 | m_stackedWidgets[stackIndex]->setCurrentIndex(0); |
815 | m_commonColorButtons[buttonIndex]->setColor(color); |
816 | m_loadedSchemeHasUnsavedChanges = true; |
817 | } |
818 | |
819 | void KColorCm::setCommonDecoration(KColorScheme::DecorationRole role, int stackIndex, |
820 | int buttonIndex) |
821 | { |
822 | QColor color = m_colorSchemes[KColorScheme::View].decoration(role).color(); |
823 | for (int i = KColorScheme::Window; i < KColorScheme::Tooltip; ++i) |
824 | { |
825 | if (m_colorSchemes[i].decoration(role).color() != color) |
826 | { |
827 | m_stackedWidgets[stackIndex]->setCurrentIndex(1); |
828 | return; |
829 | } |
830 | } |
831 | |
832 | m_stackedWidgets[stackIndex]->setCurrentIndex(0); |
833 | m_commonColorButtons[buttonIndex]->setColor(color); |
834 | m_loadedSchemeHasUnsavedChanges = true; |
835 | } |
836 | |
837 | void KColorCm::updateColorTable() |
838 | { |
839 | // subtract one here since the 0 item is "Common Colors" |
840 | const int currentSet = colorSet->currentIndex() - 1; |
841 | |
842 | if (currentSet == -1) |
843 | { |
844 | // common colors is selected |
845 | stackColors->setCurrentIndex(0); |
846 | stackPreview->setCurrentIndex(0); |
847 | |
848 | KColorButton * button; |
849 | foreach (button, m_commonColorButtons) |
850 | { |
851 | button->blockSignals(true); |
852 | } |
853 | |
854 | m_commonColorButtons[0]->setColor(m_colorSchemes[KColorScheme::View].background(KColorScheme::NormalBackground).color()); |
855 | m_commonColorButtons[1]->setColor(m_colorSchemes[KColorScheme::View].foreground(KColorScheme::NormalText).color()); |
856 | m_commonColorButtons[2]->setColor(m_colorSchemes[KColorScheme::Window].background(KColorScheme::NormalBackground).color()); |
857 | m_commonColorButtons[3]->setColor(m_colorSchemes[KColorScheme::Window].foreground(KColorScheme::NormalText).color()); |
858 | m_commonColorButtons[4]->setColor(m_colorSchemes[KColorScheme::Button].background(KColorScheme::NormalBackground).color()); |
859 | m_commonColorButtons[5]->setColor(m_colorSchemes[KColorScheme::Button].foreground(KColorScheme::NormalText).color()); |
860 | m_commonColorButtons[6]->setColor(m_colorSchemes[KColorScheme::Selection].background(KColorScheme::NormalBackground).color()); |
861 | m_commonColorButtons[7]->setColor(m_colorSchemes[KColorScheme::Selection].foreground(KColorScheme::NormalText).color()); |
862 | m_commonColorButtons[8]->setColor(m_colorSchemes[KColorScheme::Selection].foreground(KColorScheme::InactiveText).color()); |
863 | |
864 | setCommonForeground(KColorScheme::InactiveText, 0, 9); |
865 | setCommonForeground(KColorScheme::ActiveText, 1, 10); |
866 | setCommonForeground(KColorScheme::LinkText, 2, 11); |
867 | setCommonForeground(KColorScheme::VisitedText, 3, 12); |
868 | setCommonForeground(KColorScheme::NegativeText, 4, 13); |
869 | setCommonForeground(KColorScheme::NeutralText, 5, 14); |
870 | setCommonForeground(KColorScheme::PositiveText, 6, 15); |
871 | |
872 | setCommonDecoration(KColorScheme::FocusColor, 7, 16); |
873 | setCommonDecoration(KColorScheme::HoverColor, 8, 17); |
874 | |
875 | m_commonColorButtons[18]->setColor(m_colorSchemes[KColorScheme::Tooltip].background(KColorScheme::NormalBackground).color()); |
876 | m_commonColorButtons[19]->setColor(m_colorSchemes[KColorScheme::Tooltip].foreground(KColorScheme::NormalText).color()); |
877 | |
878 | m_commonColorButtons[20]->setColor(m_wmColors.color(WindecoColors::ActiveBackground)); |
879 | m_commonColorButtons[21]->setColor(m_wmColors.color(WindecoColors::ActiveForeground)); |
880 | m_commonColorButtons[22]->setColor(m_wmColors.color(WindecoColors::ActiveBlend)); |
881 | m_commonColorButtons[23]->setColor(m_wmColors.color(WindecoColors::InactiveBackground)); |
882 | m_commonColorButtons[24]->setColor(m_wmColors.color(WindecoColors::InactiveForeground)); |
883 | m_commonColorButtons[25]->setColor(m_wmColors.color(WindecoColors::InactiveBlend)); |
884 | |
885 | foreach (button, m_commonColorButtons) |
886 | { |
887 | button->blockSignals(false); |
888 | } |
889 | } |
890 | else |
891 | { |
892 | // a real color set is selected |
893 | setPreview->setPalette(m_config, (KColorScheme::ColorSet)currentSet); |
894 | stackColors->setCurrentIndex(1); |
895 | stackPreview->setCurrentIndex(1); |
896 | |
897 | for (int i = KColorScheme::NormalBackground; i <= KColorScheme::AlternateBackground; ++i) |
898 | { |
899 | m_backgroundButtons[i]->blockSignals(true); |
900 | m_backgroundButtons[i]->setColor(m_colorSchemes[currentSet].background(KColorScheme::BackgroundRole(i)).color()); |
901 | m_backgroundButtons[i]->blockSignals(false); |
902 | } |
903 | |
904 | for (int i = KColorScheme::NormalText; i <= KColorScheme::PositiveText; ++i) |
905 | { |
906 | m_foregroundButtons[i]->blockSignals(true); |
907 | m_foregroundButtons[i]->setColor(m_colorSchemes[currentSet].foreground(KColorScheme::ForegroundRole(i)).color()); |
908 | m_foregroundButtons[i]->blockSignals(false); |
909 | } |
910 | |
911 | for (int i = KColorScheme::FocusColor; i <= KColorScheme::HoverColor; ++i) |
912 | { |
913 | m_decorationButtons[i]->blockSignals(true); |
914 | m_decorationButtons[i]->setColor(m_colorSchemes[currentSet].decoration(KColorScheme::DecorationRole(i)).color()); |
915 | m_decorationButtons[i]->blockSignals(false); |
916 | } |
917 | } |
918 | } |
919 | |
920 | void KColorCm::colorChanged( const QColor &newColor ) |
921 | { |
922 | // find which button was changed |
923 | const int row = sender()->objectName().toInt(); |
924 | changeColor(row, newColor); |
925 | } |
926 | |
927 | void KColorCm::changeColor(int row, const QColor &newColor) |
928 | { |
929 | // update the m_colorSchemes for the selected colorSet |
930 | const int currentSet = colorSet->currentIndex() - 1; |
931 | |
932 | if (currentSet == -1) |
933 | { |
934 | // common colors is selected |
935 | switch (row) |
936 | { |
937 | case 0: |
938 | // View Background button |
939 | KConfigGroup(m_config, "Colors:View" ).writeEntry("BackgroundNormal" , newColor); |
940 | break; |
941 | case 1: |
942 | // View Text button |
943 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundNormal" , newColor); |
944 | break; |
945 | case 2: |
946 | // Window Background Button |
947 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("BackgroundNormal" , newColor); |
948 | break; |
949 | case 3: |
950 | // Window Text Button |
951 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundNormal" , newColor); |
952 | break; |
953 | case 4: |
954 | // Button Background button |
955 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("BackgroundNormal" , newColor); |
956 | break; |
957 | case 5: |
958 | // Button Text button |
959 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundNormal" , newColor); |
960 | break; |
961 | case 6: |
962 | // Selection Background Button |
963 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("BackgroundNormal" , newColor); |
964 | break; |
965 | case 7: |
966 | // Selection Text Button |
967 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundNormal" , newColor); |
968 | break; |
969 | case 8: |
970 | // Selection Inactive Text Button |
971 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundInactive" , newColor); |
972 | break; |
973 | |
974 | // buttons that could have varies in their place |
975 | case 9: |
976 | // Inactive Text Button (set all but Selection Inactive Text color) |
977 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundInactive" , newColor); |
978 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundInactive" , newColor); |
979 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundInactive" , newColor); |
980 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundInactive" , newColor); |
981 | break; |
982 | case 10: |
983 | // Active Text Button (set all active text colors) |
984 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundActive" , newColor); |
985 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundActive" , newColor); |
986 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundActive" , newColor); |
987 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundActive" , newColor); |
988 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundActive" , newColor); |
989 | break; |
990 | case 11: |
991 | // Link Text Button (set all link text colors) |
992 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundLink" , newColor); |
993 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundLink" , newColor); |
994 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundLink" , newColor); |
995 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundLink" , newColor); |
996 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundLink" , newColor); |
997 | break; |
998 | case 12: |
999 | // Visited Text Button (set all visited text colors) |
1000 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundVisited" , newColor); |
1001 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundVisited" , newColor); |
1002 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundVisited" , newColor); |
1003 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundVisited" , newColor); |
1004 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundVisited" , newColor); |
1005 | break; |
1006 | case 13: |
1007 | // Negative Text Button (set all negative text colors) |
1008 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundNegative" , newColor); |
1009 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundNegative" , newColor); |
1010 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundNegative" , newColor); |
1011 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundNegative" , newColor); |
1012 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundNegative" , newColor); |
1013 | break; |
1014 | case 14: |
1015 | // Neutral Text Button (set all neutral text colors) |
1016 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundNeutral" , newColor); |
1017 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundNeutral" , newColor); |
1018 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundNeutral" , newColor); |
1019 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundNeutral" , newColor); |
1020 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundNeutral" , newColor); |
1021 | break; |
1022 | case 15: |
1023 | // Positive Text Button (set all positive text colors) |
1024 | KConfigGroup(m_config, "Colors:View" ).writeEntry("ForegroundPositive" , newColor); |
1025 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("ForegroundPositive" , newColor); |
1026 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("ForegroundPositive" , newColor); |
1027 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("ForegroundPositive" , newColor); |
1028 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundPositive" , newColor); |
1029 | break; |
1030 | |
1031 | case 16: |
1032 | // Focus Decoration Button (set all focus decoration colors) |
1033 | KConfigGroup(m_config, "Colors:View" ).writeEntry("DecorationFocus" , newColor); |
1034 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("DecorationFocus" , newColor); |
1035 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("DecorationFocus" , newColor); |
1036 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("DecorationFocus" , newColor); |
1037 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("DecorationFocus" , newColor); |
1038 | break; |
1039 | case 17: |
1040 | // Hover Decoration Button (set all hover decoration colors) |
1041 | KConfigGroup(m_config, "Colors:View" ).writeEntry("DecorationHover" , newColor); |
1042 | KConfigGroup(m_config, "Colors:Window" ).writeEntry("DecorationHover" , newColor); |
1043 | KConfigGroup(m_config, "Colors:Selection" ).writeEntry("DecorationHover" , newColor); |
1044 | KConfigGroup(m_config, "Colors:Button" ).writeEntry("DecorationHover" , newColor); |
1045 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("DecorationHover" , newColor); |
1046 | break; |
1047 | |
1048 | case 18: |
1049 | // Tooltip Background button |
1050 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("BackgroundNormal" , newColor); |
1051 | break; |
1052 | case 19: |
1053 | // Tooltip Text button |
1054 | KConfigGroup(m_config, "Colors:Tooltip" ).writeEntry("ForegroundNormal" , newColor); |
1055 | break; |
1056 | case 20: |
1057 | // Active Title Background |
1058 | KConfigGroup(m_config, "WM" ).writeEntry("activeBackground" , newColor); |
1059 | break; |
1060 | case 21: |
1061 | // Active Title Text |
1062 | KConfigGroup(m_config, "WM" ).writeEntry("activeForeground" , newColor); |
1063 | break; |
1064 | case 22: |
1065 | // Active Title Secondary |
1066 | KConfigGroup(m_config, "WM" ).writeEntry("activeBlend" , newColor); |
1067 | break; |
1068 | case 23: |
1069 | // Inactive Title Background |
1070 | KConfigGroup(m_config, "WM" ).writeEntry("inactiveBackground" , newColor); |
1071 | break; |
1072 | case 24: |
1073 | // Inactive Title Text |
1074 | KConfigGroup(m_config, "WM" ).writeEntry("inactiveForeground" , newColor); |
1075 | break; |
1076 | case 25: |
1077 | // Inactive Title Secondary |
1078 | KConfigGroup(m_config, "WM" ).writeEntry("inactiveBlend" , newColor); |
1079 | break; |
1080 | } |
1081 | m_commonColorButtons[row]->blockSignals(true); |
1082 | m_commonColorButtons[row]->setColor(newColor); |
1083 | m_commonColorButtons[row]->blockSignals(false); |
1084 | } |
1085 | else |
1086 | { |
1087 | QString group = colorSetGroupKey(currentSet); |
1088 | KConfigGroup(m_config, group).writeEntry(m_colorKeys[row], newColor); |
1089 | } |
1090 | |
1091 | QIcon icon = createSchemePreviewIcon(m_config); |
1092 | schemeList->item(0)->setIcon(icon); |
1093 | updateColorSchemes(); |
1094 | updatePreviews(); |
1095 | |
1096 | m_loadedSchemeHasUnsavedChanges = true; |
1097 | m_currentColorScheme = i18nc("Current color scheme" , "Current" ); |
1098 | KConfigGroup group(m_config, "General" ); |
1099 | group.writeEntry("ColorScheme" , m_currentColorScheme); |
1100 | schemeRemoveButton->setEnabled(false); |
1101 | schemeKnsUploadButton->setEnabled(false); |
1102 | schemeList->blockSignals(true); // don't emit changed signals |
1103 | schemeList->setCurrentRow(0); |
1104 | schemeList->blockSignals(false); |
1105 | |
1106 | emit changed(true); |
1107 | } |
1108 | |
1109 | QString KColorCm::colorSetGroupKey(int colorSet) |
1110 | { |
1111 | QString group; |
1112 | switch (colorSet) { |
1113 | case KColorScheme::Window: |
1114 | group = "Colors:Window" ; |
1115 | break; |
1116 | case KColorScheme::Button: |
1117 | group = "Colors:Button" ; |
1118 | break; |
1119 | case KColorScheme::Selection: |
1120 | group = "Colors:Selection" ; |
1121 | break; |
1122 | case KColorScheme::Tooltip: |
1123 | group = "Colors:Tooltip" ; |
1124 | break; |
1125 | default: |
1126 | group = "Colors:View" ; |
1127 | } |
1128 | return group; |
1129 | } |
1130 | |
1131 | void KColorCm::on_contrastSlider_valueChanged(int value) |
1132 | { |
1133 | KConfigGroup group(m_config, "KDE" ); |
1134 | group.writeEntry("contrast" , value); |
1135 | |
1136 | updatePreviews(); |
1137 | |
1138 | emit changed(true); |
1139 | } |
1140 | |
1141 | void KColorCm::on_shadeSortedColumn_stateChanged(int state) |
1142 | { |
1143 | KConfigGroup group(m_config, "General" ); |
1144 | group.writeEntry("shadeSortColumn" , bool(state != Qt::Unchecked)); |
1145 | |
1146 | emit changed(true); |
1147 | } |
1148 | |
1149 | void KColorCm::on_useInactiveEffects_stateChanged(int state) |
1150 | { |
1151 | KConfigGroup group(m_config, "ColorEffects:Inactive" ); |
1152 | group.writeEntry("Enable" , bool(state != Qt::Unchecked)); |
1153 | |
1154 | m_disableUpdates = true; |
1155 | printf("re-init\n" ); |
1156 | inactiveSelectionEffect->setChecked(group.readEntry("ChangeSelectionColor" , bool(state != Qt::Unchecked))); |
1157 | m_disableUpdates = false; |
1158 | |
1159 | emit changed(true); |
1160 | } |
1161 | |
1162 | void KColorCm::on_inactiveSelectionEffect_stateChanged(int state) |
1163 | { |
1164 | if (m_disableUpdates) |
1165 | { |
1166 | // don't write the config as we are reading it! |
1167 | return; |
1168 | } |
1169 | |
1170 | KConfigGroup group(m_config, "ColorEffects:Inactive" ); |
1171 | group.writeEntry("ChangeSelectionColor" , bool(state != Qt::Unchecked)); |
1172 | |
1173 | emit changed(true); |
1174 | } |
1175 | |
1176 | void KColorCm::load() |
1177 | { |
1178 | loadInternal(true); |
1179 | |
1180 | // get colorscheme name from global settings |
1181 | KConfigGroup group(m_config, "General" ); |
1182 | m_currentColorScheme = group.readEntry("ColorScheme" ); |
1183 | if (m_currentColorScheme == i18nc("Current color scheme" , "Current" )) |
1184 | { |
1185 | m_loadedSchemeHasUnsavedChanges = true; |
1186 | } |
1187 | QList<QListWidgetItem*> itemList = schemeList->findItems(m_currentColorScheme, Qt::MatchExactly); |
1188 | if(!itemList.isEmpty()) // "Current" is already selected, so don't handle the case that itemList is empty |
1189 | schemeList->setCurrentItem(itemList.at(0)); |
1190 | |
1191 | KConfig cfg("kcmdisplayrc" , KConfig::NoGlobals); |
1192 | group = KConfigGroup(&cfg, "X11" ); |
1193 | |
1194 | applyToAlien->blockSignals(true); // don't emit SIGNAL(toggled(bool)) which would call SLOT(emitChanged()) |
1195 | applyToAlien->setChecked(group.readEntry("exportKDEColors" , true)); |
1196 | applyToAlien->blockSignals(false); |
1197 | } |
1198 | |
1199 | void KColorCm::loadOptions() |
1200 | { |
1201 | contrastSlider->setValue(KGlobalSettings::contrast()); |
1202 | shadeSortedColumn->setChecked(KGlobalSettings::shadeSortColumn()); |
1203 | |
1204 | KConfigGroup group(m_config, "ColorEffects:Inactive" ); |
1205 | useInactiveEffects->setChecked(group.readEntry("Enable" , false)); |
1206 | // NOTE: keep this in sync with kdelibs/kdeui/colors/kcolorscheme.cpp |
1207 | // NOTE: remove extra logic from updateFromOptions and on_useInactiveEffects_stateChanged when this changes! |
1208 | inactiveSelectionEffect->setChecked(group.readEntry("ChangeSelectionColor" , group.readEntry("Enable" , true))); |
1209 | } |
1210 | |
1211 | void KColorCm::loadInternal(bool loadOptions_) |
1212 | { |
1213 | // clean the config, in case we have changed the in-memory kconfig |
1214 | m_config->markAsClean(); |
1215 | m_config->reparseConfiguration(); |
1216 | |
1217 | // update the color table |
1218 | updateColorSchemes(); |
1219 | updateColorTable(); |
1220 | |
1221 | // fill in the color scheme list |
1222 | populateSchemeList(); |
1223 | |
1224 | if (loadOptions_) |
1225 | loadOptions(); |
1226 | |
1227 | updateEffectsPage(); |
1228 | |
1229 | updatePreviews(); |
1230 | |
1231 | m_loadedSchemeHasUnsavedChanges = false; |
1232 | |
1233 | emit changed(false); |
1234 | } |
1235 | |
1236 | void KColorCm::save() |
1237 | { |
1238 | QIcon icon = createSchemePreviewIcon(m_config); |
1239 | schemeList->item(0)->setIcon(icon); |
1240 | |
1241 | KConfigGroup groupI(m_config, "ColorEffects:Inactive" ); |
1242 | |
1243 | groupI.writeEntry("Enable" , useInactiveEffects->isChecked()); |
1244 | groupI.writeEntry("IntensityEffect" , inactiveIntensityBox->currentIndex()); |
1245 | groupI.writeEntry("ColorEffect" , inactiveColorBox->currentIndex()); |
1246 | groupI.writeEntry("ContrastEffect" , inactiveContrastBox->currentIndex()); |
1247 | |
1248 | m_config->sync(); |
1249 | KGlobalSettings::self()->emitChange(KGlobalSettings::PaletteChanged); |
1250 | #ifdef Q_WS_X11 |
1251 | // Send signal to all kwin instances |
1252 | QDBusMessage message = |
1253 | QDBusMessage::createSignal("/KWin" , "org.kde.KWin" , "reloadConfig" ); |
1254 | QDBusConnection::sessionBus().send(message); |
1255 | #endif |
1256 | |
1257 | KConfig cfg("kcmdisplayrc" , KConfig::NoGlobals); |
1258 | KConfigGroup displayGroup(&cfg, "X11" ); |
1259 | |
1260 | displayGroup.writeEntry("exportKDEColors" , applyToAlien->isChecked()); |
1261 | cfg.sync(); |
1262 | |
1263 | runRdb(KRdbExportQtColors | KRdbExportGtkTheme | ( applyToAlien->isChecked() ? KRdbExportColors : 0 ) ); |
1264 | |
1265 | emit changed(false); |
1266 | } |
1267 | |
1268 | void KColorCm::defaults() |
1269 | { |
1270 | // Switch to default scheme |
1271 | for(int i = 0; i < schemeList->count(); ++i) { |
1272 | QListWidgetItem *item = schemeList->item(i); |
1273 | if(item->text() == i18nc("Default color scheme" , "Default" )) { |
1274 | // If editing the default scheme, force a reload, else select the default scheme |
1275 | if(schemeList->currentItem() == item) |
1276 | loadScheme(item, item); |
1277 | else |
1278 | schemeList->setCurrentItem(item); |
1279 | m_currentColorScheme = item->text(); |
1280 | break; |
1281 | } |
1282 | } |
1283 | |
1284 | // Reset options (not part of scheme) |
1285 | m_config->setReadDefaults(true); |
1286 | loadOptions(); |
1287 | m_config->setReadDefaults(false); |
1288 | applyToAlien->setChecked(Qt::Checked); |
1289 | |
1290 | KCModule::defaults(); |
1291 | emit changed(true); |
1292 | } |
1293 | |
1294 | void KColorCm::emitChanged() |
1295 | { |
1296 | emit changed(true); |
1297 | } |
1298 | |
1299 | // inactive effects slots |
1300 | void KColorCm::on_inactiveIntensityBox_currentIndexChanged(int index) |
1301 | { |
1302 | Q_UNUSED( index ); |
1303 | |
1304 | updateFromEffectsPage(); |
1305 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1306 | |
1307 | m_loadedSchemeHasUnsavedChanges = true; |
1308 | |
1309 | emit changed(true); |
1310 | } |
1311 | |
1312 | void KColorCm::on_inactiveIntensitySlider_valueChanged(int value) |
1313 | { |
1314 | Q_UNUSED( value ); |
1315 | |
1316 | updateFromEffectsPage(); |
1317 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1318 | |
1319 | m_loadedSchemeHasUnsavedChanges = true; |
1320 | |
1321 | emit changed(true); |
1322 | } |
1323 | |
1324 | void KColorCm::on_inactiveColorBox_currentIndexChanged(int index) |
1325 | { |
1326 | Q_UNUSED( index ); |
1327 | |
1328 | updateFromEffectsPage(); |
1329 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1330 | |
1331 | m_loadedSchemeHasUnsavedChanges = true; |
1332 | |
1333 | emit changed(true); |
1334 | } |
1335 | |
1336 | void KColorCm::on_inactiveColorSlider_valueChanged(int value) |
1337 | { |
1338 | Q_UNUSED( value ); |
1339 | |
1340 | updateFromEffectsPage(); |
1341 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1342 | |
1343 | m_loadedSchemeHasUnsavedChanges = true; |
1344 | |
1345 | emit changed(true); |
1346 | } |
1347 | |
1348 | void KColorCm::on_inactiveColorButton_changed(const QColor& color) |
1349 | { |
1350 | Q_UNUSED( color ); |
1351 | |
1352 | updateFromEffectsPage(); |
1353 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1354 | |
1355 | m_loadedSchemeHasUnsavedChanges = true; |
1356 | |
1357 | emit changed(true); |
1358 | } |
1359 | |
1360 | void KColorCm::on_inactiveContrastBox_currentIndexChanged(int index) |
1361 | { |
1362 | Q_UNUSED( index ); |
1363 | |
1364 | updateFromEffectsPage(); |
1365 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1366 | |
1367 | m_loadedSchemeHasUnsavedChanges = true; |
1368 | |
1369 | emit changed(true); |
1370 | } |
1371 | |
1372 | void KColorCm::on_inactiveContrastSlider_valueChanged(int value) |
1373 | { |
1374 | Q_UNUSED( value ); |
1375 | |
1376 | updateFromEffectsPage(); |
1377 | inactivePreview->setPalette(m_config, QPalette::Inactive); |
1378 | |
1379 | m_loadedSchemeHasUnsavedChanges = true; |
1380 | |
1381 | emit changed(true); |
1382 | } |
1383 | |
1384 | // disabled effects slots |
1385 | void KColorCm::on_disabledIntensityBox_currentIndexChanged(int index) |
1386 | { |
1387 | Q_UNUSED( index ); |
1388 | |
1389 | updateFromEffectsPage(); |
1390 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1391 | |
1392 | m_loadedSchemeHasUnsavedChanges = true; |
1393 | |
1394 | emit changed(true); |
1395 | } |
1396 | |
1397 | void KColorCm::on_disabledIntensitySlider_valueChanged(int value) |
1398 | { |
1399 | Q_UNUSED( value ); |
1400 | |
1401 | updateFromEffectsPage(); |
1402 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1403 | |
1404 | m_loadedSchemeHasUnsavedChanges = true; |
1405 | |
1406 | emit changed(true); |
1407 | } |
1408 | |
1409 | void KColorCm::on_disabledColorBox_currentIndexChanged(int index) |
1410 | { |
1411 | Q_UNUSED( index ); |
1412 | |
1413 | updateFromEffectsPage(); |
1414 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1415 | |
1416 | m_loadedSchemeHasUnsavedChanges = true; |
1417 | |
1418 | emit changed(true); |
1419 | } |
1420 | |
1421 | void KColorCm::on_disabledColorSlider_valueChanged(int value) |
1422 | { |
1423 | Q_UNUSED( value ); |
1424 | |
1425 | updateFromEffectsPage(); |
1426 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1427 | |
1428 | m_loadedSchemeHasUnsavedChanges = true; |
1429 | |
1430 | emit changed(true); |
1431 | } |
1432 | |
1433 | void KColorCm::on_disabledColorButton_changed(const QColor& color) |
1434 | { |
1435 | Q_UNUSED( color ); |
1436 | |
1437 | updateFromEffectsPage(); |
1438 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1439 | |
1440 | m_loadedSchemeHasUnsavedChanges = true; |
1441 | |
1442 | emit changed(true); |
1443 | } |
1444 | |
1445 | void KColorCm::on_disabledContrastBox_currentIndexChanged(int index) |
1446 | { |
1447 | Q_UNUSED( index ); |
1448 | |
1449 | updateFromEffectsPage(); |
1450 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1451 | |
1452 | m_loadedSchemeHasUnsavedChanges = true; |
1453 | |
1454 | emit changed(true); |
1455 | } |
1456 | |
1457 | void KColorCm::on_disabledContrastSlider_valueChanged(int value) |
1458 | { |
1459 | Q_UNUSED( value ); |
1460 | |
1461 | updateFromEffectsPage(); |
1462 | disabledPreview->setPalette(m_config, QPalette::Disabled); |
1463 | |
1464 | m_loadedSchemeHasUnsavedChanges = true; |
1465 | |
1466 | emit changed(true); |
1467 | } |
1468 | |
1469 | #include "colorscm.moc" |
1470 | |