1 /* KDE Display color scheme setup module
2 * Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
3 * Copyright (C) 2007 Jeremy Whiting <jeremy@scitools.com>
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"
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 */
69 /** slot called when the remove button is clicked*/
70 void on_schemeRemoveButton_clicked();
72 /** slot called when the save button is clicked */
73 void on_schemeSaveButton_clicked();
75 /** slot called when the import button is clicked */
76 void on_schemeImportButton_clicked();
78 /** slot called when the get new schemes button is clicked */
79 void on_schemeKnsButton_clicked();
81 /** null slot to emit changed(true) */
85 void on_contrastSlider_valueChanged(int value
);
86 void on_shadeSortedColumn_stateChanged(int state
);
87 void on_inactiveSelectionEffect_stateChanged(int state
);
88 void on_useInactiveEffects_stateChanged(int state
);
91 void on_inactiveIntensityBox_currentIndexChanged(int index
);
92 void on_inactiveIntensitySlider_valueChanged(int value
);
93 void on_inactiveColorBox_currentIndexChanged(int index
);
94 void on_inactiveColorSlider_valueChanged(int value
);
95 void on_inactiveColorButton_changed(const QColor
& color
);
96 void on_inactiveContrastBox_currentIndexChanged(int index
);
97 void on_inactiveContrastSlider_valueChanged(int value
);
99 void on_disabledIntensityBox_currentIndexChanged(int index
);
100 void on_disabledIntensitySlider_valueChanged(int value
);
101 void on_disabledColorBox_currentIndexChanged(int index
);
102 void on_disabledColorSlider_valueChanged(int value
);
103 void on_disabledColorButton_changed(const QColor
& color
);
104 void on_disabledContrastBox_currentIndexChanged(int index
);
105 void on_disabledContrastSlider_valueChanged(int value
);
108 class WindecoColors
{
111 ActiveForeground
= 0,
112 ActiveBackground
= 1,
113 InactiveForeground
= 2,
114 InactiveBackground
= 3
118 WindecoColors(const KSharedConfigPtr
&);
119 virtual ~WindecoColors() {}
121 void load(const KSharedConfigPtr
&);
122 QColor
color(Role
) const;
127 /** create a preview of a color scheme */
128 static QPixmap
createSchemePreviewIcon(const KSharedConfigPtr
&config
);
130 /** load from global */
131 void loadInternal(bool loadOptions
);
133 /** load a scheme from a config file at a given path */
134 void loadScheme(KSharedConfigPtr config
);
136 /** populate the schemeList with color schemes found on the system */
137 void populateSchemeList();
139 /** update m_colorSchemes contents from the values in m_config */
140 void updateColorSchemes();
142 /** update the effects page from the values in m_config */
143 void updateEffectsPage();
145 /** update all preview panes from the values in m_config */
146 void updatePreviews();
148 /** setup the colortable with its buttons and labels */
149 void setupColorTable();
151 /** helper to create color entries */
152 void createColorEntry(QString text
,
154 QList
<KColorButton
*> &list
,
157 /** copy color entries from color schemes into m_config */
158 void updateFromColorSchemes();
160 /** copy effects page entries from controls into m_config */
161 void updateFromEffectsPage();
163 /** copy options from controls into m_config */
164 void updateFromOptions();
166 void changeColor(int row
, const QColor
&newColor
);
168 /** get the groupKey for the given colorSet */
169 static QString
colorSetGroupKey(int colorSet
);
171 /** save the current scheme with the given name
172 @param name name to save the scheme as
174 void saveScheme(const QString
&name
);
176 void setCommonForeground(KColorScheme::ForegroundRole role
,
179 void setCommonDecoration(KColorScheme::DecorationRole role
,
183 QList
<KColorButton
*> m_backgroundButtons
;
184 QList
<KColorButton
*> m_foregroundButtons
;
185 QList
<KColorButton
*> m_decorationButtons
;
186 QList
<KColorButton
*> m_commonColorButtons
;
187 QList
<QStackedWidget
*> m_stackedWidgets
;
188 QStringList m_colorKeys
;
190 QList
<KColorScheme
> m_colorSchemes
;
191 WindecoColors m_wmColors
;
193 KSharedConfigPtr m_config
;
195 bool m_disableUpdates
;