Diffstat (limited to 'inputmethods/multikey/configdlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 1fba9bc..fe5051d 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -34,97 +34,97 @@ | |||
34 | #include "keyboard.h" | 34 | #include "keyboard.h" |
35 | 35 | ||
36 | using namespace Opie; | 36 | using namespace Opie; |
37 | using namespace Opie::Ui; | 37 | using namespace Opie::Ui; |
38 | // ConfigDlg::ConfigDlg() {{{1 | 38 | // ConfigDlg::ConfigDlg() {{{1 |
39 | ConfigDlg::ConfigDlg () : QDialog () | 39 | ConfigDlg::ConfigDlg () : QDialog () |
40 | { | 40 | { |
41 | setCaption( tr("Multikey Configuration") ); | 41 | setCaption( tr("Multikey Configuration") ); |
42 | Config config ("multikey"); | 42 | Config config ("multikey"); |
43 | config.setGroup("keymaps"); | 43 | config.setGroup("keymaps"); |
44 | QString current_map = config.readEntry("current", 0); | 44 | QString current_map = config.readEntry("current", 0); |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * 'general config' tab | 47 | * 'general config' tab |
48 | */ | 48 | */ |
49 | 49 | ||
50 | QVBoxLayout *base_lay = new QVBoxLayout(this); | 50 | QVBoxLayout *base_lay = new QVBoxLayout(this); |
51 | 51 | ||
52 | QTabWidget *tabs = new QTabWidget(this, "tabs"); | 52 | QTabWidget *tabs = new QTabWidget(this, "tabs"); |
53 | 53 | ||
54 | QWidget *gen_box = new QWidget(tabs, "gen_tab"); | 54 | QWidget *gen_box = new QWidget(tabs, "gen_tab"); |
55 | QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); | 55 | QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); |
56 | gen_lay->setMargin(3); | 56 | gen_lay->setMargin(3); |
57 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 57 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
58 | 58 | ||
59 | QHBox *hbox1 = new QHBox(map_group); | 59 | QHBox *hbox1 = new QHBox(map_group); |
60 | keymaps = new QListBox(hbox1); | 60 | keymaps = new QListBox(hbox1); |
61 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 61 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
62 | QVBox *vbox1 = new QVBox(hbox1); | 62 | QVBox *vbox1 = new QVBox(hbox1); |
63 | 63 | ||
64 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); | 64 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); |
65 | tb1->setPixmap(Resource::loadPixmap("up")); | 65 | tb1->setPixmap(Resource::loadPixmap("up")); |
66 | tb1->setAutoRaise(TRUE); | 66 | tb1->setAutoRaise(TRUE); |
67 | tb1->setFocusPolicy(QWidget::NoFocus); | 67 | tb1->setFocusPolicy(QWidget::NoFocus); |
68 | tb1->setToggleButton(FALSE); | 68 | tb1->setToggleButton(FALSE); |
69 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); | 69 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); |
70 | 70 | ||
71 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); | 71 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); |
72 | tb2->setPixmap(Resource::loadPixmap("down")); | 72 | tb2->setPixmap(Resource::loadPixmap("down")); |
73 | tb2->setAutoRaise(TRUE); | 73 | tb2->setAutoRaise(TRUE); |
74 | tb2->setFocusPolicy(QWidget::NoFocus); | 74 | tb2->setFocusPolicy(QWidget::NoFocus); |
75 | tb2->setToggleButton(FALSE); | 75 | tb2->setToggleButton(FALSE); |
76 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); | 76 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); |
77 | 77 | ||
78 | QString cur(tr("Current Language")); | 78 | QString cur(tr("Current Language")); |
79 | keymaps->insertItem(cur); | 79 | keymaps->insertItem(cur); |
80 | keymaps->setSelected(0, true); | 80 | keymaps->setSelected(0, true); |
81 | 81 | ||
82 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 82 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); |
83 | default_maps = map_dir.entryList(); // so i can access it in other places | 83 | default_maps = map_dir.entryList(); // so i can access it in other places |
84 | custom_maps = config.readListEntry("maps", QChar('|')); | 84 | custom_maps = config.readListEntry("maps", QChar('|')); |
85 | sw_maps = ConfigDlg::loadSw(); | 85 | sw_maps = ConfigDlg::loadSw(); |
86 | 86 | ||
87 | QStringList sw_copy(sw_maps); | 87 | QStringList sw_copy(sw_maps); |
88 | for (uint i = 0; i < sw_copy.count(); i++) { | 88 | for (uint i = 0; i < sw_copy.count(); i++) { |
89 | 89 | ||
90 | QString keymap_map; | 90 | QString keymap_map; |
91 | if (sw_copy[i][0] != '/') { /* share/multikey */ | 91 | if (sw_copy[i][0] != '/') { /* share/multikey */ |
92 | 92 | ||
93 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; | 93 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; |
94 | } else { | 94 | } else { |
95 | 95 | ||
96 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) | 96 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) |
97 | || !QFile::exists(sw_copy[i])) { | 97 | || !QFile::exists(sw_copy[i])) { |
98 | 98 | ||
99 | custom_maps.remove(sw_copy[i]); | 99 | custom_maps.remove(sw_copy[i]); |
100 | sw_maps.remove(sw_copy[i]); | 100 | sw_maps.remove(sw_copy[i]); |
101 | 101 | ||
102 | // remove it from the list too | 102 | // remove it from the list too |
103 | config.writeEntry("maps", custom_maps.join("|")); | 103 | config.writeEntry("maps", custom_maps.join("|")); |
104 | 104 | ||
105 | continue; | 105 | continue; |
106 | } | 106 | } |
107 | keymap_map = sw_copy[i]; | 107 | keymap_map = sw_copy[i]; |
108 | } | 108 | } |
109 | 109 | ||
110 | QFile map(keymap_map); | 110 | QFile map(keymap_map); |
111 | if (map.open(IO_ReadOnly)) { | 111 | if (map.open(IO_ReadOnly)) { |
112 | 112 | ||
113 | QString line; bool found = 0; | 113 | QString line; bool found = 0; |
114 | 114 | ||
115 | map.readLine(line, 1024); | 115 | map.readLine(line, 1024); |
116 | while (!map.atEnd()) { | 116 | while (!map.atEnd()) { |
117 | 117 | ||
118 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 118 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
119 | 119 | ||
120 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 120 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
121 | found = 1; | 121 | found = 1; |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | map.readLine(line, 1024); | 124 | map.readLine(line, 1024); |
125 | } | 125 | } |
126 | if (!found) | 126 | if (!found) |
127 | keymaps->insertItem(keymap_map); | 127 | keymaps->insertItem(keymap_map); |
128 | 128 | ||
129 | map.close(); | 129 | map.close(); |
130 | } | 130 | } |
@@ -203,97 +203,97 @@ ConfigDlg::ConfigDlg () : QDialog () | |||
203 | 203 | ||
204 | if (color.isEmpty()) { | 204 | if (color.isEmpty()) { |
205 | color = QStringList::split(",", "240,240,240"); | 205 | color = QStringList::split(",", "240,240,240"); |
206 | config.writeEntry("keycolor", color.join(",")); | 206 | config.writeEntry("keycolor", color.join(",")); |
207 | 207 | ||
208 | } | 208 | } |
209 | */ | 209 | */ |
210 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); | 210 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); |
211 | 211 | ||
212 | 212 | ||
213 | label = new QLabel(tr("Key Pressed Color"), color_grid); | 213 | label = new QLabel(tr("Key Pressed Color"), color_grid); |
214 | keycolor_pressed_button = new QPushButton(color_grid); | 214 | keycolor_pressed_button = new QPushButton(color_grid); |
215 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); | 215 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
216 | keycolor_pressed_button->setFlat(TRUE); | 216 | keycolor_pressed_button->setFlat(TRUE); |
217 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 217 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
218 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 218 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
219 | 219 | ||
220 | label = new QLabel(tr("Line Color"), color_grid); | 220 | label = new QLabel(tr("Line Color"), color_grid); |
221 | keycolor_lines_button = new QPushButton(color_grid); | 221 | keycolor_lines_button = new QPushButton(color_grid); |
222 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); | 222 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
223 | keycolor_lines_button->setFlat(TRUE); | 223 | keycolor_lines_button->setFlat(TRUE); |
224 | color = config.readListEntry("keycolor_lines", QChar(',')); | 224 | color = config.readListEntry("keycolor_lines", QChar(',')); |
225 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 225 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
226 | 226 | ||
227 | 227 | ||
228 | label = new QLabel(tr("Text Color"), color_grid); | 228 | label = new QLabel(tr("Text Color"), color_grid); |
229 | textcolor_button = new QPushButton(color_grid); | 229 | textcolor_button = new QPushButton(color_grid); |
230 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); | 230 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
231 | textcolor_button->setFlat(TRUE); | 231 | textcolor_button->setFlat(TRUE); |
232 | color = config.readListEntry("textcolor", QChar(',')); | 232 | color = config.readListEntry("textcolor", QChar(',')); |
233 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 233 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
234 | 234 | ||
235 | label = new QLabel("", color_grid); // a spacer so the above buttons dont expand | 235 | label = new QLabel("", color_grid); // a spacer so the above buttons dont expand |
236 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 236 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
237 | /* FIXME: hacked spacer height */ | 237 | /* FIXME: hacked spacer height */ |
238 | QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); | 238 | QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); |
239 | 239 | ||
240 | color_lay->addWidget(color_grid, 0, 0); | 240 | color_lay->addWidget(color_grid, 0, 0); |
241 | color_lay->addItem(spacer); | 241 | color_lay->addItem(spacer); |
242 | 242 | ||
243 | tabs->addTab(color_box, tr("Colors")); | 243 | tabs->addTab(color_box, tr("Colors")); |
244 | base_lay->addWidget(tabs); | 244 | base_lay->addWidget(tabs); |
245 | } | 245 | } |
246 | 246 | ||
247 | QStringList ConfigDlg::loadSw() | 247 | QStringList ConfigDlg::loadSw() |
248 | { | 248 | { |
249 | Config *config = new Config("multikey"); | 249 | Config *config = new Config("multikey"); |
250 | config->setGroup("keymaps"); | 250 | config->setGroup("keymaps"); |
251 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 251 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); |
252 | QStringList d_maps = map_dir.entryList(); // so i can access it in other places | 252 | QStringList d_maps = map_dir.entryList(); // so i can access it in other places |
253 | QStringList c_maps = config->readListEntry("maps", QChar('|')); | 253 | QStringList c_maps = config->readListEntry("maps", QChar('|')); |
254 | QStringList s_maps = config->readListEntry("sw", QChar('|')); | 254 | QStringList s_maps = config->readListEntry("sw", QChar('|')); |
255 | delete config; | 255 | delete config; |
256 | 256 | ||
257 | if (!s_maps.count()) | 257 | if (!s_maps.count()) |
258 | { | 258 | { |
259 | s_maps = d_maps+c_maps; | 259 | s_maps = d_maps+c_maps; |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | /* Clear non existents entries */ | 263 | /* Clear non existents entries */ |
264 | QStringList s_copy(s_maps); | 264 | QStringList s_copy(s_maps); |
265 | for (uint i = 0; i < s_copy.count(); ++i) { | 265 | for (uint i = 0; i < s_copy.count(); ++i) { |
266 | if (d_maps.find(s_copy[i]) == d_maps.end() | 266 | if (d_maps.find(s_copy[i]) == d_maps.end() |
267 | && c_maps.find(s_copy[i]) == c_maps.end()) { | 267 | && c_maps.find(s_copy[i]) == c_maps.end()) { |
268 | s_maps.remove(s_copy[i]); | 268 | s_maps.remove(s_copy[i]); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | /* Update sw_maps from default_maps */ | 271 | /* Update sw_maps from default_maps */ |
272 | for (uint i = 0; i < d_maps.count(); ++i) { | 272 | for (uint i = 0; i < d_maps.count(); ++i) { |
273 | if (s_maps.find(d_maps[i]) == s_maps.end()) { | 273 | if (s_maps.find(d_maps[i]) == s_maps.end()) { |
274 | s_maps.append(d_maps[i]); | 274 | s_maps.append(d_maps[i]); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | /* Update sw_maps from custom_maps */ | 277 | /* Update sw_maps from custom_maps */ |
278 | for (uint i = 0; i < c_maps.count(); ++i) { | 278 | for (uint i = 0; i < c_maps.count(); ++i) { |
279 | if (s_maps.find(c_maps[i]) == s_maps.end()) { | 279 | if (s_maps.find(c_maps[i]) == s_maps.end()) { |
280 | s_maps.append(c_maps[i]); | 280 | s_maps.append(c_maps[i]); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | return s_maps; | 285 | return s_maps; |
286 | } | 286 | } |
287 | 287 | ||
288 | void ConfigDlg::accept() | 288 | void ConfigDlg::accept() |
289 | { | 289 | { |
290 | /* Writing all stuffs to config */ | 290 | /* Writing all stuffs to config */ |
291 | Config *config = new Config("multikey"); | 291 | Config *config = new Config("multikey"); |
292 | config->setGroup("general"); | 292 | config->setGroup("general"); |
293 | config->writeEntry("usePickboard", pick_button->isChecked()); // default closed | 293 | config->writeEntry("usePickboard", pick_button->isChecked()); // default closed |
294 | config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed | 294 | config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed |
295 | 295 | ||
296 | config->setGroup("keymaps"); | 296 | config->setGroup("keymaps"); |
297 | config->writeEntry("sw", sw_maps, QChar('|')); | 297 | config->writeEntry("sw", sw_maps, QChar('|')); |
298 | config->writeEntry("maps", custom_maps, QChar('|')); | 298 | config->writeEntry("maps", custom_maps, QChar('|')); |
299 | delete config; | 299 | delete config; |