-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 31 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 3 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 39 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 2 |
4 files changed, 57 insertions, 18 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 59a290b..566b2b9 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,260 +1,281 @@ | |||
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 a cursor thing |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <iostream.h> | 10 | #include <iostream.h> |
11 | 11 | ||
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | 14 | ||
15 | #include <qwidget.h> | 15 | #include <qwidget.h> |
16 | #include <qdialog.h> | 16 | #include <qdialog.h> |
17 | #include <qtabwidget.h> | 17 | #include <qtabwidget.h> |
18 | #include <qvbox.h> | 18 | #include <qvbox.h> |
19 | #include <qgrid.h> | 19 | #include <qgrid.h> |
20 | #include <qgroupbox.h> | 20 | #include <qgroupbox.h> |
21 | #include <qlabel.h> | 21 | #include <qlabel.h> |
22 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
23 | #include <qsizepolicy.h> | 23 | #include <qsizepolicy.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qlistbox.h> | 25 | #include <qlistbox.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <opie/ofiledialog.h> | 27 | #include <opie/ofiledialog.h> |
28 | #include <opie/colordialog.h> | 28 | #include <opie/colordialog.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include "configdlg.h" | 31 | #include "configdlg.h" |
32 | #include "keyboard.h" | 32 | #include "keyboard.h" |
33 | 33 | ||
34 | // ConfigDlg::ConfigDlg() {{{1 | 34 | // ConfigDlg::ConfigDlg() {{{1 |
35 | ConfigDlg::ConfigDlg () : QTabWidget () | 35 | ConfigDlg::ConfigDlg () : QTabWidget () |
36 | { | 36 | { |
37 | setCaption( tr("Multikey Configuration") ); | 37 | setCaption( tr("Multikey Configuration") ); |
38 | Config config ("multikey"); | 38 | Config config ("multikey"); |
39 | config.setGroup("keymaps"); | 39 | config.setGroup("keymaps"); |
40 | QString current_map = config.readEntry("current", 0); | 40 | QString current_map = config.readEntry("current", 0); |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * 'general config' tab | 43 | * 'general config' tab |
44 | */ | 44 | */ |
45 | 45 | ||
46 | QVBox *gen_box = new QVBox (this); | 46 | QVBox *gen_box = new QVBox (this); |
47 | gen_box->setMargin(3); | 47 | gen_box->setMargin(3); |
48 | addTab(gen_box, tr("General Settings")); | 48 | addTab(gen_box, tr("General Settings")); |
49 | 49 | ||
50 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 50 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
51 | 51 | ||
52 | keymaps = new QListBox (map_group); | 52 | keymaps = new QListBox (map_group); |
53 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 53 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
54 | 54 | ||
55 | QString cur(tr("Current Language")); | 55 | QString cur(tr("Current Language")); |
56 | keymaps->insertItem(cur); | 56 | keymaps->insertItem(cur); |
57 | keymaps->setSelected(0, true); | 57 | keymaps->setSelected(0, true); |
58 | 58 | ||
59 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 59 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); |
60 | default_maps = map_dir.entryList(); // so i can access it in other places | 60 | default_maps = map_dir.entryList(); // so i can access it in other places |
61 | 61 | ||
62 | for (uint i = 0; i <map_dir.count(); i++) { | 62 | for (uint i = 0; i <map_dir.count(); i++) { |
63 | 63 | ||
64 | keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); | 64 | keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); |
65 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { | 65 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { |
66 | 66 | ||
67 | keymaps->setSelected(i + 1, true); | 67 | keymaps->setSelected(i + 1, true); |
68 | } | 68 | } |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | custom_maps = config.readListEntry("maps", QChar('|')); | 72 | custom_maps = config.readListEntry("maps", QChar('|')); |
73 | 73 | ||
74 | for (uint i = 0; i < custom_maps.count(); i++) { | 74 | for (uint i = 0; i < custom_maps.count(); i++) { |
75 | 75 | ||
76 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) | 76 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) |
77 | || !QFile::exists(custom_maps[i])) { | 77 | || !QFile::exists(custom_maps[i])) { |
78 | 78 | ||
79 | custom_maps.remove(custom_maps.at(i)); | 79 | custom_maps.remove(custom_maps.at(i)); |
80 | 80 | ||
81 | // remove it from the list too | 81 | // remove it from the list too |
82 | config.writeEntry("maps", custom_maps.join("|")); | 82 | config.writeEntry("maps", custom_maps.join("|")); |
83 | 83 | ||
84 | 84 | ||
85 | } else { | 85 | } else { |
86 | 86 | ||
87 | keymaps->insertItem(custom_maps[i]); | 87 | keymaps->insertItem(custom_maps[i]); |
88 | if (custom_maps[i] == current_map) { | 88 | if (custom_maps[i] == current_map) { |
89 | 89 | ||
90 | keymaps->setSelected(map_dir.count() + i + 1, true); | 90 | keymaps->setSelected(map_dir.count() + i + 1, true); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | // have to "+1" because the "current language" listItem... remember? | 95 | // have to "+1" because the "current language" listItem... remember? |
96 | 96 | ||
97 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 97 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
98 | 98 | ||
99 | 99 | ||
100 | QGrid *add_remove_grid = new QGrid(2, map_group); | 100 | QGrid *add_remove_grid = new QGrid(2, map_group); |
101 | add_remove_grid->setMargin(3); | 101 | add_remove_grid->setMargin(3); |
102 | add_remove_grid->setSpacing(3); | 102 | add_remove_grid->setSpacing(3); |
103 | 103 | ||
104 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 104 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
105 | add_button->setFlat((bool)1); | 105 | add_button->setFlat((bool)1); |
106 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 106 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
107 | 107 | ||
108 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 108 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
109 | remove_button->setFlat((bool)1); | 109 | remove_button->setFlat((bool)1); |
110 | if ((int)map_dir.count() >= keymaps->currentItem()) | 110 | if ((int)map_dir.count() >= keymaps->currentItem()) |
111 | remove_button->setDisabled(true); | 111 | remove_button->setDisabled(true); |
112 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 112 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
113 | 113 | ||
114 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); | 114 | // make a box that will contain the buttons on the bottom |
115 | QGrid *other_grid = new QGrid(2, gen_box); | ||
116 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | ||
115 | 117 | ||
116 | config.setGroup ("pickboard"); | 118 | config.setGroup ("general"); |
117 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed | 119 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed |
118 | if (pick_open) { | 120 | if (pick_open) { |
119 | 121 | ||
120 | pick_button->setChecked(true); | 122 | pick_button->setChecked(true); |
121 | } | 123 | } |
122 | 124 | ||
123 | // by connecting it after checking it, the signal isn't emmited | 125 | // by connecting it after checking it, the signal isn't emmited |
124 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 126 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
125 | 127 | ||
128 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | ||
129 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); | ||
130 | |||
131 | if (repeat_on) { | ||
132 | |||
133 | repeat_button->setChecked(true); | ||
134 | } | ||
135 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); | ||
136 | |||
137 | |||
126 | /* | 138 | /* |
127 | * 'color' tab | 139 | * 'color' tab |
128 | */ | 140 | */ |
129 | 141 | ||
130 | QGrid *color_box = new QGrid(2, this); | 142 | QGrid *color_box = new QGrid(2, this); |
131 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 143 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
132 | color_box->setMargin(3); | 144 | color_box->setMargin(3); |
133 | color_box->setSpacing(3); | 145 | color_box->setSpacing(3); |
134 | addTab(color_box, tr("Colors")); | 146 | addTab(color_box, tr("Colors")); |
135 | 147 | ||
136 | QLabel *label; | 148 | QLabel *label; |
137 | QStringList color; | 149 | QStringList color; |
138 | 150 | ||
139 | label = new QLabel(tr("Key Color"), color_box); | 151 | label = new QLabel(tr("Key Color"), color_box); |
140 | key_color_button = new QPushButton(color_box); | 152 | key_color_button = new QPushButton(color_box); |
141 | connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked())); | 153 | connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked())); |
142 | key_color_button->setFlat((bool)1); | 154 | key_color_button->setFlat((bool)1); |
143 | 155 | ||
144 | config.setGroup("colors"); | 156 | config.setGroup("colors"); |
145 | color = config.readListEntry("keycolor", QChar(',')); | 157 | color = config.readListEntry("keycolor", QChar(',')); |
146 | if (color.isEmpty()) { | 158 | if (color.isEmpty()) { |
147 | color = QStringList::split(",", "240,240,240"); | 159 | color = QStringList::split(",", "240,240,240"); |
148 | config.writeEntry("keycolor", color.join(",")); | 160 | config.writeEntry("keycolor", color.join(",")); |
149 | 161 | ||
150 | } | 162 | } |
151 | key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 163 | key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
152 | 164 | ||
153 | 165 | ||
154 | label = new QLabel(tr("Key Pressed Color"), color_box); | 166 | label = new QLabel(tr("Key Pressed Color"), color_box); |
155 | QPushButton *button = new QPushButton(color_box); | 167 | QPushButton *button = new QPushButton(color_box); |
156 | button->setFlat((bool)1); | 168 | button->setFlat((bool)1); |
157 | label = new QLabel(tr("Line Color"), color_box); | 169 | label = new QLabel(tr("Line Color"), color_box); |
158 | button = new QPushButton(color_box); | 170 | button = new QPushButton(color_box); |
159 | button->setFlat((bool)1); | 171 | button->setFlat((bool)1); |
160 | label = new QLabel(tr("Text Color"), color_box); | 172 | label = new QLabel(tr("Text Color"), color_box); |
161 | button = new QPushButton(color_box); | 173 | button = new QPushButton(color_box); |
162 | button->setFlat((bool)1); | 174 | button->setFlat((bool)1); |
163 | 175 | ||
164 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 176 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
165 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 177 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
166 | 178 | ||
167 | } | 179 | } |
168 | 180 | ||
169 | void ConfigDlg::pickTog() { | 181 | void ConfigDlg::pickTog() { |
170 | 182 | ||
171 | Config config ("multikey"); | 183 | Config config ("multikey"); |
172 | config.setGroup ("pickboard"); | 184 | config.setGroup ("general"); |
173 | config.writeEntry ("open", pick_button->isChecked()); // default closed | 185 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed |
174 | 186 | ||
175 | emit pickboardToggled(pick_button->isChecked()); | 187 | emit pickboardToggled(pick_button->isChecked()); |
176 | } | 188 | } |
177 | 189 | ||
190 | void ConfigDlg::repeatTog() { | ||
191 | |||
192 | Config config ("multikey"); | ||
193 | config.setGroup ("general"); | ||
194 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed | ||
195 | |||
196 | emit repeatToggled(repeat_button->isChecked()); | ||
197 | } | ||
198 | |||
178 | /* | 199 | /* |
179 | * the index is kinda screwy, because in the config file, index 0 is just the | 200 | * the index is kinda screwy, because in the config file, index 0 is just the |
180 | * first element in the QStringList, but here it's the "Current Language" | 201 | * first element in the QStringList, but here it's the "Current Language" |
181 | * listItem. therefor you have to minus one to the index before you access it. | 202 | * listItem. therefor you have to minus one to the index before you access it. |
182 | * | 203 | * |
183 | */ | 204 | */ |
184 | 205 | ||
185 | // ConfigDlg::setMap {{{1 | 206 | // ConfigDlg::setMap {{{1 |
186 | void ConfigDlg::setMap(int index) { | 207 | void ConfigDlg::setMap(int index) { |
187 | 208 | ||
188 | if (index == 0) { | 209 | if (index == 0) { |
189 | 210 | ||
190 | remove_button->setDisabled(true); | 211 | remove_button->setDisabled(true); |
191 | emit setMapToDefault(); | 212 | emit setMapToDefault(); |
192 | } | 213 | } |
193 | else if ((uint)index <= default_maps.count()) { | 214 | else if ((uint)index <= default_maps.count()) { |
194 | 215 | ||
195 | remove_button->setDisabled(true); | 216 | remove_button->setDisabled(true); |
196 | emit setMapToFile(keymaps->text(index)); | 217 | emit setMapToFile(keymaps->text(index)); |
197 | 218 | ||
198 | } else { | 219 | } else { |
199 | 220 | ||
200 | remove_button->setEnabled(true); | 221 | remove_button->setEnabled(true); |
201 | emit setMapToFile(keymaps->text(index)); | 222 | emit setMapToFile(keymaps->text(index)); |
202 | } | 223 | } |
203 | } | 224 | } |
204 | 225 | ||
205 | // ConfigDlg::addMap() {{{1 | 226 | // ConfigDlg::addMap() {{{1 |
206 | void ConfigDlg::addMap() { | 227 | void ConfigDlg::addMap() { |
207 | 228 | ||
208 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); | 229 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); |
209 | Config config ("multikey"); | 230 | Config config ("multikey"); |
210 | config.setGroup("keymaps"); | 231 | config.setGroup("keymaps"); |
211 | QStringList maps = config.readListEntry("maps", QChar('|')); | 232 | QStringList maps = config.readListEntry("maps", QChar('|')); |
212 | maps.append(map); | 233 | maps.append(map); |
213 | keymaps->insertItem(map); | 234 | keymaps->insertItem(map); |
214 | keymaps->setSelected(keymaps->count() - 1, true); | 235 | keymaps->setSelected(keymaps->count() - 1, true); |
215 | 236 | ||
216 | 237 | ||
217 | config.writeEntry("maps", maps, QChar('|')); | 238 | config.writeEntry("maps", maps, QChar('|')); |
218 | config.writeEntry("current", map); | 239 | config.writeEntry("current", map); |
219 | 240 | ||
220 | } | 241 | } |
221 | 242 | ||
222 | // ConfigDlg::removeMap() {{{1 | 243 | // ConfigDlg::removeMap() {{{1 |
223 | void ConfigDlg::removeMap() { | 244 | void ConfigDlg::removeMap() { |
224 | 245 | ||
225 | cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n"; | 246 | cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n"; |
226 | cout << "currentItem : " << keymaps->currentItem() << "\n"; | 247 | cout << "currentItem : " << keymaps->currentItem() << "\n"; |
227 | 248 | ||
228 | // move selection up one | 249 | // move selection up one |
229 | keymaps->setSelected(keymaps->currentItem() - 1, true); | 250 | keymaps->setSelected(keymaps->currentItem() - 1, true); |
230 | // delete the next selected item cus you just moved it up | 251 | // delete the next selected item cus you just moved it up |
231 | keymaps->removeItem(keymaps->currentItem() + 1); | 252 | keymaps->removeItem(keymaps->currentItem() + 1); |
232 | 253 | ||
233 | custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); | 254 | custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); |
234 | 255 | ||
235 | // write the changes | 256 | // write the changes |
236 | Config config ("multikey"); | 257 | Config config ("multikey"); |
237 | config.setGroup("keymaps"); | 258 | config.setGroup("keymaps"); |
238 | config.writeEntry("maps", custom_maps, QChar('|')); | 259 | config.writeEntry("maps", custom_maps, QChar('|')); |
239 | } | 260 | } |
240 | 261 | ||
241 | // ConfigDlg::color {{{1 | 262 | // ConfigDlg::color {{{1 |
242 | void ConfigDlg::keyColorButtonClicked() { | 263 | void ConfigDlg::keyColorButtonClicked() { |
243 | 264 | ||
244 | Config config ("multikey"); | 265 | Config config ("multikey"); |
245 | config.setGroup ("colors"); | 266 | config.setGroup ("colors"); |
246 | 267 | ||
247 | QStringList color = config.readListEntry("keycolor", QChar(',')); | 268 | QStringList color = config.readListEntry("keycolor", QChar(',')); |
248 | 269 | ||
249 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 270 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
250 | 271 | ||
251 | color[0].setNum(newcolor.red()); | 272 | color[0].setNum(newcolor.red()); |
252 | color[1].setNum(newcolor.green()); | 273 | color[1].setNum(newcolor.green()); |
253 | color[2].setNum(newcolor.blue()); | 274 | color[2].setNum(newcolor.blue()); |
254 | 275 | ||
255 | config.writeEntry("keycolor", color, QChar(',')); | 276 | config.writeEntry("keycolor", color, QChar(',')); |
256 | config.write(); | 277 | config.write(); |
257 | 278 | ||
258 | key_color_button->setBackgroundColor(newcolor); | 279 | key_color_button->setBackgroundColor(newcolor); |
259 | emit reloadKeyboard(); | 280 | emit reloadKeyboard(); |
260 | } | 281 | } |
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h index ae7afe2..a000e60 100644 --- a/inputmethods/multikey/configdlg.h +++ b/inputmethods/multikey/configdlg.h | |||
@@ -1,47 +1,50 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qtabwidget.h> | 2 | #include <qtabwidget.h> |
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | 6 | ||
7 | #ifndef CONFIGDLG_H | 7 | #ifndef CONFIGDLG_H |
8 | #define CONFIGDLG_H | 8 | #define CONFIGDLG_H |
9 | 9 | ||
10 | class ConfigDlg : public QTabWidget | 10 | class ConfigDlg : public QTabWidget |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public: | 14 | public: |
15 | ConfigDlg (); | 15 | ConfigDlg (); |
16 | 16 | ||
17 | signals: | 17 | signals: |
18 | void pickboardToggled(bool on_off); | 18 | void pickboardToggled(bool on_off); |
19 | void repeatToggled(bool on_off); | ||
19 | void setMapToDefault(); | 20 | void setMapToDefault(); |
20 | void setMapToFile(QString map); | 21 | void setMapToFile(QString map); |
21 | void reloadKeyboard(); | 22 | void reloadKeyboard(); |
22 | 23 | ||
23 | private slots: | 24 | private slots: |
24 | void pickTog(); | 25 | void pickTog(); |
26 | void repeatTog(); | ||
25 | void setMap(int index); | 27 | void setMap(int index); |
26 | void addMap(); | 28 | void addMap(); |
27 | void removeMap(); | 29 | void removeMap(); |
28 | 30 | ||
29 | // all those required slots for the color push buttons | 31 | // all those required slots for the color push buttons |
30 | void keyColorButtonClicked(); | 32 | void keyColorButtonClicked(); |
31 | 33 | ||
32 | private: | 34 | private: |
33 | QCheckBox *pick_button; | 35 | QCheckBox *pick_button; |
36 | QCheckBox *repeat_button; | ||
34 | QListBox *keymaps; | 37 | QListBox *keymaps; |
35 | QPushButton *add_button; | 38 | QPushButton *add_button; |
36 | QPushButton *remove_button; | 39 | QPushButton *remove_button; |
37 | 40 | ||
38 | 41 | ||
39 | QStringList default_maps; // the maps in your share/multikey/ dir | 42 | QStringList default_maps; // the maps in your share/multikey/ dir |
40 | QStringList custom_maps; // maps you added with the 'add' button | 43 | QStringList custom_maps; // maps you added with the 'add' button |
41 | 44 | ||
42 | /* color buttons */ | 45 | /* color buttons */ |
43 | QPushButton *key_color_button; | 46 | QPushButton *key_color_button; |
44 | 47 | ||
45 | }; | 48 | }; |
46 | 49 | ||
47 | #endif | 50 | #endif |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 8280297..7334c1c 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,633 +1,646 @@ | |||
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 | #include <iostream.h> | 37 | #include <iostream.h> |
38 | 38 | ||
39 | #include <sys/utsname.h> | 39 | #include <sys/utsname.h> |
40 | 40 | ||
41 | 41 | ||
42 | #define USE_SMALL_BACKSPACE | ||
43 | |||
44 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
45 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
46 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
47 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | alt(0), useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), |
48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
49 | configdlg(0) | 47 | configdlg(0) |
50 | 48 | ||
51 | { | 49 | { |
52 | 50 | ||
53 | // get the default font | 51 | // get the default font |
54 | Config *config = new Config( "qpe" ); | 52 | Config *config = new Config( "qpe" ); |
55 | config->setGroup( "Appearance" ); | 53 | config->setGroup( "Appearance" ); |
56 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 54 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
57 | delete config; | 55 | delete config; |
58 | 56 | ||
59 | config = new Config("multikey"); | 57 | config = new Config("multikey"); |
60 | config->setGroup ("pickboard"); | 58 | config->setGroup ("general"); |
61 | usePicks = config->readBoolEntry ("open", "0"); // default closed | 59 | usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed |
60 | useRepeat = config->readBoolEntry ("useRepeat", "1"); | ||
62 | delete config; | 61 | delete config; |
63 | 62 | ||
63 | |||
64 | setFont( QFont( familyStr, 10 ) ); | 64 | setFont( QFont( familyStr, 10 ) ); |
65 | 65 | ||
66 | picks = new KeyboardPicks( this ); | 66 | picks = new KeyboardPicks( this ); |
67 | picks->setFont( QFont( familyStr, 10 ) ); | 67 | picks->setFont( QFont( familyStr, 10 ) ); |
68 | picks->initialise(); | 68 | picks->initialise(); |
69 | if (usePicks) { | 69 | if (usePicks) { |
70 | 70 | ||
71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
73 | 73 | ||
74 | } else picks->hide(); | 74 | } else picks->hide(); |
75 | 75 | ||
76 | loadKeyboardColors(); | 76 | loadKeyboardColors(); |
77 | 77 | ||
78 | keys = new Keys(); | 78 | keys = new Keys(); |
79 | 79 | ||
80 | repeatTimer = new QTimer( this ); | 80 | repeatTimer = new QTimer( this ); |
81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | Keyboard::~Keyboard() { | 85 | Keyboard::~Keyboard() { |
86 | 86 | ||
87 | if ( configdlg ) { | 87 | if ( configdlg ) { |
88 | delete (ConfigDlg *) configdlg; | 88 | delete (ConfigDlg *) configdlg; |
89 | configdlg = 0; | 89 | configdlg = 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | /* Keyboard::resizeEvent {{{1 */ | 94 | /* Keyboard::resizeEvent {{{1 */ |
95 | void Keyboard::resizeEvent(QResizeEvent*) | 95 | void Keyboard::resizeEvent(QResizeEvent*) |
96 | { | 96 | { |
97 | int ph = picks->sizeHint().height(); | 97 | int ph = picks->sizeHint().height(); |
98 | picks->setGeometry( 0, 0, width(), ph ); | 98 | picks->setGeometry( 0, 0, width(), ph ); |
99 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 99 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
100 | 100 | ||
101 | int nk; // number of keys? | 101 | int nk; // number of keys? |
102 | if ( useLargeKeys ) { | 102 | if ( useLargeKeys ) { |
103 | nk = 15; | 103 | nk = 15; |
104 | } else { | 104 | } else { |
105 | nk = 19; | 105 | nk = 19; |
106 | } | 106 | } |
107 | defaultKeyWidth = (width()/nk)/2; | 107 | defaultKeyWidth = (width()/nk)/2; |
108 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 108 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | /* KeyboardPicks::initialize {{{1 */ | 112 | /* KeyboardPicks::initialize {{{1 */ |
113 | void KeyboardPicks::initialise() | 113 | void KeyboardPicks::initialise() |
114 | { | 114 | { |
115 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 115 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
116 | mode = 0; | 116 | mode = 0; |
117 | dc = new KeyboardConfig(this); | 117 | dc = new KeyboardConfig(this); |
118 | configs.append(dc); | 118 | configs.append(dc); |
119 | } | 119 | } |
120 | 120 | ||
121 | /* KeyboardPicks::sizeHint {{{1 */ | 121 | /* KeyboardPicks::sizeHint {{{1 */ |
122 | QSize KeyboardPicks::sizeHint() const | 122 | QSize KeyboardPicks::sizeHint() const |
123 | { | 123 | { |
124 | return QSize(240,fontMetrics().lineSpacing()); | 124 | return QSize(240,fontMetrics().lineSpacing()); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | /* KeyboardConfig::generateText {{{1 */ | 128 | /* KeyboardConfig::generateText {{{1 */ |
129 | void KeyboardConfig::generateText(const QString &s) | 129 | void KeyboardConfig::generateText(const QString &s) |
130 | { | 130 | { |
131 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 131 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
132 | for (int i=0; i<(int)backspaces; i++) { | 132 | for (int i=0; i<(int)backspaces; i++) { |
133 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 133 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
134 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 134 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
135 | } | 135 | } |
136 | for (int i=0; i<(int)s.length(); i++) { | 136 | for (int i=0; i<(int)s.length(); i++) { |
137 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 137 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
138 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 138 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
139 | } | 139 | } |
140 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 140 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
141 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 141 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
142 | backspaces = 0; | 142 | backspaces = 0; |
143 | #endif | 143 | #endif |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | 148 | ||
149 | /* Keyboard::paintEvent {{{1 */ | 149 | /* Keyboard::paintEvent {{{1 */ |
150 | void Keyboard::paintEvent(QPaintEvent* e) | 150 | void Keyboard::paintEvent(QPaintEvent* e) |
151 | { | 151 | { |
152 | QPainter painter(this); | 152 | QPainter painter(this); |
153 | painter.setClipRect(e->rect()); | 153 | painter.setClipRect(e->rect()); |
154 | drawKeyboard( painter ); | 154 | drawKeyboard( painter ); |
155 | picks->dc->draw( &painter ); | 155 | picks->dc->draw( &painter ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | /* Keyboard::drawKeyboard {{{1 */ | 159 | /* Keyboard::drawKeyboard {{{1 */ |
160 | 160 | ||
161 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 161 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
162 | { | 162 | { |
163 | 163 | ||
164 | 164 | ||
165 | if (row != -1 && col != -1) { //just redraw one key | 165 | if (row != -1 && col != -1) { //just redraw one key |
166 | 166 | ||
167 | int x = 0; | 167 | int x = 0; |
168 | for (int i = 0; i < col; i++) { | 168 | for (int i = 0; i < col; i++) { |
169 | 169 | ||
170 | x += keys->width(row, i) * defaultKeyWidth; | 170 | x += keys->width(row, i) * defaultKeyWidth; |
171 | } | 171 | } |
172 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 172 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
173 | 173 | ||
174 | int keyWidth = keys->width(row, col); | 174 | int keyWidth = keys->width(row, col); |
175 | 175 | ||
176 | p.fillRect(x + 1, y + 1, | 176 | p.fillRect(x + 1, y + 1, |
177 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 177 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
178 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 178 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
179 | 179 | ||
180 | QPixmap *pix = keys->pix(row,col); | 180 | QPixmap *pix = keys->pix(row,col); |
181 | 181 | ||
182 | ushort c = keys->uni(row, col); | 182 | ushort c = keys->uni(row, col); |
183 | 183 | ||
184 | p.setPen(textcolor); | 184 | p.setPen(textcolor); |
185 | if (!pix) | 185 | if (!pix) |
186 | p.drawText(x, y, | 186 | p.drawText(x, y, |
187 | defaultKeyWidth * keyWidth, keyHeight, | 187 | defaultKeyWidth * keyWidth, keyHeight, |
188 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 188 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); |
189 | else | 189 | else |
190 | // center the image in the middle of the key | 190 | // center the image in the middle of the key |
191 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, | 191 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, |
192 | y + (keyHeight - pix->height())/2 + 1, | 192 | y + (keyHeight - pix->height())/2 + 1, |
193 | *pix ); | 193 | *pix ); |
194 | 194 | ||
195 | // this fixes the problem that the very right end of the board's vertical line | 195 | // this fixes the problem that the very right end of the board's vertical line |
196 | // gets painted over, because it's one pixel shorter than all other keys | 196 | // gets painted over, because it's one pixel shorter than all other keys |
197 | p.setPen(keycolor_lines); | 197 | p.setPen(keycolor_lines); |
198 | p.drawLine(width() - 1, 0, width() - 1, height()); | 198 | p.drawLine(width() - 1, 0, width() - 1, height()); |
199 | 199 | ||
200 | } else { | 200 | } else { |
201 | 201 | ||
202 | 202 | ||
203 | p.fillRect(0, 0, width(), height(), keycolor); | 203 | p.fillRect(0, 0, width(), height(), keycolor); |
204 | 204 | ||
205 | for (row = 1; row <= 5; row++) { | 205 | for (row = 1; row <= 5; row++) { |
206 | 206 | ||
207 | int x = 0; | 207 | int x = 0; |
208 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 208 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
209 | 209 | ||
210 | p.setPen(keycolor_lines); | 210 | p.setPen(keycolor_lines); |
211 | p.drawLine(x, y, x + width(), y); | 211 | p.drawLine(x, y, x + width(), y); |
212 | 212 | ||
213 | for (int col = 0; col < keys->numKeys(row); col++) { | 213 | for (int col = 0; col < keys->numKeys(row); col++) { |
214 | 214 | ||
215 | QPixmap *pix = keys->pix(row, col); | 215 | QPixmap *pix = keys->pix(row, col); |
216 | int keyWidth = keys->width(row, col); | 216 | int keyWidth = keys->width(row, col); |
217 | 217 | ||
218 | 218 | ||
219 | int keyWidthPix = defaultKeyWidth * keyWidth; | 219 | int keyWidthPix = defaultKeyWidth * keyWidth; |
220 | 220 | ||
221 | if (keys->pressed(row, col)) | 221 | if (keys->pressed(row, col)) |
222 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 222 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
223 | keyHeight - 1, keycolor_pressed); | 223 | keyHeight - 1, keycolor_pressed); |
224 | 224 | ||
225 | ushort c = keys->uni(row, col); | 225 | ushort c = keys->uni(row, col); |
226 | 226 | ||
227 | if (!pix) { | 227 | if (!pix) { |
228 | p.setPen(textcolor); | 228 | p.setPen(textcolor); |
229 | p.drawText(x, y, | 229 | p.drawText(x, y, |
230 | keyWidthPix, keyHeight, | 230 | keyWidthPix, keyHeight, |
231 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 231 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); |
232 | } | 232 | } |
233 | else { | 233 | else { |
234 | // center the image in the middle of the key | 234 | // center the image in the middle of the key |
235 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, | 235 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, |
236 | y + (keyHeight - pix->height())/2 + 1, | 236 | y + (keyHeight - pix->height())/2 + 1, |
237 | QPixmap(*pix) ); | 237 | QPixmap(*pix) ); |
238 | } | 238 | } |
239 | 239 | ||
240 | p.setPen(keycolor_lines); | 240 | p.setPen(keycolor_lines); |
241 | p.drawLine(x, y, x, y + keyHeight); | 241 | p.drawLine(x, y, x, y + keyHeight); |
242 | 242 | ||
243 | x += keyWidthPix; | 243 | x += keyWidthPix; |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | } | 247 | } |
248 | p.drawLine(0, height() - 1, width(), height() - 1); | 248 | p.drawLine(0, height() - 1, width(), height() - 1); |
249 | p.drawLine(width() - 1, 0, width() - 1, height()); | 249 | p.drawLine(width() - 1, 0, width() - 1, height()); |
250 | } | 250 | } |
251 | 251 | ||
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | /* Keyboard::mousePressEvent {{{1 */ | 255 | /* Keyboard::mousePressEvent {{{1 */ |
256 | void Keyboard::mousePressEvent(QMouseEvent *e) | 256 | void Keyboard::mousePressEvent(QMouseEvent *e) |
257 | { | 257 | { |
258 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 258 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
259 | if (row > 5) row = 5; | 259 | if (row > 5) row = 5; |
260 | 260 | ||
261 | // figure out the column | 261 | // figure out the column |
262 | int col = 0; | 262 | int col = 0; |
263 | for (int w = 0; e->x() >= w; col++) | 263 | for (int w = 0; e->x() >= w; col++) |
264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
265 | w += keys->width(row,col) * defaultKeyWidth; | 265 | w += keys->width(row,col) * defaultKeyWidth; |
266 | else break; | 266 | else break; |
267 | 267 | ||
268 | col --; // rewind one... | 268 | col --; // rewind one... |
269 | 269 | ||
270 | qkeycode = keys->qcode(row, col); | 270 | qkeycode = keys->qcode(row, col); |
271 | unicode = keys->uni(row, col); | 271 | unicode = keys->uni(row, col); |
272 | 272 | ||
273 | // might need to repaint if two or more of the same keys. | 273 | // might need to repaint if two or more of the same keys. |
274 | // should be faster if just paint one key even though multiple keys exist. | 274 | // should be faster if just paint one key even though multiple keys exist. |
275 | bool need_repaint = FALSE; | 275 | bool need_repaint = FALSE; |
276 | 276 | ||
277 | if (unicode == 0) { // either Qt char, or nothing | 277 | if (unicode == 0) { // either Qt char, or nothing |
278 | 278 | ||
279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
280 | 280 | ||
281 | if ( configdlg ) { | 281 | if ( configdlg ) { |
282 | delete (ConfigDlg *) configdlg; | 282 | delete (ConfigDlg *) configdlg; |
283 | configdlg = 0; | 283 | configdlg = 0; |
284 | } | 284 | } |
285 | else { | 285 | else { |
286 | configdlg = new ConfigDlg (); | 286 | configdlg = new ConfigDlg (); |
287 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | ||
288 | this, SLOT(togglePickboard(bool))); | ||
289 | connect(configdlg, SIGNAL(setMapToDefault()), | 287 | connect(configdlg, SIGNAL(setMapToDefault()), |
290 | this, SLOT(setMapToDefault())); | 288 | this, SLOT(setMapToDefault())); |
291 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 289 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
292 | this, SLOT(setMapToFile(QString))); | 290 | this, SLOT(setMapToFile(QString))); |
291 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | ||
292 | this, SLOT(togglePickboard(bool))); | ||
293 | connect(configdlg, SIGNAL(repeatToggled(bool)), | ||
294 | this, SLOT(toggleRepeat(bool))); | ||
293 | connect(configdlg, SIGNAL(reloadKeyboard()), | 295 | connect(configdlg, SIGNAL(reloadKeyboard()), |
294 | this, SLOT(reloadKeyboard())); | 296 | this, SLOT(reloadKeyboard())); |
295 | configdlg->showMaximized(); | 297 | configdlg->showMaximized(); |
296 | configdlg->show(); | 298 | configdlg->show(); |
297 | configdlg->raise(); | 299 | configdlg->raise(); |
298 | } | 300 | } |
299 | 301 | ||
300 | } else if (qkeycode == Qt::Key_Control) { | 302 | } else if (qkeycode == Qt::Key_Control) { |
301 | ctrl = keys->pressedPtr(row, col); | 303 | ctrl = keys->pressedPtr(row, col); |
302 | need_repaint = TRUE; | 304 | need_repaint = TRUE; |
303 | *ctrl = !keys->pressed(row, col); | 305 | *ctrl = !keys->pressed(row, col); |
304 | 306 | ||
305 | } else if (qkeycode == Qt::Key_Alt) { | 307 | } else if (qkeycode == Qt::Key_Alt) { |
306 | alt = keys->pressedPtr(row, col); | 308 | alt = keys->pressedPtr(row, col); |
307 | need_repaint = TRUE; | 309 | need_repaint = TRUE; |
308 | *alt = !keys->pressed(row, col); | 310 | *alt = !keys->pressed(row, col); |
309 | 311 | ||
310 | } else if (qkeycode == Qt::Key_Shift) { | 312 | } else if (qkeycode == Qt::Key_Shift) { |
311 | need_repaint = TRUE; | 313 | need_repaint = TRUE; |
312 | 314 | ||
313 | if (shift) { | 315 | if (shift) { |
314 | *shift = 0; | 316 | *shift = 0; |
315 | shift = 0; | 317 | shift = 0; |
316 | } | 318 | } |
317 | else { | 319 | else { |
318 | shift = keys->pressedPtr(row, col); | 320 | shift = keys->pressedPtr(row, col); |
319 | *shift = 1; | 321 | *shift = 1; |
320 | if (lock) { | 322 | if (lock) { |
321 | *lock = 0; | 323 | *lock = 0; |
322 | lock = 0; | 324 | lock = 0; |
323 | } | 325 | } |
324 | } | 326 | } |
325 | 327 | ||
326 | } else if (qkeycode == Qt::Key_CapsLock) { | 328 | } else if (qkeycode == Qt::Key_CapsLock) { |
327 | need_repaint = TRUE; | 329 | need_repaint = TRUE; |
328 | 330 | ||
329 | if (lock) { | 331 | if (lock) { |
330 | *lock = 0; | 332 | *lock = 0; |
331 | lock = 0; | 333 | lock = 0; |
332 | } | 334 | } |
333 | else { | 335 | else { |
334 | lock = keys->pressedPtr(row, col);; | 336 | lock = keys->pressedPtr(row, col);; |
335 | *lock = 1; | 337 | *lock = 1; |
336 | if (shift) { | 338 | if (shift) { |
337 | *shift = 0; | 339 | *shift = 0; |
338 | shift = 0; | 340 | shift = 0; |
339 | } | 341 | } |
340 | } | 342 | } |
341 | 343 | ||
342 | } | 344 | } |
343 | 345 | ||
344 | } | 346 | } |
345 | else { // normal char | 347 | else { // normal char |
346 | if ((shift || lock) && keys->shift(unicode)) { | 348 | if ((shift || lock) && keys->shift(unicode)) { |
347 | unicode = keys->shift(unicode); | 349 | unicode = keys->shift(unicode); |
348 | } | 350 | } |
349 | } | 351 | } |
350 | 352 | ||
351 | // korean parsing | 353 | // korean parsing |
352 | if (keys->lang == "ko") { | 354 | if (keys->lang == "ko") { |
353 | 355 | ||
354 | unicode = parseKoreanInput(unicode); | 356 | unicode = parseKoreanInput(unicode); |
355 | } | 357 | } |
356 | 358 | ||
357 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 359 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
358 | 360 | ||
359 | emit key(unicode, qkeycode, modifiers, true, false); | 361 | emit key(unicode, qkeycode, modifiers, true, false); |
360 | 362 | ||
361 | // pickboard stuff | 363 | // pickboard stuff |
362 | if (usePicks) { | 364 | if (usePicks) { |
363 | 365 | ||
364 | KeyboardConfig *dc = picks->dc; | 366 | KeyboardConfig *dc = picks->dc; |
365 | 367 | ||
366 | if (dc) { | 368 | if (dc) { |
367 | if (qkeycode == Qt::Key_Backspace) { | 369 | if (qkeycode == Qt::Key_Backspace) { |
368 | dc->input.remove(dc->input.last()); // remove last input | 370 | dc->input.remove(dc->input.last()); // remove last input |
369 | dc->decBackspaces(); | 371 | dc->decBackspaces(); |
370 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 372 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
371 | dc->input.clear(); | 373 | dc->input.clear(); |
372 | dc->resetBackspaces(); | 374 | dc->resetBackspaces(); |
373 | } else { | 375 | } else { |
374 | dc->add(QString(QChar(unicode))); | 376 | dc->add(QString(QChar(unicode))); |
375 | dc->incBackspaces(); | 377 | dc->incBackspaces(); |
376 | } | 378 | } |
377 | } | 379 | } |
378 | picks->repaint(); | 380 | picks->repaint(); |
379 | } | 381 | } |
380 | 382 | ||
381 | 383 | ||
382 | // painting | 384 | // painting |
383 | pressed = TRUE; | 385 | pressed = TRUE; |
384 | 386 | ||
385 | pressedKeyRow = row; | 387 | pressedKeyRow = row; |
386 | pressedKeyCol = col; | 388 | pressedKeyCol = col; |
387 | 389 | ||
388 | if (need_repaint) repaint(FALSE); | 390 | if (need_repaint) repaint(FALSE); |
389 | else { // just paint the one key pressed | 391 | else { // just paint the one key pressed |
390 | 392 | ||
391 | 393 | ||
392 | 394 | ||
393 | QPainter p(this); | 395 | QPainter p(this); |
394 | drawKeyboard(p, row, col); | 396 | drawKeyboard(p, row, col); |
395 | 397 | ||
396 | } | 398 | } |
397 | 399 | ||
398 | pressTid = startTimer(80); | 400 | if (useRepeat) repeatTimer->start( 800 ); |
401 | //pressTid = startTimer(80); | ||
399 | 402 | ||
400 | } | 403 | } |
401 | 404 | ||
402 | 405 | ||
403 | /* Keyboard::mouseReleaseEvent {{{1 */ | 406 | /* Keyboard::mouseReleaseEvent {{{1 */ |
404 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 407 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
405 | { | 408 | { |
406 | pressed = FALSE; | 409 | pressed = FALSE; |
407 | if ( pressTid == 0 ) | 410 | //if ( pressTid == 0 ) |
408 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 411 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
409 | if ( unicode != -1 ) { | 412 | if ( unicode != -1 ) { |
410 | emit key( unicode, qkeycode, modifiers, false, false ); | 413 | emit key( unicode, qkeycode, modifiers, false, false ); |
411 | repeatTimer->stop(); | 414 | repeatTimer->stop(); |
412 | } | 415 | } |
413 | #endif | 416 | #endif |
414 | if (shift && unicode != 0) { | 417 | if (shift && unicode != 0) { |
415 | 418 | ||
416 | 419 | ||
417 | *shift = 0; // unpress shift key | 420 | *shift = 0; // unpress shift key |
418 | shift = 0; // reset the shift pointer | 421 | shift = 0; // reset the shift pointer |
419 | repaint(FALSE); | 422 | repaint(FALSE); |
420 | 423 | ||
421 | } | 424 | } |
422 | else | 425 | else |
423 | 426 | ||
424 | clearHighlight(); | 427 | clearHighlight(); |
425 | } | 428 | } |
426 | 429 | ||
427 | /* Keyboard::timerEvent {{{1 */ | 430 | /* Keyboard::timerEvent {{{1 */ |
428 | /* | 431 | |
429 | void Keyboard::timerEvent(QTimerEvent* e) | 432 | /* dont know what this does, but i think it is here so that if your screen |
433 | * sticks (like on an ipaq) then it will stop repeating if you click another | ||
434 | * key... but who knows what anything does in this thing anyway? | ||
435 | |||
436 | void Keyboard::timerEvent(QTimerEvent* e) | ||
430 | { | 437 | { |
431 | if ( e->timerId() == pressTid ) { | 438 | if ( e->timerId() == pressTid ) { |
432 | killTimer(pressTid); | 439 | killTimer(pressTid); |
433 | pressTid = 0; | 440 | pressTid = 0; |
434 | if ( !pressed ) | 441 | if ( !pressed ) |
435 | cout << "calling clearHighlight from timerEvent\n"; | 442 | cout << "calling clearHighlight from timerEvent\n"; |
436 | clearHighlight(); | 443 | //clearHighlight(); |
437 | } | 444 | } |
438 | } | 445 | } |
439 | */ | 446 | */ |
440 | 447 | ||
441 | void Keyboard::repeat() | 448 | void Keyboard::repeat() |
442 | { | 449 | { |
443 | 450 | ||
444 | repeatTimer->start( 200 ); | 451 | repeatTimer->start( 200 ); |
445 | emit key( unicode, 0, modifiers, true, true ); | 452 | emit key( unicode, qkeycode, modifiers, true, true ); |
446 | } | 453 | } |
447 | 454 | ||
448 | void Keyboard::clearHighlight() | 455 | void Keyboard::clearHighlight() |
449 | { | 456 | { |
450 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 457 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
451 | int tmpRow = pressedKeyRow; | 458 | int tmpRow = pressedKeyRow; |
452 | int tmpCol = pressedKeyCol; | 459 | int tmpCol = pressedKeyCol; |
453 | 460 | ||
454 | pressedKeyRow = -1; | 461 | pressedKeyRow = -1; |
455 | pressedKeyCol = -1; | 462 | pressedKeyCol = -1; |
456 | 463 | ||
457 | QPainter p(this); | 464 | QPainter p(this); |
458 | drawKeyboard(p, tmpRow, tmpCol); | 465 | drawKeyboard(p, tmpRow, tmpCol); |
459 | } | 466 | } |
460 | } | 467 | } |
461 | 468 | ||
462 | 469 | ||
463 | /* Keyboard::sizeHint {{{1 */ | 470 | /* Keyboard::sizeHint {{{1 */ |
464 | QSize Keyboard::sizeHint() const | 471 | QSize Keyboard::sizeHint() const |
465 | { | 472 | { |
466 | QFontMetrics fm=fontMetrics(); | 473 | QFontMetrics fm=fontMetrics(); |
467 | int keyHeight = fm.lineSpacing() + 2; | 474 | int keyHeight = fm.lineSpacing() + 2; |
468 | 475 | ||
469 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 476 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
470 | } | 477 | } |
471 | 478 | ||
472 | 479 | ||
473 | void Keyboard::resetState() | 480 | void Keyboard::resetState() |
474 | { | 481 | { |
475 | schar = mchar = echar = 0; | 482 | schar = mchar = echar = 0; |
476 | picks->resetState(); | 483 | picks->resetState(); |
477 | } | 484 | } |
478 | 485 | ||
479 | /* Keyboard::togglePickboard {{{1 */ | 486 | /* Keyboard::togglePickboard {{{1 */ |
480 | void Keyboard::togglePickboard(bool on_off) | 487 | void Keyboard::togglePickboard(bool on_off) |
481 | { | 488 | { |
482 | usePicks = on_off; | 489 | usePicks = on_off; |
483 | if (usePicks) { | 490 | if (usePicks) { |
484 | picks->show(); | 491 | picks->show(); |
485 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 492 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
486 | //adjustSize(); | 493 | //adjustSize(); |
487 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 494 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
488 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 495 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
489 | } else { | 496 | } else { |
490 | 497 | ||
491 | picks->hide(); | 498 | picks->hide(); |
492 | picks->resetState(); | 499 | picks->resetState(); |
493 | //move(x(), y() + picks->height()); | 500 | //move(x(), y() + picks->height()); |
494 | //adjustSize(); | 501 | //adjustSize(); |
495 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 502 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
496 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 503 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
497 | 504 | ||
498 | } | 505 | } |
499 | /* | 506 | /* |
500 | * this closes && opens the input method | 507 | * this closes && opens the input method |
501 | */ | 508 | */ |
502 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 509 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
503 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 510 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
504 | } | 511 | } |
505 | 512 | ||
513 | void Keyboard::toggleRepeat(bool on) { | ||
514 | |||
515 | useRepeat = on; | ||
516 | cout << "setting useRepeat to: " << useRepeat << "\n"; | ||
517 | } | ||
518 | |||
506 | /* Keyboard::setMapTo ... {{{1 */ | 519 | /* Keyboard::setMapTo ... {{{1 */ |
507 | void Keyboard::setMapToDefault() { | 520 | void Keyboard::setMapToDefault() { |
508 | 521 | ||
509 | 522 | ||
510 | /* load current locale language map */ | 523 | /* load current locale language map */ |
511 | Config *config = new Config("locale"); | 524 | Config *config = new Config("locale"); |
512 | config->setGroup( "Language" ); | 525 | config->setGroup( "Language" ); |
513 | QString l = config->readEntry( "Language" , "en" ); | 526 | QString l = config->readEntry( "Language" , "en" ); |
514 | delete config; | 527 | delete config; |
515 | 528 | ||
516 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 529 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
517 | + l + ".keymap"; | 530 | + l + ".keymap"; |
518 | 531 | ||
519 | /* save change to multikey config file */ | 532 | /* save change to multikey config file */ |
520 | config = new Config("multikey"); | 533 | config = new Config("multikey"); |
521 | config->setGroup ("keymaps"); | 534 | config->setGroup ("keymaps"); |
522 | config->writeEntry ("current", key_map); // default closed | 535 | config->writeEntry ("current", key_map); // default closed |
523 | delete config; | 536 | delete config; |
524 | 537 | ||
525 | delete keys; | 538 | delete keys; |
526 | keys = new Keys(key_map); | 539 | keys = new Keys(key_map); |
527 | 540 | ||
528 | // have to repaint the keyboard | 541 | // have to repaint the keyboard |
529 | repaint(FALSE); | 542 | repaint(FALSE); |
530 | } | 543 | } |
531 | 544 | ||
532 | void Keyboard::setMapToFile(QString map) { | 545 | void Keyboard::setMapToFile(QString map) { |
533 | 546 | ||
534 | /* save change to multikey config file */ | 547 | /* save change to multikey config file */ |
535 | Config *config = new Config("multikey"); | 548 | Config *config = new Config("multikey"); |
536 | config->setGroup ("keymaps"); | 549 | config->setGroup ("keymaps"); |
537 | config->writeEntry ("current", map); // default closed | 550 | config->writeEntry ("current", map); // default closed |
538 | 551 | ||
539 | delete config; | 552 | delete config; |
540 | 553 | ||
541 | delete keys; | 554 | delete keys; |
542 | if (QFile(map).exists()) | 555 | if (QFile(map).exists()) |
543 | keys = new Keys(map); | 556 | keys = new Keys(map); |
544 | else | 557 | else |
545 | keys = new Keys(); | 558 | keys = new Keys(); |
546 | 559 | ||
547 | repaint(FALSE); | 560 | repaint(FALSE); |
548 | 561 | ||
549 | } | 562 | } |
550 | 563 | ||
551 | /* Keybaord::reloadKeyboard {{{1 */ | 564 | /* Keybaord::reloadKeyboard {{{1 */ |
552 | void Keyboard::reloadKeyboard() { | 565 | void Keyboard::reloadKeyboard() { |
553 | 566 | ||
554 | // reload colors and redraw | 567 | // reload colors and redraw |
555 | loadKeyboardColors(); | 568 | loadKeyboardColors(); |
556 | repaint(); | 569 | repaint(); |
557 | 570 | ||
558 | } | 571 | } |
559 | 572 | ||
560 | void Keyboard::loadKeyboardColors() { | 573 | void Keyboard::loadKeyboardColors() { |
561 | 574 | ||
562 | Config config ("multikey"); | 575 | Config config ("multikey"); |
563 | config.setGroup("colors"); | 576 | config.setGroup("colors"); |
564 | 577 | ||
565 | QStringList color; | 578 | QStringList color; |
566 | color = config.readListEntry("keycolor", QChar(',')); | 579 | color = config.readListEntry("keycolor", QChar(',')); |
567 | if (color.isEmpty()) { | 580 | if (color.isEmpty()) { |
568 | color = QStringList::split(",", "240,240,240"); | 581 | color = QStringList::split(",", "240,240,240"); |
569 | config.writeEntry("keycolor", color.join(",")); | 582 | config.writeEntry("keycolor", color.join(",")); |
570 | 583 | ||
571 | } | 584 | } |
572 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 585 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
573 | 586 | ||
574 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 587 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
575 | if (color.isEmpty()) { | 588 | if (color.isEmpty()) { |
576 | color = QStringList::split(",", "171,183,198"); | 589 | color = QStringList::split(",", "171,183,198"); |
577 | config.writeEntry("keycolor_pressed", color.join(",")); | 590 | config.writeEntry("keycolor_pressed", color.join(",")); |
578 | 591 | ||
579 | } | 592 | } |
580 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 593 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
581 | 594 | ||
582 | color = config.readListEntry("keycolor_lines", QChar(',')); | 595 | color = config.readListEntry("keycolor_lines", QChar(',')); |
583 | if (color.isEmpty()) { | 596 | if (color.isEmpty()) { |
584 | color = QStringList::split(",", "138,148,160"); | 597 | color = QStringList::split(",", "138,148,160"); |
585 | config.writeEntry("keycolor_lines", color.join(",")); | 598 | config.writeEntry("keycolor_lines", color.join(",")); |
586 | 599 | ||
587 | } | 600 | } |
588 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 601 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
589 | 602 | ||
590 | color = config.readListEntry("textcolor", QChar(',')); | 603 | color = config.readListEntry("textcolor", QChar(',')); |
591 | if (color.isEmpty()) { | 604 | if (color.isEmpty()) { |
592 | color = QStringList::split(",", "43,54,68"); | 605 | color = QStringList::split(",", "43,54,68"); |
593 | config.writeEntry("textcolor", color.join(",")); | 606 | config.writeEntry("textcolor", color.join(",")); |
594 | 607 | ||
595 | } | 608 | } |
596 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 609 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
597 | 610 | ||
598 | } | 611 | } |
599 | 612 | ||
600 | /* korean input functions {{{1 | 613 | /* korean input functions {{{1 |
601 | * | 614 | * |
602 | * TODO | 615 | * TODO |
603 | * one major problem with this implementation is that you can't move the | 616 | * one major problem with this implementation is that you can't move the |
604 | * cursor after inputing korean chars, otherwise it will eat up and replace | 617 | * cursor after inputing korean chars, otherwise it will eat up and replace |
605 | * the char before the cursor you move to. fix that | 618 | * the char before the cursor you move to. fix that |
606 | * | 619 | * |
607 | * make backspace delete one single char, not the whole thing if still | 620 | * make backspace delete one single char, not the whole thing if still |
608 | * editing. | 621 | * editing. |
609 | * | 622 | * |
610 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 623 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
611 | * | 624 | * |
612 | * how korean input works | 625 | * how korean input works |
613 | * | 626 | * |
614 | * all following chars means unicode char value and are in hex | 627 | * all following chars means unicode char value and are in hex |
615 | * | 628 | * |
616 | * ÃÊÀ½ = schar (start char) | 629 | * ÃÊÀ½ = schar (start char) |
617 | * ÁßÀ½ = mchar (middle char) | 630 | * ÁßÀ½ = mchar (middle char) |
618 | * ³¡À½ = echar (end char) | 631 | * ³¡À½ = echar (end char) |
619 | * | 632 | * |
620 | * there are 19 schars. unicode position is at 1100 - 1112 | 633 | * there are 19 schars. unicode position is at 1100 - 1112 |
621 | * there are 21 mchars. unicode position is at 1161 - 1175 | 634 | * there are 21 mchars. unicode position is at 1161 - 1175 |
622 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 635 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
623 | * | 636 | * |
624 | * the map with everything combined is at ac00 - d7a3 | 637 | * the map with everything combined is at ac00 - d7a3 |
625 | * | 638 | * |
626 | */ | 639 | */ |
627 | 640 | ||
628 | ushort Keyboard::parseKoreanInput (ushort c) { | 641 | ushort Keyboard::parseKoreanInput (ushort c) { |
629 | 642 | ||
630 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 643 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
631 | || | 644 | || |
632 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 645 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
633 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 646 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index 6e577ab..dc50e55 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -1,168 +1,170 @@ | |||
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 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include <qmap.h> | 21 | #include <qmap.h> |
22 | #include "../pickboard/pickboardcfg.h" | 22 | #include "../pickboard/pickboardcfg.h" |
23 | #include "../pickboard/pickboardpicks.h" | 23 | #include "../pickboard/pickboardpicks.h" |
24 | #include "configdlg.h" | 24 | #include "configdlg.h" |
25 | 25 | ||
26 | class QTimer; | 26 | class QTimer; |
27 | 27 | ||
28 | class KeyboardConfig : public DictFilterConfig | 28 | class KeyboardConfig : public DictFilterConfig |
29 | { | 29 | { |
30 | public: | 30 | public: |
31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
32 | virtual void generateText(const QString &s); | 32 | virtual void generateText(const QString &s); |
33 | void decBackspaces() { if (backspaces) backspaces--; } | 33 | void decBackspaces() { if (backspaces) backspaces--; } |
34 | void incBackspaces() { backspaces++; } | 34 | void incBackspaces() { backspaces++; } |
35 | void resetBackspaces() { backspaces = 0; } | 35 | void resetBackspaces() { backspaces = 0; } |
36 | private: | 36 | private: |
37 | int backspaces; | 37 | int backspaces; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | 40 | ||
41 | class KeyboardPicks : public PickboardPicks | 41 | class KeyboardPicks : public PickboardPicks |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
46 | : PickboardPicks(parent, name, f) { } | 46 | : PickboardPicks(parent, name, f) { } |
47 | void initialise(); | 47 | void initialise(); |
48 | virtual QSize sizeHint() const; | 48 | virtual QSize sizeHint() const; |
49 | KeyboardConfig *dc; | 49 | KeyboardConfig *dc; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | 52 | ||
53 | class Keys { | 53 | class Keys { |
54 | public: | 54 | public: |
55 | 55 | ||
56 | Keys(); | 56 | Keys(); |
57 | Keys(const char * filename); | 57 | Keys(const char * filename); |
58 | ~Keys(); | 58 | ~Keys(); |
59 | ushort uni(const int row, const int col); | 59 | ushort uni(const int row, const int col); |
60 | int qcode(const int row, const int col); | 60 | int qcode(const int row, const int col); |
61 | int width(const int row, const int col); | 61 | int width(const int row, const int col); |
62 | bool pressed(const int row, const int col); | 62 | bool pressed(const int row, const int col); |
63 | bool *pressedPtr(const int row, const int col); | 63 | bool *pressedPtr(const int row, const int col); |
64 | ushort shift(const ushort); | 64 | ushort shift(const ushort); |
65 | QPixmap *pix(const int row, const int col); | 65 | QPixmap *pix(const int row, const int col); |
66 | int numKeys(const int row); | 66 | int numKeys(const int row); |
67 | void setKeysFromFile(const char *filename); | 67 | void setKeysFromFile(const char *filename); |
68 | void setKey(const int row, const int qcode, const ushort unicode, | 68 | void setKey(const int row, const int qcode, const ushort unicode, |
69 | const int width, QPixmap *pix); | 69 | const int width, QPixmap *pix); |
70 | void setPressed(const int row, const int col, const bool pressed); | 70 | void setPressed(const int row, const int col, const bool pressed); |
71 | QString lang; | 71 | QString lang; |
72 | QString label; | 72 | QString label; |
73 | 73 | ||
74 | private: | 74 | private: |
75 | 75 | ||
76 | typedef struct Key { | 76 | typedef struct Key { |
77 | int qcode; // are qt key codes just unicode values? | 77 | int qcode; // are qt key codes just unicode values? |
78 | ushort unicode; | 78 | ushort unicode; |
79 | int width; // not pixels but relative key width. normal key is 2 | 79 | int width; // not pixels but relative key width. normal key is 2 |
80 | 80 | ||
81 | // only needed for keys like ctrl that can have multiple keys pressed at once | 81 | // only needed for keys like ctrl that can have multiple keys pressed at once |
82 | bool *pressed; | 82 | bool *pressed; |
83 | QPixmap *pix; | 83 | QPixmap *pix; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | QList<Key> keys[6]; | 86 | QList<Key> keys[6]; |
87 | QMap<ushort,ushort> shiftMap; | 87 | QMap<ushort,ushort> shiftMap; |
88 | 88 | ||
89 | }; | 89 | }; |
90 | 90 | ||
91 | class Keyboard : public QFrame | 91 | class Keyboard : public QFrame |
92 | { | 92 | { |
93 | Q_OBJECT | 93 | Q_OBJECT |
94 | public: | 94 | public: |
95 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 95 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
96 | ~Keyboard(); | 96 | ~Keyboard(); |
97 | 97 | ||
98 | void resetState(); | 98 | void resetState(); |
99 | 99 | ||
100 | void mousePressEvent(QMouseEvent*); | 100 | void mousePressEvent(QMouseEvent*); |
101 | void mouseReleaseEvent(QMouseEvent*); | 101 | void mouseReleaseEvent(QMouseEvent*); |
102 | void resizeEvent(QResizeEvent*); | 102 | void resizeEvent(QResizeEvent*); |
103 | void paintEvent(QPaintEvent* e); | 103 | void paintEvent(QPaintEvent* e); |
104 | //void timerEvent(QTimerEvent* e); | 104 | //void timerEvent(QTimerEvent* e); |
105 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 105 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
106 | 106 | ||
107 | QSize sizeHint() const; | 107 | QSize sizeHint() const; |
108 | 108 | ||
109 | signals: | 109 | signals: |
110 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 110 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
111 | 111 | ||
112 | private slots: | 112 | private slots: |
113 | void repeat(); | 113 | void repeat(); |
114 | void togglePickboard(bool on_off); | 114 | void togglePickboard(bool on_off); |
115 | void toggleRepeat(bool on_off); | ||
115 | void setMapToDefault(); | 116 | void setMapToDefault(); |
116 | void setMapToFile(QString map); | 117 | void setMapToFile(QString map); |
117 | 118 | ||
118 | // used to redraw keyboard after edited colors | 119 | // used to redraw keyboard after edited colors |
119 | void reloadKeyboard(); | 120 | void reloadKeyboard(); |
120 | 121 | ||
121 | private: | 122 | private: |
122 | int getKey( int &w, int j = -1 ); | 123 | int getKey( int &w, int j = -1 ); |
123 | void clearHighlight(); | 124 | void clearHighlight(); |
124 | 125 | ||
125 | bool *shift; | 126 | bool *shift; |
126 | bool *lock; | 127 | bool *lock; |
127 | bool *ctrl; | 128 | bool *ctrl; |
128 | bool *alt; | 129 | bool *alt; |
129 | uint useLargeKeys:1; | 130 | uint useLargeKeys:1; |
130 | uint usePicks:1; | 131 | uint usePicks:1; |
132 | uint useRepeat:1; | ||
131 | 133 | ||
132 | int pressedKeyRow; | 134 | int pressedKeyRow; |
133 | int pressedKeyCol; | 135 | int pressedKeyCol; |
134 | 136 | ||
135 | KeyboardPicks *picks; | 137 | KeyboardPicks *picks; |
136 | 138 | ||
137 | int keyHeight; | 139 | int keyHeight; |
138 | int defaultKeyWidth; | 140 | int defaultKeyWidth; |
139 | int xoffs; | 141 | int xoffs; |
140 | 142 | ||
141 | int unicode; | 143 | int unicode; |
142 | int qkeycode; | 144 | int qkeycode; |
143 | int modifiers; | 145 | int modifiers; |
144 | 146 | ||
145 | int pressTid; | 147 | int pressTid; |
146 | bool pressed; | 148 | bool pressed; |
147 | 149 | ||
148 | Keys *keys; | 150 | Keys *keys; |
149 | 151 | ||
150 | /* for korean input */ | 152 | /* for korean input */ |
151 | ushort schar, mchar, echar; | 153 | ushort schar, mchar, echar; |
152 | ushort parseKoreanInput(ushort c); | 154 | ushort parseKoreanInput(ushort c); |
153 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 155 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
154 | ushort constoe(const ushort c); | 156 | ushort constoe(const ushort c); |
155 | 157 | ||
156 | QTimer *repeatTimer; | 158 | QTimer *repeatTimer; |
157 | 159 | ||
158 | /* colors */ | 160 | /* colors */ |
159 | void loadKeyboardColors(); | 161 | void loadKeyboardColors(); |
160 | QColor keycolor; | 162 | QColor keycolor; |
161 | QColor keycolor_pressed; | 163 | QColor keycolor_pressed; |
162 | QColor keycolor_lines; | 164 | QColor keycolor_lines; |
163 | QColor textcolor; | 165 | QColor textcolor; |
164 | 166 | ||
165 | ConfigDlg *configdlg; | 167 | ConfigDlg *configdlg; |
166 | }; | 168 | }; |
167 | 169 | ||
168 | 170 | ||