summaryrefslogtreecommitdiff
path: root/inputmethods/multikey
authorhash <hash>2002-08-19 20:06:41 (UTC)
committer hash <hash>2002-08-19 20:06:41 (UTC)
commit5c057c7040fe0669a159173f07793c7f28c95477 (patch) (unidiff)
tree42d9dcd632c296566a3b973c2f724593c822f57a /inputmethods/multikey
parentfc58f8b2dea3629fdd486852b74e425a3da29b52 (diff)
downloadopie-5c057c7040fe0669a159173f07793c7f28c95477.zip
opie-5c057c7040fe0669a159173f07793c7f28c95477.tar.gz
opie-5c057c7040fe0669a159173f07793c7f28c95477.tar.bz2
made all the rest of the color buttons work...
Diffstat (limited to 'inputmethods/multikey') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp114
-rw-r--r--inputmethods/multikey/configdlg.h10
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
@@ -138,81 +138,98 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
138 /* 138 /*
139 * 'color' tab 139 * 'color' tab
140 */ 140 */
141 141
142 QGrid *color_box = new QGrid(2, this); 142 QGrid *color_box = new QGrid(2, this);
143 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 143 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
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
181void ConfigDlg::pickTog() { 197void ConfigDlg::pickTog() {
182 198
183 Config config ("multikey"); 199 Config config ("multikey");
184 config.setGroup ("general"); 200 config.setGroup ("general");
185 config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed 201 config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed
186 202
187 emit pickboardToggled(pick_button->isChecked()); 203 emit pickboardToggled(pick_button->isChecked());
188} 204}
189 205
190void ConfigDlg::repeatTog() { 206void ConfigDlg::repeatTog() {
191 207
192 Config config ("multikey"); 208 Config config ("multikey");
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
207void ConfigDlg::setMap(int index) { 224void 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();
213 } 230 }
214 else if ((uint)index <= default_maps.count()) { 231 else if ((uint)index <= default_maps.count()) {
215 232
216 remove_button->setDisabled(true); 233 remove_button->setDisabled(true);
217 emit setMapToFile(keymaps->text(index)); 234 emit setMapToFile(keymaps->text(index));
218 235
@@ -250,32 +267,97 @@ void ConfigDlg::removeMap() {
250 keymaps->setSelected(keymaps->currentItem() - 1, true); 267 keymaps->setSelected(keymaps->currentItem() - 1, true);
251 // delete the next selected item cus you just moved it up 268 // delete the next selected item cus you just moved it up
252 keymaps->removeItem(keymaps->currentItem() + 1); 269 keymaps->removeItem(keymaps->currentItem() + 1);
253 270
254 custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); 271 custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]);
255 272
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
263void 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
288void 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
270 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 295 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
271 296
272 color[0].setNum(newcolor.red()); 297 color[0].setNum(newcolor.red());
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}
307void 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}
326void 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}
345void 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
@@ -20,31 +20,37 @@ signals:
20 void setMapToDefault(); 20 void setMapToDefault();
21 void setMapToFile(QString map); 21 void setMapToFile(QString map);
22 void reloadKeyboard(); 22 void reloadKeyboard();
23 23
24private slots: 24private slots:
25 void pickTog(); 25 void pickTog();
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
34private: 37private:
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;
39 QPushButton *remove_button; 42 QPushButton *remove_button;
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