author | mickeyl <mickeyl> | 2004-01-03 16:57:51 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-03 16:57:51 (UTC) |
commit | bdabd0e055d494c7546de08348e32cf5622c9074 (patch) (unidiff) | |
tree | 97346f3ef40158d31c2e649390a941135890a39b | |
parent | 4f7bf49ba4c0466aa9cea618c9317ac965a1118f (diff) | |
download | opie-bdabd0e055d494c7546de08348e32cf5622c9074.zip opie-bdabd0e055d494c7546de08348e32cf5622c9074.tar.gz opie-bdabd0e055d494c7546de08348e32cf5622c9074.tar.bz2 |
add multikey patches courtesy Anton Kachalov <mouse@altlinux.ru>
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 200 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 8 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 42 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 2 |
4 files changed, 190 insertions, 62 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index a8206b7..f127d0e 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,247 +1,328 @@ | |||
1 | /* | 1 | /* |
2 | * TODO | 2 | * TODO |
3 | * make a font selection thing (size too) | 3 | * make a font selection thing (size too) |
4 | * make a keymap editor | 4 | * make a keymap editor |
5 | * make keys translucent | 5 | * make keys translucent |
6 | * make vertical keys possible | 6 | * make vertical keys possible |
7 | * | 7 | * |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/resource.h> | ||
13 | 14 | ||
14 | #include <qwidget.h> | 15 | #include <qwidget.h> |
15 | #include <qdialog.h> | 16 | #include <qdialog.h> |
16 | #include <qtabwidget.h> | 17 | #include <qtabwidget.h> |
17 | #include <qvbox.h> | 18 | #include <qvbox.h> |
18 | #include <qgrid.h> | 19 | #include <qgrid.h> |
19 | #include <qgroupbox.h> | 20 | #include <qgroupbox.h> |
20 | #include <qlabel.h> | 21 | #include <qlabel.h> |
21 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
22 | #include <qsizepolicy.h> | 23 | #include <qsizepolicy.h> |
23 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
24 | #include <qlistbox.h> | 25 | #include <qlistbox.h> |
25 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qtoolbutton.h> | ||
26 | #include <opie/ofiledialog.h> | 28 | #include <opie/ofiledialog.h> |
27 | #include <opie/colordialog.h> | 29 | #include <opie/colordialog.h> |
28 | #include <qdir.h> | 30 | #include <qdir.h> |
29 | #include <qfileinfo.h> | 31 | #include <qfileinfo.h> |
30 | #include "configdlg.h" | 32 | #include "configdlg.h" |
31 | #include "keyboard.h" | 33 | #include "keyboard.h" |
32 | 34 | ||
33 | // ConfigDlg::ConfigDlg() {{{1 | 35 | // ConfigDlg::ConfigDlg() {{{1 |
34 | ConfigDlg::ConfigDlg () : QTabWidget () | 36 | ConfigDlg::ConfigDlg () : QTabWidget () |
35 | { | 37 | { |
36 | setCaption( tr("Multikey Configuration") ); | 38 | setCaption( tr("Multikey Configuration") ); |
37 | Config config ("multikey"); | 39 | Config config ("multikey"); |
38 | config.setGroup("keymaps"); | 40 | config.setGroup("keymaps"); |
39 | QString current_map = config.readEntry("current", 0); | 41 | QString current_map = config.readEntry("current", 0); |
40 | 42 | ||
41 | /* | 43 | /* |
42 | * 'general config' tab | 44 | * 'general config' tab |
43 | */ | 45 | */ |
44 | 46 | ||
45 | QVBox *gen_box = new QVBox (this); | 47 | QVBox *gen_box = new QVBox (this); |
46 | gen_box->setMargin(3); | 48 | gen_box->setMargin(3); |
47 | addTab(gen_box, tr("General Settings")); | 49 | addTab(gen_box, tr("General Settings")); |
48 | 50 | ||
49 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 51 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
50 | 52 | ||
51 | keymaps = new QListBox (map_group); | 53 | QHBox *hbox1 = new QHBox(map_group); |
54 | keymaps = new QListBox(hbox1); | ||
52 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 55 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
56 | QVBox *vbox1 = new QVBox(hbox1); | ||
57 | |||
58 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); | ||
59 | tb1->setPixmap(Resource::loadPixmap("up")); | ||
60 | tb1->setAutoRaise(TRUE); | ||
61 | tb1->setFocusPolicy(QWidget::NoFocus); | ||
62 | tb1->setToggleButton(FALSE); | ||
63 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); | ||
64 | |||
65 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); | ||
66 | tb2->setPixmap(Resource::loadPixmap("down")); | ||
67 | tb2->setAutoRaise(TRUE); | ||
68 | tb2->setFocusPolicy(QWidget::NoFocus); | ||
69 | tb2->setToggleButton(FALSE); | ||
70 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); | ||
53 | 71 | ||
54 | QString cur(tr("Current Language")); | 72 | QString cur(tr("Current Language")); |
55 | keymaps->insertItem(cur); | 73 | keymaps->insertItem(cur); |
56 | keymaps->setSelected(0, true); | 74 | keymaps->setSelected(0, true); |
57 | 75 | ||
58 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 76 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); |
59 | default_maps = map_dir.entryList(); // so i can access it in other places | 77 | default_maps = map_dir.entryList(); // so i can access it in other places |
78 | custom_maps = config.readListEntry("maps", QChar('|')); | ||
79 | sw_maps = ConfigDlg::loadSw(); | ||
60 | 80 | ||
61 | for (uint i = 0; i < map_dir.count(); i++) { | 81 | QStringList sw_copy(sw_maps); |
62 | 82 | for (uint i = 0; i < sw_copy.count(); i++) { | |
63 | QFile map (map_dir.absPath() + "/" + map_dir[i]); | ||
64 | if (map.open(IO_ReadOnly)) { | ||
65 | |||
66 | QString line; bool found = 0; | ||
67 | |||
68 | map.readLine(line, 1024); | ||
69 | while (!map.atEnd()) { | ||
70 | |||
71 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | ||
72 | |||
73 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | ||
74 | found = 1; | ||
75 | break; | ||
76 | } | ||
77 | map.readLine(line, 1024); | ||
78 | } | ||
79 | if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); | ||
80 | |||
81 | map.close(); | ||
82 | } | ||
83 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { | ||
84 | |||
85 | keymaps->setSelected(i + 1, true); | ||
86 | } | ||
87 | |||
88 | } | ||
89 | 83 | ||
90 | custom_maps = config.readListEntry("maps", QChar('|')); | 84 | QString keymap_map; |
85 | if (sw_copy[i][0] != '/') { /* share/multikey */ | ||
91 | 86 | ||
92 | for (uint i = 0; i < custom_maps.count(); i++) { | 87 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; |
88 | } else { | ||
93 | 89 | ||
94 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) | 90 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) |
95 | || !QFile::exists(custom_maps[i])) { | 91 | || !QFile::exists(sw_copy[i])) { |
96 | 92 | ||
97 | custom_maps.remove(custom_maps.at(i)); | 93 | custom_maps.remove(sw_copy[i]); |
94 | sw_maps.remove(sw_copy[i]); | ||
98 | 95 | ||
99 | // remove it from the list too | 96 | // remove it from the list too |
100 | config.writeEntry("maps", custom_maps.join("|")); | 97 | config.writeEntry("maps", custom_maps.join("|")); |
101 | 98 | ||
99 | continue; | ||
100 | } | ||
101 | keymap_map = sw_copy[i]; | ||
102 | } | ||
102 | 103 | ||
103 | } else { | 104 | QFile map(keymap_map); |
104 | |||
105 | 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) |
121 | keymaps->insertItem(keymap_map); | ||
122 | 122 | ||
123 | map.close(); | 123 | map.close(); |
124 | } | 124 | } |
125 | if (custom_maps[i] == current_map) { | ||
126 | 125 | ||
127 | keymaps->setSelected(map_dir.count() + i + 1, true); | 126 | if (keymap_map == current_map) { |
128 | } | 127 | keymaps->setSelected(i + 1, true); |
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 | |||
137 | QGrid *add_remove_grid = new QGrid(2, map_group); | 135 | QGrid *add_remove_grid = new QGrid(2, map_group); |
138 | add_remove_grid->setMargin(3); | 136 | add_remove_grid->setMargin(3); |
139 | add_remove_grid->setSpacing(3); | 137 | add_remove_grid->setSpacing(3); |
140 | 138 | ||
141 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 139 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
142 | add_button->setFlat((bool)1); | 140 | add_button->setFlat(TRUE); |
143 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 141 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
144 | 142 | ||
145 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 143 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
146 | remove_button->setFlat((bool)1); | 144 | remove_button->setFlat(TRUE); |
147 | if ((int)map_dir.count() >= keymaps->currentItem()) | 145 | if (default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) |
148 | remove_button->setDisabled(true); | 146 | remove_button->setDisabled(true); |
149 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 147 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
150 | 148 | ||
151 | // make a box that will contain the buttons on the bottom | 149 | // make a box that will contain the buttons on the bottom |
152 | QGrid *other_grid = new QGrid(2, gen_box); | 150 | QGrid *other_grid = new QGrid(2, gen_box); |
153 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | 151 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); |
154 | 152 | ||
155 | config.setGroup ("general"); | 153 | config.setGroup ("general"); |
156 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed | 154 | bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed |
157 | if (pick_open) { | 155 | if (pick_open) { |
158 | 156 | ||
159 | pick_button->setChecked(true); | 157 | pick_button->setChecked(true); |
160 | } | 158 | } |
161 | 159 | ||
162 | // by connecting it after checking it, the signal isn't emmited | 160 | // by connecting it after checking it, the signal isn't emmited |
163 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 161 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
164 | 162 | ||
165 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | 163 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); |
166 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); | 164 | bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); |
167 | 165 | ||
168 | if (repeat_on) { | 166 | if (repeat_on) { |
169 | 167 | ||
170 | repeat_button->setChecked(true); | 168 | repeat_button->setChecked(true); |
171 | } | 169 | } |
172 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); | 170 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); |
173 | 171 | ||
174 | |||
175 | /* | 172 | /* |
176 | * 'color' tab | 173 | * 'color' tab |
177 | */ | 174 | */ |
178 | 175 | ||
179 | QGrid *color_box = new QGrid(2, this); | 176 | QGrid *color_box = new QGrid(2, this); |
180 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 177 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
181 | color_box->setMargin(3); | 178 | color_box->setMargin(3); |
182 | color_box->setSpacing(3); | 179 | color_box->setSpacing(3); |
183 | addTab(color_box, tr("Colors")); | 180 | addTab(color_box, tr("Colors")); |
184 | 181 | ||
185 | QLabel *label; | 182 | QLabel *label; |
186 | QStringList color; | 183 | QStringList color; |
187 | config.setGroup("colors"); | 184 | config.setGroup("colors"); |
188 | 185 | ||
189 | label = new QLabel(tr("Key Color"), color_box); | 186 | label = new QLabel(tr("Key Color"), color_box); |
190 | keycolor_button = new QPushButton(color_box); | 187 | keycolor_button = new QPushButton(color_box); |
191 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); | 188 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
192 | keycolor_button->setFlat((bool)1); | 189 | keycolor_button->setFlat(TRUE); |
193 | color = config.readListEntry("keycolor", QChar(',')); | 190 | color = config.readListEntry("keycolor", QChar(',')); |
194 | /* | 191 | /* |
195 | * hopefully not required | 192 | * hopefully not required |
196 | 193 | ||
197 | if (color.isEmpty()) { | 194 | if (color.isEmpty()) { |
198 | color = QStringList::split(",", "240,240,240"); | 195 | color = QStringList::split(",", "240,240,240"); |
199 | config.writeEntry("keycolor", color.join(",")); | 196 | config.writeEntry("keycolor", color.join(",")); |
200 | 197 | ||
201 | } | 198 | } |
202 | */ | 199 | */ |
203 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); | 200 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); |
204 | 201 | ||
205 | 202 | ||
206 | label = new QLabel(tr("Key Pressed Color"), color_box); | 203 | label = new QLabel(tr("Key Pressed Color"), color_box); |
207 | keycolor_pressed_button = new QPushButton(color_box); | 204 | keycolor_pressed_button = new QPushButton(color_box); |
208 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); | 205 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
209 | keycolor_pressed_button->setFlat((bool)1); | 206 | keycolor_pressed_button->setFlat(TRUE); |
210 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 207 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
211 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 208 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
212 | 209 | ||
213 | label = new QLabel(tr("Line Color"), color_box); | 210 | label = new QLabel(tr("Line Color"), color_box); |
214 | keycolor_lines_button = new QPushButton(color_box); | 211 | keycolor_lines_button = new QPushButton(color_box); |
215 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); | 212 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
216 | keycolor_lines_button->setFlat((bool)1); | 213 | keycolor_lines_button->setFlat(TRUE); |
217 | color = config.readListEntry("keycolor_lines", QChar(',')); | 214 | color = config.readListEntry("keycolor_lines", QChar(',')); |
218 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 215 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
219 | 216 | ||
220 | 217 | ||
221 | label = new QLabel(tr("Text Color"), color_box); | 218 | label = new QLabel(tr("Text Color"), color_box); |
222 | textcolor_button = new QPushButton(color_box); | 219 | textcolor_button = new QPushButton(color_box); |
223 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); | 220 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
224 | textcolor_button->setFlat((bool)1); | 221 | textcolor_button->setFlat(TRUE); |
225 | color = config.readListEntry("textcolor", QChar(',')); | 222 | color = config.readListEntry("textcolor", QChar(',')); |
226 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 223 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
227 | 224 | ||
228 | |||
229 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 225 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
230 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 226 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
227 | } | ||
228 | |||
229 | ConfigDlg::~ConfigDlg() | ||
230 | { | ||
231 | emit reloadSw(); | ||
232 | } | ||
233 | |||
234 | QStringList ConfigDlg::loadSw() | ||
235 | { | ||
236 | Config *config = new Config("multikey"); | ||
237 | config->setGroup("keymaps"); | ||
238 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | ||
239 | QStringList d_maps = map_dir.entryList(); // so i can access it in other places | ||
240 | QStringList c_maps = config->readListEntry("maps", QChar('|')); | ||
241 | QStringList s_maps = config->readListEntry("sw", QChar('|')); | ||
242 | delete config; | ||
243 | |||
244 | if (!s_maps.count()) | ||
245 | { | ||
246 | s_maps = d_maps+c_maps; | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | /* Clear non existents entries */ | ||
251 | QStringList s_copy = s_maps; | ||
252 | for (uint i = 0; i < s_copy.count(); ++i) { | ||
253 | if (d_maps.find(s_copy[i]) == d_maps.end() | ||
254 | && c_maps.find(s_copy[i]) == c_maps.end()) { | ||
255 | s_maps.remove(s_copy[i]); | ||
256 | } | ||
257 | } | ||
258 | /* Update sw_maps from default_maps */ | ||
259 | for (uint i = 0; i < d_maps.count(); ++i) { | ||
260 | if (s_maps.find(d_maps[i]) == s_maps.end()) { | ||
261 | s_maps.append(d_maps[i]); | ||
262 | } | ||
263 | } | ||
264 | /* Update sw_maps from custom_maps */ | ||
265 | for (uint i = 0; i < c_maps.count(); ++i) { | ||
266 | if (s_maps.find(c_maps[i]) == s_maps.end()) { | ||
267 | s_maps.append(c_maps[i]); | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | |||
272 | return s_maps; | ||
273 | } | ||
231 | 274 | ||
275 | void ConfigDlg::moveSelectedUp() | ||
276 | { | ||
277 | int i = keymaps->currentItem(); | ||
278 | /* Ignore Current Language */ | ||
279 | if (i > 1) { | ||
280 | QString t = sw_maps[i-1]; | ||
281 | sw_maps[i-1] = sw_maps[i-2]; | ||
282 | sw_maps[i-2] = t; | ||
283 | |||
284 | QString item = keymaps->currentText(); | ||
285 | keymaps->removeItem(i); | ||
286 | keymaps->insertItem(item, i-1); | ||
287 | keymaps->setCurrentItem(i-1); | ||
288 | |||
289 | Config config("multikey"); | ||
290 | config.setGroup("keymaps"); | ||
291 | config.writeEntry("sw", sw_maps, QChar('|')); | ||
292 | } | ||
293 | } | ||
294 | |||
295 | void ConfigDlg::moveSelectedDown() | ||
296 | { | ||
297 | int i = keymaps->currentItem(); | ||
298 | /* Ignore Current Language */ | ||
299 | if (i > 0 && i < (int)keymaps->count() - 1) { | ||
300 | QString t = sw_maps[i-1]; | ||
301 | sw_maps[i-1] = sw_maps[i]; | ||
302 | sw_maps[i] = t; | ||
303 | |||
304 | QString item = keymaps->currentText(); | ||
305 | keymaps->removeItem(i); | ||
306 | keymaps->insertItem(item, i+1); | ||
307 | keymaps->setCurrentItem(i+1); | ||
308 | |||
309 | Config config("multikey"); | ||
310 | config.setGroup("keymaps"); | ||
311 | config.writeEntry("sw", sw_maps, QChar('|')); | ||
312 | } | ||
232 | } | 313 | } |
233 | 314 | ||
234 | void ConfigDlg::pickTog() { | 315 | void ConfigDlg::pickTog() { |
235 | 316 | ||
236 | Config config ("multikey"); | 317 | Config config ("multikey"); |
237 | config.setGroup ("general"); | 318 | config.setGroup ("general"); |
238 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed | 319 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed |
239 | 320 | ||
240 | emit pickboardToggled(pick_button->isChecked()); | 321 | emit pickboardToggled(pick_button->isChecked()); |
241 | } | 322 | } |
242 | 323 | ||
243 | void ConfigDlg::repeatTog() { | 324 | void ConfigDlg::repeatTog() { |
244 | 325 | ||
245 | Config config ("multikey"); | 326 | Config config ("multikey"); |
246 | config.setGroup ("general"); | 327 | config.setGroup ("general"); |
247 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed | 328 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed |
@@ -258,100 +339,105 @@ void ConfigDlg::closeEvent(QCloseEvent *) { | |||
258 | // ConfigDlg::setMap {{{1 | 339 | // ConfigDlg::setMap {{{1 |
259 | 340 | ||
260 | /* | 341 | /* |
261 | * the index is kinda screwy, because in the config file, index 0 is just the | 342 | * the index is kinda screwy, because in the config file, index 0 is just the |
262 | * first element in the QStringList, but here it's the "Current Language" | 343 | * first element in the QStringList, but here it's the "Current Language" |
263 | * listItem. therefor you have to minus one to the index before you access it. | 344 | * listItem. therefor you have to minus one to the index before you access it. |
264 | * | 345 | * |
265 | */ | 346 | */ |
266 | 347 | ||
267 | void ConfigDlg::setMap(int index) { | 348 | void ConfigDlg::setMap(int index) { |
268 | 349 | ||
269 | if (index == 0) { | 350 | if (index == 0) { |
270 | 351 | ||
271 | remove_button->setDisabled(true); | 352 | remove_button->setDisabled(true); |
272 | emit setMapToDefault(); | 353 | emit setMapToDefault(); |
273 | } | 354 | } |
274 | else if ((uint)index <= default_maps.count()) { | 355 | else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { |
275 | 356 | ||
276 | remove_button->setDisabled(true); | 357 | remove_button->setDisabled(true); |
277 | emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + default_maps[index - 1]); | 358 | emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); |
278 | 359 | ||
279 | } else { | 360 | } else { |
280 | 361 | ||
281 | remove_button->setEnabled(true); | 362 | remove_button->setEnabled(true); |
282 | emit setMapToFile(custom_maps[index - default_maps.count() - 1]); | 363 | emit setMapToFile(sw_maps[index - 1]); |
283 | } | 364 | } |
284 | } | 365 | } |
285 | 366 | ||
286 | // ConfigDlg::addMap() {{{1 | 367 | // ConfigDlg::addMap() {{{1 |
287 | void ConfigDlg::addMap() { | 368 | void ConfigDlg::addMap() { |
288 | 369 | ||
289 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); | 370 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); |
290 | 371 | ||
291 | if (map.isNull()) return; | 372 | if (map.isNull()) return; |
292 | 373 | ||
293 | Config config ("multikey"); | 374 | Config config ("multikey"); |
294 | config.setGroup("keymaps"); | 375 | config.setGroup("keymaps"); |
295 | QStringList maps = config.readListEntry("maps", QChar('|')); | 376 | QStringList maps = config.readListEntry("maps", QChar('|')); |
296 | maps.append(map); | 377 | maps.append(map); |
297 | custom_maps.append(map); | 378 | custom_maps.append(map); |
379 | if (sw_maps.find(map) == sw_maps.end()) | ||
380 | sw_maps.append(map); | ||
298 | 381 | ||
299 | QFile map_file (map); | 382 | QFile map_file (map); |
300 | if (map_file.open(IO_ReadOnly)) { | 383 | if (map_file.open(IO_ReadOnly)) { |
301 | 384 | ||
302 | QString line; bool found = 0; | 385 | QString line; bool found = 0; |
303 | 386 | ||
304 | map_file.readLine(line, 1024); | 387 | map_file.readLine(line, 1024); |
305 | while (!map_file.atEnd()) { | 388 | while (!map_file.atEnd()) { |
306 | 389 | ||
307 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 390 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
308 | 391 | ||
309 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 392 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
310 | found = 1; | 393 | found = 1; |
311 | break; | 394 | break; |
312 | } | 395 | } |
313 | map_file.readLine(line, 1024); | 396 | map_file.readLine(line, 1024); |
314 | } | 397 | } |
315 | if (!found) keymaps->insertItem(map); | 398 | if (!found) keymaps->insertItem(map); |
316 | 399 | ||
317 | map_file.close(); | 400 | map_file.close(); |
318 | } | 401 | } |
319 | 402 | ||
320 | keymaps->setSelected(keymaps->count() - 1, true); | 403 | keymaps->setSelected(keymaps->count() - 1, true); |
321 | 404 | ||
322 | 405 | ||
323 | config.writeEntry("maps", maps, QChar('|')); | 406 | config.writeEntry("maps", maps, QChar('|')); |
407 | config.writeEntry("sw", sw_maps, QChar('|')); | ||
324 | config.writeEntry("current", map); | 408 | config.writeEntry("current", map); |
325 | 409 | ||
326 | } | 410 | } |
327 | 411 | ||
328 | // ConfigDlg::removeMap() {{{1 | 412 | // ConfigDlg::removeMap() {{{1 |
329 | void ConfigDlg::removeMap() { | 413 | void ConfigDlg::removeMap() { |
330 | 414 | ||
331 | // move selection up one | 415 | // move selection up one |
332 | keymaps->setSelected(keymaps->currentItem() - 1, true); | 416 | keymaps->setSelected(keymaps->currentItem() - 1, true); |
333 | // delete the next selected item cus you just moved it up | 417 | // delete the next selected item cus you just moved it up |
334 | keymaps->removeItem(keymaps->currentItem() + 1); | 418 | keymaps->removeItem(keymaps->currentItem() + 1); |
335 | 419 | ||
336 | custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count())); | 420 | custom_maps.remove(sw_maps[keymaps->currentItem()]); |
421 | sw_maps.remove(sw_maps.at(keymaps->currentItem())); | ||
337 | 422 | ||
338 | // write the changes | 423 | // write the changes |
339 | Config config ("multikey"); | 424 | Config config ("multikey"); |
340 | config.setGroup("keymaps"); | 425 | config.setGroup("keymaps"); |
341 | config.writeEntry("maps", custom_maps, QChar('|')); | 426 | config.writeEntry("maps", custom_maps, QChar('|')); |
427 | config.writeEntry("sw", sw_maps, QChar('|')); | ||
342 | } | 428 | } |
343 | 429 | ||
344 | /* ConfigDlg::slots for the color buttons {{{1 | 430 | /* ConfigDlg::slots for the color buttons {{{1 |
345 | * | 431 | * |
346 | * these four slots are almost the same, except for the names. i was thinking | 432 | * these four slots are almost the same, except for the names. i was thinking |
347 | * of making a map with pointers to the buttons and names of the configEntry | 433 | * of making a map with pointers to the buttons and names of the configEntry |
348 | * so it could be one slot, but then there would be no way of telling which | 434 | * so it could be one slot, but then there would be no way of telling which |
349 | * of the buttons was clicked if they all connect to the same slot. | 435 | * of the buttons was clicked if they all connect to the same slot. |
350 | * | 436 | * |
351 | */ | 437 | */ |
352 | 438 | ||
353 | void ConfigDlg::keyColorClicked() { | 439 | void ConfigDlg::keyColorClicked() { |
354 | 440 | ||
355 | Config config ("multikey"); | 441 | Config config ("multikey"); |
356 | config.setGroup ("colors"); | 442 | config.setGroup ("colors"); |
357 | 443 | ||
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h index 336932b..ea157c5 100644 --- a/inputmethods/multikey/configdlg.h +++ b/inputmethods/multikey/configdlg.h | |||
@@ -1,59 +1,67 @@ | |||
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 | ~ConfigDlg (); | ||
17 | static QStringList ConfigDlg::loadSw(); | ||
16 | 18 | ||
17 | signals: | 19 | signals: |
18 | void pickboardToggled(bool on_off); | 20 | void pickboardToggled(bool on_off); |
19 | void repeatToggled(bool on_off); | 21 | void repeatToggled(bool on_off); |
20 | void setMapToDefault(); | 22 | void setMapToDefault(); |
21 | void setMapToFile(QString map); | 23 | void setMapToFile(QString map); |
22 | void reloadKeyboard(); | 24 | void reloadKeyboard(); |
23 | void configDlgClosed(); | 25 | void configDlgClosed(); |
26 | void reloadSw(); | ||
27 | |||
28 | protected slots: | ||
29 | void moveSelectedUp(); | ||
30 | void moveSelectedDown(); | ||
24 | 31 | ||
25 | private slots: | 32 | private slots: |
26 | void pickTog(); | 33 | void pickTog(); |
27 | void repeatTog(); | 34 | void repeatTog(); |
28 | void setMap(int index); | 35 | void setMap(int index); |
29 | void addMap(); | 36 | void addMap(); |
30 | void removeMap(); | 37 | void removeMap(); |
31 | virtual void closeEvent ( QCloseEvent * ); | 38 | virtual void closeEvent ( QCloseEvent * ); |
32 | 39 | ||
33 | 40 | ||
34 | // all those required slots for the color push buttons | 41 | // all those required slots for the color push buttons |
35 | void keyColorClicked(); | 42 | void keyColorClicked(); |
36 | void keyColorPressedClicked(); | 43 | void keyColorPressedClicked(); |
37 | void keyColorLinesClicked(); | 44 | void keyColorLinesClicked(); |
38 | void textColorClicked(); | 45 | void textColorClicked(); |
39 | 46 | ||
40 | private: | 47 | private: |
41 | QCheckBox *pick_button; | 48 | QCheckBox *pick_button; |
42 | QCheckBox *repeat_button; | 49 | QCheckBox *repeat_button; |
43 | QListBox *keymaps; | 50 | QListBox *keymaps; |
44 | QPushButton *add_button; | 51 | QPushButton *add_button; |
45 | QPushButton *remove_button; | 52 | QPushButton *remove_button; |
46 | 53 | ||
47 | 54 | ||
48 | QStringList default_maps; // the maps in your share/multikey/ dir | 55 | QStringList default_maps; // the maps in your share/multikey/ dir |
49 | QStringList custom_maps; // maps you added with the 'add' button | 56 | QStringList custom_maps; // maps you added with the 'add' button |
57 | QStringList sw_maps; // maps, which used in keyboard switch rotation ring | ||
50 | 58 | ||
51 | /* color buttons */ | 59 | /* color buttons */ |
52 | QPushButton *keycolor_button; | 60 | QPushButton *keycolor_button; |
53 | QPushButton *keycolor_pressed_button; | 61 | QPushButton *keycolor_pressed_button; |
54 | QPushButton *keycolor_lines_button; | 62 | QPushButton *keycolor_lines_button; |
55 | QPushButton *textcolor_button; | 63 | QPushButton *textcolor_button; |
56 | 64 | ||
57 | }; | 65 | }; |
58 | 66 | ||
59 | #endif | 67 | #endif |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 2ce6dd3..aec0ad3 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -18,33 +18,33 @@ | |||
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 <qdir.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 | using namespace MultiKey; | 40 | using namespace MultiKey; |
41 | 41 | ||
42 | static const char * const kb_config_xpm[] = { | 42 | static const char * const kb_config_xpm[] = { |
43 | "13 7 2 1", | 43 | "13 7 2 1", |
44 | " c None", | 44 | " c None", |
45 | ". c #000000", | 45 | ". c #000000", |
46 | " ", | 46 | " ", |
47 | " . ", | 47 | " . ", |
48 | " ... ", | 48 | " ... ", |
49 | " ..... ", | 49 | " ..... ", |
50 | " . ", | 50 | " . ", |
@@ -81,38 +81,41 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | |||
81 | picks->setFont( QFont( familyStr, 10 ) ); | 81 | picks->setFont( QFont( familyStr, 10 ) ); |
82 | picks->initialise(); | 82 | picks->initialise(); |
83 | if (usePicks) { | 83 | if (usePicks) { |
84 | 84 | ||
85 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 85 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
86 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 86 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
87 | 87 | ||
88 | } else picks->hide(); | 88 | } else picks->hide(); |
89 | 89 | ||
90 | loadKeyboardColors(); | 90 | loadKeyboardColors(); |
91 | 91 | ||
92 | keys = new Keys(); | 92 | keys = new Keys(); |
93 | 93 | ||
94 | repeatTimer = new QTimer( this ); | 94 | repeatTimer = new QTimer( this ); |
95 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 95 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
96 | 96 | ||
97 | QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); | ||
98 | connect(kbdChannel, SIGNAL(received(const QCString &, const QByteArray &)), | ||
99 | this, SLOT(receive(const QCString &, const QByteArray &))); | ||
97 | } | 100 | } |
98 | 101 | ||
99 | Keyboard::~Keyboard() { | 102 | Keyboard::~Keyboard() { |
100 | 103 | ||
101 | if ( configdlg ) { | 104 | if ( configdlg ) { |
102 | delete (ConfigDlg *) configdlg; | 105 | delete configdlg; |
103 | configdlg = 0; | 106 | configdlg = 0; |
104 | } | 107 | } |
105 | 108 | ||
106 | } | 109 | } |
107 | 110 | ||
108 | /* Keyboard::resizeEvent {{{1 */ | 111 | /* Keyboard::resizeEvent {{{1 */ |
109 | void Keyboard::resizeEvent(QResizeEvent*) | 112 | void Keyboard::resizeEvent(QResizeEvent*) |
110 | { | 113 | { |
111 | int ph = picks->sizeHint().height(); | 114 | int ph = picks->sizeHint().height(); |
112 | picks->setGeometry( 0, 0, width(), ph ); | 115 | picks->setGeometry( 0, 0, width(), ph ); |
113 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); | 116 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); |
114 | 117 | ||
115 | int nk; // number of keys? | 118 | int nk; // number of keys? |
116 | if ( useLargeKeys ) { | 119 | if ( useLargeKeys ) { |
117 | nk = 15; | 120 | nk = 15; |
118 | } else { | 121 | } else { |
@@ -404,49 +407,51 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
404 | qkeycode = 0x2001; | 407 | qkeycode = 0x2001; |
405 | } | 408 | } |
406 | else { | 409 | else { |
407 | 410 | ||
408 | // accent | 411 | // accent |
409 | qkeycode = 0x2003; | 412 | qkeycode = 0x2003; |
410 | } | 413 | } |
411 | } | 414 | } |
412 | 415 | ||
413 | 416 | ||
414 | if (unicode == 0) { // either Qt char, or nothing | 417 | if (unicode == 0) { // either Qt char, or nothing |
415 | 418 | ||
416 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 419 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
417 | 420 | ||
418 | if ( configdlg ) { | 421 | if ( configdlg ) { |
419 | 422 | ||
420 | delete (ConfigDlg *) configdlg; | 423 | delete configdlg; |
421 | configdlg = 0; | 424 | configdlg = 0; |
422 | } | 425 | } |
423 | else { | 426 | else { |
424 | configdlg = new ConfigDlg (); | 427 | configdlg = new ConfigDlg (); |
425 | connect(configdlg, SIGNAL(setMapToDefault()), | 428 | connect(configdlg, SIGNAL(setMapToDefault()), |
426 | this, SLOT(setMapToDefault())); | 429 | this, SLOT(setMapToDefault())); |
427 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 430 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
428 | this, SLOT(setMapToFile(QString))); | 431 | this, SLOT(setMapToFile(QString))); |
429 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 432 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
430 | this, SLOT(togglePickboard(bool))); | 433 | this, SLOT(togglePickboard(bool))); |
431 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 434 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
432 | this, SLOT(toggleRepeat(bool))); | 435 | this, SLOT(toggleRepeat(bool))); |
433 | connect(configdlg, SIGNAL(reloadKeyboard()), | 436 | connect(configdlg, SIGNAL(reloadKeyboard()), |
434 | this, SLOT(reloadKeyboard())); | 437 | this, SLOT(reloadKeyboard())); |
435 | connect(configdlg, SIGNAL(configDlgClosed()), | 438 | connect(configdlg, SIGNAL(configDlgClosed()), |
436 | this, SLOT(cleanupConfigDlg())); | 439 | this, SLOT(cleanupConfigDlg())); |
440 | connect(configdlg, SIGNAL(reloadSw()), | ||
441 | this, SLOT(reloadSw())); | ||
437 | configdlg->showMaximized(); | 442 | configdlg->showMaximized(); |
438 | configdlg->show(); | 443 | configdlg->show(); |
439 | configdlg->raise(); | 444 | configdlg->raise(); |
440 | } | 445 | } |
441 | 446 | ||
442 | } else if (qkeycode == Qt::Key_Control) { | 447 | } else if (qkeycode == Qt::Key_Control) { |
443 | need_repaint = TRUE; | 448 | need_repaint = TRUE; |
444 | 449 | ||
445 | if (ctrl) { | 450 | if (ctrl) { |
446 | 451 | ||
447 | *ctrl = 0; | 452 | *ctrl = 0; |
448 | ctrl = 0; | 453 | ctrl = 0; |
449 | 454 | ||
450 | } else { | 455 | } else { |
451 | 456 | ||
452 | ctrl = keys->pressedPtr(row, col); | 457 | ctrl = keys->pressedPtr(row, col); |
@@ -747,32 +752,43 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
747 | 752 | ||
748 | if (need_repaint) repaint(FALSE); | 753 | if (need_repaint) repaint(FALSE); |
749 | else { // just paint the one key pressed | 754 | else { // just paint the one key pressed |
750 | 755 | ||
751 | 756 | ||
752 | 757 | ||
753 | QPainter p(this); | 758 | QPainter p(this); |
754 | drawKeyboard(p, row, col); | 759 | drawKeyboard(p, row, col); |
755 | 760 | ||
756 | } | 761 | } |
757 | 762 | ||
758 | if (useRepeat) repeatTimer->start( 800 ); | 763 | if (useRepeat) repeatTimer->start( 800 ); |
759 | //pressTid = startTimer(80); | 764 | //pressTid = startTimer(80); |
760 | 765 | ||
761 | } | 766 | } |
762 | 767 | ||
768 | void Keyboard::receive(const QCString &msg, const QByteArray &data) | ||
769 | { | ||
770 | if (msg == "setmultikey(QString)") { | ||
771 | QDataStream stream(data, IO_ReadOnly); | ||
772 | QString map; | ||
773 | stream >> map; | ||
774 | setMapToFile(map); | ||
775 | } else if (msg == "getmultikey()") { | ||
776 | reloadSw(); | ||
777 | } | ||
778 | } | ||
763 | 779 | ||
764 | /* Keyboard::mouseReleaseEvent {{{1 */ | 780 | /* Keyboard::mouseReleaseEvent {{{1 */ |
765 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 781 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
766 | { | 782 | { |
767 | pressed = FALSE; | 783 | pressed = FALSE; |
768 | //if ( pressTid == 0 ) | 784 | //if ( pressTid == 0 ) |
769 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 785 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
770 | if ( unicode != -1 ) { | 786 | if ( unicode != -1 ) { |
771 | emit key( unicode, qkeycode, modifiers, false, false ); | 787 | emit key( unicode, qkeycode, modifiers, false, false ); |
772 | repeatTimer->stop(); | 788 | repeatTimer->stop(); |
773 | } | 789 | } |
774 | #endif | 790 | #endif |
775 | if (shift && unicode != 0) { | 791 | if (shift && unicode != 0) { |
776 | 792 | ||
777 | 793 | ||
778 | *shift = 0; // unpress shift key | 794 | *shift = 0; // unpress shift key |
@@ -898,47 +914,63 @@ void Keyboard::togglePickboard(bool on_off) | |||
898 | /* | 914 | /* |
899 | * this closes && opens the input method | 915 | * this closes && opens the input method |
900 | */ | 916 | */ |
901 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 917 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
902 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 918 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
903 | } | 919 | } |
904 | 920 | ||
905 | void Keyboard::toggleRepeat(bool on) { | 921 | void Keyboard::toggleRepeat(bool on) { |
906 | 922 | ||
907 | useRepeat = on; | 923 | useRepeat = on; |
908 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 924 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
909 | } | 925 | } |
910 | 926 | ||
911 | void Keyboard::cleanupConfigDlg() { | 927 | void Keyboard::cleanupConfigDlg() { |
912 | 928 | ||
913 | if ( configdlg ) { | 929 | if ( configdlg ) { |
914 | delete (ConfigDlg *) configdlg; | 930 | delete configdlg; |
915 | configdlg = 0; | 931 | configdlg = 0; |
916 | } | 932 | } |
917 | } | 933 | } |
918 | 934 | ||
935 | void Keyboard::reloadSw() { | ||
936 | QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)"); | ||
937 | |||
938 | Config* config = new Config("multikey"); | ||
939 | config->setGroup("keymaps"); | ||
940 | QString current_map = config->readEntry("current", "en.keymap"); | ||
941 | delete config; | ||
942 | |||
943 | e << ConfigDlg::loadSw().join("|") << current_map; | ||
944 | } | ||
945 | |||
919 | /* Keyboard::setMapTo ... {{{1 */ | 946 | /* Keyboard::setMapTo ... {{{1 */ |
920 | void Keyboard::setMapToDefault() { | 947 | void Keyboard::setMapToDefault() { |
921 | 948 | ||
922 | 949 | ||
923 | /* load current locale language map */ | 950 | /* load current locale language map */ |
924 | Config *config = new Config("locale"); | 951 | Config *config = new Config("locale"); |
925 | config->setGroup( "Language" ); | 952 | config->setGroup( "Language" ); |
926 | QString l = config->readEntry( "Language" , "en" ); | 953 | QString l = config->readEntry( "Language" , "en" ); |
927 | delete config; | 954 | delete config; |
928 | 955 | ||
956 | /* if Language represents as en_US, ru_RU, etc... */ | ||
957 | int d = l.find('_'); | ||
958 | if (d != -1) { | ||
959 | l.remove(d, l.length()-d); | ||
960 | } | ||
929 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" | 961 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" |
930 | + l + ".keymap"; | 962 | + l + ".keymap"; |
931 | 963 | ||
932 | /* save change to multikey config file */ | 964 | /* save change to multikey config file */ |
933 | config = new Config("multikey"); | 965 | config = new Config("multikey"); |
934 | config->setGroup ("keymaps"); | 966 | config->setGroup ("keymaps"); |
935 | config->writeEntry ("current", key_map); // default closed | 967 | config->writeEntry ("current", key_map); // default closed |
936 | delete config; | 968 | delete config; |
937 | 969 | ||
938 | int prevRows = keys->rows(); | 970 | int prevRows = keys->rows(); |
939 | 971 | ||
940 | delete keys; | 972 | delete keys; |
941 | keys = new Keys(key_map); | 973 | keys = new Keys(key_map); |
942 | 974 | ||
943 | // have to repaint the keyboard | 975 | // have to repaint the keyboard |
944 | if (prevRows != keys->rows()) { | 976 | if (prevRows != keys->rows()) { |
@@ -1493,33 +1525,33 @@ void Keys::setKeysFromFile(const char * filename) { | |||
1493 | qDebug ("Estoy aadiendo %i con %i", lower, shift); | 1525 | qDebug ("Estoy aadiendo %i con %i", lower, shift); |
1494 | buf = t.readLine(); | 1526 | buf = t.readLine(); |
1495 | } | 1527 | } |
1496 | // accent | 1528 | // accent |
1497 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1529 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1498 | 1530 | ||
1499 | QTextStream tmp (buf, IO_ReadOnly); | 1531 | QTextStream tmp (buf, IO_ReadOnly); |
1500 | ushort lower, shift; | 1532 | ushort lower, shift; |
1501 | QChar d; | 1533 | QChar d; |
1502 | tmp >> d >> lower >> shift; | 1534 | tmp >> d >> lower >> shift; |
1503 | 1535 | ||
1504 | accentMap.insert(lower, shift); | 1536 | accentMap.insert(lower, shift); |
1505 | 1537 | ||
1506 | buf = t.readLine(); | 1538 | buf = t.readLine(); |
1507 | } | 1539 | } |
1508 | 1540 | ||
1509 | // other variables like lang & title | 1541 | // other variables like lang & title & sw |
1510 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1542 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1511 | 1543 | ||
1512 | QTextStream tmp (buf, IO_ReadOnly); | 1544 | QTextStream tmp (buf, IO_ReadOnly); |
1513 | QString name, equals, value; | 1545 | QString name, equals, value; |
1514 | 1546 | ||
1515 | tmp >> name >> equals >> value; | 1547 | tmp >> name >> equals >> value; |
1516 | 1548 | ||
1517 | if (name == "lang") { | 1549 | if (name == "lang") { |
1518 | 1550 | ||
1519 | lang = value; | 1551 | lang = value; |
1520 | 1552 | ||
1521 | } | 1553 | } |
1522 | 1554 | ||
1523 | buf = t.readLine(); | 1555 | buf = t.readLine(); |
1524 | } | 1556 | } |
1525 | // comments | 1557 | // comments |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index 20c5cee..0b56988 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -117,35 +117,37 @@ public: | |||
117 | void paintEvent(QPaintEvent* e); | 117 | void paintEvent(QPaintEvent* e); |
118 | //void timerEvent(QTimerEvent* e); | 118 | //void timerEvent(QTimerEvent* e); |
119 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 119 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
120 | 120 | ||
121 | QSize sizeHint() const; | 121 | QSize sizeHint() const; |
122 | 122 | ||
123 | signals: | 123 | signals: |
124 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 124 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
125 | 125 | ||
126 | private slots: | 126 | private slots: |
127 | void repeat(); | 127 | void repeat(); |
128 | void togglePickboard(bool on_off); | 128 | void togglePickboard(bool on_off); |
129 | void toggleRepeat(bool on_off); | 129 | void toggleRepeat(bool on_off); |
130 | void setMapToDefault(); | 130 | void setMapToDefault(); |
131 | void setMapToFile(QString map); | 131 | void setMapToFile(QString map); |
132 | void cleanupConfigDlg(); | 132 | void cleanupConfigDlg(); |
133 | void reloadSw(); | ||
133 | 134 | ||
134 | // used to redraw keyboard after edited colors | 135 | // used to redraw keyboard after edited colors |
135 | void reloadKeyboard(); | 136 | void reloadKeyboard(); |
137 | void receive( const QCString &msg, const QByteArray &data ); | ||
136 | 138 | ||
137 | private: | 139 | private: |
138 | int getKey( int &w, int j = -1 ); | 140 | int getKey( int &w, int j = -1 ); |
139 | void clearHighlight(); | 141 | void clearHighlight(); |
140 | 142 | ||
141 | bool *shift; | 143 | bool *shift; |
142 | bool *lock; | 144 | bool *lock; |
143 | bool *ctrl; | 145 | bool *ctrl; |
144 | bool *alt; | 146 | bool *alt; |
145 | bool *meta; | 147 | bool *meta; |
146 | bool *circumflex; | 148 | bool *circumflex; |
147 | bool *diaeresis; | 149 | bool *diaeresis; |
148 | bool *baccent; | 150 | bool *baccent; |
149 | bool *accent; | 151 | bool *accent; |
150 | 152 | ||
151 | uint useLargeKeys:1; | 153 | uint useLargeKeys:1; |