author | hash <hash> | 2002-08-27 17:55:22 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-27 17:55:22 (UTC) |
commit | 48a1af2115e44f44ccc3918ef77f77167d1bbc24 (patch) (unidiff) | |
tree | f6cbd81ac5019c6fc5b38ae9445b1510a9b91845 | |
parent | 83091c400324e103650a709206f6983ebf2a5e22 (diff) | |
download | opie-48a1af2115e44f44ccc3918ef77f77167d1bbc24.zip opie-48a1af2115e44f44ccc3918ef77f77167d1bbc24.tar.gz opie-48a1af2115e44f44ccc3918ef77f77167d1bbc24.tar.bz2 |
pickboard off by default now working
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 5 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index f6507b4..26c9233 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,422 +1,421 @@ | |||
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 cursor thing | 4 | * make vertical keys possible |
5 | * add meta key support for german, etc | 5 | * make a keymap editor |
6 | * | ||
7 | * | 6 | * |
8 | * | 7 | * |
9 | */ | 8 | */ |
10 | 9 | ||
11 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
13 | 12 | ||
14 | #include <qwidget.h> | 13 | #include <qwidget.h> |
15 | #include <qdialog.h> | 14 | #include <qdialog.h> |
16 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
17 | #include <qvbox.h> | 16 | #include <qvbox.h> |
18 | #include <qgrid.h> | 17 | #include <qgrid.h> |
19 | #include <qgroupbox.h> | 18 | #include <qgroupbox.h> |
20 | #include <qlabel.h> | 19 | #include <qlabel.h> |
21 | #include <qcheckbox.h> | 20 | #include <qcheckbox.h> |
22 | #include <qsizepolicy.h> | 21 | #include <qsizepolicy.h> |
23 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
24 | #include <qlistbox.h> | 23 | #include <qlistbox.h> |
25 | #include <qstringlist.h> | 24 | #include <qstringlist.h> |
26 | #include <opie/ofiledialog.h> | 25 | #include <opie/ofiledialog.h> |
27 | #include <opie/colordialog.h> | 26 | #include <opie/colordialog.h> |
28 | #include <qdir.h> | 27 | #include <qdir.h> |
29 | #include <qfileinfo.h> | 28 | #include <qfileinfo.h> |
30 | #include "configdlg.h" | 29 | #include "configdlg.h" |
31 | #include "keyboard.h" | 30 | #include "keyboard.h" |
32 | 31 | ||
33 | // ConfigDlg::ConfigDlg() {{{1 | 32 | // ConfigDlg::ConfigDlg() {{{1 |
34 | ConfigDlg::ConfigDlg () : QTabWidget () | 33 | ConfigDlg::ConfigDlg () : QTabWidget () |
35 | { | 34 | { |
36 | setCaption( tr("Multikey Configuration") ); | 35 | setCaption( tr("Multikey Configuration") ); |
37 | Config config ("multikey"); | 36 | Config config ("multikey"); |
38 | config.setGroup("keymaps"); | 37 | config.setGroup("keymaps"); |
39 | QString current_map = config.readEntry("current", 0); | 38 | QString current_map = config.readEntry("current", 0); |
40 | 39 | ||
41 | /* | 40 | /* |
42 | * 'general config' tab | 41 | * 'general config' tab |
43 | */ | 42 | */ |
44 | 43 | ||
45 | QVBox *gen_box = new QVBox (this); | 44 | QVBox *gen_box = new QVBox (this); |
46 | gen_box->setMargin(3); | 45 | gen_box->setMargin(3); |
47 | addTab(gen_box, tr("General Settings")); | 46 | addTab(gen_box, tr("General Settings")); |
48 | 47 | ||
49 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 48 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
50 | 49 | ||
51 | keymaps = new QListBox (map_group); | 50 | keymaps = new QListBox (map_group); |
52 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 51 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
53 | 52 | ||
54 | QString cur(tr("Current Language")); | 53 | QString cur(tr("Current Language")); |
55 | keymaps->insertItem(cur); | 54 | keymaps->insertItem(cur); |
56 | keymaps->setSelected(0, true); | 55 | keymaps->setSelected(0, true); |
57 | 56 | ||
58 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 57 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); |
59 | default_maps = map_dir.entryList(); // so i can access it in other places | 58 | default_maps = map_dir.entryList(); // so i can access it in other places |
60 | 59 | ||
61 | for (uint i = 0; i < map_dir.count(); i++) { | 60 | for (uint i = 0; i < map_dir.count(); i++) { |
62 | 61 | ||
63 | QFile map (map_dir.absPath() + "/" + map_dir[i]); | 62 | QFile map (map_dir.absPath() + "/" + map_dir[i]); |
64 | if (map.open(IO_ReadOnly)) { | 63 | if (map.open(IO_ReadOnly)) { |
65 | 64 | ||
66 | QString line; bool found = 0; | 65 | QString line; bool found = 0; |
67 | 66 | ||
68 | map.readLine(line, 1024); | 67 | map.readLine(line, 1024); |
69 | while (!map.atEnd()) { | 68 | while (!map.atEnd()) { |
70 | 69 | ||
71 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 70 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
72 | 71 | ||
73 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 72 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
74 | found = 1; | 73 | found = 1; |
75 | break; | 74 | break; |
76 | } | 75 | } |
77 | map.readLine(line, 1024); | 76 | map.readLine(line, 1024); |
78 | } | 77 | } |
79 | if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); | 78 | if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); |
80 | 79 | ||
81 | map.close(); | 80 | map.close(); |
82 | } | 81 | } |
83 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { | 82 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { |
84 | 83 | ||
85 | keymaps->setSelected(i + 1, true); | 84 | keymaps->setSelected(i + 1, true); |
86 | } | 85 | } |
87 | 86 | ||
88 | } | 87 | } |
89 | 88 | ||
90 | custom_maps = config.readListEntry("maps", QChar('|')); | 89 | custom_maps = config.readListEntry("maps", QChar('|')); |
91 | 90 | ||
92 | for (uint i = 0; i < custom_maps.count(); i++) { | 91 | for (uint i = 0; i < custom_maps.count(); i++) { |
93 | 92 | ||
94 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) | 93 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) |
95 | || !QFile::exists(custom_maps[i])) { | 94 | || !QFile::exists(custom_maps[i])) { |
96 | 95 | ||
97 | custom_maps.remove(custom_maps.at(i)); | 96 | custom_maps.remove(custom_maps.at(i)); |
98 | 97 | ||
99 | // remove it from the list too | 98 | // remove it from the list too |
100 | config.writeEntry("maps", custom_maps.join("|")); | 99 | config.writeEntry("maps", custom_maps.join("|")); |
101 | 100 | ||
102 | 101 | ||
103 | } else { | 102 | } else { |
104 | 103 | ||
105 | QFile map (custom_maps[i]); | 104 | QFile map (custom_maps[i]); |
106 | if (map.open(IO_ReadOnly)) { | 105 | if (map.open(IO_ReadOnly)) { |
107 | 106 | ||
108 | QString line; bool found = 0; | 107 | QString line; bool found = 0; |
109 | 108 | ||
110 | map.readLine(line, 1024); | 109 | map.readLine(line, 1024); |
111 | while (!map.atEnd()) { | 110 | while (!map.atEnd()) { |
112 | 111 | ||
113 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 112 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
114 | 113 | ||
115 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 114 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
116 | found = 1; | 115 | found = 1; |
117 | break; | 116 | break; |
118 | } | 117 | } |
119 | map.readLine(line, 1024); | 118 | map.readLine(line, 1024); |
120 | } | 119 | } |
121 | if (!found) keymaps->insertItem(custom_maps[i]); | 120 | if (!found) keymaps->insertItem(custom_maps[i]); |
122 | 121 | ||
123 | map.close(); | 122 | map.close(); |
124 | } | 123 | } |
125 | if (custom_maps[i] == current_map) { | 124 | if (custom_maps[i] == current_map) { |
126 | 125 | ||
127 | keymaps->setSelected(map_dir.count() + i + 1, true); | 126 | keymaps->setSelected(map_dir.count() + i + 1, true); |
128 | } | 127 | } |
129 | } | 128 | } |
130 | } | 129 | } |
131 | 130 | ||
132 | // have to "+1" because the "current language" listItem... remember? | 131 | // have to "+1" because the "current language" listItem... remember? |
133 | 132 | ||
134 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 133 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
135 | 134 | ||
136 | 135 | ||
137 | QGrid *add_remove_grid = new QGrid(2, map_group); | 136 | QGrid *add_remove_grid = new QGrid(2, map_group); |
138 | add_remove_grid->setMargin(3); | 137 | add_remove_grid->setMargin(3); |
139 | add_remove_grid->setSpacing(3); | 138 | add_remove_grid->setSpacing(3); |
140 | 139 | ||
141 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 140 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
142 | add_button->setFlat((bool)1); | 141 | add_button->setFlat((bool)1); |
143 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 142 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
144 | 143 | ||
145 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 144 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
146 | remove_button->setFlat((bool)1); | 145 | remove_button->setFlat((bool)1); |
147 | if ((int)map_dir.count() >= keymaps->currentItem()) | 146 | if ((int)map_dir.count() >= keymaps->currentItem()) |
148 | remove_button->setDisabled(true); | 147 | remove_button->setDisabled(true); |
149 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 148 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
150 | 149 | ||
151 | // make a box that will contain the buttons on the bottom | 150 | // make a box that will contain the buttons on the bottom |
152 | QGrid *other_grid = new QGrid(2, gen_box); | 151 | QGrid *other_grid = new QGrid(2, gen_box); |
153 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | 152 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); |
154 | 153 | ||
155 | config.setGroup ("general"); | 154 | config.setGroup ("general"); |
156 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed | 155 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed |
157 | if (pick_open) { | 156 | if (pick_open) { |
158 | 157 | ||
159 | pick_button->setChecked(true); | 158 | pick_button->setChecked(true); |
160 | } | 159 | } |
161 | 160 | ||
162 | // by connecting it after checking it, the signal isn't emmited | 161 | // by connecting it after checking it, the signal isn't emmited |
163 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 162 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
164 | 163 | ||
165 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | 164 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); |
166 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); | 165 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); |
167 | 166 | ||
168 | if (repeat_on) { | 167 | if (repeat_on) { |
169 | 168 | ||
170 | repeat_button->setChecked(true); | 169 | repeat_button->setChecked(true); |
171 | } | 170 | } |
172 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); | 171 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); |
173 | 172 | ||
174 | 173 | ||
175 | /* | 174 | /* |
176 | * 'color' tab | 175 | * 'color' tab |
177 | */ | 176 | */ |
178 | 177 | ||
179 | QGrid *color_box = new QGrid(2, this); | 178 | QGrid *color_box = new QGrid(2, this); |
180 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 179 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
181 | color_box->setMargin(3); | 180 | color_box->setMargin(3); |
182 | color_box->setSpacing(3); | 181 | color_box->setSpacing(3); |
183 | addTab(color_box, tr("Colors")); | 182 | addTab(color_box, tr("Colors")); |
184 | 183 | ||
185 | QLabel *label; | 184 | QLabel *label; |
186 | QStringList color; | 185 | QStringList color; |
187 | config.setGroup("colors"); | 186 | config.setGroup("colors"); |
188 | 187 | ||
189 | label = new QLabel(tr("Key Color"), color_box); | 188 | label = new QLabel(tr("Key Color"), color_box); |
190 | keycolor_button = new QPushButton(color_box); | 189 | keycolor_button = new QPushButton(color_box); |
191 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); | 190 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
192 | keycolor_button->setFlat((bool)1); | 191 | keycolor_button->setFlat((bool)1); |
193 | color = config.readListEntry("keycolor", QChar(',')); | 192 | color = config.readListEntry("keycolor", QChar(',')); |
194 | /* | 193 | /* |
195 | * hopefully not required | 194 | * hopefully not required |
196 | 195 | ||
197 | if (color.isEmpty()) { | 196 | if (color.isEmpty()) { |
198 | color = QStringList::split(",", "240,240,240"); | 197 | color = QStringList::split(",", "240,240,240"); |
199 | config.writeEntry("keycolor", color.join(",")); | 198 | config.writeEntry("keycolor", color.join(",")); |
200 | 199 | ||
201 | } | 200 | } |
202 | */ | 201 | */ |
203 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); | 202 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); |
204 | 203 | ||
205 | 204 | ||
206 | label = new QLabel(tr("Key Pressed Color"), color_box); | 205 | label = new QLabel(tr("Key Pressed Color"), color_box); |
207 | keycolor_pressed_button = new QPushButton(color_box); | 206 | keycolor_pressed_button = new QPushButton(color_box); |
208 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); | 207 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
209 | keycolor_pressed_button->setFlat((bool)1); | 208 | keycolor_pressed_button->setFlat((bool)1); |
210 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 209 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
211 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 210 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
212 | 211 | ||
213 | label = new QLabel(tr("Line Color"), color_box); | 212 | label = new QLabel(tr("Line Color"), color_box); |
214 | keycolor_lines_button = new QPushButton(color_box); | 213 | keycolor_lines_button = new QPushButton(color_box); |
215 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); | 214 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
216 | keycolor_lines_button->setFlat((bool)1); | 215 | keycolor_lines_button->setFlat((bool)1); |
217 | color = config.readListEntry("keycolor_lines", QChar(',')); | 216 | color = config.readListEntry("keycolor_lines", QChar(',')); |
218 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 217 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
219 | 218 | ||
220 | 219 | ||
221 | label = new QLabel(tr("Text Color"), color_box); | 220 | label = new QLabel(tr("Text Color"), color_box); |
222 | textcolor_button = new QPushButton(color_box); | 221 | textcolor_button = new QPushButton(color_box); |
223 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); | 222 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
224 | textcolor_button->setFlat((bool)1); | 223 | textcolor_button->setFlat((bool)1); |
225 | color = config.readListEntry("textcolor", QChar(',')); | 224 | color = config.readListEntry("textcolor", QChar(',')); |
226 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 225 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
227 | 226 | ||
228 | 227 | ||
229 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 228 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
230 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 229 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
231 | 230 | ||
232 | } | 231 | } |
233 | 232 | ||
234 | void ConfigDlg::pickTog() { | 233 | void ConfigDlg::pickTog() { |
235 | 234 | ||
236 | Config config ("multikey"); | 235 | Config config ("multikey"); |
237 | config.setGroup ("general"); | 236 | config.setGroup ("general"); |
238 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed | 237 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed |
239 | 238 | ||
240 | emit pickboardToggled(pick_button->isChecked()); | 239 | emit pickboardToggled(pick_button->isChecked()); |
241 | } | 240 | } |
242 | 241 | ||
243 | void ConfigDlg::repeatTog() { | 242 | void ConfigDlg::repeatTog() { |
244 | 243 | ||
245 | Config config ("multikey"); | 244 | Config config ("multikey"); |
246 | config.setGroup ("general"); | 245 | config.setGroup ("general"); |
247 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed | 246 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed |
248 | 247 | ||
249 | emit repeatToggled(repeat_button->isChecked()); | 248 | emit repeatToggled(repeat_button->isChecked()); |
250 | } | 249 | } |
251 | 250 | ||
252 | // ConfigDlg::setMap {{{1 | 251 | // ConfigDlg::setMap {{{1 |
253 | 252 | ||
254 | /* | 253 | /* |
255 | * the index is kinda screwy, because in the config file, index 0 is just the | 254 | * the index is kinda screwy, because in the config file, index 0 is just the |
256 | * first element in the QStringList, but here it's the "Current Language" | 255 | * first element in the QStringList, but here it's the "Current Language" |
257 | * listItem. therefor you have to minus one to the index before you access it. | 256 | * listItem. therefor you have to minus one to the index before you access it. |
258 | * | 257 | * |
259 | */ | 258 | */ |
260 | 259 | ||
261 | void ConfigDlg::setMap(int index) { | 260 | void ConfigDlg::setMap(int index) { |
262 | 261 | ||
263 | if (index == 0) { | 262 | if (index == 0) { |
264 | 263 | ||
265 | remove_button->setDisabled(true); | 264 | remove_button->setDisabled(true); |
266 | emit setMapToDefault(); | 265 | emit setMapToDefault(); |
267 | } | 266 | } |
268 | else if ((uint)index <= default_maps.count()) { | 267 | else if ((uint)index <= default_maps.count()) { |
269 | 268 | ||
270 | remove_button->setDisabled(true); | 269 | remove_button->setDisabled(true); |
271 | emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]); | 270 | emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]); |
272 | 271 | ||
273 | } else { | 272 | } else { |
274 | 273 | ||
275 | remove_button->setEnabled(true); | 274 | remove_button->setEnabled(true); |
276 | emit setMapToFile(custom_maps[index - default_maps.count() - 1]); | 275 | emit setMapToFile(custom_maps[index - default_maps.count() - 1]); |
277 | } | 276 | } |
278 | } | 277 | } |
279 | 278 | ||
280 | // ConfigDlg::addMap() {{{1 | 279 | // ConfigDlg::addMap() {{{1 |
281 | void ConfigDlg::addMap() { | 280 | void ConfigDlg::addMap() { |
282 | 281 | ||
283 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); | 282 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); |
284 | 283 | ||
285 | if (map.isNull()) return; | 284 | if (map.isNull()) return; |
286 | 285 | ||
287 | Config config ("multikey"); | 286 | Config config ("multikey"); |
288 | config.setGroup("keymaps"); | 287 | config.setGroup("keymaps"); |
289 | QStringList maps = config.readListEntry("maps", QChar('|')); | 288 | QStringList maps = config.readListEntry("maps", QChar('|')); |
290 | maps.append(map); | 289 | maps.append(map); |
291 | custom_maps.append(map); | 290 | custom_maps.append(map); |
292 | 291 | ||
293 | QFile map_file (map); | 292 | QFile map_file (map); |
294 | if (map_file.open(IO_ReadOnly)) { | 293 | if (map_file.open(IO_ReadOnly)) { |
295 | 294 | ||
296 | QString line; bool found = 0; | 295 | QString line; bool found = 0; |
297 | 296 | ||
298 | map_file.readLine(line, 1024); | 297 | map_file.readLine(line, 1024); |
299 | while (!map_file.atEnd()) { | 298 | while (!map_file.atEnd()) { |
300 | 299 | ||
301 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 300 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
302 | 301 | ||
303 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 302 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
304 | found = 1; | 303 | found = 1; |
305 | break; | 304 | break; |
306 | } | 305 | } |
307 | map_file.readLine(line, 1024); | 306 | map_file.readLine(line, 1024); |
308 | } | 307 | } |
309 | if (!found) keymaps->insertItem(map); | 308 | if (!found) keymaps->insertItem(map); |
310 | 309 | ||
311 | map_file.close(); | 310 | map_file.close(); |
312 | } | 311 | } |
313 | 312 | ||
314 | keymaps->setSelected(keymaps->count() - 1, true); | 313 | keymaps->setSelected(keymaps->count() - 1, true); |
315 | 314 | ||
316 | 315 | ||
317 | config.writeEntry("maps", maps, QChar('|')); | 316 | config.writeEntry("maps", maps, QChar('|')); |
318 | config.writeEntry("current", map); | 317 | config.writeEntry("current", map); |
319 | 318 | ||
320 | } | 319 | } |
321 | 320 | ||
322 | // ConfigDlg::removeMap() {{{1 | 321 | // ConfigDlg::removeMap() {{{1 |
323 | void ConfigDlg::removeMap() { | 322 | void ConfigDlg::removeMap() { |
324 | 323 | ||
325 | // move selection up one | 324 | // move selection up one |
326 | keymaps->setSelected(keymaps->currentItem() - 1, true); | 325 | keymaps->setSelected(keymaps->currentItem() - 1, true); |
327 | // delete the next selected item cus you just moved it up | 326 | // delete the next selected item cus you just moved it up |
328 | keymaps->removeItem(keymaps->currentItem() + 1); | 327 | keymaps->removeItem(keymaps->currentItem() + 1); |
329 | 328 | ||
330 | custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count())); | 329 | custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count())); |
331 | 330 | ||
332 | // write the changes | 331 | // write the changes |
333 | Config config ("multikey"); | 332 | Config config ("multikey"); |
334 | config.setGroup("keymaps"); | 333 | config.setGroup("keymaps"); |
335 | config.writeEntry("maps", custom_maps, QChar('|')); | 334 | config.writeEntry("maps", custom_maps, QChar('|')); |
336 | } | 335 | } |
337 | 336 | ||
338 | /* ConfigDlg::slots for the color buttons {{{1 | 337 | /* ConfigDlg::slots for the color buttons {{{1 |
339 | * | 338 | * |
340 | * these four slots are almost the same, except for the names. i was thinking | 339 | * these four slots are almost the same, except for the names. i was thinking |
341 | * of making a map with pointers to the buttons and names of the configEntry | 340 | * of making a map with pointers to the buttons and names of the configEntry |
342 | * so it could be one slot, but then there would be no way of telling which | 341 | * so it could be one slot, but then there would be no way of telling which |
343 | * of the buttons was clicked if they all connect to the same slot. | 342 | * of the buttons was clicked if they all connect to the same slot. |
344 | * | 343 | * |
345 | */ | 344 | */ |
346 | 345 | ||
347 | void ConfigDlg::keyColorClicked() { | 346 | void ConfigDlg::keyColorClicked() { |
348 | 347 | ||
349 | Config config ("multikey"); | 348 | Config config ("multikey"); |
350 | config.setGroup ("colors"); | 349 | config.setGroup ("colors"); |
351 | 350 | ||
352 | QStringList color = config.readListEntry("keycolor", QChar(',')); | 351 | QStringList color = config.readListEntry("keycolor", QChar(',')); |
353 | 352 | ||
354 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 353 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
355 | 354 | ||
356 | color[0].setNum(newcolor.red()); | 355 | color[0].setNum(newcolor.red()); |
357 | color[1].setNum(newcolor.green()); | 356 | color[1].setNum(newcolor.green()); |
358 | color[2].setNum(newcolor.blue()); | 357 | color[2].setNum(newcolor.blue()); |
359 | 358 | ||
360 | config.writeEntry("keycolor", color, QChar(',')); | 359 | config.writeEntry("keycolor", color, QChar(',')); |
361 | config.write(); | 360 | config.write(); |
362 | 361 | ||
363 | keycolor_button->setPalette(QPalette(newcolor)); | 362 | keycolor_button->setPalette(QPalette(newcolor)); |
364 | emit reloadKeyboard(); | 363 | emit reloadKeyboard(); |
365 | } | 364 | } |
366 | void ConfigDlg::keyColorPressedClicked() { | 365 | void ConfigDlg::keyColorPressedClicked() { |
367 | 366 | ||
368 | Config config ("multikey"); | 367 | Config config ("multikey"); |
369 | config.setGroup ("colors"); | 368 | config.setGroup ("colors"); |
370 | 369 | ||
371 | QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); | 370 | QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); |
372 | 371 | ||
373 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 372 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
374 | 373 | ||
375 | color[0].setNum(newcolor.red()); | 374 | color[0].setNum(newcolor.red()); |
376 | color[1].setNum(newcolor.green()); | 375 | color[1].setNum(newcolor.green()); |
377 | color[2].setNum(newcolor.blue()); | 376 | color[2].setNum(newcolor.blue()); |
378 | 377 | ||
379 | config.writeEntry("keycolor_pressed", color, QChar(',')); | 378 | config.writeEntry("keycolor_pressed", color, QChar(',')); |
380 | config.write(); | 379 | config.write(); |
381 | 380 | ||
382 | keycolor_pressed_button->setPalette(QPalette(newcolor)); | 381 | keycolor_pressed_button->setPalette(QPalette(newcolor)); |
383 | emit reloadKeyboard(); | 382 | emit reloadKeyboard(); |
384 | } | 383 | } |
385 | void ConfigDlg::keyColorLinesClicked() { | 384 | void ConfigDlg::keyColorLinesClicked() { |
386 | 385 | ||
387 | Config config ("multikey"); | 386 | Config config ("multikey"); |
388 | config.setGroup ("colors"); | 387 | config.setGroup ("colors"); |
389 | 388 | ||
390 | QStringList color = config.readListEntry("keycolor_lines", QChar(',')); | 389 | QStringList color = config.readListEntry("keycolor_lines", QChar(',')); |
391 | 390 | ||
392 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 391 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
393 | 392 | ||
394 | color[0].setNum(newcolor.red()); | 393 | color[0].setNum(newcolor.red()); |
395 | color[1].setNum(newcolor.green()); | 394 | color[1].setNum(newcolor.green()); |
396 | color[2].setNum(newcolor.blue()); | 395 | color[2].setNum(newcolor.blue()); |
397 | 396 | ||
398 | config.writeEntry("keycolor_lines", color, QChar(',')); | 397 | config.writeEntry("keycolor_lines", color, QChar(',')); |
399 | config.write(); | 398 | config.write(); |
400 | 399 | ||
401 | keycolor_lines_button->setPalette(QPalette(newcolor)); | 400 | keycolor_lines_button->setPalette(QPalette(newcolor)); |
402 | emit reloadKeyboard(); | 401 | emit reloadKeyboard(); |
403 | } | 402 | } |
404 | void ConfigDlg::textColorClicked() { | 403 | void ConfigDlg::textColorClicked() { |
405 | 404 | ||
406 | Config config ("multikey"); | 405 | Config config ("multikey"); |
407 | config.setGroup ("colors"); | 406 | config.setGroup ("colors"); |
408 | 407 | ||
409 | QStringList color = config.readListEntry("textcolor", QChar(',')); | 408 | QStringList color = config.readListEntry("textcolor", QChar(',')); |
410 | 409 | ||
411 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 410 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
412 | 411 | ||
413 | color[0].setNum(newcolor.red()); | 412 | color[0].setNum(newcolor.red()); |
414 | color[1].setNum(newcolor.green()); | 413 | color[1].setNum(newcolor.green()); |
415 | color[2].setNum(newcolor.blue()); | 414 | color[2].setNum(newcolor.blue()); |
416 | 415 | ||
417 | config.writeEntry("textcolor", color, QChar(',')); | 416 | config.writeEntry("textcolor", color, QChar(',')); |
418 | config.write(); | 417 | config.write(); |
419 | 418 | ||
420 | textcolor_button->setPalette(QPalette(newcolor)); | 419 | textcolor_button->setPalette(QPalette(newcolor)); |
421 | emit reloadKeyboard(); | 420 | emit reloadKeyboard(); |
422 | } | 421 | } |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 92ea896..4747f59 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1264 +1,1264 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <sys/utsname.h> | 38 | #include <sys/utsname.h> |
39 | 39 | ||
40 | 40 | ||
41 | /* Keyboard::Keyboard {{{1 */ | 41 | /* Keyboard::Keyboard {{{1 */ |
42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), | 43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), |
44 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), | 44 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), |
45 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 45 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
46 | configdlg(0) | 46 | configdlg(0) |
47 | 47 | ||
48 | { | 48 | { |
49 | 49 | ||
50 | // get the default font | 50 | // get the default font |
51 | Config *config = new Config( "qpe" ); | 51 | Config *config = new Config( "qpe" ); |
52 | config->setGroup( "Appearance" ); | 52 | config->setGroup( "Appearance" ); |
53 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 53 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
54 | delete config; | 54 | delete config; |
55 | 55 | ||
56 | config = new Config("multikey"); | 56 | config = new Config("multikey"); |
57 | config->setGroup ("general"); | 57 | config->setGroup ("general"); |
58 | usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed | 58 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
59 | useRepeat = config->readBoolEntry ("useRepeat", "1"); | 59 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
60 | delete config; | 60 | delete config; |
61 | 61 | ||
62 | 62 | ||
63 | setFont( QFont( familyStr, 10 ) ); | 63 | setFont( QFont( familyStr, 10 ) ); |
64 | 64 | ||
65 | picks = new KeyboardPicks( this ); | 65 | picks = new KeyboardPicks( this ); |
66 | picks->setFont( QFont( familyStr, 10 ) ); | 66 | picks->setFont( QFont( familyStr, 10 ) ); |
67 | picks->initialise(); | 67 | picks->initialise(); |
68 | if (usePicks) { | 68 | if (usePicks) { |
69 | 69 | ||
70 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 70 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
71 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 71 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
72 | 72 | ||
73 | } else picks->hide(); | 73 | } else picks->hide(); |
74 | 74 | ||
75 | loadKeyboardColors(); | 75 | loadKeyboardColors(); |
76 | 76 | ||
77 | keys = new Keys(); | 77 | keys = new Keys(); |
78 | 78 | ||
79 | repeatTimer = new QTimer( this ); | 79 | repeatTimer = new QTimer( this ); |
80 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 80 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | Keyboard::~Keyboard() { | 84 | Keyboard::~Keyboard() { |
85 | 85 | ||
86 | if ( configdlg ) { | 86 | if ( configdlg ) { |
87 | delete (ConfigDlg *) configdlg; | 87 | delete (ConfigDlg *) configdlg; |
88 | configdlg = 0; | 88 | configdlg = 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | /* Keyboard::resizeEvent {{{1 */ | 93 | /* Keyboard::resizeEvent {{{1 */ |
94 | void Keyboard::resizeEvent(QResizeEvent*) | 94 | void Keyboard::resizeEvent(QResizeEvent*) |
95 | { | 95 | { |
96 | int ph = picks->sizeHint().height(); | 96 | int ph = picks->sizeHint().height(); |
97 | picks->setGeometry( 0, 0, width(), ph ); | 97 | picks->setGeometry( 0, 0, width(), ph ); |
98 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 98 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
99 | 99 | ||
100 | int nk; // number of keys? | 100 | int nk; // number of keys? |
101 | if ( useLargeKeys ) { | 101 | if ( useLargeKeys ) { |
102 | nk = 15; | 102 | nk = 15; |
103 | } else { | 103 | } else { |
104 | nk = 19; | 104 | nk = 19; |
105 | } | 105 | } |
106 | defaultKeyWidth = (width()/nk)/2; | 106 | defaultKeyWidth = (width()/nk)/2; |
107 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 107 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | /* KeyboardPicks::initialize {{{1 */ | 111 | /* KeyboardPicks::initialize {{{1 */ |
112 | void KeyboardPicks::initialise() | 112 | void KeyboardPicks::initialise() |
113 | { | 113 | { |
114 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 114 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
115 | mode = 0; | 115 | mode = 0; |
116 | dc = new KeyboardConfig(this); | 116 | dc = new KeyboardConfig(this); |
117 | configs.append(dc); | 117 | configs.append(dc); |
118 | } | 118 | } |
119 | 119 | ||
120 | /* KeyboardPicks::sizeHint {{{1 */ | 120 | /* KeyboardPicks::sizeHint {{{1 */ |
121 | QSize KeyboardPicks::sizeHint() const | 121 | QSize KeyboardPicks::sizeHint() const |
122 | { | 122 | { |
123 | return QSize(240,fontMetrics().lineSpacing()); | 123 | return QSize(240,fontMetrics().lineSpacing()); |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | /* KeyboardConfig::generateText {{{1 */ | 127 | /* KeyboardConfig::generateText {{{1 */ |
128 | void KeyboardConfig::generateText(const QString &s) | 128 | void KeyboardConfig::generateText(const QString &s) |
129 | { | 129 | { |
130 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 130 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
131 | for (int i=0; i<(int)backspaces; i++) { | 131 | for (int i=0; i<(int)backspaces; i++) { |
132 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 132 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
133 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 133 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
134 | } | 134 | } |
135 | for (int i=0; i<(int)s.length(); i++) { | 135 | for (int i=0; i<(int)s.length(); i++) { |
136 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 136 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
137 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 137 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
138 | } | 138 | } |
139 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 139 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
140 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 140 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
141 | backspaces = 0; | 141 | backspaces = 0; |
142 | #endif | 142 | #endif |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | /* Keyboard::paintEvent {{{1 */ | 148 | /* Keyboard::paintEvent {{{1 */ |
149 | void Keyboard::paintEvent(QPaintEvent* e) | 149 | void Keyboard::paintEvent(QPaintEvent* e) |
150 | { | 150 | { |
151 | QPainter painter(this); | 151 | QPainter painter(this); |
152 | painter.setClipRect(e->rect()); | 152 | painter.setClipRect(e->rect()); |
153 | drawKeyboard( painter ); | 153 | drawKeyboard( painter ); |
154 | picks->dc->draw( &painter ); | 154 | picks->dc->draw( &painter ); |
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | /* Keyboard::drawKeyboard {{{1 */ | 158 | /* Keyboard::drawKeyboard {{{1 */ |
159 | 159 | ||
160 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 160 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
161 | { | 161 | { |
162 | 162 | ||
163 | 163 | ||
164 | if (row != -1 && col != -1) { //just redraw one key | 164 | if (row != -1 && col != -1) { //just redraw one key |
165 | 165 | ||
166 | int x = 0; | 166 | int x = 0; |
167 | for (int i = 0; i < col; i++) { | 167 | for (int i = 0; i < col; i++) { |
168 | 168 | ||
169 | x += keys->width(row, i) * defaultKeyWidth; | 169 | x += keys->width(row, i) * defaultKeyWidth; |
170 | } | 170 | } |
171 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 171 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
172 | 172 | ||
173 | int keyWidth = keys->width(row, col); | 173 | int keyWidth = keys->width(row, col); |
174 | 174 | ||
175 | p.fillRect(x + 1, y + 1, | 175 | p.fillRect(x + 1, y + 1, |
176 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 176 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
177 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 177 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
178 | 178 | ||
179 | QImage *pix = keys->pix(row,col); | 179 | QImage *pix = keys->pix(row,col); |
180 | 180 | ||
181 | ushort c = keys->uni(row, col); | 181 | ushort c = keys->uni(row, col); |
182 | 182 | ||
183 | p.setPen(textcolor); | 183 | p.setPen(textcolor); |
184 | if (!pix) { | 184 | if (!pix) { |
185 | if (shift || lock) | 185 | if (shift || lock) |
186 | c = keys->shift(c); | 186 | c = keys->shift(c); |
187 | if (meta) { | 187 | if (meta) { |
188 | 188 | ||
189 | c = keys->meta(c); | 189 | c = keys->meta(c); |
190 | } | 190 | } |
191 | p.drawText(x, y, | 191 | p.drawText(x, y, |
192 | defaultKeyWidth * keyWidth + 3, keyHeight, | 192 | defaultKeyWidth * keyWidth + 3, keyHeight, |
193 | AlignCenter, (QChar)c); | 193 | AlignCenter, (QChar)c); |
194 | } | 194 | } |
195 | else | 195 | else |
196 | // center the image in the middle of the key | 196 | // center the image in the middle of the key |
197 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 197 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
198 | y + (keyHeight - pix->height())/2 + 1, | 198 | y + (keyHeight - pix->height())/2 + 1, |
199 | *pix ); | 199 | *pix ); |
200 | 200 | ||
201 | // this fixes the problem that the very right end of the board's vertical line | 201 | // this fixes the problem that the very right end of the board's vertical line |
202 | // gets painted over, because it's one pixel shorter than all other keys | 202 | // gets painted over, because it's one pixel shorter than all other keys |
203 | p.setPen(keycolor_lines); | 203 | p.setPen(keycolor_lines); |
204 | p.drawLine(width() - 1, 0, width() - 1, height()); | 204 | p.drawLine(width() - 1, 0, width() - 1, height()); |
205 | 205 | ||
206 | } else { | 206 | } else { |
207 | 207 | ||
208 | 208 | ||
209 | p.fillRect(0, 0, width(), height(), keycolor); | 209 | p.fillRect(0, 0, width(), height(), keycolor); |
210 | 210 | ||
211 | for (row = 1; row <= 5; row++) { | 211 | for (row = 1; row <= 5; row++) { |
212 | 212 | ||
213 | int x = 0; | 213 | int x = 0; |
214 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 214 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
215 | 215 | ||
216 | p.setPen(keycolor_lines); | 216 | p.setPen(keycolor_lines); |
217 | p.drawLine(x, y, x + width(), y); | 217 | p.drawLine(x, y, x + width(), y); |
218 | 218 | ||
219 | for (int col = 0; col < keys->numKeys(row); col++) { | 219 | for (int col = 0; col < keys->numKeys(row); col++) { |
220 | 220 | ||
221 | QImage *pix = keys->pix(row, col); | 221 | QImage *pix = keys->pix(row, col); |
222 | int keyWidth = keys->width(row, col); | 222 | int keyWidth = keys->width(row, col); |
223 | 223 | ||
224 | 224 | ||
225 | int keyWidthPix = defaultKeyWidth * keyWidth; | 225 | int keyWidthPix = defaultKeyWidth * keyWidth; |
226 | 226 | ||
227 | if (keys->pressed(row, col)) | 227 | if (keys->pressed(row, col)) |
228 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 228 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
229 | keyHeight - 1, keycolor_pressed); | 229 | keyHeight - 1, keycolor_pressed); |
230 | 230 | ||
231 | ushort c = keys->uni(row, col); | 231 | ushort c = keys->uni(row, col); |
232 | 232 | ||
233 | p.setPen(textcolor); | 233 | p.setPen(textcolor); |
234 | if (!pix) { | 234 | if (!pix) { |
235 | if ((shift || lock) && keys->shift(c)) | 235 | if ((shift || lock) && keys->shift(c)) |
236 | c = keys->shift(c); | 236 | c = keys->shift(c); |
237 | else if (meta && keys->meta(c)) | 237 | else if (meta && keys->meta(c)) |
238 | c = keys->meta(c); | 238 | c = keys->meta(c); |
239 | 239 | ||
240 | p.drawText(x, y, | 240 | p.drawText(x, y, |
241 | keyWidthPix + 3, keyHeight, | 241 | keyWidthPix + 3, keyHeight, |
242 | AlignCenter, (QChar)c); | 242 | AlignCenter, (QChar)c); |
243 | } | 243 | } |
244 | else { | 244 | else { |
245 | // center the image in the middle of the key | 245 | // center the image in the middle of the key |
246 | pix->setColor(1, textcolor.rgb()); | 246 | pix->setColor(1, textcolor.rgb()); |
247 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 247 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
248 | y + (keyHeight - pix->height())/2 + 1, | 248 | y + (keyHeight - pix->height())/2 + 1, |
249 | QImage(*pix) ); | 249 | QImage(*pix) ); |
250 | } | 250 | } |
251 | 251 | ||
252 | p.setPen(keycolor_lines); | 252 | p.setPen(keycolor_lines); |
253 | p.drawLine(x, y, x, y + keyHeight); | 253 | p.drawLine(x, y, x, y + keyHeight); |
254 | 254 | ||
255 | x += keyWidthPix; | 255 | x += keyWidthPix; |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | } | 259 | } |
260 | p.setPen(keycolor_lines); | 260 | p.setPen(keycolor_lines); |
261 | p.drawLine(0, height() - 1, width(), height() - 1); | 261 | p.drawLine(0, height() - 1, width(), height() - 1); |
262 | p.drawLine(width() - 1, 0, width() - 1, height()); | 262 | p.drawLine(width() - 1, 0, width() - 1, height()); |
263 | } | 263 | } |
264 | 264 | ||
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | /* Keyboard::mousePressEvent {{{1 */ | 268 | /* Keyboard::mousePressEvent {{{1 */ |
269 | void Keyboard::mousePressEvent(QMouseEvent *e) | 269 | void Keyboard::mousePressEvent(QMouseEvent *e) |
270 | { | 270 | { |
271 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 271 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
272 | if (row > 5) row = 5; | 272 | if (row > 5) row = 5; |
273 | 273 | ||
274 | // figure out the column | 274 | // figure out the column |
275 | int col = 0; | 275 | int col = 0; |
276 | for (int w = 0; e->x() >= w; col++) | 276 | for (int w = 0; e->x() >= w; col++) |
277 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 277 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
278 | w += keys->width(row,col) * defaultKeyWidth; | 278 | w += keys->width(row,col) * defaultKeyWidth; |
279 | else break; | 279 | else break; |
280 | 280 | ||
281 | if (col <= 0) return; | 281 | if (col <= 0) return; |
282 | 282 | ||
283 | col --; // rewind one... | 283 | col --; // rewind one... |
284 | 284 | ||
285 | qkeycode = keys->qcode(row, col); | 285 | qkeycode = keys->qcode(row, col); |
286 | unicode = keys->uni(row, col); | 286 | unicode = keys->uni(row, col); |
287 | 287 | ||
288 | // might need to repaint if two or more of the same keys. | 288 | // might need to repaint if two or more of the same keys. |
289 | // should be faster if just paint one key even though multiple keys exist. | 289 | // should be faster if just paint one key even though multiple keys exist. |
290 | bool need_repaint = FALSE; | 290 | bool need_repaint = FALSE; |
291 | 291 | ||
292 | if (unicode == 0) { // either Qt char, or nothing | 292 | if (unicode == 0) { // either Qt char, or nothing |
293 | 293 | ||
294 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 294 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
295 | 295 | ||
296 | if ( configdlg ) { | 296 | if ( configdlg ) { |
297 | delete (ConfigDlg *) configdlg; | 297 | delete (ConfigDlg *) configdlg; |
298 | configdlg = 0; | 298 | configdlg = 0; |
299 | } | 299 | } |
300 | else { | 300 | else { |
301 | configdlg = new ConfigDlg (); | 301 | configdlg = new ConfigDlg (); |
302 | connect(configdlg, SIGNAL(setMapToDefault()), | 302 | connect(configdlg, SIGNAL(setMapToDefault()), |
303 | this, SLOT(setMapToDefault())); | 303 | this, SLOT(setMapToDefault())); |
304 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 304 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
305 | this, SLOT(setMapToFile(QString))); | 305 | this, SLOT(setMapToFile(QString))); |
306 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 306 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
307 | this, SLOT(togglePickboard(bool))); | 307 | this, SLOT(togglePickboard(bool))); |
308 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 308 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
309 | this, SLOT(toggleRepeat(bool))); | 309 | this, SLOT(toggleRepeat(bool))); |
310 | connect(configdlg, SIGNAL(reloadKeyboard()), | 310 | connect(configdlg, SIGNAL(reloadKeyboard()), |
311 | this, SLOT(reloadKeyboard())); | 311 | this, SLOT(reloadKeyboard())); |
312 | configdlg->showMaximized(); | 312 | configdlg->showMaximized(); |
313 | configdlg->show(); | 313 | configdlg->show(); |
314 | configdlg->raise(); | 314 | configdlg->raise(); |
315 | } | 315 | } |
316 | 316 | ||
317 | } else if (qkeycode == Qt::Key_Control) { | 317 | } else if (qkeycode == Qt::Key_Control) { |
318 | need_repaint = TRUE; | 318 | need_repaint = TRUE; |
319 | 319 | ||
320 | if (ctrl) { | 320 | if (ctrl) { |
321 | 321 | ||
322 | *ctrl = 0; | 322 | *ctrl = 0; |
323 | ctrl = 0; | 323 | ctrl = 0; |
324 | 324 | ||
325 | } else { | 325 | } else { |
326 | 326 | ||
327 | ctrl = keys->pressedPtr(row, col); | 327 | ctrl = keys->pressedPtr(row, col); |
328 | need_repaint = TRUE; | 328 | need_repaint = TRUE; |
329 | *ctrl = !keys->pressed(row, col); | 329 | *ctrl = !keys->pressed(row, col); |
330 | 330 | ||
331 | } | 331 | } |
332 | 332 | ||
333 | } else if (qkeycode == Qt::Key_Alt) { | 333 | } else if (qkeycode == Qt::Key_Alt) { |
334 | need_repaint = TRUE; | 334 | need_repaint = TRUE; |
335 | 335 | ||
336 | if (alt) { | 336 | if (alt) { |
337 | *alt = 0; | 337 | *alt = 0; |
338 | alt = 0; | 338 | alt = 0; |
339 | 339 | ||
340 | } else { | 340 | } else { |
341 | 341 | ||
342 | alt = keys->pressedPtr(row, col); | 342 | alt = keys->pressedPtr(row, col); |
343 | need_repaint = TRUE; | 343 | need_repaint = TRUE; |
344 | *alt = !keys->pressed(row, col); | 344 | *alt = !keys->pressed(row, col); |
345 | } | 345 | } |
346 | 346 | ||
347 | } else if (qkeycode == Qt::Key_Shift) { | 347 | } else if (qkeycode == Qt::Key_Shift) { |
348 | need_repaint = TRUE; | 348 | need_repaint = TRUE; |
349 | 349 | ||
350 | if (shift) { | 350 | if (shift) { |
351 | *shift = 0; | 351 | *shift = 0; |
352 | shift = 0; | 352 | shift = 0; |
353 | } | 353 | } |
354 | else { | 354 | else { |
355 | shift = keys->pressedPtr(row, col); | 355 | shift = keys->pressedPtr(row, col); |
356 | *shift = 1; | 356 | *shift = 1; |
357 | if (lock) { | 357 | if (lock) { |
358 | *lock = 0; | 358 | *lock = 0; |
359 | lock = 0; | 359 | lock = 0; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | if (meta) { | 362 | if (meta) { |
363 | 363 | ||
364 | *meta = 0; | 364 | *meta = 0; |
365 | meta = 0; | 365 | meta = 0; |
366 | } | 366 | } |
367 | 367 | ||
368 | } else if (qkeycode == Qt::Key_CapsLock) { | 368 | } else if (qkeycode == Qt::Key_CapsLock) { |
369 | need_repaint = TRUE; | 369 | need_repaint = TRUE; |
370 | 370 | ||
371 | if (lock) { | 371 | if (lock) { |
372 | *lock = 0; | 372 | *lock = 0; |
373 | lock = 0; | 373 | lock = 0; |
374 | } | 374 | } |
375 | else { | 375 | else { |
376 | lock = keys->pressedPtr(row, col);; | 376 | lock = keys->pressedPtr(row, col);; |
377 | *lock = 1; | 377 | *lock = 1; |
378 | if (shift) { | 378 | if (shift) { |
379 | *shift = 0; | 379 | *shift = 0; |
380 | shift = 0; | 380 | shift = 0; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | if (meta) { | 383 | if (meta) { |
384 | 384 | ||
385 | *meta = 0; | 385 | *meta = 0; |
386 | meta = 0; | 386 | meta = 0; |
387 | } | 387 | } |
388 | 388 | ||
389 | } else if (qkeycode == Qt::Key_Meta) { | 389 | } else if (qkeycode == Qt::Key_Meta) { |
390 | need_repaint = TRUE; | 390 | need_repaint = TRUE; |
391 | 391 | ||
392 | if (meta) { | 392 | if (meta) { |
393 | *meta = 0; | 393 | *meta = 0; |
394 | meta = 0; | 394 | meta = 0; |
395 | 395 | ||
396 | } else { | 396 | } else { |
397 | 397 | ||
398 | meta = keys->pressedPtr(row, col); | 398 | meta = keys->pressedPtr(row, col); |
399 | need_repaint = TRUE; | 399 | need_repaint = TRUE; |
400 | *meta = !keys->pressed(row, col); | 400 | *meta = !keys->pressed(row, col); |
401 | } | 401 | } |
402 | 402 | ||
403 | if (shift) { | 403 | if (shift) { |
404 | 404 | ||
405 | *shift = 0; | 405 | *shift = 0; |
406 | shift = 0; | 406 | shift = 0; |
407 | 407 | ||
408 | } | 408 | } |
409 | if (lock) { | 409 | if (lock) { |
410 | 410 | ||
411 | *lock = 0; | 411 | *lock = 0; |
412 | lock = 0; | 412 | lock = 0; |
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | // dont need to emit this key... acts same as alt | 416 | // dont need to emit this key... acts same as alt |
417 | qkeycode = 0; | 417 | qkeycode = 0; |
418 | } | 418 | } |
419 | 419 | ||
420 | } | 420 | } |
421 | else { // normal char | 421 | else { // normal char |
422 | if ((shift || lock) && keys->shift(unicode)) { | 422 | if ((shift || lock) && keys->shift(unicode)) { |
423 | unicode = keys->shift(unicode); | 423 | unicode = keys->shift(unicode); |
424 | } | 424 | } |
425 | if (meta && keys->meta(unicode)) { | 425 | if (meta && keys->meta(unicode)) { |
426 | unicode = keys->meta(unicode); | 426 | unicode = keys->meta(unicode); |
427 | } | 427 | } |
428 | } | 428 | } |
429 | 429 | ||
430 | // korean parsing | 430 | // korean parsing |
431 | if (keys->lang == "ko") { | 431 | if (keys->lang == "ko") { |
432 | 432 | ||
433 | unicode = parseKoreanInput(unicode); | 433 | unicode = parseKoreanInput(unicode); |
434 | } | 434 | } |
435 | 435 | ||
436 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 436 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
437 | 437 | ||
438 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 438 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
439 | 439 | ||
440 | qkeycode = QChar(unicode).upper(); | 440 | qkeycode = QChar(unicode).upper(); |
441 | unicode = qkeycode - '@'; | 441 | unicode = qkeycode - '@'; |
442 | } | 442 | } |
443 | 443 | ||
444 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 444 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
445 | 445 | ||
446 | // pickboard stuff | 446 | // pickboard stuff |
447 | if (usePicks) { | 447 | if (usePicks) { |
448 | 448 | ||
449 | KeyboardConfig *dc = picks->dc; | 449 | KeyboardConfig *dc = picks->dc; |
450 | 450 | ||
451 | if (dc) { | 451 | if (dc) { |
452 | if (qkeycode == Qt::Key_Backspace) { | 452 | if (qkeycode == Qt::Key_Backspace) { |
453 | dc->input.remove(dc->input.last()); // remove last input | 453 | dc->input.remove(dc->input.last()); // remove last input |
454 | dc->decBackspaces(); | 454 | dc->decBackspaces(); |
455 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 455 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
456 | dc->input.clear(); | 456 | dc->input.clear(); |
457 | dc->resetBackspaces(); | 457 | dc->resetBackspaces(); |
458 | } else { | 458 | } else { |
459 | dc->add(QString(QChar(unicode))); | 459 | dc->add(QString(QChar(unicode))); |
460 | dc->incBackspaces(); | 460 | dc->incBackspaces(); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | picks->repaint(); | 463 | picks->repaint(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | // painting | 467 | // painting |
468 | pressed = TRUE; | 468 | pressed = TRUE; |
469 | 469 | ||
470 | pressedKeyRow = row; | 470 | pressedKeyRow = row; |
471 | pressedKeyCol = col; | 471 | pressedKeyCol = col; |
472 | 472 | ||
473 | if (need_repaint) repaint(FALSE); | 473 | if (need_repaint) repaint(FALSE); |
474 | else { // just paint the one key pressed | 474 | else { // just paint the one key pressed |
475 | 475 | ||
476 | 476 | ||
477 | 477 | ||
478 | QPainter p(this); | 478 | QPainter p(this); |
479 | drawKeyboard(p, row, col); | 479 | drawKeyboard(p, row, col); |
480 | 480 | ||
481 | } | 481 | } |
482 | 482 | ||
483 | if (useRepeat) repeatTimer->start( 800 ); | 483 | if (useRepeat) repeatTimer->start( 800 ); |
484 | //pressTid = startTimer(80); | 484 | //pressTid = startTimer(80); |
485 | 485 | ||
486 | } | 486 | } |
487 | 487 | ||
488 | 488 | ||
489 | /* Keyboard::mouseReleaseEvent {{{1 */ | 489 | /* Keyboard::mouseReleaseEvent {{{1 */ |
490 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 490 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
491 | { | 491 | { |
492 | pressed = FALSE; | 492 | pressed = FALSE; |
493 | //if ( pressTid == 0 ) | 493 | //if ( pressTid == 0 ) |
494 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 494 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
495 | if ( unicode != -1 ) { | 495 | if ( unicode != -1 ) { |
496 | emit key( unicode, qkeycode, modifiers, false, false ); | 496 | emit key( unicode, qkeycode, modifiers, false, false ); |
497 | repeatTimer->stop(); | 497 | repeatTimer->stop(); |
498 | } | 498 | } |
499 | #endif | 499 | #endif |
500 | if (shift && unicode != 0) { | 500 | if (shift && unicode != 0) { |
501 | 501 | ||
502 | 502 | ||
503 | *shift = 0; // unpress shift key | 503 | *shift = 0; // unpress shift key |
504 | shift = 0; // reset the shift pointer | 504 | shift = 0; // reset the shift pointer |
505 | repaint(FALSE); | 505 | repaint(FALSE); |
506 | 506 | ||
507 | } else if (meta && unicode != 0) { | 507 | } else if (meta && unicode != 0) { |
508 | 508 | ||
509 | *meta = 0; | 509 | *meta = 0; |
510 | meta = 0; | 510 | meta = 0; |
511 | repaint(FALSE); | 511 | repaint(FALSE); |
512 | } | 512 | } |
513 | else | 513 | else |
514 | 514 | ||
515 | clearHighlight(); | 515 | clearHighlight(); |
516 | } | 516 | } |
517 | 517 | ||
518 | /* Keyboard::timerEvent {{{1 */ | 518 | /* Keyboard::timerEvent {{{1 */ |
519 | 519 | ||
520 | /* dont know what this does, but i think it is here so that if your screen | 520 | /* dont know what this does, but i think it is here so that if your screen |
521 | * sticks (like on an ipaq) then it will stop repeating if you click another | 521 | * sticks (like on an ipaq) then it will stop repeating if you click another |
522 | * key... but who knows what anything does in this thing anyway? | 522 | * key... but who knows what anything does in this thing anyway? |
523 | 523 | ||
524 | void Keyboard::timerEvent(QTimerEvent* e) | 524 | void Keyboard::timerEvent(QTimerEvent* e) |
525 | { | 525 | { |
526 | if ( e->timerId() == pressTid ) { | 526 | if ( e->timerId() == pressTid ) { |
527 | killTimer(pressTid); | 527 | killTimer(pressTid); |
528 | pressTid = 0; | 528 | pressTid = 0; |
529 | if ( !pressed ) | 529 | if ( !pressed ) |
530 | cout << "calling clearHighlight from timerEvent\n"; | 530 | cout << "calling clearHighlight from timerEvent\n"; |
531 | //clearHighlight(); | 531 | //clearHighlight(); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | */ | 534 | */ |
535 | 535 | ||
536 | void Keyboard::repeat() | 536 | void Keyboard::repeat() |
537 | { | 537 | { |
538 | 538 | ||
539 | repeatTimer->start( 200 ); | 539 | repeatTimer->start( 200 ); |
540 | emit key( unicode, qkeycode, modifiers, true, true ); | 540 | emit key( unicode, qkeycode, modifiers, true, true ); |
541 | } | 541 | } |
542 | 542 | ||
543 | void Keyboard::clearHighlight() | 543 | void Keyboard::clearHighlight() |
544 | { | 544 | { |
545 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 545 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
546 | int tmpRow = pressedKeyRow; | 546 | int tmpRow = pressedKeyRow; |
547 | int tmpCol = pressedKeyCol; | 547 | int tmpCol = pressedKeyCol; |
548 | 548 | ||
549 | pressedKeyRow = -1; | 549 | pressedKeyRow = -1; |
550 | pressedKeyCol = -1; | 550 | pressedKeyCol = -1; |
551 | 551 | ||
552 | QPainter p(this); | 552 | QPainter p(this); |
553 | drawKeyboard(p, tmpRow, tmpCol); | 553 | drawKeyboard(p, tmpRow, tmpCol); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | /* Keyboard::sizeHint {{{1 */ | 558 | /* Keyboard::sizeHint {{{1 */ |
559 | QSize Keyboard::sizeHint() const | 559 | QSize Keyboard::sizeHint() const |
560 | { | 560 | { |
561 | QFontMetrics fm=fontMetrics(); | 561 | QFontMetrics fm=fontMetrics(); |
562 | int keyHeight = fm.lineSpacing() + 2; | 562 | int keyHeight = fm.lineSpacing() + 2; |
563 | 563 | ||
564 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 564 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
565 | } | 565 | } |
566 | 566 | ||
567 | 567 | ||
568 | void Keyboard::resetState() | 568 | void Keyboard::resetState() |
569 | { | 569 | { |
570 | schar = mchar = echar = 0; | 570 | schar = mchar = echar = 0; |
571 | picks->resetState(); | 571 | picks->resetState(); |
572 | } | 572 | } |
573 | 573 | ||
574 | /* Keyboard::togglePickboard {{{1 */ | 574 | /* Keyboard::togglePickboard {{{1 */ |
575 | void Keyboard::togglePickboard(bool on_off) | 575 | void Keyboard::togglePickboard(bool on_off) |
576 | { | 576 | { |
577 | usePicks = on_off; | 577 | usePicks = on_off; |
578 | if (usePicks) { | 578 | if (usePicks) { |
579 | picks->show(); | 579 | picks->show(); |
580 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 580 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
581 | //adjustSize(); | 581 | //adjustSize(); |
582 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 582 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
583 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 583 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
584 | } else { | 584 | } else { |
585 | 585 | ||
586 | picks->hide(); | 586 | picks->hide(); |
587 | picks->resetState(); | 587 | picks->resetState(); |
588 | //move(x(), y() + picks->height()); | 588 | //move(x(), y() + picks->height()); |
589 | //adjustSize(); | 589 | //adjustSize(); |
590 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 590 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
591 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 591 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
592 | 592 | ||
593 | } | 593 | } |
594 | /* | 594 | /* |
595 | * this closes && opens the input method | 595 | * this closes && opens the input method |
596 | */ | 596 | */ |
597 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 597 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
598 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 598 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
599 | } | 599 | } |
600 | 600 | ||
601 | void Keyboard::toggleRepeat(bool on) { | 601 | void Keyboard::toggleRepeat(bool on) { |
602 | 602 | ||
603 | useRepeat = on; | 603 | useRepeat = on; |
604 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 604 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
605 | } | 605 | } |
606 | 606 | ||
607 | /* Keyboard::setMapTo ... {{{1 */ | 607 | /* Keyboard::setMapTo ... {{{1 */ |
608 | void Keyboard::setMapToDefault() { | 608 | void Keyboard::setMapToDefault() { |
609 | 609 | ||
610 | 610 | ||
611 | /* load current locale language map */ | 611 | /* load current locale language map */ |
612 | Config *config = new Config("locale"); | 612 | Config *config = new Config("locale"); |
613 | config->setGroup( "Language" ); | 613 | config->setGroup( "Language" ); |
614 | QString l = config->readEntry( "Language" , "en" ); | 614 | QString l = config->readEntry( "Language" , "en" ); |
615 | delete config; | 615 | delete config; |
616 | 616 | ||
617 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 617 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
618 | + l + ".keymap"; | 618 | + l + ".keymap"; |
619 | 619 | ||
620 | /* save change to multikey config file */ | 620 | /* save change to multikey config file */ |
621 | config = new Config("multikey"); | 621 | config = new Config("multikey"); |
622 | config->setGroup ("keymaps"); | 622 | config->setGroup ("keymaps"); |
623 | config->writeEntry ("current", key_map); // default closed | 623 | config->writeEntry ("current", key_map); // default closed |
624 | delete config; | 624 | delete config; |
625 | 625 | ||
626 | delete keys; | 626 | delete keys; |
627 | keys = new Keys(key_map); | 627 | keys = new Keys(key_map); |
628 | 628 | ||
629 | // have to repaint the keyboard | 629 | // have to repaint the keyboard |
630 | repaint(FALSE); | 630 | repaint(FALSE); |
631 | } | 631 | } |
632 | 632 | ||
633 | void Keyboard::setMapToFile(QString map) { | 633 | void Keyboard::setMapToFile(QString map) { |
634 | 634 | ||
635 | /* save change to multikey config file */ | 635 | /* save change to multikey config file */ |
636 | Config *config = new Config("multikey"); | 636 | Config *config = new Config("multikey"); |
637 | config->setGroup ("keymaps"); | 637 | config->setGroup ("keymaps"); |
638 | config->writeEntry ("current", map); // default closed | 638 | config->writeEntry ("current", map); // default closed |
639 | 639 | ||
640 | delete config; | 640 | delete config; |
641 | 641 | ||
642 | delete keys; | 642 | delete keys; |
643 | if (QFile(map).exists()) | 643 | if (QFile(map).exists()) |
644 | keys = new Keys(map); | 644 | keys = new Keys(map); |
645 | else | 645 | else |
646 | keys = new Keys(); | 646 | keys = new Keys(); |
647 | 647 | ||
648 | repaint(FALSE); | 648 | repaint(FALSE); |
649 | 649 | ||
650 | } | 650 | } |
651 | 651 | ||
652 | /* Keybaord::reloadKeyboard {{{1 */ | 652 | /* Keybaord::reloadKeyboard {{{1 */ |
653 | void Keyboard::reloadKeyboard() { | 653 | void Keyboard::reloadKeyboard() { |
654 | 654 | ||
655 | // reload colors and redraw | 655 | // reload colors and redraw |
656 | loadKeyboardColors(); | 656 | loadKeyboardColors(); |
657 | repaint(); | 657 | repaint(); |
658 | 658 | ||
659 | } | 659 | } |
660 | 660 | ||
661 | void Keyboard::loadKeyboardColors() { | 661 | void Keyboard::loadKeyboardColors() { |
662 | 662 | ||
663 | Config config ("multikey"); | 663 | Config config ("multikey"); |
664 | config.setGroup("colors"); | 664 | config.setGroup("colors"); |
665 | 665 | ||
666 | QStringList color; | 666 | QStringList color; |
667 | color = config.readListEntry("keycolor", QChar(',')); | 667 | color = config.readListEntry("keycolor", QChar(',')); |
668 | if (color.isEmpty()) { | 668 | if (color.isEmpty()) { |
669 | color = QStringList::split(",", "240,240,240"); | 669 | color = QStringList::split(",", "240,240,240"); |
670 | config.writeEntry("keycolor", color.join(",")); | 670 | config.writeEntry("keycolor", color.join(",")); |
671 | 671 | ||
672 | } | 672 | } |
673 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 673 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
674 | 674 | ||
675 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 675 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
676 | if (color.isEmpty()) { | 676 | if (color.isEmpty()) { |
677 | color = QStringList::split(",", "171,183,198"); | 677 | color = QStringList::split(",", "171,183,198"); |
678 | config.writeEntry("keycolor_pressed", color.join(",")); | 678 | config.writeEntry("keycolor_pressed", color.join(",")); |
679 | 679 | ||
680 | } | 680 | } |
681 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 681 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
682 | 682 | ||
683 | color = config.readListEntry("keycolor_lines", QChar(',')); | 683 | color = config.readListEntry("keycolor_lines", QChar(',')); |
684 | if (color.isEmpty()) { | 684 | if (color.isEmpty()) { |
685 | color = QStringList::split(",", "138,148,160"); | 685 | color = QStringList::split(",", "138,148,160"); |
686 | config.writeEntry("keycolor_lines", color.join(",")); | 686 | config.writeEntry("keycolor_lines", color.join(",")); |
687 | 687 | ||
688 | } | 688 | } |
689 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 689 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
690 | 690 | ||
691 | color = config.readListEntry("textcolor", QChar(',')); | 691 | color = config.readListEntry("textcolor", QChar(',')); |
692 | if (color.isEmpty()) { | 692 | if (color.isEmpty()) { |
693 | color = QStringList::split(",", "43,54,68"); | 693 | color = QStringList::split(",", "43,54,68"); |
694 | config.writeEntry("textcolor", color.join(",")); | 694 | config.writeEntry("textcolor", color.join(",")); |
695 | 695 | ||
696 | } | 696 | } |
697 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 697 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
698 | 698 | ||
699 | } | 699 | } |
700 | 700 | ||
701 | /* korean input functions {{{1 | 701 | /* korean input functions {{{1 |
702 | * | 702 | * |
703 | * TODO | 703 | * TODO |
704 | * one major problem with this implementation is that you can't move the | 704 | * one major problem with this implementation is that you can't move the |
705 | * cursor after inputing korean chars, otherwise it will eat up and replace | 705 | * cursor after inputing korean chars, otherwise it will eat up and replace |
706 | * the char before the cursor you move to. fix that | 706 | * the char before the cursor you move to. fix that |
707 | * | 707 | * |
708 | * make backspace delete one single char, not the whole thing if still | 708 | * make backspace delete one single char, not the whole thing if still |
709 | * editing. | 709 | * editing. |
710 | * | 710 | * |
711 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 711 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
712 | * | 712 | * |
713 | * how korean input works | 713 | * how korean input works |
714 | * | 714 | * |
715 | * all following chars means unicode char value and are in hex | 715 | * all following chars means unicode char value and are in hex |
716 | * | 716 | * |
717 | * ÃÊÀ½ = schar (start char) | 717 | * ÃÊÀ½ = schar (start char) |
718 | * ÁßÀ½ = mchar (middle char) | 718 | * ÁßÀ½ = mchar (middle char) |
719 | * ³¡À½ = echar (end char) | 719 | * ³¡À½ = echar (end char) |
720 | * | 720 | * |
721 | * there are 19 schars. unicode position is at 1100 - 1112 | 721 | * there are 19 schars. unicode position is at 1100 - 1112 |
722 | * there are 21 mchars. unicode position is at 1161 - 1175 | 722 | * there are 21 mchars. unicode position is at 1161 - 1175 |
723 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 723 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
724 | * | 724 | * |
725 | * the map with everything combined is at ac00 - d7a3 | 725 | * the map with everything combined is at ac00 - d7a3 |
726 | * | 726 | * |
727 | */ | 727 | */ |
728 | 728 | ||
729 | ushort Keyboard::parseKoreanInput (ushort c) { | 729 | ushort Keyboard::parseKoreanInput (ushort c) { |
730 | 730 | ||
731 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 731 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
732 | || | 732 | || |
733 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 733 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
734 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 734 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
735 | 735 | ||
736 | schar = 0, mchar = 0, echar = 0; | 736 | schar = 0, mchar = 0, echar = 0; |
737 | return c; | 737 | return c; |
738 | } | 738 | } |
739 | 739 | ||
740 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 740 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
741 | 741 | ||
742 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 742 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
743 | schar = c; mchar = 0; echar = 0; | 743 | schar = c; mchar = 0; echar = 0; |
744 | return c; | 744 | return c; |
745 | } | 745 | } |
746 | else if (mchar != 0) { | 746 | else if (mchar != 0) { |
747 | 747 | ||
748 | if (echar == 0) { | 748 | if (echar == 0) { |
749 | 749 | ||
750 | if (!(echar = constoe(c))) { | 750 | if (!(echar = constoe(c))) { |
751 | 751 | ||
752 | schar = c; mchar = 0; echar = 0; | 752 | schar = c; mchar = 0; echar = 0; |
753 | return c; | 753 | return c; |
754 | } | 754 | } |
755 | 755 | ||
756 | } | 756 | } |
757 | else { // must figure out what the echar is | 757 | else { // must figure out what the echar is |
758 | 758 | ||
759 | if (echar == 0x11a8) { // ¤¡ | 759 | if (echar == 0x11a8) { // ¤¡ |
760 | 760 | ||
761 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ | 761 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ |
762 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ | 762 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ |
763 | else { | 763 | else { |
764 | schar = c; mchar = 0; echar = 0; | 764 | schar = c; mchar = 0; echar = 0; |
765 | return c; | 765 | return c; |
766 | } | 766 | } |
767 | 767 | ||
768 | } else if (echar == 0x11ab) { // ¤¤ | 768 | } else if (echar == 0x11ab) { // ¤¤ |
769 | 769 | ||
770 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ | 770 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ |
771 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ | 771 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ |
772 | else { | 772 | else { |
773 | schar = c; mchar = 0; echar = 0; | 773 | schar = c; mchar = 0; echar = 0; |
774 | return c; | 774 | return c; |
775 | } | 775 | } |
776 | 776 | ||
777 | } else if (echar == 0x11af) { // ¤© | 777 | } else if (echar == 0x11af) { // ¤© |
778 | 778 | ||
779 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ | 779 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ |
780 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± | 780 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± |
781 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² | 781 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² |
782 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ | 782 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ |
783 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ | 783 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ |
784 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ | 784 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ |
785 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ | 785 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ |
786 | else { | 786 | else { |
787 | schar = c; mchar = 0; echar = 0; | 787 | schar = c; mchar = 0; echar = 0; |
788 | return c; | 788 | return c; |
789 | } | 789 | } |
790 | 790 | ||
791 | } else if (echar == 0x11b8) { // ¤² | 791 | } else if (echar == 0x11b8) { // ¤² |
792 | 792 | ||
793 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ | 793 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ |
794 | else { | 794 | else { |
795 | schar = c; mchar = 0; echar = 0; | 795 | schar = c; mchar = 0; echar = 0; |
796 | return c; | 796 | return c; |
797 | } | 797 | } |
798 | 798 | ||
799 | } else if (echar == 0x11ba) { // ¤µ | 799 | } else if (echar == 0x11ba) { // ¤µ |
800 | 800 | ||
801 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ | 801 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ |
802 | else { | 802 | else { |
803 | schar = c; mchar = 0; echar = 0; | 803 | schar = c; mchar = 0; echar = 0; |
804 | return c; | 804 | return c; |
805 | } | 805 | } |
806 | 806 | ||
807 | } else { // if any other char, cannot combine chars | 807 | } else { // if any other char, cannot combine chars |
808 | 808 | ||
809 | schar = c; mchar = 0; echar = 0; | 809 | schar = c; mchar = 0; echar = 0; |
810 | return c; | 810 | return c; |
811 | } | 811 | } |
812 | 812 | ||
813 | unicode = echar; | 813 | unicode = echar; |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
817 | } | 817 | } |
818 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 818 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
819 | 819 | ||
820 | if (schar != 0 && mchar == 0) { mchar = c; } | 820 | if (schar != 0 && mchar == 0) { mchar = c; } |
821 | 821 | ||
822 | else if (schar != 0 && mchar != 0 && echar == 0) { | 822 | else if (schar != 0 && mchar != 0 && echar == 0) { |
823 | 823 | ||
824 | switch (mchar) { | 824 | switch (mchar) { |
825 | case 0x1169: | 825 | case 0x1169: |
826 | if (c == 0x1161) mchar = 0x116a; | 826 | if (c == 0x1161) mchar = 0x116a; |
827 | else if (c == 0x1162) mchar = 0x116b; | 827 | else if (c == 0x1162) mchar = 0x116b; |
828 | else if (c == 0x1175) mchar = 0x116c; | 828 | else if (c == 0x1175) mchar = 0x116c; |
829 | else { | 829 | else { |
830 | schar = 0; mchar = 0; echar = 0; | 830 | schar = 0; mchar = 0; echar = 0; |
831 | return c; | 831 | return c; |
832 | } | 832 | } |
833 | break; | 833 | break; |
834 | case 0x116e: | 834 | case 0x116e: |
835 | if (c == 0x1165) mchar = 0x116f; | 835 | if (c == 0x1165) mchar = 0x116f; |
836 | else if (c == 0x1166) mchar = 0x1170; | 836 | else if (c == 0x1166) mchar = 0x1170; |
837 | else if (c == 0x1175) mchar = 0x1171; | 837 | else if (c == 0x1175) mchar = 0x1171; |
838 | else { | 838 | else { |
839 | schar = 0; mchar = 0; echar = 0; | 839 | schar = 0; mchar = 0; echar = 0; |
840 | return c; | 840 | return c; |
841 | } | 841 | } |
842 | break; | 842 | break; |
843 | case 0x1173: | 843 | case 0x1173: |
844 | if (c == 0x1175) mchar = 0x1174; | 844 | if (c == 0x1175) mchar = 0x1174; |
845 | else { | 845 | else { |
846 | schar = 0; mchar = 0; echar = 0; | 846 | schar = 0; mchar = 0; echar = 0; |
847 | return c; | 847 | return c; |
848 | } | 848 | } |
849 | break; | 849 | break; |
850 | default: | 850 | default: |
851 | schar = 0; mchar = 0; echar = 0; | 851 | schar = 0; mchar = 0; echar = 0; |
852 | return c; | 852 | return c; |
853 | } | 853 | } |
854 | } | 854 | } |
855 | else if (schar != 0 && mchar != 0 && echar != 0) { | 855 | else if (schar != 0 && mchar != 0 && echar != 0) { |
856 | 856 | ||
857 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 857 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
858 | 858 | ||
859 | ushort prev = 0; | 859 | ushort prev = 0; |
860 | switch (echar) { | 860 | switch (echar) { |
861 | /* | 861 | /* |
862 | case 0x11a9: | 862 | case 0x11a9: |
863 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 863 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
864 | schar = 0x1100; | 864 | schar = 0x1100; |
865 | break; | 865 | break; |
866 | */ | 866 | */ |
867 | case 0x11aa: | 867 | case 0x11aa: |
868 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 868 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
869 | schar = 0x1109; | 869 | schar = 0x1109; |
870 | break; | 870 | break; |
871 | case 0x11ac: | 871 | case 0x11ac: |
872 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 872 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
873 | schar = 0x110c; | 873 | schar = 0x110c; |
874 | break; | 874 | break; |
875 | case 0x11ad: | 875 | case 0x11ad: |
876 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 876 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
877 | schar = 0x1112; | 877 | schar = 0x1112; |
878 | break; | 878 | break; |
879 | case 0x11b0: | 879 | case 0x11b0: |
880 | prev = combineKoreanChars(schar, mchar, 0x11af); | 880 | prev = combineKoreanChars(schar, mchar, 0x11af); |
881 | schar = 0x1100; | 881 | schar = 0x1100; |
882 | break; | 882 | break; |
883 | case 0x11b1: | 883 | case 0x11b1: |
884 | prev = combineKoreanChars(schar, mchar, 0x11af); | 884 | prev = combineKoreanChars(schar, mchar, 0x11af); |
885 | schar = 0x1106; | 885 | schar = 0x1106; |
886 | break; | 886 | break; |
887 | case 0x11b2: | 887 | case 0x11b2: |
888 | prev = combineKoreanChars(schar, mchar, 0x11af); | 888 | prev = combineKoreanChars(schar, mchar, 0x11af); |
889 | schar = 0x1107; | 889 | schar = 0x1107; |
890 | break; | 890 | break; |
891 | case 0x11b3: | 891 | case 0x11b3: |
892 | prev = combineKoreanChars(schar, mchar, 0x11af); | 892 | prev = combineKoreanChars(schar, mchar, 0x11af); |
893 | schar = 0x1109; | 893 | schar = 0x1109; |
894 | break; | 894 | break; |
895 | case 0x11b4: | 895 | case 0x11b4: |
896 | prev = combineKoreanChars(schar, mchar, 0x11af); | 896 | prev = combineKoreanChars(schar, mchar, 0x11af); |
897 | schar = 0x1110; | 897 | schar = 0x1110; |
898 | break; | 898 | break; |
899 | case 0x11b9: | 899 | case 0x11b9: |
900 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 900 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
901 | schar = 0x1109; | 901 | schar = 0x1109; |
902 | break; | 902 | break; |
903 | /* | 903 | /* |
904 | case 0x11bb: | 904 | case 0x11bb: |
905 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 905 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
906 | schar = 0x1109; | 906 | schar = 0x1109; |
907 | break; | 907 | break; |
908 | */ | 908 | */ |
909 | default: | 909 | default: |
910 | 910 | ||
911 | if (constoe(echar)) { | 911 | if (constoe(echar)) { |
912 | 912 | ||
913 | prev = combineKoreanChars(schar, mchar, 0); | 913 | prev = combineKoreanChars(schar, mchar, 0); |
914 | schar = constoe(echar); | 914 | schar = constoe(echar); |
915 | } | 915 | } |
916 | break; | 916 | break; |
917 | } | 917 | } |
918 | 918 | ||
919 | emit key( prev, prev, 0, true, false ); | 919 | emit key( prev, prev, 0, true, false ); |
920 | 920 | ||
921 | mchar = c; echar = 0; | 921 | mchar = c; echar = 0; |
922 | 922 | ||
923 | return combineKoreanChars(schar, mchar, 0); | 923 | return combineKoreanChars(schar, mchar, 0); |
924 | 924 | ||
925 | } | 925 | } |
926 | else { | 926 | else { |
927 | schar = 0; mchar = 0; echar = 0; | 927 | schar = 0; mchar = 0; echar = 0; |
928 | return c; | 928 | return c; |
929 | } | 929 | } |
930 | 930 | ||
931 | } | 931 | } |
932 | else /*if (c == ' ')*/ return c; | 932 | else /*if (c == ' ')*/ return c; |
933 | 933 | ||
934 | 934 | ||
935 | // and now... finally delete previous char, and return new char | 935 | // and now... finally delete previous char, and return new char |
936 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 936 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
937 | 937 | ||
938 | 938 | ||
939 | return combineKoreanChars( schar, mchar, echar); | 939 | return combineKoreanChars( schar, mchar, echar); |
940 | 940 | ||
941 | } | 941 | } |
942 | 942 | ||
943 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 943 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
944 | 944 | ||
945 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 945 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
946 | 946 | ||
947 | } | 947 | } |
948 | 948 | ||
949 | ushort Keyboard::constoe(const ushort c) { | 949 | ushort Keyboard::constoe(const ushort c) { |
950 | 950 | ||
951 | // converts schars to echars if possible | 951 | // converts schars to echars if possible |
952 | 952 | ||
953 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 953 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
954 | 954 | ||
955 | switch (c) { | 955 | switch (c) { |
956 | case 0x1100: return 0x11a8; | 956 | case 0x1100: return 0x11a8; |
957 | case 0x1101: return 0x11a9; | 957 | case 0x1101: return 0x11a9; |
958 | case 0x1102: return 0x11ab; | 958 | case 0x1102: return 0x11ab; |
959 | case 0x1103: return 0x11ae; | 959 | case 0x1103: return 0x11ae; |
960 | case 0x1105: return 0x11af; | 960 | case 0x1105: return 0x11af; |
961 | case 0x1106: return 0x11b7; | 961 | case 0x1106: return 0x11b7; |
962 | case 0x1107: return 0x11b8; | 962 | case 0x1107: return 0x11b8; |
963 | case 0x1109: return 0x11ba; | 963 | case 0x1109: return 0x11ba; |
964 | case 0x110a: return 0x11bb; | 964 | case 0x110a: return 0x11bb; |
965 | case 0x110b: return 0x11bc; | 965 | case 0x110b: return 0x11bc; |
966 | case 0x110c: return 0x11bd; | 966 | case 0x110c: return 0x11bd; |
967 | case 0x110e: return 0x11be; | 967 | case 0x110e: return 0x11be; |
968 | case 0x110f: return 0x11bf; | 968 | case 0x110f: return 0x11bf; |
969 | case 0x1110: return 0x11c0; | 969 | case 0x1110: return 0x11c0; |
970 | case 0x1111: return 0x11c1; | 970 | case 0x1111: return 0x11c1; |
971 | case 0x1112: return 0x11c2; | 971 | case 0x1112: return 0x11c2; |
972 | default: return 0; | 972 | default: return 0; |
973 | 973 | ||
974 | } | 974 | } |
975 | 975 | ||
976 | } else { //echar to schar | 976 | } else { //echar to schar |
977 | 977 | ||
978 | switch (c) { | 978 | switch (c) { |
979 | case 0x11a8: return 0x1100; | 979 | case 0x11a8: return 0x1100; |
980 | case 0x11a9: return 0x1101; | 980 | case 0x11a9: return 0x1101; |
981 | case 0x11ab: return 0x1102; | 981 | case 0x11ab: return 0x1102; |
982 | case 0x11ae: return 0x1103; | 982 | case 0x11ae: return 0x1103; |
983 | case 0x11af: return 0x1105; | 983 | case 0x11af: return 0x1105; |
984 | case 0x11b7: return 0x1106; | 984 | case 0x11b7: return 0x1106; |
985 | case 0x11b8: return 0x1107; | 985 | case 0x11b8: return 0x1107; |
986 | case 0x11ba: return 0x1109; | 986 | case 0x11ba: return 0x1109; |
987 | case 0x11bb: return 0x110a; | 987 | case 0x11bb: return 0x110a; |
988 | case 0x11bc: return 0x110b; | 988 | case 0x11bc: return 0x110b; |
989 | case 0x11bd: return 0x110c; | 989 | case 0x11bd: return 0x110c; |
990 | case 0x11be: return 0x110e; | 990 | case 0x11be: return 0x110e; |
991 | case 0x11bf: return 0x110f; | 991 | case 0x11bf: return 0x110f; |
992 | case 0x11c0: return 0x1110; | 992 | case 0x11c0: return 0x1110; |
993 | case 0x11c1: return 0x1111; | 993 | case 0x11c1: return 0x1111; |
994 | case 0x11c2: return 0x1112; | 994 | case 0x11c2: return 0x1112; |
995 | default: return 0; | 995 | default: return 0; |
996 | 996 | ||
997 | } | 997 | } |
998 | 998 | ||
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | 1002 | ||
1003 | // Keys::Keys {{{1 | 1003 | // Keys::Keys {{{1 |
1004 | 1004 | ||
1005 | Keys::Keys() { | 1005 | Keys::Keys() { |
1006 | 1006 | ||
1007 | Config *config = new Config ("multikey"); | 1007 | Config *config = new Config ("multikey"); |
1008 | config->setGroup( "keymaps" ); | 1008 | config->setGroup( "keymaps" ); |
1009 | QString map = config->readEntry( "current" ); | 1009 | QString map = config->readEntry( "current" ); |
1010 | delete config; | 1010 | delete config; |
1011 | 1011 | ||
1012 | if (map.isNull() || !(QFile(map).exists())) { | 1012 | if (map.isNull() || !(QFile(map).exists())) { |
1013 | 1013 | ||
1014 | Config *config = new Config("locale"); | 1014 | Config *config = new Config("locale"); |
1015 | config->setGroup( "Language" ); | 1015 | config->setGroup( "Language" ); |
1016 | QString l = config->readEntry( "Language" , "en" ); | 1016 | QString l = config->readEntry( "Language" , "en" ); |
1017 | delete config; | 1017 | delete config; |
1018 | 1018 | ||
1019 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1019 | map = QPEApplication::qpeDir() + "/share/multikey/" |
1020 | + l + ".keymap"; | 1020 | + l + ".keymap"; |
1021 | 1021 | ||
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | setKeysFromFile(map); | 1024 | setKeysFromFile(map); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | Keys::Keys(const char * filename) { | 1027 | Keys::Keys(const char * filename) { |
1028 | 1028 | ||
1029 | setKeysFromFile(filename); | 1029 | setKeysFromFile(filename); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | // Keys::setKeysFromFile {{{2 | 1032 | // Keys::setKeysFromFile {{{2 |
1033 | void Keys::setKeysFromFile(const char * filename) { | 1033 | void Keys::setKeysFromFile(const char * filename) { |
1034 | 1034 | ||
1035 | QFile f(filename); | 1035 | QFile f(filename); |
1036 | 1036 | ||
1037 | if (f.open(IO_ReadOnly)) { | 1037 | if (f.open(IO_ReadOnly)) { |
1038 | 1038 | ||
1039 | QTextStream t(&f); | 1039 | QTextStream t(&f); |
1040 | int row; | 1040 | int row; |
1041 | int qcode; | 1041 | int qcode; |
1042 | ushort unicode; | 1042 | ushort unicode; |
1043 | int width; | 1043 | int width; |
1044 | QString buf; | 1044 | QString buf; |
1045 | QString comment; | 1045 | QString comment; |
1046 | char * xpm[256]; //couldnt be larger than that... could it? | 1046 | char * xpm[256]; //couldnt be larger than that... could it? |
1047 | QImage *xpm2pix = 0; | 1047 | QImage *xpm2pix = 0; |
1048 | 1048 | ||
1049 | buf = t.readLine(); | 1049 | buf = t.readLine(); |
1050 | while (buf) { | 1050 | while (buf) { |
1051 | 1051 | ||
1052 | // get rid of comments | 1052 | // get rid of comments |
1053 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1053 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1054 | 1054 | ||
1055 | // key definition | 1055 | // key definition |
1056 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1056 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1057 | // no $1 type referencing!!! this implementation of regexp sucks | 1057 | // no $1 type referencing!!! this implementation of regexp sucks |
1058 | 1058 | ||
1059 | // dont know of any sscanf() type funcs in Qt lib | 1059 | // dont know of any sscanf() type funcs in Qt lib |
1060 | QTextStream tmp (buf, IO_ReadOnly); | 1060 | QTextStream tmp (buf, IO_ReadOnly); |
1061 | tmp >> row >> qcode >> unicode >> width >> comment; | 1061 | tmp >> row >> qcode >> unicode >> width >> comment; |
1062 | 1062 | ||
1063 | buf = t.readLine(); | 1063 | buf = t.readLine(); |
1064 | int xpmLineCount = 0; | 1064 | int xpmLineCount = 0; |
1065 | xpm2pix = 0; | 1065 | xpm2pix = 0; |
1066 | 1066 | ||
1067 | // erase blank space | 1067 | // erase blank space |
1068 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1068 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1069 | 1069 | ||
1070 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1070 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1071 | 1071 | ||
1072 | QString xpmBuf = buf.stripWhiteSpace(); | 1072 | QString xpmBuf = buf.stripWhiteSpace(); |
1073 | 1073 | ||
1074 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1074 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1075 | 1075 | ||
1076 | int j = 0; | 1076 | int j = 0; |
1077 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1077 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1078 | if (xpmBuf[i].latin1() != '"') { | 1078 | if (xpmBuf[i].latin1() != '"') { |
1079 | 1079 | ||
1080 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1080 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1081 | j++; | 1081 | j++; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | } | 1084 | } |
1085 | // have to close that facker up | 1085 | // have to close that facker up |
1086 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1086 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1087 | 1087 | ||
1088 | xpmLineCount++; | 1088 | xpmLineCount++; |
1089 | buf = t.readLine(); | 1089 | buf = t.readLine(); |
1090 | } | 1090 | } |
1091 | if (xpmLineCount) { | 1091 | if (xpmLineCount) { |
1092 | 1092 | ||
1093 | xpm2pix = new QImage((const char **)xpm); | 1093 | xpm2pix = new QImage((const char **)xpm); |
1094 | for (int i = 0; i < xpmLineCount; i++) | 1094 | for (int i = 0; i < xpmLineCount; i++) |
1095 | 1095 | ||
1096 | delete [] (xpm[i]); | 1096 | delete [] (xpm[i]); |
1097 | 1097 | ||
1098 | } | 1098 | } |
1099 | setKey(row, qcode, unicode, width, xpm2pix); | 1099 | setKey(row, qcode, unicode, width, xpm2pix); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | // shift map | 1102 | // shift map |
1103 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1103 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1104 | 1104 | ||
1105 | QTextStream tmp (buf, IO_ReadOnly); | 1105 | QTextStream tmp (buf, IO_ReadOnly); |
1106 | ushort lower, shift; | 1106 | ushort lower, shift; |
1107 | tmp >> lower >> shift; | 1107 | tmp >> lower >> shift; |
1108 | 1108 | ||
1109 | shiftMap.insert(lower, shift); | 1109 | shiftMap.insert(lower, shift); |
1110 | 1110 | ||
1111 | buf = t.readLine(); | 1111 | buf = t.readLine(); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | // meta key map | 1114 | // meta key map |
1115 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1115 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1116 | 1116 | ||
1117 | QTextStream tmp (buf, IO_ReadOnly); | 1117 | QTextStream tmp (buf, IO_ReadOnly); |
1118 | ushort lower, shift; | 1118 | ushort lower, shift; |
1119 | QChar m; | 1119 | QChar m; |
1120 | tmp >> m >> lower >> shift; | 1120 | tmp >> m >> lower >> shift; |
1121 | 1121 | ||
1122 | metaMap.insert(lower, shift); | 1122 | metaMap.insert(lower, shift); |
1123 | 1123 | ||
1124 | buf = t.readLine(); | 1124 | buf = t.readLine(); |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | // other variables like lang & title | 1127 | // other variables like lang & title |
1128 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1128 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1129 | 1129 | ||
1130 | QTextStream tmp (buf, IO_ReadOnly); | 1130 | QTextStream tmp (buf, IO_ReadOnly); |
1131 | QString name, equals, value; | 1131 | QString name, equals, value; |
1132 | 1132 | ||
1133 | tmp >> name >> equals >> value; | 1133 | tmp >> name >> equals >> value; |
1134 | 1134 | ||
1135 | if (name == "lang") { | 1135 | if (name == "lang") { |
1136 | 1136 | ||
1137 | lang = value; | 1137 | lang = value; |
1138 | 1138 | ||
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | buf = t.readLine(); | 1141 | buf = t.readLine(); |
1142 | } | 1142 | } |
1143 | // comments | 1143 | // comments |
1144 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1144 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1145 | 1145 | ||
1146 | buf = t.readLine(); | 1146 | buf = t.readLine(); |
1147 | 1147 | ||
1148 | } else { // blank line, or garbage | 1148 | } else { // blank line, or garbage |
1149 | 1149 | ||
1150 | buf = t.readLine(); | 1150 | buf = t.readLine(); |
1151 | 1151 | ||
1152 | } | 1152 | } |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | f.close(); | 1155 | f.close(); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | // Keys::setKey {{{2 | 1160 | // Keys::setKey {{{2 |
1161 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1161 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1162 | const int width, QImage *pix) { | 1162 | const int width, QImage *pix) { |
1163 | 1163 | ||
1164 | Key * key; | 1164 | Key * key; |
1165 | key = new Key; | 1165 | key = new Key; |
1166 | key->qcode = qcode; | 1166 | key->qcode = qcode; |
1167 | key->unicode = unicode; | 1167 | key->unicode = unicode; |
1168 | key->width = width; | 1168 | key->width = width; |
1169 | 1169 | ||
1170 | // share key->pressed between same keys | 1170 | // share key->pressed between same keys |
1171 | bool found = 0; | 1171 | bool found = 0; |
1172 | for (int i = 1; i <= 5; i++) { | 1172 | for (int i = 1; i <= 5; i++) { |
1173 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1173 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1174 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1174 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1175 | 1175 | ||
1176 | key->pressed = keys[i].at(j)->pressed; | 1176 | key->pressed = keys[i].at(j)->pressed; |
1177 | found = 1; | 1177 | found = 1; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | } | 1180 | } |
1181 | if (!found) { | 1181 | if (!found) { |
1182 | 1182 | ||
1183 | key->pressed = new bool; | 1183 | key->pressed = new bool; |
1184 | *(key->pressed) = 0; | 1184 | *(key->pressed) = 0; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | key->pix = pix; | 1187 | key->pix = pix; |
1188 | 1188 | ||
1189 | 1189 | ||
1190 | keys[row].append(key); | 1190 | keys[row].append(key); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | // Keys::~Keys {{{2 | 1193 | // Keys::~Keys {{{2 |
1194 | Keys::~Keys() { | 1194 | Keys::~Keys() { |
1195 | 1195 | ||
1196 | for (int i = 1; i <= 5; i++) | 1196 | for (int i = 1; i <= 5; i++) |
1197 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1197 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1198 | delete keys[i].at(j); | 1198 | delete keys[i].at(j); |
1199 | 1199 | ||
1200 | } | 1200 | } |
1201 | 1201 | ||
1202 | // Keys:: other functions {{{2 | 1202 | // Keys:: other functions {{{2 |
1203 | int Keys::width(const int row, const int col) { | 1203 | int Keys::width(const int row, const int col) { |
1204 | 1204 | ||
1205 | return keys[row].at(col)->width; | 1205 | return keys[row].at(col)->width; |
1206 | 1206 | ||
1207 | } | 1207 | } |
1208 | ushort Keys::uni(const int row, const int col) { | 1208 | ushort Keys::uni(const int row, const int col) { |
1209 | 1209 | ||
1210 | return keys[row].at(col)->unicode; | 1210 | return keys[row].at(col)->unicode; |
1211 | 1211 | ||
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | int Keys::qcode(const int row, const int col) { | 1214 | int Keys::qcode(const int row, const int col) { |
1215 | 1215 | ||
1216 | return keys[row].at(col)->qcode; | 1216 | return keys[row].at(col)->qcode; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | QImage *Keys::pix(const int row, const int col) { | 1219 | QImage *Keys::pix(const int row, const int col) { |
1220 | 1220 | ||
1221 | return keys[row].at(col)->pix; | 1221 | return keys[row].at(col)->pix; |
1222 | 1222 | ||
1223 | } | 1223 | } |
1224 | bool Keys::pressed(const int row, const int col) { | 1224 | bool Keys::pressed(const int row, const int col) { |
1225 | 1225 | ||
1226 | return *(keys[row].at(col)->pressed); | 1226 | return *(keys[row].at(col)->pressed); |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | int Keys::numKeys(const int row) { | 1229 | int Keys::numKeys(const int row) { |
1230 | 1230 | ||
1231 | return keys[row].count(); | 1231 | return keys[row].count(); |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1234 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1235 | 1235 | ||
1236 | *(keys[row].at(col)->pressed) = pressed; | 1236 | *(keys[row].at(col)->pressed) = pressed; |
1237 | } | 1237 | } |
1238 | 1238 | ||
1239 | ushort Keys::shift(const ushort uni) { | 1239 | ushort Keys::shift(const ushort uni) { |
1240 | 1240 | ||
1241 | if (shiftMap[uni]) { | 1241 | if (shiftMap[uni]) { |
1242 | 1242 | ||
1243 | return shiftMap[uni]; | 1243 | return shiftMap[uni]; |
1244 | } | 1244 | } |
1245 | else | 1245 | else |
1246 | return 0; | 1246 | return 0; |
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | ushort Keys::meta(const ushort uni) { | 1250 | ushort Keys::meta(const ushort uni) { |
1251 | 1251 | ||
1252 | if (metaMap[uni]) { | 1252 | if (metaMap[uni]) { |
1253 | 1253 | ||
1254 | return metaMap[uni]; | 1254 | return metaMap[uni]; |
1255 | } | 1255 | } |
1256 | else | 1256 | else |
1257 | return 0; | 1257 | return 0; |
1258 | 1258 | ||
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | bool *Keys::pressedPtr(const int row, const int col) { | 1261 | bool *Keys::pressedPtr(const int row, const int col) { |
1262 | 1262 | ||
1263 | return keys[row].at(col)->pressed; | 1263 | return keys[row].at(col)->pressed; |
1264 | } | 1264 | } |