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>
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.
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.
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.
21
#ifndef __COLORSCM_H__
22
#define __COLORSCM_H__
25
#include <KColorScheme>
26
#include <KPushButton>
28
#include "ui_colorsettings.h"
31
class QListWidgetItem;
34
* The Desktop/Colors tab in kcontrol.
36
class KColorCm : public KCModule, public Ui::colorSettings
41
KColorCm(QWidget *parent, const QVariantList &);
46
/// load the settings from the config
49
/// save the current settings
52
/// sets the configuration to sensible default values.
53
virtual void defaults();
57
/** set the colortable color buttons up according to the current colorset */
58
void updateColorTable();
60
/** slot called when color on a KColorButton changes */
61
void colorChanged( const QColor &newColor );
63
/** slot called when any varies button is clicked */
66
/** slot called when the schemeList selection changes */
67
void loadScheme(QListWidgetItem *currentItem, QListWidgetItem *previousItem);
69
/** reselect the previously selected scheme in schemeList without loading it */
70
void selectPreviousSchemeAgain();
72
/** slot called when the remove button is clicked*/
73
void on_schemeRemoveButton_clicked();
75
/** slot called when the save button is clicked */
76
void on_schemeSaveButton_clicked();
78
/** slot called when the import button is clicked */
79
void on_schemeImportButton_clicked();
81
/** slot called when the get new schemes button is clicked */
82
void on_schemeKnsButton_clicked();
84
/** slot called when the upload scheme button is clicked */
85
void on_schemeKnsUploadButton_clicked();
87
/** null slot to emit changed(true) */
91
void on_contrastSlider_valueChanged(int value);
92
void on_shadeSortedColumn_stateChanged(int state);
93
void on_inactiveSelectionEffect_stateChanged(int state);
94
void on_useInactiveEffects_stateChanged(int state);
97
void on_inactiveIntensityBox_currentIndexChanged(int index);
98
void on_inactiveIntensitySlider_valueChanged(int value);
99
void on_inactiveColorBox_currentIndexChanged(int index);
100
void on_inactiveColorSlider_valueChanged(int value);
101
void on_inactiveColorButton_changed(const QColor & color);
102
void on_inactiveContrastBox_currentIndexChanged(int index);
103
void on_inactiveContrastSlider_valueChanged(int value);
105
void on_disabledIntensityBox_currentIndexChanged(int index);
106
void on_disabledIntensitySlider_valueChanged(int value);
107
void on_disabledColorBox_currentIndexChanged(int index);
108
void on_disabledColorSlider_valueChanged(int value);
109
void on_disabledColorButton_changed(const QColor & color);
110
void on_disabledContrastBox_currentIndexChanged(int index);
111
void on_disabledContrastSlider_valueChanged(int value);
114
class WindecoColors {
117
ActiveForeground = 0,
118
ActiveBackground = 1,
119
InactiveForeground = 2,
120
InactiveBackground = 3,
126
WindecoColors(const KSharedConfigPtr&);
127
virtual ~WindecoColors() {}
129
void load(const KSharedConfigPtr&);
130
QColor color(Role) const;
135
/** create a preview of a color scheme */
136
static QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
138
/** load options from global */
141
/** load from global */
142
void loadInternal(bool loadOptions);
144
/** load a scheme from a config file at a given path */
145
void loadScheme(KSharedConfigPtr config);
147
/** populate the schemeList with color schemes found on the system */
148
void populateSchemeList();
150
/** update m_colorSchemes contents from the values in m_config */
151
void updateColorSchemes();
153
/** update the effects page from the values in m_config */
154
void updateEffectsPage();
156
/** update all preview panes from the values in m_config */
157
void updatePreviews();
159
/** setup the colortable with its buttons and labels */
160
void setupColorTable();
162
/** helper to create color entries */
163
void createColorEntry(const QString &text,
165
QList<KColorButton *> &list,
168
/** copy color entries from color schemes into m_config */
169
void updateFromColorSchemes();
171
/** copy effects page entries from controls into m_config */
172
void updateFromEffectsPage();
174
/** copy options from controls into m_config */
175
void updateFromOptions();
177
void changeColor(int row, const QColor &newColor);
179
/** get the groupKey for the given colorSet */
180
static QString colorSetGroupKey(int colorSet);
182
/** save the current scheme with the given name
183
@param name name to save the scheme as
185
void saveScheme(const QString &name);
187
void setCommonForeground(KColorScheme::ForegroundRole role,
190
void setCommonDecoration(KColorScheme::DecorationRole role,
194
QList<KColorButton *> m_backgroundButtons;
195
QList<KColorButton *> m_foregroundButtons;
196
QList<KColorButton *> m_decorationButtons;
197
QList<KColorButton *> m_commonColorButtons;
198
QList<QStackedWidget *> m_stackedWidgets;
199
QStringList m_colorKeys;
201
QList<KColorScheme> m_colorSchemes;
202
WindecoColors m_wmColors;
203
QString m_currentColorScheme;
205
KSharedConfigPtr m_config;
207
bool m_disableUpdates;
208
bool m_loadedSchemeHasUnsavedChanges;
209
// don't (re)load the scheme, only select it in schemeList
210
bool m_dontLoadSelectedScheme;
212
// the item previously selected in schemeList
213
QListWidgetItem *m_previousSchemeItem;