summaryrefslogtreecommitdiff
path: root/inputmethods
Unidiff
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp18
-rw-r--r--inputmethods/multikey/configdlg.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 52c498b..24fdb7f 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -22,197 +22,199 @@
22#include <qvbox.h> 22#include <qvbox.h>
23#include <qgrid.h> 23#include <qgrid.h>
24#include <qgroupbox.h> 24#include <qgroupbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qsizepolicy.h> 27#include <qsizepolicy.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlistbox.h> 29#include <qlistbox.h>
30#include <qstringlist.h> 30#include <qstringlist.h>
31#include <qtoolbutton.h> 31#include <qtoolbutton.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include "configdlg.h" 34#include "configdlg.h"
35#include "keyboard.h" 35#include "keyboard.h"
36 36
37using namespace Opie; 37using namespace Opie;
38using namespace Opie::Ui; 38using namespace Opie::Ui;
39// ConfigDlg::ConfigDlg() {{{1 39// ConfigDlg::ConfigDlg() {{{1
40ConfigDlg::ConfigDlg () : QDialog () 40ConfigDlg::ConfigDlg () : QDialog ()
41{ 41{
42 setCaption( tr("Multikey Configuration") ); 42 setCaption( tr("Multikey Configuration") );
43 Config config ("multikey"); 43 Config config ("multikey");
44 config.setGroup("keymaps"); 44 config.setGroup("keymaps");
45 QString current_map = config.readEntry("current", 0); 45 QString current_map = config.readEntry("current", 0);
46 46
47 /* 47 /*
48 * 'general config' tab 48 * 'general config' tab
49 */ 49 */
50 50
51 QVBoxLayout *base_lay = new QVBoxLayout(this); 51 QVBoxLayout *base_lay = new QVBoxLayout(this);
52 52
53 QTabWidget *tabs = new QTabWidget(this, "tabs"); 53 QTabWidget *tabs = new QTabWidget(this, "tabs");
54 54
55 QWidget *gen_box = new QWidget(tabs, "gen_tab"); 55 QWidget *gen_box = new QWidget(tabs, "gen_tab");
56 QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); 56 QVBoxLayout *gen_lay = new QVBoxLayout(gen_box);
57 gen_lay->setMargin(3); 57 gen_lay->setMargin(3);
58 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); 58 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box);
59 59
60 QHBox *hbox1 = new QHBox(map_group); 60 QHBox *hbox1 = new QHBox(map_group);
61 keymaps = new QListBox(hbox1); 61 keymaps = new QListBox(hbox1);
62 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 62 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
63 QVBox *vbox1 = new QVBox(hbox1); 63 QVBox *vbox1 = new QVBox(hbox1);
64 64
65 QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); 65 QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up"));
66 tb1->setUsesBigPixmap( qApp->desktop()->size().width() > 330 ); 66 tb1->setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
67 tb1->setPixmap(Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon)); 67 tb1->setPixmap(Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon));
68 tb1->setAutoRaise(TRUE); 68 tb1->setAutoRaise(TRUE);
69 tb1->setFocusPolicy(QWidget::NoFocus); 69 tb1->setFocusPolicy(QWidget::NoFocus);
70 tb1->setToggleButton(FALSE); 70 tb1->setToggleButton(FALSE);
71 connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); 71 connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp()));
72 72
73 QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); 73 QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down"));
74 tb2->setUsesBigPixmap( qApp->desktop()->size().width() > 330 ); 74 tb2->setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
75 tb2->setPixmap(Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon)); 75 tb2->setPixmap(Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon));
76 tb2->setAutoRaise(TRUE); 76 tb2->setAutoRaise(TRUE);
77 tb2->setFocusPolicy(QWidget::NoFocus); 77 tb2->setFocusPolicy(QWidget::NoFocus);
78 tb2->setToggleButton(FALSE); 78 tb2->setToggleButton(FALSE);
79 connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); 79 connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown()));
80 80
81 QString cur(tr("Current Language")); 81 QString cur(tr("Current Language"));
82 keymaps->insertItem(cur); 82 keymaps->insertItem(cur);
83 keymaps->setSelected(0, true); 83 keymaps->setSelected(0, true);
84 84
85 QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); 85 QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap");
86 default_maps = map_dir.entryList(); // so i can access it in other places 86 default_maps = map_dir.entryList(); // so the object can access keymaps in other places
87 custom_maps = config.readListEntry("maps", QChar('|')); 87 custom_maps = config.readListEntry("maps", QChar('|'));
88 sw_maps = ConfigDlg::loadSw(); 88 sw_maps = ConfigDlg::loadSw();
89 89
90 QStringList sw_copy(sw_maps); 90 QStringList sw_copy(sw_maps);
91 for (uint i = 0; i < sw_copy.count(); i++) { 91 for (uint i = 0; i < sw_copy.count(); i++) {
92 92
93 QString keymap_map; 93 QString keymap_map;
94 if (sw_copy[i][0] != '/') { /* share/multikey */ 94 if (sw_copy[i][0] != '/') { /* share/multikey */
95 95
96 keymap_map = map_dir.absPath() + "/" + sw_copy[i]; 96 keymap_map = map_dir.absPath() + "/" + sw_copy[i];
97 } else { 97 } else {
98 98
99 if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) 99 if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false)
100 || !QFile::exists(sw_copy[i])) { 100 || !QFile::exists(sw_copy[i])) {
101 101
102 custom_maps.remove(sw_copy[i]); 102 custom_maps.remove(sw_copy[i]);
103 sw_maps.remove(sw_copy[i]); 103 sw_maps.remove(sw_copy[i]);
104 104
105 // remove it from the list too 105 // remove it from the list too
106 config.writeEntry("maps", custom_maps.join("|")); 106 config.writeEntry("maps", custom_maps.join("|"));
107 107
108 continue; 108 continue;
109 } 109 }
110 keymap_map = sw_copy[i]; 110 keymap_map = sw_copy[i];
111 } 111 }
112 112
113 QFile map(keymap_map); 113 QFile map(keymap_map);
114 if (map.open(IO_ReadOnly)) { 114 if (map.open(IO_ReadOnly)) {
115 115
116 QString line; bool found = 0; 116 QString line; bool found = 0;
117 117
118 map.readLine(line, 1024); 118 map.readLine(line, 1024);
119 while (!map.atEnd()) { 119 while (!map.atEnd()) {
120 120
121 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 121 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
122 122
123 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 123 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
124 found = 1; 124 found = 1;
125 break; 125 break;
126 } 126 }
127 map.readLine(line, 1024); 127 map.readLine(line, 1024);
128 } 128 }
129 if (!found) 129 if (!found)
130 keymaps->insertItem(keymap_map); 130 keymaps->insertItem(keymap_map);
131 131
132 map.close(); 132 map.close();
133 } 133 }
134 134
135 if (keymap_map == current_map) { 135 if (keymap_map == current_map) {
136 keymaps->setSelected(i + 1, true); 136 keymaps->setSelected(i + 1, true);
137 } 137 }
138 } 138 }
139 139
140 // have to "+1" because the "current language" listItem... remember? 140 // have to "+1" because the "current language" listItem... remember?
141 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); 141 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int)));
142 142
143 QGrid *add_remove_grid = new QGrid(2, map_group); 143 QGrid *add_remove_grid = new QGrid(2, map_group);
144 add_remove_grid->setMargin(3); 144 add_remove_grid->setMargin(3);
145 add_remove_grid->setSpacing(3); 145 add_remove_grid->setSpacing(3);
146 146
147 add_button = new QPushButton(tr("Add"), add_remove_grid); 147 add_button = new QPushButton(tr("Add keymap..."), add_remove_grid);
148 add_button->setFlat(TRUE); 148 add_button->setFlat(TRUE);
149 connect(add_button, SIGNAL(clicked()), SLOT(addMap())); 149 connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
150 150
151 remove_button = new QPushButton(tr("Remove"), add_remove_grid); 151 remove_button = new QPushButton(tr("Remove keymap"), add_remove_grid);
152 remove_button->setFlat(TRUE); 152 remove_button->setFlat(TRUE);
153 if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) 153 if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) {
154 remove_button->setDisabled(true); 154 remove_button->setDisabled(true);
155 remove_button->hide();
156 }
155 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); 157 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
156 158
157 gen_lay->addWidget(map_group); 159 gen_lay->addWidget(map_group);
158 160
159 // make a box that will contain the buttons on the bottom 161 // make a box that will contain the buttons on the bottom
160 QGrid *other_grid = new QGrid(2, gen_box); 162 QGrid *other_grid = new QGrid(2, gen_box);
161 pick_button = new QCheckBox(tr("Pickboard"), other_grid); 163 pick_button = new QCheckBox(tr("Pickboard"), other_grid);
162 164
163 config.setGroup ("general"); 165 config.setGroup ("general");
164 bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed 166 bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed
165 if (pick_open) { 167 if (pick_open) {
166 168
167 pick_button->setChecked(true); 169 pick_button->setChecked(true);
168 } 170 }
169 171
170 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); 172 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid);
171 bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); 173 bool repeat_on = config.readBoolEntry ("useRepeat", TRUE);
172 174
173 if (repeat_on) { 175 if (repeat_on) {
174 176
175 repeat_button->setChecked(true); 177 repeat_button->setChecked(true);
176 } 178 }
177 179
178 gen_lay->addWidget(other_grid); 180 gen_lay->addWidget(other_grid);
179 tabs->addTab(gen_box, tr("General Settings")); 181 tabs->addTab(gen_box, tr("General Settings"));
180 182
181 /* 183 /*
182 * 'color' tab 184 * 'color' tab
183 */ 185 */
184 186
185 QWidget *color_box = new QWidget(tabs, "color_tab"); 187 QWidget *color_box = new QWidget(tabs, "color_tab");
186 188
187 QGridLayout *color_lay = new QGridLayout(color_box); 189 QGridLayout *color_lay = new QGridLayout(color_box);
188 QGrid *color_grid = new QGrid(2, color_box); 190 QGrid *color_grid = new QGrid(2, color_box);
189 color_lay->setAlignment(Qt::AlignTop); 191 color_lay->setAlignment(Qt::AlignTop);
190 color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 192 color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
191 color_grid->layout()->setAlignment(Qt::AlignTop); 193 color_grid->layout()->setAlignment(Qt::AlignTop);
192 color_grid->setMargin(3); 194 color_grid->setMargin(3);
193 color_grid->setSpacing(3); 195 color_grid->setSpacing(3);
194 196
195 QLabel *label; 197 QLabel *label;
196 QStringList color; 198 QStringList color;
197 config.setGroup("colors"); 199 config.setGroup("colors");
198 200
199 label = new QLabel(tr("Key Color"), color_grid); 201 label = new QLabel(tr("Key Color"), color_grid);
200 keycolor_button = new QPushButton(color_grid); 202 keycolor_button = new QPushButton(color_grid);
201 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); 203 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked()));
202 keycolor_button->setFlat(TRUE); 204 keycolor_button->setFlat(TRUE);
203 color = config.readListEntry("keycolor", QChar(',')); 205 color = config.readListEntry("keycolor", QChar(','));
204 /* 206 /*
205 * hopefully not required 207 * hopefully not required
206 208
207 if (color.isEmpty()) { 209 if (color.isEmpty()) {
208 color = QStringList::split(",", "240,240,240"); 210 color = QStringList::split(",", "240,240,240");
209 config.writeEntry("keycolor", color.join(",")); 211 config.writeEntry("keycolor", color.join(","));
210 212
211 } 213 }
212 */ 214 */
213 keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); 215 keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())));
214 216
215 217
216 label = new QLabel(tr("Key Pressed Color"), color_grid); 218 label = new QLabel(tr("Key Pressed Color"), color_grid);
217 keycolor_pressed_button = new QPushButton(color_grid); 219 keycolor_pressed_button = new QPushButton(color_grid);
218 connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); 220 connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked()));
@@ -244,192 +246,196 @@ ConfigDlg::ConfigDlg () : QDialog ()
244 color_lay->addItem(spacer); 246 color_lay->addItem(spacer);
245 247
246 tabs->addTab(color_box, tr("Colors")); 248 tabs->addTab(color_box, tr("Colors"));
247 base_lay->addWidget(tabs); 249 base_lay->addWidget(tabs);
248} 250}
249 251
250QStringList ConfigDlg::loadSw() 252QStringList ConfigDlg::loadSw()
251{ 253{
252 Config *config = new Config("multikey"); 254 Config *config = new Config("multikey");
253 config->setGroup("keymaps"); 255 config->setGroup("keymaps");
254 QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); 256 QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap");
255 QStringList d_maps = map_dir.entryList(); // so i can access it in other places 257 QStringList d_maps = map_dir.entryList(); // so i can access it in other places
256 QStringList c_maps = config->readListEntry("maps", QChar('|')); 258 QStringList c_maps = config->readListEntry("maps", QChar('|'));
257 QStringList s_maps = config->readListEntry("sw", QChar('|')); 259 QStringList s_maps = config->readListEntry("sw", QChar('|'));
258 delete config; 260 delete config;
259 261
260 if (!s_maps.count()) 262 if (!s_maps.count())
261 { 263 {
262 s_maps = d_maps+c_maps; 264 s_maps = d_maps+c_maps;
263 } 265 }
264 else 266 else
265 { 267 {
266 /* Clear non existents entries */ 268 /* Clear non existents entries */
267 QStringList s_copy(s_maps); 269 QStringList s_copy(s_maps);
268 for (uint i = 0; i < s_copy.count(); ++i) { 270 for (uint i = 0; i < s_copy.count(); ++i) {
269 if (d_maps.find(s_copy[i]) == d_maps.end() 271 if (d_maps.find(s_copy[i]) == d_maps.end()
270 && c_maps.find(s_copy[i]) == c_maps.end()) { 272 && c_maps.find(s_copy[i]) == c_maps.end()) {
271 s_maps.remove(s_copy[i]); 273 s_maps.remove(s_copy[i]);
272 } 274 }
273 } 275 }
274 /* Update sw_maps from default_maps */ 276 /* Update sw_maps from default_maps */
275 for (uint i = 0; i < d_maps.count(); ++i) { 277 for (uint i = 0; i < d_maps.count(); ++i) {
276 if (s_maps.find(d_maps[i]) == s_maps.end()) { 278 if (s_maps.find(d_maps[i]) == s_maps.end()) {
277 s_maps.append(d_maps[i]); 279 s_maps.append(d_maps[i]);
278 } 280 }
279 } 281 }
280 /* Update sw_maps from custom_maps */ 282 /* Update sw_maps from custom_maps */
281 for (uint i = 0; i < c_maps.count(); ++i) { 283 for (uint i = 0; i < c_maps.count(); ++i) {
282 if (s_maps.find(c_maps[i]) == s_maps.end()) { 284 if (s_maps.find(c_maps[i]) == s_maps.end()) {
283 s_maps.append(c_maps[i]); 285 s_maps.append(c_maps[i]);
284 } 286 }
285 } 287 }
286 } 288 }
287 289
288 return s_maps; 290 return s_maps;
289} 291}
290 292
291void ConfigDlg::accept() 293void ConfigDlg::accept()
292{ 294{
293 /* Writing all stuffs to config */ 295 /* Writing all stuffs to config */
294 Config *config = new Config("multikey"); 296 Config *config = new Config("multikey");
295 config->setGroup("general"); 297 config->setGroup("general");
296 config->writeEntry("usePickboard", pick_button->isChecked()); // default closed 298 config->writeEntry("usePickboard", pick_button->isChecked()); // default closed
297 config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed 299 config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed
298 300
299 config->setGroup("keymaps"); 301 config->setGroup("keymaps");
300 config->writeEntry("sw", sw_maps, QChar('|')); 302 config->writeEntry("sw", sw_maps, QChar('|'));
301 config->writeEntry("maps", custom_maps, QChar('|')); 303 config->writeEntry("maps", custom_maps, QChar('|'));
302 delete config; 304 delete config;
303 305
304 int index = keymaps->currentItem(); 306 int index = keymaps->currentItem();
305 if (index == 0) { 307 if (index == 0) {
306 308
307 remove_button->setDisabled(true); 309 remove_button->setDisabled(true);
310 remove_button->hide();
308 emit setMapToDefault(); 311 emit setMapToDefault();
309 } 312 }
310 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { 313 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) {
311 314
312 remove_button->setDisabled(true); 315 remove_button->setDisabled(true);
316 remove_button->hide();
313 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); 317 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]);
314 318
315 } else { 319 } else {
316 320 remove_button->show();
317 remove_button->setEnabled(true); 321 remove_button->setEnabled(true);
318 emit setMapToFile(sw_maps[index - 1]); 322 emit setMapToFile(sw_maps[index - 1]);
319 } 323 }
320 324
321 emit pickboardToggled(pick_button->isChecked()); 325 emit pickboardToggled(pick_button->isChecked());
322 emit repeatToggled(repeat_button->isChecked()); 326 emit repeatToggled(repeat_button->isChecked());
323 emit reloadSw(); 327 emit reloadSw();
324 328
325 QDialog::accept(); 329 QDialog::accept();
326 emit configDlgClosed(); 330 emit configDlgClosed();
327} 331}
328 332
329void ConfigDlg::moveSelectedUp() 333void ConfigDlg::moveSelectedUp()
330{ 334{
331 int i = keymaps->currentItem(); 335 int i = keymaps->currentItem();
332 /* Ignore Current Language */ 336 /* Ignore Current Language */
333 if (i > 1) { 337 if (i > 1) {
334 QString t = sw_maps[i-1]; 338 QString t = sw_maps[i-1];
335 sw_maps[i-1] = sw_maps[i-2]; 339 sw_maps[i-1] = sw_maps[i-2];
336 sw_maps[i-2] = t; 340 sw_maps[i-2] = t;
337 341
338 QString item = keymaps->currentText(); 342 QString item = keymaps->currentText();
339 keymaps->removeItem(i); 343 keymaps->removeItem(i);
340 keymaps->insertItem(item, i-1); 344 keymaps->insertItem(item, i-1);
341 keymaps->setCurrentItem(i-1); 345 keymaps->setCurrentItem(i-1);
342 } 346 }
343} 347}
344 348
345void ConfigDlg::moveSelectedDown() 349void ConfigDlg::moveSelectedDown()
346{ 350{
347 int i = keymaps->currentItem(); 351 int i = keymaps->currentItem();
348 /* Ignore Current Language */ 352 /* Ignore Current Language */
349 if (i > 0 && i < (int)keymaps->count() - 1) { 353 if (i > 0 && i < (int)keymaps->count() - 1) {
350 QString t = sw_maps[i-1]; 354 QString t = sw_maps[i-1];
351 sw_maps[i-1] = sw_maps[i]; 355 sw_maps[i-1] = sw_maps[i];
352 sw_maps[i] = t; 356 sw_maps[i] = t;
353 357
354 QString item = keymaps->currentText(); 358 QString item = keymaps->currentText();
355 keymaps->removeItem(i); 359 keymaps->removeItem(i);
356 keymaps->insertItem(item, i+1); 360 keymaps->insertItem(item, i+1);
357 keymaps->setCurrentItem(i+1); 361 keymaps->setCurrentItem(i+1);
358 } 362 }
359} 363}
360 364
361void ConfigDlg::closeEvent(QCloseEvent *) { 365void ConfigDlg::closeEvent(QCloseEvent *) {
362 366
363 // tell the parent it was closed, so delete me 367 // tell the parent it was closed, so delete me
364 emit configDlgClosed(); 368 emit configDlgClosed();
365} 369}
366 370
367void ConfigDlg::setMap(int index) { 371void ConfigDlg::setMap(int index) {
368 372
369 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) { 373 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) {
370 remove_button->setDisabled(true); 374 remove_button->setDisabled(true);
375 remove_button->hide();
371 } else { 376 } else {
377 remove_button->show();
372 remove_button->setEnabled(true); 378 remove_button->setEnabled(true);
373 } 379 }
374} 380}
375 381
376// ConfigDlg::addMap() {{{1 382// ConfigDlg::addMap() {{{1
377void ConfigDlg::addMap() { 383void ConfigDlg::addMap() {
378 384
379 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 385 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
380 386
381 if (map.isNull()) return; 387 if (map.isNull()) return;
382 388
383 Config config ("multikey"); 389 Config config ("multikey");
384 config.setGroup("keymaps"); 390 config.setGroup("keymaps");
385 QStringList maps = config.readListEntry("maps", QChar('|')); 391 QStringList maps = config.readListEntry("maps", QChar('|'));
386 maps.append(map); 392 maps.append(map);
387 custom_maps.append(map); 393 custom_maps.append(map);
388 if (sw_maps.find(map) == sw_maps.end()) 394 if (sw_maps.find(map) == sw_maps.end())
389 sw_maps.append(map); 395 sw_maps.append(map);
390 396
391 QFile map_file (map); 397 QFile map_file (map);
392 if (map_file.open(IO_ReadOnly)) { 398 if (map_file.open(IO_ReadOnly)) {
393 399
394 QString line; bool found = 0; 400 QString line; bool found = 0;
395 401
396 map_file.readLine(line, 1024); 402 map_file.readLine(line, 1024);
397 while (!map_file.atEnd()) { 403 while (!map_file.atEnd()) {
398 404
399 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 405 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
400 406
401 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 407 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
402 found = 1; 408 found = 1;
403 break; 409 break;
404 } 410 }
405 map_file.readLine(line, 1024); 411 map_file.readLine(line, 1024);
406 } 412 }
407 if (!found) keymaps->insertItem(map); 413 if (!found) keymaps->insertItem(map);
408 414
409 map_file.close(); 415 map_file.close();
410 } 416 }
411 417
412 keymaps->setSelected(keymaps->count() - 1, true); 418 keymaps->setSelected(keymaps->count() - 1, true);
413} 419}
414 420
415// ConfigDlg::removeMap() {{{1 421// ConfigDlg::removeMap() {{{1
416void ConfigDlg::removeMap() { 422void ConfigDlg::removeMap() {
417 423
418 // move selection up one 424 // move selection up one
419 keymaps->setSelected(keymaps->currentItem() - 1, true); 425 keymaps->setSelected(keymaps->currentItem() - 1, true);
420 // delete the next selected item cus you just moved it up 426 // delete the next selected item cus you just moved it up
421 keymaps->removeItem(keymaps->currentItem() + 1); 427 keymaps->removeItem(keymaps->currentItem() + 1);
422 428
423 custom_maps.remove(sw_maps[keymaps->currentItem()]); 429 custom_maps.remove(sw_maps[keymaps->currentItem()]);
424 sw_maps.remove(sw_maps.at(keymaps->currentItem())); 430 sw_maps.remove(sw_maps.at(keymaps->currentItem()));
425} 431}
426 432
427/* ConfigDlg::slots for the color buttons {{{1 433/* ConfigDlg::slots for the color buttons {{{1
428 * 434 *
429 * these four slots are almost the same, except for the names. i was thinking 435 * these four slots are almost the same, except for the names. i was thinking
430 * of making a map with pointers to the buttons and names of the configEntry 436 * of making a map with pointers to the buttons and names of the configEntry
431 * so it could be one slot, but then there would be no way of telling which 437 * so it could be one slot, but then there would be no way of telling which
432 * of the buttons was clicked if they all connect to the same slot. 438 * of the buttons was clicked if they all connect to the same slot.
433 * 439 *
434 */ 440 */
435 441
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h
index 8e96e9b..f900a14 100644
--- a/inputmethods/multikey/configdlg.h
+++ b/inputmethods/multikey/configdlg.h
@@ -1,65 +1,65 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6 6
7#ifndef CONFIGDLG_H 7#ifndef CONFIGDLG_H
8#define CONFIGDLG_H 8#define CONFIGDLG_H
9 9
10class ConfigDlg : public QDialog 10class ConfigDlg : public QDialog
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 ConfigDlg (); 15 ConfigDlg ();
16 static QStringList loadSw(); 16 static QStringList loadSw();
17 17
18signals: 18signals:
19 void pickboardToggled(bool on_off); 19 void pickboardToggled(bool on_off);
20 void repeatToggled(bool on_off); 20 void repeatToggled(bool on_off);
21 void setMapToDefault(); 21 void setMapToDefault();
22 void setMapToFile(QString map); 22 void setMapToFile(QString map);
23 void reloadKeyboard(); 23 void reloadKeyboard();
24 void configDlgClosed(); 24 void configDlgClosed();
25 void reloadSw(); 25 void reloadSw();
26 26
27protected: 27protected:
28 virtual void accept(); 28 virtual void accept();
29 29
30protected slots: 30protected slots:
31 void moveSelectedUp(); 31 void moveSelectedUp();
32 void moveSelectedDown(); 32 void moveSelectedDown();
33 33
34private slots: 34private slots:
35 void setMap(int index); 35 void setMap(int index);
36 void addMap(); 36 void addMap();
37 void removeMap(); 37 void removeMap();
38 virtual void closeEvent ( QCloseEvent * ); 38 virtual void closeEvent ( QCloseEvent * );
39 39
40 // all those required slots for the color push buttons 40 // all those required slots for the color push buttons
41 void keyColorClicked(); 41 void keyColorClicked();
42 void keyColorPressedClicked(); 42 void keyColorPressedClicked();
43 void keyColorLinesClicked(); 43 void keyColorLinesClicked();
44 void textColorClicked(); 44 void textColorClicked();
45 45
46private: 46private:
47 QCheckBox *pick_button; 47 QCheckBox *pick_button;
48 QCheckBox *repeat_button; 48 QCheckBox *repeat_button;
49 QListBox *keymaps; 49 QListBox *keymaps;
50 QPushButton *add_button; 50 QPushButton *add_button;
51 QPushButton *remove_button; 51 QPushButton *remove_button;
52 52
53 QStringList default_maps; // the maps in your share/multikey/ dir 53 QStringList default_maps; // the maps in your share/multikey/ dir
54 QStringList custom_maps; // maps you added with the 'add' button 54 QStringList custom_maps; // maps you added with the 'add' button
55 QStringList sw_maps; // maps, which used in keyboard switch rotation ring 55 QStringList sw_maps; // maps used in keyboard switch rotation ring
56 56
57 /* color buttons */ 57 /* color buttons */
58 QPushButton *keycolor_button; 58 QPushButton *keycolor_button;
59 QPushButton *keycolor_pressed_button; 59 QPushButton *keycolor_pressed_button;
60 QPushButton *keycolor_lines_button; 60 QPushButton *keycolor_lines_button;
61 QPushButton *textcolor_button; 61 QPushButton *textcolor_button;
62 62
63}; 63};
64 64
65#endif 65#endif