Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colorscm.h
1 | /* KDE Display color scheme setup module | 1 | /* KDE Display color scheme setup module | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> | 2 | * Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> | ||
3 | * Copyright (C) 2007 Jeremy Whiting <jpwhiting@kde.org> | 3 | * Copyright (C) 2007 Jeremy Whiting <jpwhiting@kde.org> | ||
4 | * Copyright (C) 2016 Olivier Churlaud <olivier@churlaud.com> | ||||
4 | * | 5 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | 6 | * 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 | * it under the terms of the GNU General Public License as published by | ||
Context not available. | |||||
22 | #define __COLORSCM_H__ | 23 | #define __COLORSCM_H__ | ||
23 | 24 | | |||
24 | #include <KCModule> | 25 | #include <KCModule> | ||
25 | #include <KColorScheme> | | |||
26 | 26 | | |||
27 | #include "ui_colorsettings.h" | 27 | #include "ui_colorsettings.h" | ||
28 | 28 | | |||
29 | class QStackedWidget; | 29 | class QStackedWidget; | ||
30 | class QListWidgetItem; | 30 | class QListWidgetItem; | ||
31 | 31 | | |||
32 | class KColorButton; | ||||
33 | | ||||
34 | | ||||
32 | /** | 35 | /** | ||
33 | * The Desktop/Colors tab in kcontrol. | 36 | * The Desktop/Colors tab in kcontrol. | ||
34 | */ | 37 | */ | ||
Context not available. | |||||
42 | 45 | | |||
43 | public Q_SLOTS: | 46 | public Q_SLOTS: | ||
44 | 47 | | |||
45 | /// load the settings from the config | 48 | /** | ||
49 | * load the settings from the config | ||||
50 | */ | ||||
46 | virtual void load(); | 51 | virtual void load(); | ||
47 | 52 | | |||
48 | /// save the current settings | 53 | /** | ||
54 | * save the current settings | ||||
55 | */ | ||||
49 | virtual void save(); | 56 | virtual void save(); | ||
50 | 57 | | |||
51 | /// sets the configuration to sensible default values. | 58 | /** | ||
59 | * sets the configuration to sensible default values. | ||||
60 | */ | ||||
52 | virtual void defaults(); | 61 | virtual void defaults(); | ||
53 | 62 | | |||
54 | private Q_SLOTS: | 63 | private Q_SLOTS: | ||
55 | 64 | | |||
56 | /** set the colortable color buttons up according to the current colorset */ | | |||
57 | void updateColorTable(); | | |||
58 | | ||||
59 | /** slot called when color on a KColorButton changes */ | | |||
60 | void colorChanged( const QColor &newColor ); | | |||
61 | 65 | | |||
62 | /** slot called when any varies button is clicked */ | 66 | /** | ||
63 | void variesClicked(); | 67 | * slot called when the schemeList selection changes. | ||
64 | 68 | * | |||
65 | /** slot called when the schemeList selection changes */ | 69 | * It loads the scheme with loadScheme(KSharedConfigPtr), which updates the | ||
70 | * config (updateConfig()) | ||||
71 | */ | ||||
66 | void loadScheme(QListWidgetItem *currentItem, QListWidgetItem *previousItem); | 72 | void loadScheme(QListWidgetItem *currentItem, QListWidgetItem *previousItem); | ||
67 | 73 | | |||
68 | /** reselect the previously selected scheme in schemeList without loading it */ | 74 | /** | ||
75 | * Reselect the previously selected scheme in schemeList without loading it | ||||
76 | */ | ||||
69 | void selectPreviousSchemeAgain(); | 77 | void selectPreviousSchemeAgain(); | ||
70 | 78 | | |||
71 | /** slot called when the remove button is clicked*/ | 79 | /** | ||
80 | * Slot called when the remove button is clicked | ||||
81 | */ | ||||
72 | void on_schemeRemoveButton_clicked(); | 82 | void on_schemeRemoveButton_clicked(); | ||
73 | 83 | | |||
74 | /** slot called when the save button is clicked */ | 84 | /** | ||
75 | void on_schemeSaveButton_clicked(); | 85 | * Slot called when the import button is clicked | ||
76 | 86 | */ | |||
77 | /** slot called when the import button is clicked */ | | |||
78 | void on_schemeImportButton_clicked(); | 87 | void on_schemeImportButton_clicked(); | ||
79 | 88 | | |||
80 | /** slot called when the get new schemes button is clicked */ | 89 | /** | ||
90 | * slot called when the get new schemes button is clicked | ||||
91 | */ | ||||
81 | void on_schemeKnsButton_clicked(); | 92 | void on_schemeKnsButton_clicked(); | ||
82 | 93 | | |||
83 | /** slot called when the upload scheme button is clicked */ | 94 | /** | ||
84 | void on_schemeKnsUploadButton_clicked(); | 95 | * Slot called when the Edit button is clicked. | ||
85 | 96 | * | |||
86 | /** null slot to emit changed(true) */ | 97 | * It opens a dialog for the edition/creation. | ||
87 | void emitChanged(); | 98 | */ | ||
88 | 99 | void on_schemeEditButton_clicked(); | |||
89 | // options slots | | |||
90 | void on_contrastSlider_valueChanged(int value); | | |||
91 | void on_shadeSortedColumn_stateChanged(int state); | | |||
92 | void on_inactiveSelectionEffect_stateChanged(int state); | | |||
93 | void on_useInactiveEffects_stateChanged(int state); | | |||
94 | | ||||
95 | // effects page slots | | |||
96 | void on_inactiveIntensityBox_currentIndexChanged(int index); | | |||
97 | void on_inactiveIntensitySlider_valueChanged(int value); | | |||
98 | void on_inactiveColorBox_currentIndexChanged(int index); | | |||
99 | void on_inactiveColorSlider_valueChanged(int value); | | |||
100 | void on_inactiveColorButton_changed(const QColor & color); | | |||
101 | void on_inactiveContrastBox_currentIndexChanged(int index); | | |||
102 | void on_inactiveContrastSlider_valueChanged(int value); | | |||
103 | | ||||
104 | void on_disabledIntensityBox_currentIndexChanged(int index); | | |||
105 | void on_disabledIntensitySlider_valueChanged(int value); | | |||
106 | void on_disabledColorBox_currentIndexChanged(int index); | | |||
107 | void on_disabledColorSlider_valueChanged(int value); | | |||
108 | void on_disabledColorButton_changed(const QColor & color); | | |||
109 | void on_disabledContrastBox_currentIndexChanged(int index); | | |||
110 | void on_disabledContrastSlider_valueChanged(int value); | | |||
111 | | ||||
112 | private: | 100 | private: | ||
113 | class WindecoColors { | | |||
114 | public: | | |||
115 | enum Role { | | |||
116 | ActiveForeground = 0, | | |||
117 | ActiveBackground = 1, | | |||
118 | InactiveForeground = 2, | | |||
119 | InactiveBackground = 3, | | |||
120 | ActiveBlend = 4, | | |||
121 | InactiveBlend = 5 | | |||
122 | }; | | |||
123 | | ||||
124 | WindecoColors() {} | | |||
125 | WindecoColors(const KSharedConfigPtr&); | | |||
126 | virtual ~WindecoColors() {} | | |||
127 | | ||||
128 | void load(const KSharedConfigPtr&); | | |||
129 | QColor color(Role) const; | | |||
130 | private: | | |||
131 | QColor m_colors[6]; | | |||
132 | }; | | |||
133 | | ||||
134 | /** create a preview of a color scheme */ | | |||
135 | static QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config); | | |||
136 | 101 | | |||
137 | /** load options from global */ | 102 | /** | ||
138 | void loadOptions(); | 103 | * Create a preview icon of a color scheme | ||
104 | */ | ||||
105 | static QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config); | ||||
139 | 106 | | |||
140 | /** load from global */ | 107 | /** | ||
141 | void loadInternal(bool loadOptions); | 108 | * Load from global. | ||
109 | */ | ||||
110 | void loadInternal(); | ||||
142 | 111 | | |||
143 | /** load a scheme from a config file at a given path */ | 112 | /** | ||
113 | * load a scheme from a config file at a given path and updates the | ||||
114 | * config (updateConfig()) | ||||
115 | */ | ||||
144 | void loadScheme(KSharedConfigPtr config); | 116 | void loadScheme(KSharedConfigPtr config); | ||
145 | 117 | | |||
146 | /** populate the schemeList with color schemes found on the system */ | 118 | /** | ||
119 | * Populate the schemeList with color schemes found on the system | ||||
120 | */ | ||||
147 | void populateSchemeList(); | 121 | void populateSchemeList(); | ||
148 | 122 | | |||
149 | /** update m_colorSchemes contents from the values in m_config */ | 123 | /** | ||
150 | void updateColorSchemes(); | 124 | * Update all keys of the Global config with the theme ones. | ||
151 | 125 | */ | |||
152 | /** update the effects page from the values in m_config */ | 126 | void updateConfig(KSharedConfigPtr config); | ||
153 | void updateEffectsPage(); | | |||
154 | | ||||
155 | /** update all preview panes from the values in m_config */ | | |||
156 | void updatePreviews(); | | |||
157 | | ||||
158 | /** setup the colortable with its buttons and labels */ | | |||
159 | void setupColorTable(); | | |||
160 | | ||||
161 | /** helper to create color entries */ | | |||
162 | void createColorEntry(const QString &text, | | |||
163 | const QString &key, | | |||
164 | QList<KColorButton *> &list, | | |||
165 | int index); | | |||
166 | | ||||
167 | /** copy color entries from color schemes into m_config */ | | |||
168 | void updateFromColorSchemes(); | | |||
169 | | ||||
170 | /** copy effects page entries from controls into m_config */ | | |||
171 | void updateFromEffectsPage(); | | |||
172 | | ||||
173 | /** copy options from controls into m_config */ | | |||
174 | void updateFromOptions(); | | |||
175 | | ||||
176 | void changeColor(int row, const QColor &newColor); | | |||
177 | 127 | | |||
178 | /** get the groupKey for the given colorSet */ | | |||
179 | static QString colorSetGroupKey(int colorSet); | | |||
180 | 128 | | |||
181 | /** save the current scheme with the given name | | |||
182 | @param name name to save the scheme as | | |||
183 | */ | | |||
184 | void saveScheme(const QString &name); | | |||
185 | | ||||
186 | void setCommonForeground(KColorScheme::ForegroundRole role, | | |||
187 | int stackIndex, | | |||
188 | int buttonIndex); | | |||
189 | void setCommonDecoration(KColorScheme::DecorationRole role, | | |||
190 | int stackIndex, | | |||
191 | int buttonIndex); | | |||
192 | | ||||
193 | QList<KColorButton *> m_backgroundButtons; | | |||
194 | QList<KColorButton *> m_foregroundButtons; | | |||
195 | QList<KColorButton *> m_decorationButtons; | | |||
196 | QList<KColorButton *> m_commonColorButtons; | | |||
197 | QList<QStackedWidget *> m_stackedWidgets; | | |||
198 | QStringList m_colorKeys; | | |||
199 | | ||||
200 | QList<KColorScheme> m_colorSchemes; | | |||
201 | WindecoColors m_wmColors; | | |||
202 | QString m_currentColorScheme; | 129 | QString m_currentColorScheme; | ||
203 | 130 | | |||
131 | // The global config | ||||
204 | KSharedConfigPtr m_config; | 132 | KSharedConfigPtr m_config; | ||
205 | 133 | | |||
206 | bool m_disableUpdates; | | |||
207 | bool m_loadedSchemeHasUnsavedChanges; | | |||
208 | // don't (re)load the scheme, only select it in schemeList | 134 | // don't (re)load the scheme, only select it in schemeList | ||
209 | bool m_dontLoadSelectedScheme; | 135 | bool m_dontLoadSelectedScheme; | ||
210 | 136 | | |||
Context not available. |