author | hash <hash> | 2002-08-19 20:06:41 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-19 20:06:41 (UTC) |
commit | 5c057c7040fe0669a159173f07793c7f28c95477 (patch) (unidiff) | |
tree | 42d9dcd632c296566a3b973c2f724593c822f57a /inputmethods/multikey | |
parent | fc58f8b2dea3629fdd486852b74e425a3da29b52 (diff) | |
download | opie-5c057c7040fe0669a159173f07793c7f28c95477.zip opie-5c057c7040fe0669a159173f07793c7f28c95477.tar.gz opie-5c057c7040fe0669a159173f07793c7f28c95477.tar.bz2 |
made all the rest of the color buttons work...
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 114 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 10 |
2 files changed, 106 insertions, 18 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 566b2b9..89b713e 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -144,37 +144,53 @@ ConfigDlg::ConfigDlg () : QTabWidget () | |||
144 | color_box->setMargin(3); | 144 | color_box->setMargin(3); |
145 | color_box->setSpacing(3); | 145 | color_box->setSpacing(3); |
146 | addTab(color_box, tr("Colors")); | 146 | addTab(color_box, tr("Colors")); |
147 | 147 | ||
148 | QLabel *label; | 148 | QLabel *label; |
149 | QStringList color; | 149 | QStringList color; |
150 | config.setGroup("colors"); | ||
150 | 151 | ||
151 | label = new QLabel(tr("Key Color"), color_box); | 152 | label = new QLabel(tr("Key Color"), color_box); |
152 | key_color_button = new QPushButton(color_box); | 153 | keycolor_button = new QPushButton(color_box); |
153 | connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked())); | 154 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
154 | key_color_button->setFlat((bool)1); | 155 | keycolor_button->setFlat((bool)1); |
155 | |||
156 | config.setGroup("colors"); | ||
157 | color = config.readListEntry("keycolor", QChar(',')); | 156 | color = config.readListEntry("keycolor", QChar(',')); |
157 | /* | ||
158 | * hopefully not required | ||
159 | |||
158 | if (color.isEmpty()) { | 160 | if (color.isEmpty()) { |
159 | color = QStringList::split(",", "240,240,240"); | 161 | color = QStringList::split(",", "240,240,240"); |
160 | config.writeEntry("keycolor", color.join(",")); | 162 | config.writeEntry("keycolor", color.join(",")); |
161 | 163 | ||
162 | } | 164 | } |
163 | key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 165 | */ |
166 | keycolor_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
164 | 167 | ||
165 | 168 | ||
166 | label = new QLabel(tr("Key Pressed Color"), color_box); | 169 | label = new QLabel(tr("Key Pressed Color"), color_box); |
167 | QPushButton *button = new QPushButton(color_box); | 170 | keycolor_pressed_button = new QPushButton(color_box); |
168 | button->setFlat((bool)1); | 171 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
172 | keycolor_pressed_button->setFlat((bool)1); | ||
173 | color = config.readListEntry("keycolor_pressed", QChar(',')); | ||
174 | keycolor_pressed_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
175 | |||
169 | label = new QLabel(tr("Line Color"), color_box); | 176 | label = new QLabel(tr("Line Color"), color_box); |
170 | button = new QPushButton(color_box); | 177 | keycolor_lines_button = new QPushButton(color_box); |
171 | button->setFlat((bool)1); | 178 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
179 | keycolor_lines_button->setFlat((bool)1); | ||
180 | color = config.readListEntry("keycolor_lines", QChar(',')); | ||
181 | keycolor_lines_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
182 | |||
183 | |||
172 | label = new QLabel(tr("Text Color"), color_box); | 184 | label = new QLabel(tr("Text Color"), color_box); |
173 | button = new QPushButton(color_box); | 185 | textcolor_button = new QPushButton(color_box); |
174 | button->setFlat((bool)1); | 186 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
187 | textcolor_button->setFlat((bool)1); | ||
188 | color = config.readListEntry("textcolor", QChar(',')); | ||
189 | textcolor_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
190 | |||
175 | 191 | ||
176 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 192 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
177 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 193 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
178 | 194 | ||
179 | } | 195 | } |
180 | 196 | ||
@@ -193,20 +209,21 @@ void ConfigDlg::repeatTog() { | |||
193 | config.setGroup ("general"); | 209 | config.setGroup ("general"); |
194 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed | 210 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed |
195 | 211 | ||
196 | emit repeatToggled(repeat_button->isChecked()); | 212 | emit repeatToggled(repeat_button->isChecked()); |
197 | } | 213 | } |
198 | 214 | ||
215 | // ConfigDlg::setMap {{{1 | ||
216 | |||
199 | /* | 217 | /* |
200 | * the index is kinda screwy, because in the config file, index 0 is just the | 218 | * the index is kinda screwy, because in the config file, index 0 is just the |
201 | * first element in the QStringList, but here it's the "Current Language" | 219 | * first element in the QStringList, but here it's the "Current Language" |
202 | * listItem. therefor you have to minus one to the index before you access it. | 220 | * listItem. therefor you have to minus one to the index before you access it. |
203 | * | 221 | * |
204 | */ | 222 | */ |
205 | 223 | ||
206 | // ConfigDlg::setMap {{{1 | ||
207 | void ConfigDlg::setMap(int index) { | 224 | void ConfigDlg::setMap(int index) { |
208 | 225 | ||
209 | if (index == 0) { | 226 | if (index == 0) { |
210 | 227 | ||
211 | remove_button->setDisabled(true); | 228 | remove_button->setDisabled(true); |
212 | emit setMapToDefault(); | 229 | emit setMapToDefault(); |
@@ -256,14 +273,22 @@ void ConfigDlg::removeMap() { | |||
256 | // write the changes | 273 | // write the changes |
257 | Config config ("multikey"); | 274 | Config config ("multikey"); |
258 | config.setGroup("keymaps"); | 275 | config.setGroup("keymaps"); |
259 | config.writeEntry("maps", custom_maps, QChar('|')); | 276 | config.writeEntry("maps", custom_maps, QChar('|')); |
260 | } | 277 | } |
261 | 278 | ||
262 | // ConfigDlg::color {{{1 | 279 | /* ConfigDlg::slots for the color buttons {{{1 |
263 | void ConfigDlg::keyColorButtonClicked() { | 280 | * |
281 | * these four slots are almost the same, except for the names. i was thinking | ||
282 | * of making a map with pointers to the buttons and names of the configEntry | ||
283 | * so it could be one slot, but then there would be no way of telling which | ||
284 | * of the buttons was clicked if they all connect to the same slot. | ||
285 | * | ||
286 | */ | ||
287 | |||
288 | void ConfigDlg::keyColorClicked() { | ||
264 | 289 | ||
265 | Config config ("multikey"); | 290 | Config config ("multikey"); |
266 | config.setGroup ("colors"); | 291 | config.setGroup ("colors"); |
267 | 292 | ||
268 | QStringList color = config.readListEntry("keycolor", QChar(',')); | 293 | QStringList color = config.readListEntry("keycolor", QChar(',')); |
269 | 294 | ||
@@ -273,9 +298,66 @@ void ConfigDlg::keyColorButtonClicked() { | |||
273 | color[1].setNum(newcolor.green()); | 298 | color[1].setNum(newcolor.green()); |
274 | color[2].setNum(newcolor.blue()); | 299 | color[2].setNum(newcolor.blue()); |
275 | 300 | ||
276 | config.writeEntry("keycolor", color, QChar(',')); | 301 | config.writeEntry("keycolor", color, QChar(',')); |
277 | config.write(); | 302 | config.write(); |
278 | 303 | ||
279 | key_color_button->setBackgroundColor(newcolor); | 304 | keycolor_button->setBackgroundColor(newcolor); |
305 | emit reloadKeyboard(); | ||
306 | } | ||
307 | void ConfigDlg::keyColorPressedClicked() { | ||
308 | |||
309 | Config config ("multikey"); | ||
310 | config.setGroup ("colors"); | ||
311 | |||
312 | QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); | ||
313 | |||
314 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
315 | |||
316 | color[0].setNum(newcolor.red()); | ||
317 | color[1].setNum(newcolor.green()); | ||
318 | color[2].setNum(newcolor.blue()); | ||
319 | |||
320 | config.writeEntry("keycolor_pressed", color, QChar(',')); | ||
321 | config.write(); | ||
322 | |||
323 | keycolor_pressed_button->setBackgroundColor(newcolor); | ||
324 | emit reloadKeyboard(); | ||
325 | } | ||
326 | void ConfigDlg::keyColorLinesClicked() { | ||
327 | |||
328 | Config config ("multikey"); | ||
329 | config.setGroup ("colors"); | ||
330 | |||
331 | QStringList color = config.readListEntry("keycolor_lines", QChar(',')); | ||
332 | |||
333 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
334 | |||
335 | color[0].setNum(newcolor.red()); | ||
336 | color[1].setNum(newcolor.green()); | ||
337 | color[2].setNum(newcolor.blue()); | ||
338 | |||
339 | config.writeEntry("keycolor_lines", color, QChar(',')); | ||
340 | config.write(); | ||
341 | |||
342 | keycolor_lines_button->setBackgroundColor(newcolor); | ||
343 | emit reloadKeyboard(); | ||
344 | } | ||
345 | void ConfigDlg::textColorClicked() { | ||
346 | |||
347 | Config config ("multikey"); | ||
348 | config.setGroup ("colors"); | ||
349 | |||
350 | QStringList color = config.readListEntry("textcolor", QChar(',')); | ||
351 | |||
352 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | ||
353 | |||
354 | color[0].setNum(newcolor.red()); | ||
355 | color[1].setNum(newcolor.green()); | ||
356 | color[2].setNum(newcolor.blue()); | ||
357 | |||
358 | config.writeEntry("textcolor", color, QChar(',')); | ||
359 | config.write(); | ||
360 | |||
361 | textcolor_button->setBackgroundColor(newcolor); | ||
280 | emit reloadKeyboard(); | 362 | emit reloadKeyboard(); |
281 | } | 363 | } |
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h index a000e60..5d6403f 100644 --- a/inputmethods/multikey/configdlg.h +++ b/inputmethods/multikey/configdlg.h | |||
@@ -26,13 +26,16 @@ private slots: | |||
26 | void repeatTog(); | 26 | void repeatTog(); |
27 | void setMap(int index); | 27 | void setMap(int index); |
28 | void addMap(); | 28 | void addMap(); |
29 | void removeMap(); | 29 | void removeMap(); |
30 | 30 | ||
31 | // all those required slots for the color push buttons | 31 | // all those required slots for the color push buttons |
32 | void keyColorButtonClicked(); | 32 | void keyColorClicked(); |
33 | void keyColorPressedClicked(); | ||
34 | void keyColorLinesClicked(); | ||
35 | void textColorClicked(); | ||
33 | 36 | ||
34 | private: | 37 | private: |
35 | QCheckBox *pick_button; | 38 | QCheckBox *pick_button; |
36 | QCheckBox *repeat_button; | 39 | QCheckBox *repeat_button; |
37 | QListBox *keymaps; | 40 | QListBox *keymaps; |
38 | QPushButton *add_button; | 41 | QPushButton *add_button; |
@@ -40,11 +43,14 @@ private: | |||
40 | 43 | ||
41 | 44 | ||
42 | QStringList default_maps; // the maps in your share/multikey/ dir | 45 | QStringList default_maps; // the maps in your share/multikey/ dir |
43 | QStringList custom_maps; // maps you added with the 'add' button | 46 | QStringList custom_maps; // maps you added with the 'add' button |
44 | 47 | ||
45 | /* color buttons */ | 48 | /* color buttons */ |
46 | QPushButton *key_color_button; | 49 | QPushButton *keycolor_button; |
50 | QPushButton *keycolor_pressed_button; | ||
51 | QPushButton *keycolor_lines_button; | ||
52 | QPushButton *textcolor_button; | ||
47 | 53 | ||
48 | }; | 54 | }; |
49 | 55 | ||
50 | #endif | 56 | #endif |