author | hash <hash> | 2002-08-27 02:05:55 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-27 02:05:55 (UTC) |
commit | 59172653912647168c44ec30c66458b7ed4c5a41 (patch) (unidiff) | |
tree | dff146bf9812c39764ef2c134a9bb0764b3dc104 /inputmethods | |
parent | b35f6fbca5a2720044e0a1dc309191e9b39eb3ce (diff) | |
download | opie-59172653912647168c44ec30c66458b7ed4c5a41.zip opie-59172653912647168c44ec30c66458b7ed4c5a41.tar.gz opie-59172653912647168c44ec30c66458b7ed4c5a41.tar.bz2 |
now shows whatever you wrote in the keymap 'title' var as the listItem
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 23 | ||||
-rw-r--r-- | inputmethods/multikey/multikey.pro | 2 |
2 files changed, 23 insertions, 2 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index c5ebe3c..f6507b4 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,401 +1,422 @@ | |||
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 | * add meta key support for german, etc | 5 | * add meta key support for german, etc |
6 | * | 6 | * |
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 | 13 | ||
14 | #include <qwidget.h> | 14 | #include <qwidget.h> |
15 | #include <qdialog.h> | 15 | #include <qdialog.h> |
16 | #include <qtabwidget.h> | 16 | #include <qtabwidget.h> |
17 | #include <qvbox.h> | 17 | #include <qvbox.h> |
18 | #include <qgrid.h> | 18 | #include <qgrid.h> |
19 | #include <qgroupbox.h> | 19 | #include <qgroupbox.h> |
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qcheckbox.h> | 21 | #include <qcheckbox.h> |
22 | #include <qsizepolicy.h> | 22 | #include <qsizepolicy.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qlistbox.h> | 24 | #include <qlistbox.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <opie/ofiledialog.h> | 26 | #include <opie/ofiledialog.h> |
27 | #include <opie/colordialog.h> | 27 | #include <opie/colordialog.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qfileinfo.h> | 29 | #include <qfileinfo.h> |
30 | #include "configdlg.h" | 30 | #include "configdlg.h" |
31 | #include "keyboard.h" | 31 | #include "keyboard.h" |
32 | 32 | ||
33 | // ConfigDlg::ConfigDlg() {{{1 | 33 | // ConfigDlg::ConfigDlg() {{{1 |
34 | ConfigDlg::ConfigDlg () : QTabWidget () | 34 | ConfigDlg::ConfigDlg () : QTabWidget () |
35 | { | 35 | { |
36 | setCaption( tr("Multikey Configuration") ); | 36 | setCaption( tr("Multikey Configuration") ); |
37 | Config config ("multikey"); | 37 | Config config ("multikey"); |
38 | config.setGroup("keymaps"); | 38 | config.setGroup("keymaps"); |
39 | QString current_map = config.readEntry("current", 0); | 39 | QString current_map = config.readEntry("current", 0); |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * 'general config' tab | 42 | * 'general config' tab |
43 | */ | 43 | */ |
44 | 44 | ||
45 | QVBox *gen_box = new QVBox (this); | 45 | QVBox *gen_box = new QVBox (this); |
46 | gen_box->setMargin(3); | 46 | gen_box->setMargin(3); |
47 | addTab(gen_box, tr("General Settings")); | 47 | addTab(gen_box, tr("General Settings")); |
48 | 48 | ||
49 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 49 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
50 | 50 | ||
51 | keymaps = new QListBox (map_group); | 51 | keymaps = new QListBox (map_group); |
52 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 52 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
53 | 53 | ||
54 | QString cur(tr("Current Language")); | 54 | QString cur(tr("Current Language")); |
55 | keymaps->insertItem(cur); | 55 | keymaps->insertItem(cur); |
56 | keymaps->setSelected(0, true); | 56 | keymaps->setSelected(0, true); |
57 | 57 | ||
58 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 58 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); |
59 | default_maps = map_dir.entryList(); // so i can access it in other places | 59 | default_maps = map_dir.entryList(); // so i can access it in other places |
60 | 60 | ||
61 | for (uint i = 0; i < map_dir.count(); i++) { | 61 | for (uint i = 0; i < map_dir.count(); i++) { |
62 | 62 | ||
63 | QFile map (map_dir.absPath() + "/" + map_dir[i]); | 63 | QFile map (map_dir.absPath() + "/" + map_dir[i]); |
64 | if (map.open(IO_ReadOnly)) { | 64 | if (map.open(IO_ReadOnly)) { |
65 | 65 | ||
66 | QString line; bool found = 0; | 66 | QString line; bool found = 0; |
67 | 67 | ||
68 | map.readLine(line, 1024); | 68 | map.readLine(line, 1024); |
69 | while (!map.atEnd()) { | 69 | while (!map.atEnd()) { |
70 | 70 | ||
71 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 71 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
72 | 72 | ||
73 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 73 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
74 | found = 1; | 74 | found = 1; |
75 | break; | 75 | break; |
76 | } | 76 | } |
77 | map.readLine(line, 1024); | 77 | map.readLine(line, 1024); |
78 | } | 78 | } |
79 | if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); | 79 | if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); |
80 | 80 | ||
81 | map.close(); | 81 | map.close(); |
82 | } | 82 | } |
83 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { | 83 | if (map_dir.absPath() + "/" + map_dir[i] == current_map) { |
84 | 84 | ||
85 | keymaps->setSelected(i + 1, true); | 85 | keymaps->setSelected(i + 1, true); |
86 | } | 86 | } |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | custom_maps = config.readListEntry("maps", QChar('|')); | 90 | custom_maps = config.readListEntry("maps", QChar('|')); |
91 | 91 | ||
92 | for (uint i = 0; i < custom_maps.count(); i++) { | 92 | for (uint i = 0; i < custom_maps.count(); i++) { |
93 | 93 | ||
94 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) | 94 | if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) |
95 | || !QFile::exists(custom_maps[i])) { | 95 | || !QFile::exists(custom_maps[i])) { |
96 | 96 | ||
97 | custom_maps.remove(custom_maps.at(i)); | 97 | custom_maps.remove(custom_maps.at(i)); |
98 | 98 | ||
99 | // remove it from the list too | 99 | // remove it from the list too |
100 | config.writeEntry("maps", custom_maps.join("|")); | 100 | config.writeEntry("maps", custom_maps.join("|")); |
101 | 101 | ||
102 | 102 | ||
103 | } else { | 103 | } else { |
104 | 104 | ||
105 | QFile map (custom_maps[i]); | 105 | QFile map (custom_maps[i]); |
106 | if (map.open(IO_ReadOnly)) { | 106 | if (map.open(IO_ReadOnly)) { |
107 | 107 | ||
108 | QString line; bool found = 0; | 108 | QString line; bool found = 0; |
109 | 109 | ||
110 | map.readLine(line, 1024); | 110 | map.readLine(line, 1024); |
111 | while (!map.atEnd()) { | 111 | while (!map.atEnd()) { |
112 | 112 | ||
113 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 113 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
114 | 114 | ||
115 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 115 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
116 | found = 1; | 116 | found = 1; |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | map.readLine(line, 1024); | 119 | map.readLine(line, 1024); |
120 | } | 120 | } |
121 | if (!found) keymaps->insertItem(custom_maps[i]); | 121 | if (!found) keymaps->insertItem(custom_maps[i]); |
122 | 122 | ||
123 | map.close(); | 123 | map.close(); |
124 | } | 124 | } |
125 | if (custom_maps[i] == current_map) { | 125 | if (custom_maps[i] == current_map) { |
126 | 126 | ||
127 | keymaps->setSelected(map_dir.count() + i + 1, true); | 127 | keymaps->setSelected(map_dir.count() + i + 1, true); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | // have to "+1" because the "current language" listItem... remember? | 132 | // have to "+1" because the "current language" listItem... remember? |
133 | 133 | ||
134 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 134 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
135 | 135 | ||
136 | 136 | ||
137 | QGrid *add_remove_grid = new QGrid(2, map_group); | 137 | QGrid *add_remove_grid = new QGrid(2, map_group); |
138 | add_remove_grid->setMargin(3); | 138 | add_remove_grid->setMargin(3); |
139 | add_remove_grid->setSpacing(3); | 139 | add_remove_grid->setSpacing(3); |
140 | 140 | ||
141 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 141 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
142 | add_button->setFlat((bool)1); | 142 | add_button->setFlat((bool)1); |
143 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 143 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
144 | 144 | ||
145 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 145 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
146 | remove_button->setFlat((bool)1); | 146 | remove_button->setFlat((bool)1); |
147 | if ((int)map_dir.count() >= keymaps->currentItem()) | 147 | if ((int)map_dir.count() >= keymaps->currentItem()) |
148 | remove_button->setDisabled(true); | 148 | remove_button->setDisabled(true); |
149 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 149 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
150 | 150 | ||
151 | // make a box that will contain the buttons on the bottom | 151 | // make a box that will contain the buttons on the bottom |
152 | QGrid *other_grid = new QGrid(2, gen_box); | 152 | QGrid *other_grid = new QGrid(2, gen_box); |
153 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | 153 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); |
154 | 154 | ||
155 | config.setGroup ("general"); | 155 | config.setGroup ("general"); |
156 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed | 156 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed |
157 | if (pick_open) { | 157 | if (pick_open) { |
158 | 158 | ||
159 | pick_button->setChecked(true); | 159 | pick_button->setChecked(true); |
160 | } | 160 | } |
161 | 161 | ||
162 | // by connecting it after checking it, the signal isn't emmited | 162 | // by connecting it after checking it, the signal isn't emmited |
163 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 163 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
164 | 164 | ||
165 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | 165 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); |
166 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); | 166 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); |
167 | 167 | ||
168 | if (repeat_on) { | 168 | if (repeat_on) { |
169 | 169 | ||
170 | repeat_button->setChecked(true); | 170 | repeat_button->setChecked(true); |
171 | } | 171 | } |
172 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); | 172 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); |
173 | 173 | ||
174 | 174 | ||
175 | /* | 175 | /* |
176 | * 'color' tab | 176 | * 'color' tab |
177 | */ | 177 | */ |
178 | 178 | ||
179 | QGrid *color_box = new QGrid(2, this); | 179 | QGrid *color_box = new QGrid(2, this); |
180 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 180 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
181 | color_box->setMargin(3); | 181 | color_box->setMargin(3); |
182 | color_box->setSpacing(3); | 182 | color_box->setSpacing(3); |
183 | addTab(color_box, tr("Colors")); | 183 | addTab(color_box, tr("Colors")); |
184 | 184 | ||
185 | QLabel *label; | 185 | QLabel *label; |
186 | QStringList color; | 186 | QStringList color; |
187 | config.setGroup("colors"); | 187 | config.setGroup("colors"); |
188 | 188 | ||
189 | label = new QLabel(tr("Key Color"), color_box); | 189 | label = new QLabel(tr("Key Color"), color_box); |
190 | keycolor_button = new QPushButton(color_box); | 190 | keycolor_button = new QPushButton(color_box); |
191 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); | 191 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
192 | keycolor_button->setFlat((bool)1); | 192 | keycolor_button->setFlat((bool)1); |
193 | color = config.readListEntry("keycolor", QChar(',')); | 193 | color = config.readListEntry("keycolor", QChar(',')); |
194 | /* | 194 | /* |
195 | * hopefully not required | 195 | * hopefully not required |
196 | 196 | ||
197 | if (color.isEmpty()) { | 197 | if (color.isEmpty()) { |
198 | color = QStringList::split(",", "240,240,240"); | 198 | color = QStringList::split(",", "240,240,240"); |
199 | config.writeEntry("keycolor", color.join(",")); | 199 | config.writeEntry("keycolor", color.join(",")); |
200 | 200 | ||
201 | } | 201 | } |
202 | */ | 202 | */ |
203 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); | 203 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); |
204 | 204 | ||
205 | 205 | ||
206 | label = new QLabel(tr("Key Pressed Color"), color_box); | 206 | label = new QLabel(tr("Key Pressed Color"), color_box); |
207 | keycolor_pressed_button = new QPushButton(color_box); | 207 | keycolor_pressed_button = new QPushButton(color_box); |
208 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); | 208 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
209 | keycolor_pressed_button->setFlat((bool)1); | 209 | keycolor_pressed_button->setFlat((bool)1); |
210 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 210 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
211 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 211 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
212 | 212 | ||
213 | label = new QLabel(tr("Line Color"), color_box); | 213 | label = new QLabel(tr("Line Color"), color_box); |
214 | keycolor_lines_button = new QPushButton(color_box); | 214 | keycolor_lines_button = new QPushButton(color_box); |
215 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); | 215 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
216 | keycolor_lines_button->setFlat((bool)1); | 216 | keycolor_lines_button->setFlat((bool)1); |
217 | color = config.readListEntry("keycolor_lines", QChar(',')); | 217 | color = config.readListEntry("keycolor_lines", QChar(',')); |
218 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 218 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
219 | 219 | ||
220 | 220 | ||
221 | label = new QLabel(tr("Text Color"), color_box); | 221 | label = new QLabel(tr("Text Color"), color_box); |
222 | textcolor_button = new QPushButton(color_box); | 222 | textcolor_button = new QPushButton(color_box); |
223 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); | 223 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
224 | textcolor_button->setFlat((bool)1); | 224 | textcolor_button->setFlat((bool)1); |
225 | color = config.readListEntry("textcolor", QChar(',')); | 225 | color = config.readListEntry("textcolor", QChar(',')); |
226 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 226 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
227 | 227 | ||
228 | 228 | ||
229 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 229 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
230 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 230 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | void ConfigDlg::pickTog() { | 234 | void ConfigDlg::pickTog() { |
235 | 235 | ||
236 | Config config ("multikey"); | 236 | Config config ("multikey"); |
237 | config.setGroup ("general"); | 237 | config.setGroup ("general"); |
238 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed | 238 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed |
239 | 239 | ||
240 | emit pickboardToggled(pick_button->isChecked()); | 240 | emit pickboardToggled(pick_button->isChecked()); |
241 | } | 241 | } |
242 | 242 | ||
243 | void ConfigDlg::repeatTog() { | 243 | void ConfigDlg::repeatTog() { |
244 | 244 | ||
245 | Config config ("multikey"); | 245 | Config config ("multikey"); |
246 | config.setGroup ("general"); | 246 | config.setGroup ("general"); |
247 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed | 247 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed |
248 | 248 | ||
249 | emit repeatToggled(repeat_button->isChecked()); | 249 | emit repeatToggled(repeat_button->isChecked()); |
250 | } | 250 | } |
251 | 251 | ||
252 | // ConfigDlg::setMap {{{1 | 252 | // ConfigDlg::setMap {{{1 |
253 | 253 | ||
254 | /* | 254 | /* |
255 | * the index is kinda screwy, because in the config file, index 0 is just the | 255 | * the index is kinda screwy, because in the config file, index 0 is just the |
256 | * first element in the QStringList, but here it's the "Current Language" | 256 | * first element in the QStringList, but here it's the "Current Language" |
257 | * listItem. therefor you have to minus one to the index before you access it. | 257 | * listItem. therefor you have to minus one to the index before you access it. |
258 | * | 258 | * |
259 | */ | 259 | */ |
260 | 260 | ||
261 | void ConfigDlg::setMap(int index) { | 261 | void ConfigDlg::setMap(int index) { |
262 | 262 | ||
263 | if (index == 0) { | 263 | if (index == 0) { |
264 | 264 | ||
265 | remove_button->setDisabled(true); | 265 | remove_button->setDisabled(true); |
266 | emit setMapToDefault(); | 266 | emit setMapToDefault(); |
267 | } | 267 | } |
268 | else if ((uint)index <= default_maps.count()) { | 268 | else if ((uint)index <= default_maps.count()) { |
269 | 269 | ||
270 | remove_button->setDisabled(true); | 270 | remove_button->setDisabled(true); |
271 | emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]); | 271 | emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]); |
272 | 272 | ||
273 | } else { | 273 | } else { |
274 | 274 | ||
275 | remove_button->setEnabled(true); | 275 | remove_button->setEnabled(true); |
276 | emit setMapToFile(custom_maps[index - default_maps.count() - 1]); | 276 | emit setMapToFile(custom_maps[index - default_maps.count() - 1]); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | // ConfigDlg::addMap() {{{1 | 280 | // ConfigDlg::addMap() {{{1 |
281 | void ConfigDlg::addMap() { | 281 | void ConfigDlg::addMap() { |
282 | 282 | ||
283 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); | 283 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); |
284 | 284 | ||
285 | if (map.isNull()) return; | 285 | if (map.isNull()) return; |
286 | 286 | ||
287 | Config config ("multikey"); | 287 | Config config ("multikey"); |
288 | config.setGroup("keymaps"); | 288 | config.setGroup("keymaps"); |
289 | QStringList maps = config.readListEntry("maps", QChar('|')); | 289 | QStringList maps = config.readListEntry("maps", QChar('|')); |
290 | maps.append(map); | 290 | maps.append(map); |
291 | custom_maps.append(map); | 291 | custom_maps.append(map); |
292 | keymaps->insertItem(map); | 292 | |
293 | QFile map_file (map); | ||
294 | if (map_file.open(IO_ReadOnly)) { | ||
295 | |||
296 | QString line; bool found = 0; | ||
297 | |||
298 | map_file.readLine(line, 1024); | ||
299 | while (!map_file.atEnd()) { | ||
300 | |||
301 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | ||
302 | |||
303 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | ||
304 | found = 1; | ||
305 | break; | ||
306 | } | ||
307 | map_file.readLine(line, 1024); | ||
308 | } | ||
309 | if (!found) keymaps->insertItem(map); | ||
310 | |||
311 | map_file.close(); | ||
312 | } | ||
313 | |||
293 | keymaps->setSelected(keymaps->count() - 1, true); | 314 | keymaps->setSelected(keymaps->count() - 1, true); |
294 | 315 | ||
295 | 316 | ||
296 | config.writeEntry("maps", maps, QChar('|')); | 317 | config.writeEntry("maps", maps, QChar('|')); |
297 | config.writeEntry("current", map); | 318 | config.writeEntry("current", map); |
298 | 319 | ||
299 | } | 320 | } |
300 | 321 | ||
301 | // ConfigDlg::removeMap() {{{1 | 322 | // ConfigDlg::removeMap() {{{1 |
302 | void ConfigDlg::removeMap() { | 323 | void ConfigDlg::removeMap() { |
303 | 324 | ||
304 | // move selection up one | 325 | // move selection up one |
305 | keymaps->setSelected(keymaps->currentItem() - 1, true); | 326 | keymaps->setSelected(keymaps->currentItem() - 1, true); |
306 | // delete the next selected item cus you just moved it up | 327 | // delete the next selected item cus you just moved it up |
307 | keymaps->removeItem(keymaps->currentItem() + 1); | 328 | keymaps->removeItem(keymaps->currentItem() + 1); |
308 | 329 | ||
309 | custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count())); | 330 | custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count())); |
310 | 331 | ||
311 | // write the changes | 332 | // write the changes |
312 | Config config ("multikey"); | 333 | Config config ("multikey"); |
313 | config.setGroup("keymaps"); | 334 | config.setGroup("keymaps"); |
314 | config.writeEntry("maps", custom_maps, QChar('|')); | 335 | config.writeEntry("maps", custom_maps, QChar('|')); |
315 | } | 336 | } |
316 | 337 | ||
317 | /* ConfigDlg::slots for the color buttons {{{1 | 338 | /* ConfigDlg::slots for the color buttons {{{1 |
318 | * | 339 | * |
319 | * these four slots are almost the same, except for the names. i was thinking | 340 | * these four slots are almost the same, except for the names. i was thinking |
320 | * of making a map with pointers to the buttons and names of the configEntry | 341 | * of making a map with pointers to the buttons and names of the configEntry |
321 | * so it could be one slot, but then there would be no way of telling which | 342 | * so it could be one slot, but then there would be no way of telling which |
322 | * of the buttons was clicked if they all connect to the same slot. | 343 | * of the buttons was clicked if they all connect to the same slot. |
323 | * | 344 | * |
324 | */ | 345 | */ |
325 | 346 | ||
326 | void ConfigDlg::keyColorClicked() { | 347 | void ConfigDlg::keyColorClicked() { |
327 | 348 | ||
328 | Config config ("multikey"); | 349 | Config config ("multikey"); |
329 | config.setGroup ("colors"); | 350 | config.setGroup ("colors"); |
330 | 351 | ||
331 | QStringList color = config.readListEntry("keycolor", QChar(',')); | 352 | QStringList color = config.readListEntry("keycolor", QChar(',')); |
332 | 353 | ||
333 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 354 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
334 | 355 | ||
335 | color[0].setNum(newcolor.red()); | 356 | color[0].setNum(newcolor.red()); |
336 | color[1].setNum(newcolor.green()); | 357 | color[1].setNum(newcolor.green()); |
337 | color[2].setNum(newcolor.blue()); | 358 | color[2].setNum(newcolor.blue()); |
338 | 359 | ||
339 | config.writeEntry("keycolor", color, QChar(',')); | 360 | config.writeEntry("keycolor", color, QChar(',')); |
340 | config.write(); | 361 | config.write(); |
341 | 362 | ||
342 | keycolor_button->setPalette(QPalette(newcolor)); | 363 | keycolor_button->setPalette(QPalette(newcolor)); |
343 | emit reloadKeyboard(); | 364 | emit reloadKeyboard(); |
344 | } | 365 | } |
345 | void ConfigDlg::keyColorPressedClicked() { | 366 | void ConfigDlg::keyColorPressedClicked() { |
346 | 367 | ||
347 | Config config ("multikey"); | 368 | Config config ("multikey"); |
348 | config.setGroup ("colors"); | 369 | config.setGroup ("colors"); |
349 | 370 | ||
350 | QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); | 371 | QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); |
351 | 372 | ||
352 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 373 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
353 | 374 | ||
354 | color[0].setNum(newcolor.red()); | 375 | color[0].setNum(newcolor.red()); |
355 | color[1].setNum(newcolor.green()); | 376 | color[1].setNum(newcolor.green()); |
356 | color[2].setNum(newcolor.blue()); | 377 | color[2].setNum(newcolor.blue()); |
357 | 378 | ||
358 | config.writeEntry("keycolor_pressed", color, QChar(',')); | 379 | config.writeEntry("keycolor_pressed", color, QChar(',')); |
359 | config.write(); | 380 | config.write(); |
360 | 381 | ||
361 | keycolor_pressed_button->setPalette(QPalette(newcolor)); | 382 | keycolor_pressed_button->setPalette(QPalette(newcolor)); |
362 | emit reloadKeyboard(); | 383 | emit reloadKeyboard(); |
363 | } | 384 | } |
364 | void ConfigDlg::keyColorLinesClicked() { | 385 | void ConfigDlg::keyColorLinesClicked() { |
365 | 386 | ||
366 | Config config ("multikey"); | 387 | Config config ("multikey"); |
367 | config.setGroup ("colors"); | 388 | config.setGroup ("colors"); |
368 | 389 | ||
369 | QStringList color = config.readListEntry("keycolor_lines", QChar(',')); | 390 | QStringList color = config.readListEntry("keycolor_lines", QChar(',')); |
370 | 391 | ||
371 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 392 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
372 | 393 | ||
373 | color[0].setNum(newcolor.red()); | 394 | color[0].setNum(newcolor.red()); |
374 | color[1].setNum(newcolor.green()); | 395 | color[1].setNum(newcolor.green()); |
375 | color[2].setNum(newcolor.blue()); | 396 | color[2].setNum(newcolor.blue()); |
376 | 397 | ||
377 | config.writeEntry("keycolor_lines", color, QChar(',')); | 398 | config.writeEntry("keycolor_lines", color, QChar(',')); |
378 | config.write(); | 399 | config.write(); |
379 | 400 | ||
380 | keycolor_lines_button->setPalette(QPalette(newcolor)); | 401 | keycolor_lines_button->setPalette(QPalette(newcolor)); |
381 | emit reloadKeyboard(); | 402 | emit reloadKeyboard(); |
382 | } | 403 | } |
383 | void ConfigDlg::textColorClicked() { | 404 | void ConfigDlg::textColorClicked() { |
384 | 405 | ||
385 | Config config ("multikey"); | 406 | Config config ("multikey"); |
386 | config.setGroup ("colors"); | 407 | config.setGroup ("colors"); |
387 | 408 | ||
388 | QStringList color = config.readListEntry("textcolor", QChar(',')); | 409 | QStringList color = config.readListEntry("textcolor", QChar(',')); |
389 | 410 | ||
390 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 411 | QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
391 | 412 | ||
392 | color[0].setNum(newcolor.red()); | 413 | color[0].setNum(newcolor.red()); |
393 | color[1].setNum(newcolor.green()); | 414 | color[1].setNum(newcolor.green()); |
394 | color[2].setNum(newcolor.blue()); | 415 | color[2].setNum(newcolor.blue()); |
395 | 416 | ||
396 | config.writeEntry("textcolor", color, QChar(',')); | 417 | config.writeEntry("textcolor", color, QChar(',')); |
397 | config.write(); | 418 | config.write(); |
398 | 419 | ||
399 | textcolor_button->setPalette(QPalette(newcolor)); | 420 | textcolor_button->setPalette(QPalette(newcolor)); |
400 | emit reloadKeyboard(); | 421 | emit reloadKeyboard(); |
401 | } | 422 | } |
diff --git a/inputmethods/multikey/multikey.pro b/inputmethods/multikey/multikey.pro index 9d76a3d..1171602 100644 --- a/inputmethods/multikey/multikey.pro +++ b/inputmethods/multikey/multikey.pro | |||
@@ -1,31 +1,31 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= keyboard.h \ | 3 | HEADERS= keyboard.h \ |
4 | configdlg.h \ | 4 | configdlg.h \ |
5 | ../pickboard/pickboardcfg.h \ | 5 | ../pickboard/pickboardcfg.h \ |
6 | ../pickboard/pickboardpicks.h \ | 6 | ../pickboard/pickboardpicks.h \ |
7 | keyboardimpl.h | 7 | keyboardimpl.h |
8 | SOURCES= keyboard.cpp \ | 8 | SOURCES= keyboard.cpp \ |
9 | configdlg.cpp \ | 9 | configdlg.cpp \ |
10 | ../pickboard/pickboardcfg.cpp \ | 10 | ../pickboard/pickboardcfg.cpp \ |
11 | ../pickboard/pickboardpicks.cpp \ | 11 | ../pickboard/pickboardpicks.cpp \ |
12 | keyboardimpl.cpp | 12 | keyboardimpl.cpp |
13 | TARGET = qmultikey | 13 | TARGET = qmultikey |
14 | DESTDIR = ../../plugins/inputmethods | 14 | DESTDIR = $(OPIEDIR)/plugins/inputmethods |
15 | INCLUDEPATH += $(OPIEDIR)/include | 15 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += ../$(OPIEDIR)/include ../../launcher | 16 | DEPENDPATH += ../$(OPIEDIR)/include ../../launcher |
17 | LIBS += -lqpe | 17 | LIBS += -lqpe |
18 | VERSION = 1.0.0 | 18 | VERSION = 1.0.0 |
19 | 19 | ||
20 | TRANSLATIONS = ../../i18n/pt_BR/libqmultikey.ts | 20 | TRANSLATIONS = ../../i18n/pt_BR/libqmultikey.ts |
21 | TRANSLATIONS += ../../i18n/de/libqmultikey.ts | 21 | TRANSLATIONS += ../../i18n/de/libqmultikey.ts |
22 | TRANSLATIONS += ../../i18n/en/libqmultikey.ts | 22 | TRANSLATIONS += ../../i18n/en/libqmultikey.ts |
23 | TRANSLATIONS += ../../i18n/hu/libqmultikey.ts | 23 | TRANSLATIONS += ../../i18n/hu/libqmultikey.ts |
24 | TRANSLATIONS += ../../i18n/sl/libqmultikey.ts | 24 | TRANSLATIONS += ../../i18n/sl/libqmultikey.ts |
25 | TRANSLATIONS += ../../i18n/ja/libqmultikey.ts | 25 | TRANSLATIONS += ../../i18n/ja/libqmultikey.ts |
26 | TRANSLATIONS += ../../i18n/ko/libqmultikey.ts | 26 | TRANSLATIONS += ../../i18n/ko/libqmultikey.ts |
27 | TRANSLATIONS += ../../i18n/pl/libqmultikey.ts | 27 | TRANSLATIONS += ../../i18n/pl/libqmultikey.ts |
28 | TRANSLATIONS += ../../i18n/no/libqmultikey.ts | 28 | TRANSLATIONS += ../../i18n/no/libqmultikey.ts |
29 | TRANSLATIONS += ../../i18n/zh_CN/libqmultikey.ts | 29 | TRANSLATIONS += ../../i18n/zh_CN/libqmultikey.ts |
30 | TRANSLATIONS += ../../i18n/zh_TW/libqmultikey.ts | 30 | TRANSLATIONS += ../../i18n/zh_TW/libqmultikey.ts |
31 | TRANSLATIONS += ../../i18n/fr/libqmultikey.ts | 31 | TRANSLATIONS += ../../i18n/fr/libqmultikey.ts |