summaryrefslogtreecommitdiff
path: root/inputmethods
Unidiff
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp4
-rw-r--r--inputmethods/multikey/keyboard.cpp4
2 files changed, 4 insertions, 4 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
@@ -1,508 +1,508 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make a keymap editor 4 * make a keymap editor
5 * make keys translucent 5 * make keys translucent
6 * make vertical keys possible 6 * make vertical keys possible
7 * 7 *
8 * 8 *
9 */ 9 */
10 10
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/resource.h> 13#include <qpe/resource.h>
14 14
15#include <qlayout.h> 15#include <qlayout.h>
16#include <qwidget.h> 16#include <qwidget.h>
17#include <qdialog.h> 17#include <qdialog.h>
18#include <qtabwidget.h> 18#include <qtabwidget.h>
19#include <qvbox.h> 19#include <qvbox.h>
20#include <qgrid.h> 20#include <qgrid.h>
21#include <qgroupbox.h> 21#include <qgroupbox.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qcheckbox.h> 23#include <qcheckbox.h>
24#include <qsizepolicy.h> 24#include <qsizepolicy.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <opie2/ofiledialog.h> 29#include <opie2/ofiledialog.h>
30#include <opie2/qcolordialog.h> 30#include <opie2/qcolordialog.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfileinfo.h> 32#include <qfileinfo.h>
33#include "configdlg.h" 33#include "configdlg.h"
34#include "keyboard.h" 34#include "keyboard.h"
35 35
36using namespace Opie; 36using namespace Opie;
37using namespace Opie::Ui; 37using namespace Opie::Ui;
38// ConfigDlg::ConfigDlg() {{{1 38// ConfigDlg::ConfigDlg() {{{1
39ConfigDlg::ConfigDlg () : QDialog () 39ConfigDlg::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 }
131 131
132 if (keymap_map == current_map) { 132 if (keymap_map == current_map) {
133 keymaps->setSelected(i + 1, true); 133 keymaps->setSelected(i + 1, true);
134 } 134 }
135 } 135 }
136 136
137 // have to "+1" because the "current language" listItem... remember? 137 // have to "+1" because the "current language" listItem... remember?
138 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); 138 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int)));
139 139
140 QGrid *add_remove_grid = new QGrid(2, map_group); 140 QGrid *add_remove_grid = new QGrid(2, map_group);
141 add_remove_grid->setMargin(3); 141 add_remove_grid->setMargin(3);
142 add_remove_grid->setSpacing(3); 142 add_remove_grid->setSpacing(3);
143 143
144 add_button = new QPushButton(tr("Add"), add_remove_grid); 144 add_button = new QPushButton(tr("Add"), add_remove_grid);
145 add_button->setFlat(TRUE); 145 add_button->setFlat(TRUE);
146 connect(add_button, SIGNAL(clicked()), SLOT(addMap())); 146 connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
147 147
148 remove_button = new QPushButton(tr("Remove"), add_remove_grid); 148 remove_button = new QPushButton(tr("Remove"), add_remove_grid);
149 remove_button->setFlat(TRUE); 149 remove_button->setFlat(TRUE);
150 if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) 150 if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end())
151 remove_button->setDisabled(true); 151 remove_button->setDisabled(true);
152 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); 152 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
153 153
154 gen_lay->addWidget(map_group); 154 gen_lay->addWidget(map_group);
155 155
156 // make a box that will contain the buttons on the bottom 156 // make a box that will contain the buttons on the bottom
157 QGrid *other_grid = new QGrid(2, gen_box); 157 QGrid *other_grid = new QGrid(2, gen_box);
158 pick_button = new QCheckBox(tr("Pickboard"), other_grid); 158 pick_button = new QCheckBox(tr("Pickboard"), other_grid);
159 159
160 config.setGroup ("general"); 160 config.setGroup ("general");
161 bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed 161 bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed
162 if (pick_open) { 162 if (pick_open) {
163 163
164 pick_button->setChecked(true); 164 pick_button->setChecked(true);
165 } 165 }
166 166
167 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); 167 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid);
168 bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); 168 bool repeat_on = config.readBoolEntry ("useRepeat", TRUE);
169 169
170 if (repeat_on) { 170 if (repeat_on) {
171 171
172 repeat_button->setChecked(true); 172 repeat_button->setChecked(true);
173 } 173 }
174 174
175 gen_lay->addWidget(other_grid); 175 gen_lay->addWidget(other_grid);
176 tabs->addTab(gen_box, tr("General Settings")); 176 tabs->addTab(gen_box, tr("General Settings"));
177 177
178 /* 178 /*
179 * 'color' tab 179 * 'color' tab
180 */ 180 */
181 181
182 QWidget *color_box = new QWidget(tabs, "color_tab"); 182 QWidget *color_box = new QWidget(tabs, "color_tab");
183 183
184 QGridLayout *color_lay = new QGridLayout(color_box); 184 QGridLayout *color_lay = new QGridLayout(color_box);
185 QGrid *color_grid = new QGrid(2, color_box); 185 QGrid *color_grid = new QGrid(2, color_box);
186 color_lay->setAlignment(Qt::AlignTop); 186 color_lay->setAlignment(Qt::AlignTop);
187 color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 187 color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
188 color_grid->layout()->setAlignment(Qt::AlignTop); 188 color_grid->layout()->setAlignment(Qt::AlignTop);
189 color_grid->setMargin(3); 189 color_grid->setMargin(3);
190 color_grid->setSpacing(3); 190 color_grid->setSpacing(3);
191 191
192 QLabel *label; 192 QLabel *label;
193 QStringList color; 193 QStringList color;
194 config.setGroup("colors"); 194 config.setGroup("colors");
195 195
196 label = new QLabel(tr("Key Color"), color_grid); 196 label = new QLabel(tr("Key Color"), color_grid);
197 keycolor_button = new QPushButton(color_grid); 197 keycolor_button = new QPushButton(color_grid);
198 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); 198 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked()));
199 keycolor_button->setFlat(TRUE); 199 keycolor_button->setFlat(TRUE);
200 color = config.readListEntry("keycolor", QChar(',')); 200 color = config.readListEntry("keycolor", QChar(','));
201 /* 201 /*
202 * hopefully not required 202 * hopefully not required
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
247QStringList ConfigDlg::loadSw() 247QStringList 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
288void ConfigDlg::accept() 288void 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;
300 300
301 int index = keymaps->currentItem(); 301 int index = keymaps->currentItem();
302 if (index == 0) { 302 if (index == 0) {
303 303
304 remove_button->setDisabled(true); 304 remove_button->setDisabled(true);
305 emit setMapToDefault(); 305 emit setMapToDefault();
306 } 306 }
307 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { 307 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) {
308 308
309 remove_button->setDisabled(true); 309 remove_button->setDisabled(true);
310 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); 310 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]);
311 311
312 } else { 312 } else {
313 313
314 remove_button->setEnabled(true); 314 remove_button->setEnabled(true);
315 emit setMapToFile(sw_maps[index - 1]); 315 emit setMapToFile(sw_maps[index - 1]);
316 } 316 }
317 317
318 emit pickboardToggled(pick_button->isChecked()); 318 emit pickboardToggled(pick_button->isChecked());
319 emit repeatToggled(repeat_button->isChecked()); 319 emit repeatToggled(repeat_button->isChecked());
320 emit reloadSw(); 320 emit reloadSw();
321 321
322 QDialog::accept(); 322 QDialog::accept();
323 emit configDlgClosed(); 323 emit configDlgClosed();
324} 324}
325 325
326void ConfigDlg::moveSelectedUp() 326void ConfigDlg::moveSelectedUp()
327{ 327{
328 int i = keymaps->currentItem(); 328 int i = keymaps->currentItem();
329 /* Ignore Current Language */ 329 /* Ignore Current Language */
330 if (i > 1) { 330 if (i > 1) {
331 QString t = sw_maps[i-1]; 331 QString t = sw_maps[i-1];
332 sw_maps[i-1] = sw_maps[i-2]; 332 sw_maps[i-1] = sw_maps[i-2];
333 sw_maps[i-2] = t; 333 sw_maps[i-2] = t;
334 334
335 QString item = keymaps->currentText(); 335 QString item = keymaps->currentText();
336 keymaps->removeItem(i); 336 keymaps->removeItem(i);
337 keymaps->insertItem(item, i-1); 337 keymaps->insertItem(item, i-1);
338 keymaps->setCurrentItem(i-1); 338 keymaps->setCurrentItem(i-1);
339 } 339 }
340} 340}
341 341
342void ConfigDlg::moveSelectedDown() 342void ConfigDlg::moveSelectedDown()
343{ 343{
344 int i = keymaps->currentItem(); 344 int i = keymaps->currentItem();
345 /* Ignore Current Language */ 345 /* Ignore Current Language */
346 if (i > 0 && i < (int)keymaps->count() - 1) { 346 if (i > 0 && i < (int)keymaps->count() - 1) {
347 QString t = sw_maps[i-1]; 347 QString t = sw_maps[i-1];
348 sw_maps[i-1] = sw_maps[i]; 348 sw_maps[i-1] = sw_maps[i];
349 sw_maps[i] = t; 349 sw_maps[i] = t;
350 350
351 QString item = keymaps->currentText(); 351 QString item = keymaps->currentText();
352 keymaps->removeItem(i); 352 keymaps->removeItem(i);
353 keymaps->insertItem(item, i+1); 353 keymaps->insertItem(item, i+1);
354 keymaps->setCurrentItem(i+1); 354 keymaps->setCurrentItem(i+1);
355 } 355 }
356} 356}
357 357
358void ConfigDlg::closeEvent(QCloseEvent *) { 358void ConfigDlg::closeEvent(QCloseEvent *) {
359 359
360 // tell the parent it was closed, so delete me 360 // tell the parent it was closed, so delete me
361 emit configDlgClosed(); 361 emit configDlgClosed();
362} 362}
363 363
364void ConfigDlg::setMap(int index) { 364void ConfigDlg::setMap(int index) {
365 365
366 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) { 366 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) {
367 remove_button->setDisabled(true); 367 remove_button->setDisabled(true);
368 } else { 368 } else {
369 remove_button->setEnabled(true); 369 remove_button->setEnabled(true);
370 } 370 }
371} 371}
372 372
373// ConfigDlg::addMap() {{{1 373// ConfigDlg::addMap() {{{1
374void ConfigDlg::addMap() { 374void ConfigDlg::addMap() {
375 375
376 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 376 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
377 377
378 if (map.isNull()) return; 378 if (map.isNull()) return;
379 379
380 Config config ("multikey"); 380 Config config ("multikey");
381 config.setGroup("keymaps"); 381 config.setGroup("keymaps");
382 QStringList maps = config.readListEntry("maps", QChar('|')); 382 QStringList maps = config.readListEntry("maps", QChar('|'));
383 maps.append(map); 383 maps.append(map);
384 custom_maps.append(map); 384 custom_maps.append(map);
385 if (sw_maps.find(map) == sw_maps.end()) 385 if (sw_maps.find(map) == sw_maps.end())
386 sw_maps.append(map); 386 sw_maps.append(map);
387 387
388 QFile map_file (map); 388 QFile map_file (map);
389 if (map_file.open(IO_ReadOnly)) { 389 if (map_file.open(IO_ReadOnly)) {
390 390
391 QString line; bool found = 0; 391 QString line; bool found = 0;
392 392
393 map_file.readLine(line, 1024); 393 map_file.readLine(line, 1024);
394 while (!map_file.atEnd()) { 394 while (!map_file.atEnd()) {
395 395
396 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 396 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
397 397
398 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 398 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
399 found = 1; 399 found = 1;
400 break; 400 break;
401 } 401 }
402 map_file.readLine(line, 1024); 402 map_file.readLine(line, 1024);
403 } 403 }
404 if (!found) keymaps->insertItem(map); 404 if (!found) keymaps->insertItem(map);
405 405
406 map_file.close(); 406 map_file.close();
407 } 407 }
408 408
409 keymaps->setSelected(keymaps->count() - 1, true); 409 keymaps->setSelected(keymaps->count() - 1, true);
410} 410}
411 411
412// ConfigDlg::removeMap() {{{1 412// ConfigDlg::removeMap() {{{1
413void ConfigDlg::removeMap() { 413void ConfigDlg::removeMap() {
414 414
415 // move selection up one 415 // move selection up one
416 keymaps->setSelected(keymaps->currentItem() - 1, true); 416 keymaps->setSelected(keymaps->currentItem() - 1, true);
417 // delete the next selected item cus you just moved it up 417 // delete the next selected item cus you just moved it up
418 keymaps->removeItem(keymaps->currentItem() + 1); 418 keymaps->removeItem(keymaps->currentItem() + 1);
419 419
420 custom_maps.remove(sw_maps[keymaps->currentItem()]); 420 custom_maps.remove(sw_maps[keymaps->currentItem()]);
421 sw_maps.remove(sw_maps.at(keymaps->currentItem())); 421 sw_maps.remove(sw_maps.at(keymaps->currentItem()));
422} 422}
423 423
424/* ConfigDlg::slots for the color buttons {{{1 424/* ConfigDlg::slots for the color buttons {{{1
425 * 425 *
426 * these four slots are almost the same, except for the names. i was thinking 426 * these four slots are almost the same, except for the names. i was thinking
427 * of making a map with pointers to the buttons and names of the configEntry 427 * of making a map with pointers to the buttons and names of the configEntry
428 * so it could be one slot, but then there would be no way of telling which 428 * so it could be one slot, but then there would be no way of telling which
429 * of the buttons was clicked if they all connect to the same slot. 429 * of the buttons was clicked if they all connect to the same slot.
430 * 430 *
431 */ 431 */
432 432
433void ConfigDlg::keyColorClicked() { 433void ConfigDlg::keyColorClicked() {
434 434
435 Config config ("multikey"); 435 Config config ("multikey");
436 config.setGroup ("colors"); 436 config.setGroup ("colors");
437 437
438 QStringList color = config.readListEntry("keycolor", QChar(',')); 438 QStringList color = config.readListEntry("keycolor", QChar(','));
439 439
440 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 440 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
441 441
442 color[0].setNum(newcolor.red()); 442 color[0].setNum(newcolor.red());
443 color[1].setNum(newcolor.green()); 443 color[1].setNum(newcolor.green());
444 color[2].setNum(newcolor.blue()); 444 color[2].setNum(newcolor.blue());
445 445
446 config.writeEntry("keycolor", color, QChar(',')); 446 config.writeEntry("keycolor", color, QChar(','));
447 config.write(); 447 config.write();
448 448
449 keycolor_button->setPalette(QPalette(newcolor)); 449 keycolor_button->setPalette(QPalette(newcolor));
450 emit reloadKeyboard(); 450 emit reloadKeyboard();
451} 451}
452void ConfigDlg::keyColorPressedClicked() { 452void ConfigDlg::keyColorPressedClicked() {
453 453
454 Config config ("multikey"); 454 Config config ("multikey");
455 config.setGroup ("colors"); 455 config.setGroup ("colors");
456 456
457 QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); 457 QStringList color = config.readListEntry("keycolor_pressed", QChar(','));
458 458
459 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 459 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
460 460
461 color[0].setNum(newcolor.red()); 461 color[0].setNum(newcolor.red());
462 color[1].setNum(newcolor.green()); 462 color[1].setNum(newcolor.green());
463 color[2].setNum(newcolor.blue()); 463 color[2].setNum(newcolor.blue());
464 464
465 config.writeEntry("keycolor_pressed", color, QChar(',')); 465 config.writeEntry("keycolor_pressed", color, QChar(','));
466 config.write(); 466 config.write();
467 467
468 keycolor_pressed_button->setPalette(QPalette(newcolor)); 468 keycolor_pressed_button->setPalette(QPalette(newcolor));
469 emit reloadKeyboard(); 469 emit reloadKeyboard();
470} 470}
471void ConfigDlg::keyColorLinesClicked() { 471void ConfigDlg::keyColorLinesClicked() {
472 472
473 Config config ("multikey"); 473 Config config ("multikey");
474 config.setGroup ("colors"); 474 config.setGroup ("colors");
475 475
476 QStringList color = config.readListEntry("keycolor_lines", QChar(',')); 476 QStringList color = config.readListEntry("keycolor_lines", QChar(','));
477 477
478 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 478 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
479 479
480 color[0].setNum(newcolor.red()); 480 color[0].setNum(newcolor.red());
481 color[1].setNum(newcolor.green()); 481 color[1].setNum(newcolor.green());
482 color[2].setNum(newcolor.blue()); 482 color[2].setNum(newcolor.blue());
483 483
484 config.writeEntry("keycolor_lines", color, QChar(',')); 484 config.writeEntry("keycolor_lines", color, QChar(','));
485 config.write(); 485 config.write();
486 486
487 keycolor_lines_button->setPalette(QPalette(newcolor)); 487 keycolor_lines_button->setPalette(QPalette(newcolor));
488 emit reloadKeyboard(); 488 emit reloadKeyboard();
489} 489}
490void ConfigDlg::textColorClicked() { 490void ConfigDlg::textColorClicked() {
491 491
492 Config config ("multikey"); 492 Config config ("multikey");
493 config.setGroup ("colors"); 493 config.setGroup ("colors");
494 494
495 QStringList color = config.readListEntry("textcolor", QChar(',')); 495 QStringList color = config.readListEntry("textcolor", QChar(','));
496 496
497 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 497 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
498 498
499 color[0].setNum(newcolor.red()); 499 color[0].setNum(newcolor.red());
500 color[1].setNum(newcolor.green()); 500 color[1].setNum(newcolor.green());
501 color[2].setNum(newcolor.blue()); 501 color[2].setNum(newcolor.blue());
502 502
503 config.writeEntry("textcolor", color, QChar(',')); 503 config.writeEntry("textcolor", color, QChar(','));
504 config.write(); 504 config.write();
505 505
506 textcolor_button->setPalette(QPalette(newcolor)); 506 textcolor_button->setPalette(QPalette(newcolor));
507 emit reloadKeyboard(); 507 emit reloadKeyboard();
508} 508}
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 7ddfd3e..f8cafd5 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -996,715 +996,715 @@ void Keyboard::setMapToFile(QString map) {
996 996
997 delete keys; 997 delete keys;
998 if (QFile(map).exists()) 998 if (QFile(map).exists())
999 keys = new Keys(map); 999 keys = new Keys(map);
1000 else 1000 else
1001 keys = new Keys(); 1001 keys = new Keys();
1002 1002
1003 if (keys->rows() != prevRows) { 1003 if (keys->rows() != prevRows) {
1004 1004
1005 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 1005 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
1006 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 1006 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
1007 } 1007 }
1008 else repaint(FALSE); 1008 else repaint(FALSE);
1009 1009
1010 resetState(); 1010 resetState();
1011} 1011}
1012 1012
1013/* Keybaord::reloadKeyboard {{{1 */ 1013/* Keybaord::reloadKeyboard {{{1 */
1014void Keyboard::reloadKeyboard() { 1014void Keyboard::reloadKeyboard() {
1015 1015
1016 // reload colors and redraw 1016 // reload colors and redraw
1017 loadKeyboardColors(); 1017 loadKeyboardColors();
1018 repaint(); 1018 repaint();
1019 1019
1020} 1020}
1021 1021
1022void Keyboard::loadKeyboardColors() { 1022void Keyboard::loadKeyboardColors() {
1023 1023
1024 Config config ("multikey"); 1024 Config config ("multikey");
1025 config.setGroup("colors"); 1025 config.setGroup("colors");
1026 1026
1027 QStringList color; 1027 QStringList color;
1028 color = config.readListEntry("keycolor", QChar(',')); 1028 color = config.readListEntry("keycolor", QChar(','));
1029 if (color.isEmpty()) { 1029 if (color.isEmpty()) {
1030 color = QStringList::split(",", "240,240,240"); 1030 color = QStringList::split(",", "240,240,240");
1031 config.writeEntry("keycolor", color.join(",")); 1031 config.writeEntry("keycolor", color.join(","));
1032 1032
1033 } 1033 }
1034 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1034 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1035 1035
1036 color = config.readListEntry("keycolor_pressed", QChar(',')); 1036 color = config.readListEntry("keycolor_pressed", QChar(','));
1037 if (color.isEmpty()) { 1037 if (color.isEmpty()) {
1038 color = QStringList::split(",", "171,183,198"); 1038 color = QStringList::split(",", "171,183,198");
1039 config.writeEntry("keycolor_pressed", color.join(",")); 1039 config.writeEntry("keycolor_pressed", color.join(","));
1040 1040
1041 } 1041 }
1042 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1042 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1043 1043
1044 color = config.readListEntry("keycolor_lines", QChar(',')); 1044 color = config.readListEntry("keycolor_lines", QChar(','));
1045 if (color.isEmpty()) { 1045 if (color.isEmpty()) {
1046 color = QStringList::split(",", "138,148,160"); 1046 color = QStringList::split(",", "138,148,160");
1047 config.writeEntry("keycolor_lines", color.join(",")); 1047 config.writeEntry("keycolor_lines", color.join(","));
1048 1048
1049 } 1049 }
1050 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1050 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1051 1051
1052 color = config.readListEntry("textcolor", QChar(',')); 1052 color = config.readListEntry("textcolor", QChar(','));
1053 if (color.isEmpty()) { 1053 if (color.isEmpty()) {
1054 color = QStringList::split(",", "43,54,68"); 1054 color = QStringList::split(",", "43,54,68");
1055 config.writeEntry("textcolor", color.join(",")); 1055 config.writeEntry("textcolor", color.join(","));
1056 1056
1057 } 1057 }
1058 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1058 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1059 1059
1060} 1060}
1061 1061
1062/* korean input functions {{{1 1062/* korean input functions {{{1
1063 * 1063 *
1064 * TODO 1064 * TODO
1065 * one major problem with this implementation is that you can't move the 1065 * one major problem with this implementation is that you can't move the
1066 * cursor after inputing korean chars, otherwise it will eat up and replace 1066 * cursor after inputing korean chars, otherwise it will eat up and replace
1067 * the char before the cursor you move to. fix that 1067 * the char before the cursor you move to. fix that
1068 * 1068 *
1069 * make backspace delete one single char, not the whole thing if still 1069 * make backspace delete one single char, not the whole thing if still
1070 * editing. 1070 * editing.
1071 * 1071 *
1072 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1072 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1073 * 1073 *
1074 * how korean input works 1074 * how korean input works
1075 * 1075 *
1076 * all following chars means unicode char value and are in hex 1076 * all following chars means unicode char value and are in hex
1077 * 1077 *
1078 * 초음 = schar (start char) 1078 * 초음 = schar (start char)
1079 * 중음 = mchar (middle char) 1079 * 중음 = mchar (middle char)
1080 * 끝음 = echar (end char) 1080 * 끝음 = echar (end char)
1081 * 1081 *
1082 * there are 19 schars. unicode position is at 1100 - 1112 1082 * there are 19 schars. unicode position is at 1100 - 1112
1083 * there are 21 mchars. unicode position is at 1161 - 1175 1083 * there are 21 mchars. unicode position is at 1161 - 1175
1084 * there are 27 echars. unicode position is at 11a8 - 11c2 1084 * there are 27 echars. unicode position is at 11a8 - 11c2
1085 * 1085 *
1086 * the map with everything combined is at ac00 - d7a3 1086 * the map with everything combined is at ac00 - d7a3
1087 * 1087 *
1088 */ 1088 */
1089 1089
1090ushort Keyboard::parseKoreanInput (ushort c) { 1090ushort Keyboard::parseKoreanInput (ushort c) {
1091 1091
1092 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 1092 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
1093 || 1093 ||
1094 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 1094 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
1095 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 1095 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
1096 1096
1097 schar = 0, mchar = 0, echar = 0; 1097 schar = 0, mchar = 0, echar = 0;
1098 return c; 1098 return c;
1099 } 1099 }
1100 1100
1101 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 1101 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
1102 1102
1103 if (schar == 0 || (schar != 0 && mchar == 0)) { 1103 if (schar == 0 || (schar != 0 && mchar == 0)) {
1104 schar = c; mchar = 0; echar = 0; 1104 schar = c; mchar = 0; echar = 0;
1105 return c; 1105 return c;
1106 } 1106 }
1107 else if (mchar != 0) { 1107 else if (mchar != 0) {
1108 1108
1109 if (echar == 0) { 1109 if (echar == 0) {
1110 1110
1111 if (!(echar = constoe(c))) { 1111 if (!(echar = constoe(c))) {
1112 1112
1113 schar = c; mchar = 0; echar = 0; 1113 schar = c; mchar = 0; echar = 0;
1114 return c; 1114 return c;
1115 } 1115 }
1116 1116
1117 } 1117 }
1118 else { // must figure out what the echar is 1118 else { // must figure out what the echar is
1119 1119
1120 if (echar == 0x11a8) { // ㄱ 1120 if (echar == 0x11a8) { // ㄱ
1121 1121
1122 if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ 1122 if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ
1123 else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ 1123 else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ
1124 else { 1124 else {
1125 schar = c; mchar = 0; echar = 0; 1125 schar = c; mchar = 0; echar = 0;
1126 return c; 1126 return c;
1127 } 1127 }
1128 1128
1129 } else if (echar == 0x11ab) { // ㄴ 1129 } else if (echar == 0x11ab) { // ㄴ
1130 1130
1131 if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ 1131 if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ
1132 else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ 1132 else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ
1133 else { 1133 else {
1134 schar = c; mchar = 0; echar = 0; 1134 schar = c; mchar = 0; echar = 0;
1135 return c; 1135 return c;
1136 } 1136 }
1137 1137
1138 } else if (echar == 0x11af) { // ㄹ 1138 } else if (echar == 0x11af) { // ㄹ
1139 1139
1140 if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ 1140 if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ
1141 else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ 1141 else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ
1142 else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ 1142 else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ
1143 else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ 1143 else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ
1144 else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ 1144 else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ
1145 else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ 1145 else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ
1146 else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ 1146 else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ
1147 else { 1147 else {
1148 schar = c; mchar = 0; echar = 0; 1148 schar = c; mchar = 0; echar = 0;
1149 return c; 1149 return c;
1150 } 1150 }
1151 1151
1152 } else if (echar == 0x11b8) { // ㅂ 1152 } else if (echar == 0x11b8) { // ㅂ
1153 1153
1154 if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ 1154 if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ
1155 else { 1155 else {
1156 schar = c; mchar = 0; echar = 0; 1156 schar = c; mchar = 0; echar = 0;
1157 return c; 1157 return c;
1158 } 1158 }
1159 1159
1160 } else if (echar == 0x11ba) { // ㅅ 1160 } else if (echar == 0x11ba) { // ㅅ
1161 1161
1162 if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ 1162 if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ
1163 else { 1163 else {
1164 schar = c; mchar = 0; echar = 0; 1164 schar = c; mchar = 0; echar = 0;
1165 return c; 1165 return c;
1166 } 1166 }
1167 1167
1168 } else { // if any other char, cannot combine chars 1168 } else { // if any other char, cannot combine chars
1169 1169
1170 schar = c; mchar = 0; echar = 0; 1170 schar = c; mchar = 0; echar = 0;
1171 return c; 1171 return c;
1172 } 1172 }
1173 1173
1174 unicode = echar; 1174 unicode = echar;
1175 } 1175 }
1176 } 1176 }
1177 1177
1178 } 1178 }
1179 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 1179 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
1180 1180
1181 if (schar != 0 && mchar == 0) { mchar = c; } 1181 if (schar != 0 && mchar == 0) { mchar = c; }
1182 1182
1183 else if (schar != 0 && mchar != 0 && echar == 0) { 1183 else if (schar != 0 && mchar != 0 && echar == 0) {
1184 1184
1185 switch (mchar) { 1185 switch (mchar) {
1186 case 0x1169: 1186 case 0x1169:
1187 if (c == 0x1161) mchar = 0x116a; 1187 if (c == 0x1161) mchar = 0x116a;
1188 else if (c == 0x1162) mchar = 0x116b; 1188 else if (c == 0x1162) mchar = 0x116b;
1189 else if (c == 0x1175) mchar = 0x116c; 1189 else if (c == 0x1175) mchar = 0x116c;
1190 else { 1190 else {
1191 schar = 0; mchar = 0; echar = 0; 1191 schar = 0; mchar = 0; echar = 0;
1192 return c; 1192 return c;
1193 } 1193 }
1194 break; 1194 break;
1195 case 0x116e: 1195 case 0x116e:
1196 if (c == 0x1165) mchar = 0x116f; 1196 if (c == 0x1165) mchar = 0x116f;
1197 else if (c == 0x1166) mchar = 0x1170; 1197 else if (c == 0x1166) mchar = 0x1170;
1198 else if (c == 0x1175) mchar = 0x1171; 1198 else if (c == 0x1175) mchar = 0x1171;
1199 else { 1199 else {
1200 schar = 0; mchar = 0; echar = 0; 1200 schar = 0; mchar = 0; echar = 0;
1201 return c; 1201 return c;
1202 } 1202 }
1203 break; 1203 break;
1204 case 0x1173: 1204 case 0x1173:
1205 if (c == 0x1175) mchar = 0x1174; 1205 if (c == 0x1175) mchar = 0x1174;
1206 else { 1206 else {
1207 schar = 0; mchar = 0; echar = 0; 1207 schar = 0; mchar = 0; echar = 0;
1208 return c; 1208 return c;
1209 } 1209 }
1210 break; 1210 break;
1211 default: 1211 default:
1212 schar = 0; mchar = 0; echar = 0; 1212 schar = 0; mchar = 0; echar = 0;
1213 return c; 1213 return c;
1214 } 1214 }
1215 } 1215 }
1216 else if (schar != 0 && mchar != 0 && echar != 0) { 1216 else if (schar != 0 && mchar != 0 && echar != 0) {
1217 1217
1218 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1218 emit key( 8, Qt::Key_Backspace, 0, true, false );
1219 1219
1220 ushort prev = 0; 1220 ushort prev = 0;
1221 switch (echar) { 1221 switch (echar) {
1222 /* 1222 /*
1223 case 0x11a9: 1223 case 0x11a9:
1224 prev = combineKoreanChars(schar, mchar, 0x11a8); 1224 prev = combineKoreanChars(schar, mchar, 0x11a8);
1225 schar = 0x1100; 1225 schar = 0x1100;
1226 break; 1226 break;
1227 */ 1227 */
1228 case 0x11aa: 1228 case 0x11aa:
1229 prev = combineKoreanChars(schar, mchar, 0x11a8); 1229 prev = combineKoreanChars(schar, mchar, 0x11a8);
1230 schar = 0x1109; 1230 schar = 0x1109;
1231 break; 1231 break;
1232 case 0x11ac: 1232 case 0x11ac:
1233 prev = combineKoreanChars(schar, mchar, 0x11ab); 1233 prev = combineKoreanChars(schar, mchar, 0x11ab);
1234 schar = 0x110c; 1234 schar = 0x110c;
1235 break; 1235 break;
1236 case 0x11ad: 1236 case 0x11ad:
1237 prev = combineKoreanChars(schar, mchar, 0x11ab); 1237 prev = combineKoreanChars(schar, mchar, 0x11ab);
1238 schar = 0x1112; 1238 schar = 0x1112;
1239 break; 1239 break;
1240 case 0x11b0: 1240 case 0x11b0:
1241 prev = combineKoreanChars(schar, mchar, 0x11af); 1241 prev = combineKoreanChars(schar, mchar, 0x11af);
1242 schar = 0x1100; 1242 schar = 0x1100;
1243 break; 1243 break;
1244 case 0x11b1: 1244 case 0x11b1:
1245 prev = combineKoreanChars(schar, mchar, 0x11af); 1245 prev = combineKoreanChars(schar, mchar, 0x11af);
1246 schar = 0x1106; 1246 schar = 0x1106;
1247 break; 1247 break;
1248 case 0x11b2: 1248 case 0x11b2:
1249 prev = combineKoreanChars(schar, mchar, 0x11af); 1249 prev = combineKoreanChars(schar, mchar, 0x11af);
1250 schar = 0x1107; 1250 schar = 0x1107;
1251 break; 1251 break;
1252 case 0x11b3: 1252 case 0x11b3:
1253 prev = combineKoreanChars(schar, mchar, 0x11af); 1253 prev = combineKoreanChars(schar, mchar, 0x11af);
1254 schar = 0x1109; 1254 schar = 0x1109;
1255 break; 1255 break;
1256 case 0x11b4: 1256 case 0x11b4:
1257 prev = combineKoreanChars(schar, mchar, 0x11af); 1257 prev = combineKoreanChars(schar, mchar, 0x11af);
1258 schar = 0x1110; 1258 schar = 0x1110;
1259 break; 1259 break;
1260 case 0x11b9: 1260 case 0x11b9:
1261 prev = combineKoreanChars(schar, mchar, 0x11b8); 1261 prev = combineKoreanChars(schar, mchar, 0x11b8);
1262 schar = 0x1109; 1262 schar = 0x1109;
1263 break; 1263 break;
1264 /* 1264 /*
1265 case 0x11bb: 1265 case 0x11bb:
1266 prev = combineKoreanChars(schar, mchar, 0x11ba); 1266 prev = combineKoreanChars(schar, mchar, 0x11ba);
1267 schar = 0x1109; 1267 schar = 0x1109;
1268 break; 1268 break;
1269 */ 1269 */
1270 default: 1270 default:
1271 1271
1272 if (constoe(echar)) { 1272 if (constoe(echar)) {
1273 1273
1274 prev = combineKoreanChars(schar, mchar, 0); 1274 prev = combineKoreanChars(schar, mchar, 0);
1275 schar = constoe(echar); 1275 schar = constoe(echar);
1276 } 1276 }
1277 break; 1277 break;
1278 } 1278 }
1279 1279
1280 emit key( prev, prev, 0, true, false ); 1280 emit key( prev, prev, 0, true, false );
1281 1281
1282 mchar = c; echar = 0; 1282 mchar = c; echar = 0;
1283 1283
1284 return combineKoreanChars(schar, mchar, 0); 1284 return combineKoreanChars(schar, mchar, 0);
1285 1285
1286 } 1286 }
1287 else { 1287 else {
1288 schar = 0; mchar = 0; echar = 0; 1288 schar = 0; mchar = 0; echar = 0;
1289 return c; 1289 return c;
1290 } 1290 }
1291 1291
1292 } 1292 }
1293 else /*if (c == ' ')*/ return c; 1293 else /*if (c == ' ')*/ return c;
1294 1294
1295 1295
1296 // and now... finally delete previous char, and return new char 1296 // and now... finally delete previous char, and return new char
1297 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1297 emit key( 8, Qt::Key_Backspace, 0, true, false );
1298 1298
1299 1299
1300 return combineKoreanChars( schar, mchar, echar); 1300 return combineKoreanChars( schar, mchar, echar);
1301 1301
1302} 1302}
1303 1303
1304ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 1304ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
1305 1305
1306 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 1306 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
1307 1307
1308} 1308}
1309 1309
1310ushort Keyboard::constoe(const ushort c) { 1310ushort Keyboard::constoe(const ushort c) {
1311 1311
1312 // converts schars to echars if possible 1312 // converts schars to echars if possible
1313 1313
1314 if (0x1100 <= c && c <= 0x1112) { // schar to echar 1314 if (0x1100 <= c && c <= 0x1112) { // schar to echar
1315 1315
1316 switch (c) { 1316 switch (c) {
1317 case 0x1100: return 0x11a8; 1317 case 0x1100: return 0x11a8;
1318 case 0x1101: return 0x11a9; 1318 case 0x1101: return 0x11a9;
1319 case 0x1102: return 0x11ab; 1319 case 0x1102: return 0x11ab;
1320 case 0x1103: return 0x11ae; 1320 case 0x1103: return 0x11ae;
1321 case 0x1105: return 0x11af; 1321 case 0x1105: return 0x11af;
1322 case 0x1106: return 0x11b7; 1322 case 0x1106: return 0x11b7;
1323 case 0x1107: return 0x11b8; 1323 case 0x1107: return 0x11b8;
1324 case 0x1109: return 0x11ba; 1324 case 0x1109: return 0x11ba;
1325 case 0x110a: return 0x11bb; 1325 case 0x110a: return 0x11bb;
1326 case 0x110b: return 0x11bc; 1326 case 0x110b: return 0x11bc;
1327 case 0x110c: return 0x11bd; 1327 case 0x110c: return 0x11bd;
1328 case 0x110e: return 0x11be; 1328 case 0x110e: return 0x11be;
1329 case 0x110f: return 0x11bf; 1329 case 0x110f: return 0x11bf;
1330 case 0x1110: return 0x11c0; 1330 case 0x1110: return 0x11c0;
1331 case 0x1111: return 0x11c1; 1331 case 0x1111: return 0x11c1;
1332 case 0x1112: return 0x11c2; 1332 case 0x1112: return 0x11c2;
1333 default: return 0; 1333 default: return 0;
1334 1334
1335 } 1335 }
1336 1336
1337 } else { //echar to schar 1337 } else { //echar to schar
1338 1338
1339 switch (c) { 1339 switch (c) {
1340 case 0x11a8: return 0x1100; 1340 case 0x11a8: return 0x1100;
1341 case 0x11a9: return 0x1101; 1341 case 0x11a9: return 0x1101;
1342 case 0x11ab: return 0x1102; 1342 case 0x11ab: return 0x1102;
1343 case 0x11ae: return 0x1103; 1343 case 0x11ae: return 0x1103;
1344 case 0x11af: return 0x1105; 1344 case 0x11af: return 0x1105;
1345 case 0x11b7: return 0x1106; 1345 case 0x11b7: return 0x1106;
1346 case 0x11b8: return 0x1107; 1346 case 0x11b8: return 0x1107;
1347 case 0x11ba: return 0x1109; 1347 case 0x11ba: return 0x1109;
1348 case 0x11bb: return 0x110a; 1348 case 0x11bb: return 0x110a;
1349 case 0x11bc: return 0x110b; 1349 case 0x11bc: return 0x110b;
1350 case 0x11bd: return 0x110c; 1350 case 0x11bd: return 0x110c;
1351 case 0x11be: return 0x110e; 1351 case 0x11be: return 0x110e;
1352 case 0x11bf: return 0x110f; 1352 case 0x11bf: return 0x110f;
1353 case 0x11c0: return 0x1110; 1353 case 0x11c0: return 0x1110;
1354 case 0x11c1: return 0x1111; 1354 case 0x11c1: return 0x1111;
1355 case 0x11c2: return 0x1112; 1355 case 0x11c2: return 0x1112;
1356 default: return 0; 1356 default: return 0;
1357 1357
1358 } 1358 }
1359 1359
1360 } 1360 }
1361} 1361}
1362 1362
1363 1363
1364// Keys::Keys {{{1 1364// Keys::Keys {{{1
1365 1365
1366Keys::Keys() { 1366Keys::Keys() {
1367 1367
1368 Config *config = new Config ("multikey"); 1368 Config *config = new Config ("multikey");
1369 config->setGroup( "keymaps" ); 1369 config->setGroup( "keymaps" );
1370 QString map = config->readEntry( "current" ); 1370 QString map = config->readEntry( "current" );
1371 delete config; 1371 delete config;
1372 1372
1373 if (map.isNull() || !(QFile(map).exists())) { 1373 if (map.isNull() || !(QFile(map).exists())) {
1374 1374
1375 Config *config = new Config("locale"); 1375 Config *config = new Config("locale");
1376 config->setGroup( "Language" ); 1376 config->setGroup( "Language" );
1377 QString l = config->readEntry( "Language" , "en" ); 1377 QString l = config->readEntry( "Language" , "en" );
1378 delete config; 1378 delete config;
1379 1379
1380 map = QPEApplication::qpeDir() + "/share/multikey/" 1380 map = QPEApplication::qpeDir() + "share/multikey/"
1381 + l + ".keymap"; 1381 + l + ".keymap";
1382 1382
1383 } 1383 }
1384 if (map.isNull() || !(QFile(map).exists())) { 1384 if (map.isNull() || !(QFile(map).exists())) {
1385 map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; 1385 map = QPEApplication::qpeDir() + "share/multikey/en.keymap";
1386 } 1386 }
1387 1387
1388 setKeysFromFile(map); 1388 setKeysFromFile(map);
1389} 1389}
1390 1390
1391Keys::Keys(const char * filename) { 1391Keys::Keys(const char * filename) {
1392 1392
1393 setKeysFromFile(filename); 1393 setKeysFromFile(filename);
1394} 1394}
1395 1395
1396// Keys::setKeysFromFile {{{2 1396// Keys::setKeysFromFile {{{2
1397void Keys::setKeysFromFile(const char * filename) { 1397void Keys::setKeysFromFile(const char * filename) {
1398 1398
1399 QFile f(filename); 1399 QFile f(filename);
1400 1400
1401 if (f.open(IO_ReadOnly)) { 1401 if (f.open(IO_ReadOnly)) {
1402 1402
1403 QTextStream t(&f); 1403 QTextStream t(&f);
1404 int row; 1404 int row;
1405 int qcode; 1405 int qcode;
1406 ushort unicode; 1406 ushort unicode;
1407 int width; 1407 int width;
1408 QString buf; 1408 QString buf;
1409 QString comment; 1409 QString comment;
1410 char * xpm[256]; //couldnt be larger than that... could it? 1410 char * xpm[256]; //couldnt be larger than that... could it?
1411 QImage *xpm2pix = 0; 1411 QImage *xpm2pix = 0;
1412 1412
1413 buf = t.readLine(); 1413 buf = t.readLine();
1414 while (buf) { 1414 while (buf) {
1415 1415
1416 // get rid of comments 1416 // get rid of comments
1417 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1417 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1418 1418
1419 // key definition 1419 // key definition
1420 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1420 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1421 // no $1 type referencing!!! this implementation of regexp sucks 1421 // no $1 type referencing!!! this implementation of regexp sucks
1422 1422
1423 // dont know of any sscanf() type funcs in Qt lib 1423 // dont know of any sscanf() type funcs in Qt lib
1424 QTextStream tmp (buf, IO_ReadOnly); 1424 QTextStream tmp (buf, IO_ReadOnly);
1425 tmp >> row >> qcode >> unicode >> width >> comment; 1425 tmp >> row >> qcode >> unicode >> width >> comment;
1426 1426
1427 buf = t.readLine(); 1427 buf = t.readLine();
1428 int xpmLineCount = 0; 1428 int xpmLineCount = 0;
1429 xpm2pix = 0; 1429 xpm2pix = 0;
1430 1430
1431 // erase blank space 1431 // erase blank space
1432 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1432 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1433 1433
1434 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1434 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1435 1435
1436 QString xpmBuf = buf.stripWhiteSpace(); 1436 QString xpmBuf = buf.stripWhiteSpace();
1437 1437
1438 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1438 xpm[xpmLineCount] = new char [xpmBuf.length()];
1439 1439
1440 int j = 0; 1440 int j = 0;
1441 for (ushort i = 0; i < xpmBuf.length(); i++) { 1441 for (ushort i = 0; i < xpmBuf.length(); i++) {
1442 if (xpmBuf[i].latin1() != '"') { 1442 if (xpmBuf[i].latin1() != '"') {
1443 1443
1444 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1444 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1445 j++; 1445 j++;
1446 } 1446 }
1447 1447
1448 } 1448 }
1449 // have to close that facker up 1449 // have to close that facker up
1450 ((char *)xpm[xpmLineCount])[j] = '\0'; 1450 ((char *)xpm[xpmLineCount])[j] = '\0';
1451 1451
1452 xpmLineCount++; 1452 xpmLineCount++;
1453 buf = t.readLine(); 1453 buf = t.readLine();
1454 } 1454 }
1455 if (xpmLineCount) { 1455 if (xpmLineCount) {
1456 1456
1457 xpm2pix = new QImage((const char **)xpm); 1457 xpm2pix = new QImage((const char **)xpm);
1458 for (int i = 0; i < xpmLineCount; i++) 1458 for (int i = 0; i < xpmLineCount; i++)
1459 1459
1460 delete [] (xpm[i]); 1460 delete [] (xpm[i]);
1461 1461
1462 } 1462 }
1463 setKey(row, qcode, unicode, width, xpm2pix); 1463 setKey(row, qcode, unicode, width, xpm2pix);
1464 } 1464 }
1465 1465
1466 // shift map 1466 // shift map
1467 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1467 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1468 1468
1469 QTextStream tmp (buf, IO_ReadOnly); 1469 QTextStream tmp (buf, IO_ReadOnly);
1470 ushort lower, shift; 1470 ushort lower, shift;
1471 tmp >> lower >> shift; 1471 tmp >> lower >> shift;
1472 1472
1473 shiftMap.insert(lower, shift); 1473 shiftMap.insert(lower, shift);
1474 1474
1475 buf = t.readLine(); 1475 buf = t.readLine();
1476 } 1476 }
1477 1477
1478 // meta key map 1478 // meta key map
1479 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1479 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1480 1480
1481 QTextStream tmp (buf, IO_ReadOnly); 1481 QTextStream tmp (buf, IO_ReadOnly);
1482 ushort lower, shift; 1482 ushort lower, shift;
1483 QChar m; 1483 QChar m;
1484 tmp >> m >> lower >> shift; 1484 tmp >> m >> lower >> shift;
1485 1485
1486 metaMap.insert(lower, shift); 1486 metaMap.insert(lower, shift);
1487 1487
1488 buf = t.readLine(); 1488 buf = t.readLine();
1489 } 1489 }
1490 1490
1491 // circumflex 1491 // circumflex
1492 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1492 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1493 1493
1494 QTextStream tmp (buf, IO_ReadOnly); 1494 QTextStream tmp (buf, IO_ReadOnly);
1495 ushort lower, shift; 1495 ushort lower, shift;
1496 QChar c; 1496 QChar c;
1497 tmp >> c >> lower >> shift; 1497 tmp >> c >> lower >> shift;
1498 1498
1499 circumflexMap.insert(lower, shift); 1499 circumflexMap.insert(lower, shift);
1500 1500
1501 buf = t.readLine(); 1501 buf = t.readLine();
1502 } 1502 }
1503 // diaeresis 1503 // diaeresis
1504 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1504 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1505 1505
1506 QTextStream tmp (buf, IO_ReadOnly); 1506 QTextStream tmp (buf, IO_ReadOnly);
1507 ushort lower, shift; 1507 ushort lower, shift;
1508 QChar d; 1508 QChar d;
1509 tmp >> d >> lower >> shift; 1509 tmp >> d >> lower >> shift;
1510 1510
1511 diaeresisMap.insert(lower, shift); 1511 diaeresisMap.insert(lower, shift);
1512 1512
1513 buf = t.readLine(); 1513 buf = t.readLine();
1514 } 1514 }
1515 // back accent 1515 // back accent
1516 else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1516 else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1517 1517
1518 QTextStream tmp (buf, IO_ReadOnly); 1518 QTextStream tmp (buf, IO_ReadOnly);
1519 ushort lower, shift; 1519 ushort lower, shift;
1520 QChar d; 1520 QChar d;
1521 tmp >> d >> lower >> shift; 1521 tmp >> d >> lower >> shift;
1522 1522
1523 baccentMap.insert(lower, shift); 1523 baccentMap.insert(lower, shift);
1524 1524
1525 qDebug ("Estoy aadiendo %i con %i", lower, shift); 1525 qDebug ("Estoy aadiendo %i con %i", lower, shift);
1526 buf = t.readLine(); 1526 buf = t.readLine();
1527 } 1527 }
1528 // accent 1528 // accent
1529 else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1529 else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1530 1530
1531 QTextStream tmp (buf, IO_ReadOnly); 1531 QTextStream tmp (buf, IO_ReadOnly);
1532 ushort lower, shift; 1532 ushort lower, shift;
1533 QChar d; 1533 QChar d;
1534 tmp >> d >> lower >> shift; 1534 tmp >> d >> lower >> shift;
1535 1535
1536 accentMap.insert(lower, shift); 1536 accentMap.insert(lower, shift);
1537 1537
1538 buf = t.readLine(); 1538 buf = t.readLine();
1539 } 1539 }
1540 1540
1541 // other variables like lang & title & sw 1541 // other variables like lang & title & sw
1542 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1542 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1543 1543
1544 QTextStream tmp (buf, IO_ReadOnly); 1544 QTextStream tmp (buf, IO_ReadOnly);
1545 QString name, equals, value; 1545 QString name, equals, value;
1546 1546
1547 tmp >> name >> equals >> value; 1547 tmp >> name >> equals >> value;
1548 1548
1549 if (name == "lang") { 1549 if (name == "lang") {
1550 1550
1551 lang = value; 1551 lang = value;
1552 1552
1553 } 1553 }
1554 1554
1555 buf = t.readLine(); 1555 buf = t.readLine();
1556 } 1556 }
1557 // comments 1557 // comments
1558 else if (buf.contains(QRegExp("^\\s*#"))) { 1558 else if (buf.contains(QRegExp("^\\s*#"))) {
1559 1559
1560 buf = t.readLine(); 1560 buf = t.readLine();
1561 1561
1562 } else { // blank line, or garbage 1562 } else { // blank line, or garbage
1563 1563
1564 buf = t.readLine(); 1564 buf = t.readLine();
1565 1565
1566 } 1566 }
1567 1567
1568 } 1568 }
1569 1569
1570 f.close(); 1570 f.close();
1571 } else { 1571 } else {
1572 // We couldnt find the selected keymap, give them a configure button 1572 // We couldnt find the selected keymap, give them a configure button
1573 QImage * btn = new QImage((const char ** )kb_config_xpm); 1573 QImage * btn = new QImage((const char ** )kb_config_xpm);
1574 setKey(1, 0x1030, 0, 2, btn); 1574 setKey(1, 0x1030, 0, 2, btn);
1575 } 1575 }
1576 1576
1577} 1577}
1578 1578
1579 1579
1580// Keys::setKey {{{2 1580// Keys::setKey {{{2
1581void Keys::setKey(const int row, const int qcode, const ushort unicode, 1581void Keys::setKey(const int row, const int qcode, const ushort unicode,
1582 const int width, QImage *pix) { 1582 const int width, QImage *pix) {
1583 1583
1584 Key * key; 1584 Key * key;
1585 key = new Key; 1585 key = new Key;
1586 key->qcode = qcode; 1586 key->qcode = qcode;
1587 key->unicode = unicode; 1587 key->unicode = unicode;
1588 key->width = width; 1588 key->width = width;
1589 1589
1590 // share key->pressed between same keys 1590 // share key->pressed between same keys
1591 bool found = 0; 1591 bool found = 0;
1592 for (int i = 1; i <= 5; i++) { 1592 for (int i = 1; i <= 5; i++) {
1593 for (unsigned int j = 0; j < keys[i].count(); j++) 1593 for (unsigned int j = 0; j < keys[i].count(); j++)
1594 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1594 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1595 1595
1596 key->pressed = keys[i].at(j)->pressed; 1596 key->pressed = keys[i].at(j)->pressed;
1597 found = 1; 1597 found = 1;
1598 } 1598 }
1599 1599
1600 } 1600 }
1601 if (!found) { 1601 if (!found) {
1602 1602
1603 key->pressed = new bool; 1603 key->pressed = new bool;
1604 *(key->pressed) = 0; 1604 *(key->pressed) = 0;
1605 } 1605 }
1606 1606
1607 key->pix = pix; 1607 key->pix = pix;
1608 1608
1609 1609
1610 keys[row].append(key); 1610 keys[row].append(key);
1611} 1611}
1612 1612
1613// Keys::~Keys {{{2 1613// Keys::~Keys {{{2
1614Keys::~Keys() { 1614Keys::~Keys() {
1615 1615
1616 for (int i = 1; i <= 5; i++) 1616 for (int i = 1; i <= 5; i++)
1617 for (unsigned int j = 0; j < keys[i].count(); j++) 1617 for (unsigned int j = 0; j < keys[i].count(); j++)
1618 delete keys[i].at(j); 1618 delete keys[i].at(j);
1619 1619
1620} 1620}
1621 1621
1622// Keys:: other functions {{{2 1622// Keys:: other functions {{{2
1623int Keys::width(const int row, const int col) { 1623int Keys::width(const int row, const int col) {
1624 1624
1625 return keys[row].at(col)->width; 1625 return keys[row].at(col)->width;
1626 1626
1627} 1627}
1628 1628
1629int Keys::rows() { 1629int Keys::rows() {
1630 1630
1631 for (int i = 1; i <= 5; i++) { 1631 for (int i = 1; i <= 5; i++) {
1632 1632
1633 if (keys[i].count() == 0) 1633 if (keys[i].count() == 0)
1634 return i - 1; 1634 return i - 1;
1635 1635
1636 } 1636 }
1637 return 5; 1637 return 5;
1638} 1638}
1639 1639
1640ushort Keys::uni(const int row, const int col) { 1640ushort Keys::uni(const int row, const int col) {
1641 1641
1642 return keys[row].at(col)->unicode; 1642 return keys[row].at(col)->unicode;
1643 1643
1644} 1644}
1645 1645
1646int Keys::qcode(const int row, const int col) { 1646int Keys::qcode(const int row, const int col) {
1647 1647
1648 return keys[row].at(col)->qcode; 1648 return keys[row].at(col)->qcode;
1649} 1649}
1650 1650
1651QImage *Keys::pix(const int row, const int col) { 1651QImage *Keys::pix(const int row, const int col) {
1652 1652
1653 return keys[row].at(col)->pix; 1653 return keys[row].at(col)->pix;
1654 1654
1655} 1655}
1656bool Keys::pressed(const int row, const int col) { 1656bool Keys::pressed(const int row, const int col) {
1657 1657
1658 return *(keys[row].at(col)->pressed); 1658 return *(keys[row].at(col)->pressed);
1659} 1659}
1660 1660
1661int Keys::numKeys(const int row) { 1661int Keys::numKeys(const int row) {
1662 1662
1663 return keys[row].count(); 1663 return keys[row].count();
1664} 1664}
1665 1665
1666void Keys::setPressed(const int row, const int col, const bool pressed) { 1666void Keys::setPressed(const int row, const int col, const bool pressed) {
1667 1667
1668 *(keys[row].at(col)->pressed) = pressed; 1668 *(keys[row].at(col)->pressed) = pressed;
1669} 1669}
1670 1670
1671ushort Keys::shift(const ushort uni) { 1671ushort Keys::shift(const ushort uni) {
1672 1672
1673 if (shiftMap[uni]) return shiftMap[uni]; 1673 if (shiftMap[uni]) return shiftMap[uni];
1674 else return 0; 1674 else return 0;
1675} 1675}
1676 1676
1677ushort Keys::meta(const ushort uni) { 1677ushort Keys::meta(const ushort uni) {
1678 1678
1679 if (metaMap[uni]) return metaMap[uni]; 1679 if (metaMap[uni]) return metaMap[uni];
1680 else return 0; 1680 else return 0;
1681} 1681}
1682 1682
1683ushort Keys::circumflex(const ushort uni) { 1683ushort Keys::circumflex(const ushort uni) {
1684 1684
1685 if (circumflexMap[uni]) return circumflexMap[uni]; 1685 if (circumflexMap[uni]) return circumflexMap[uni];
1686 else return 0; 1686 else return 0;
1687} 1687}
1688 1688
1689ushort Keys::diaeresis(const ushort uni) { 1689ushort Keys::diaeresis(const ushort uni) {
1690 1690
1691 if(diaeresisMap[uni]) return diaeresisMap[uni]; 1691 if(diaeresisMap[uni]) return diaeresisMap[uni];
1692 else return 0; 1692 else return 0;
1693} 1693}
1694 1694
1695ushort Keys::baccent(const ushort uni) { 1695ushort Keys::baccent(const ushort uni) {
1696 1696
1697 if(baccentMap[uni]) return baccentMap[uni]; 1697 if(baccentMap[uni]) return baccentMap[uni];
1698 else return 0; 1698 else return 0;
1699} 1699}
1700 1700
1701ushort Keys::accent(const ushort uni) { 1701ushort Keys::accent(const ushort uni) {
1702 1702
1703 if(accentMap[uni]) return accentMap[uni]; 1703 if(accentMap[uni]) return accentMap[uni];
1704 else return 0; 1704 else return 0;
1705} 1705}
1706 1706
1707bool *Keys::pressedPtr(const int row, const int col) { 1707bool *Keys::pressedPtr(const int row, const int col) {
1708 1708
1709 return keys[row].at(col)->pressed; 1709 return keys[row].at(col)->pressed;
1710} 1710}