summaryrefslogtreecommitdiff
path: root/inputmethods/multikey
authorzecke <zecke>2004-03-14 19:35:00 (UTC)
committer zecke <zecke>2004-03-14 19:35:00 (UTC)
commit05c8d999941989a97a581fb5822437034ec10fd7 (patch) (unidiff)
tree28ba32dcf84bf8297550bf0f79fc504855caf341 /inputmethods/multikey
parentcbb87c7c24dfe46462602c73b10bd76ce81a3baf (diff)
downloadopie-05c8d999941989a97a581fb5822437034ec10fd7.zip
opie-05c8d999941989a97a581fb5822437034ec10fd7.tar.gz
opie-05c8d999941989a97a581fb5822437034ec10fd7.tar.bz2
Input Methods -> ODP
Diffstat (limited to 'inputmethods/multikey') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/config.in2
-rw-r--r--inputmethods/multikey/configdlg.cpp14
-rw-r--r--inputmethods/multikey/multikey.pro2
3 files changed, 10 insertions, 8 deletions
diff --git a/inputmethods/multikey/config.in b/inputmethods/multikey/config.in
index b34bd3d..ad7d1e8 100644
--- a/inputmethods/multikey/config.in
+++ b/inputmethods/multikey/config.in
@@ -1,4 +1,4 @@
1 config MULTIKEY 1 config MULTIKEY
2 boolean "opie-multikey (OnScreen keyboard for multiple languages)" 2 boolean "opie-multikey (OnScreen keyboard for multiple languages)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && PICKBOARD 4 depends ( LIBQPE || LIBQPE-X11 ) && PICKBOARD && LIBQTAUX2 && LIBOPIEUI2
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 3e39415..1fba9bc 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,506 +1,508 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make a keymap editor 4 * make a keymap editor
5 * make keys translucent 5 * make keys translucent
6 * make vertical keys possible 6 * make vertical keys possible
7 * 7 *
8 * 8 *
9 */ 9 */
10 10
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/resource.h> 13#include <qpe/resource.h>
14 14
15#include <qlayout.h> 15#include <qlayout.h>
16#include <qwidget.h> 16#include <qwidget.h>
17#include <qdialog.h> 17#include <qdialog.h>
18#include <qtabwidget.h> 18#include <qtabwidget.h>
19#include <qvbox.h> 19#include <qvbox.h>
20#include <qgrid.h> 20#include <qgrid.h>
21#include <qgroupbox.h> 21#include <qgroupbox.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qcheckbox.h> 23#include <qcheckbox.h>
24#include <qsizepolicy.h> 24#include <qsizepolicy.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <opie/ofiledialog.h> 29#include <opie2/ofiledialog.h>
30#include <opie/colordialog.h> 30#include <opie2/qcolordialog.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfileinfo.h> 32#include <qfileinfo.h>
33#include "configdlg.h" 33#include "configdlg.h"
34#include "keyboard.h" 34#include "keyboard.h"
35 35
36using namespace Opie;
37using namespace Opie::Ui;
36// ConfigDlg::ConfigDlg() {{{1 38// ConfigDlg::ConfigDlg() {{{1
37ConfigDlg::ConfigDlg () : QDialog () 39ConfigDlg::ConfigDlg () : QDialog ()
38{ 40{
39 setCaption( tr("Multikey Configuration") ); 41 setCaption( tr("Multikey Configuration") );
40 Config config ("multikey"); 42 Config config ("multikey");
41 config.setGroup("keymaps"); 43 config.setGroup("keymaps");
42 QString current_map = config.readEntry("current", 0); 44 QString current_map = config.readEntry("current", 0);
43 45
44 /* 46 /*
45 * 'general config' tab 47 * 'general config' tab
46 */ 48 */
47 49
48 QVBoxLayout *base_lay = new QVBoxLayout(this); 50 QVBoxLayout *base_lay = new QVBoxLayout(this);
49 51
50 QTabWidget *tabs = new QTabWidget(this, "tabs"); 52 QTabWidget *tabs = new QTabWidget(this, "tabs");
51 53
52 QWidget *gen_box = new QWidget(tabs, "gen_tab"); 54 QWidget *gen_box = new QWidget(tabs, "gen_tab");
53 QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); 55 QVBoxLayout *gen_lay = new QVBoxLayout(gen_box);
54 gen_lay->setMargin(3); 56 gen_lay->setMargin(3);
55 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); 57 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box);
56 58
57 QHBox *hbox1 = new QHBox(map_group); 59 QHBox *hbox1 = new QHBox(map_group);
58 keymaps = new QListBox(hbox1); 60 keymaps = new QListBox(hbox1);
59 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 61 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
60 QVBox *vbox1 = new QVBox(hbox1); 62 QVBox *vbox1 = new QVBox(hbox1);
61 63
62 QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); 64 QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up"));
63 tb1->setPixmap(Resource::loadPixmap("up")); 65 tb1->setPixmap(Resource::loadPixmap("up"));
64 tb1->setAutoRaise(TRUE); 66 tb1->setAutoRaise(TRUE);
65 tb1->setFocusPolicy(QWidget::NoFocus); 67 tb1->setFocusPolicy(QWidget::NoFocus);
66 tb1->setToggleButton(FALSE); 68 tb1->setToggleButton(FALSE);
67 connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); 69 connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp()));
68 70
69 QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); 71 QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down"));
70 tb2->setPixmap(Resource::loadPixmap("down")); 72 tb2->setPixmap(Resource::loadPixmap("down"));
71 tb2->setAutoRaise(TRUE); 73 tb2->setAutoRaise(TRUE);
72 tb2->setFocusPolicy(QWidget::NoFocus); 74 tb2->setFocusPolicy(QWidget::NoFocus);
73 tb2->setToggleButton(FALSE); 75 tb2->setToggleButton(FALSE);
74 connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); 76 connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown()));
75 77
76 QString cur(tr("Current Language")); 78 QString cur(tr("Current Language"));
77 keymaps->insertItem(cur); 79 keymaps->insertItem(cur);
78 keymaps->setSelected(0, true); 80 keymaps->setSelected(0, true);
79 81
80 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); 82 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap");
81 default_maps = map_dir.entryList(); // so i can access it in other places 83 default_maps = map_dir.entryList(); // so i can access it in other places
82 custom_maps = config.readListEntry("maps", QChar('|')); 84 custom_maps = config.readListEntry("maps", QChar('|'));
83 sw_maps = ConfigDlg::loadSw(); 85 sw_maps = ConfigDlg::loadSw();
84 86
85 QStringList sw_copy(sw_maps); 87 QStringList sw_copy(sw_maps);
86 for (uint i = 0; i < sw_copy.count(); i++) { 88 for (uint i = 0; i < sw_copy.count(); i++) {
87 89
88 QString keymap_map; 90 QString keymap_map;
89 if (sw_copy[i][0] != '/') { /* share/multikey */ 91 if (sw_copy[i][0] != '/') { /* share/multikey */
90 92
91 keymap_map = map_dir.absPath() + "/" + sw_copy[i]; 93 keymap_map = map_dir.absPath() + "/" + sw_copy[i];
92 } else { 94 } else {
93 95
94 if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) 96 if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false)
95 || !QFile::exists(sw_copy[i])) { 97 || !QFile::exists(sw_copy[i])) {
96 98
97 custom_maps.remove(sw_copy[i]); 99 custom_maps.remove(sw_copy[i]);
98 sw_maps.remove(sw_copy[i]); 100 sw_maps.remove(sw_copy[i]);
99 101
100 // remove it from the list too 102 // remove it from the list too
101 config.writeEntry("maps", custom_maps.join("|")); 103 config.writeEntry("maps", custom_maps.join("|"));
102 104
103 continue; 105 continue;
104 } 106 }
105 keymap_map = sw_copy[i]; 107 keymap_map = sw_copy[i];
106 } 108 }
107 109
108 QFile map(keymap_map); 110 QFile map(keymap_map);
109 if (map.open(IO_ReadOnly)) { 111 if (map.open(IO_ReadOnly)) {
110 112
111 QString line; bool found = 0; 113 QString line; bool found = 0;
112 114
113 map.readLine(line, 1024); 115 map.readLine(line, 1024);
114 while (!map.atEnd()) { 116 while (!map.atEnd()) {
115 117
116 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 118 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
117 119
118 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 120 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
119 found = 1; 121 found = 1;
120 break; 122 break;
121 } 123 }
122 map.readLine(line, 1024); 124 map.readLine(line, 1024);
123 } 125 }
124 if (!found) 126 if (!found)
125 keymaps->insertItem(keymap_map); 127 keymaps->insertItem(keymap_map);
126 128
127 map.close(); 129 map.close();
128 } 130 }
129 131
130 if (keymap_map == current_map) { 132 if (keymap_map == current_map) {
131 keymaps->setSelected(i + 1, true); 133 keymaps->setSelected(i + 1, true);
132 } 134 }
133 } 135 }
134 136
135 // have to "+1" because the "current language" listItem... remember? 137 // have to "+1" because the "current language" listItem... remember?
136 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); 138 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int)));
137 139
138 QGrid *add_remove_grid = new QGrid(2, map_group); 140 QGrid *add_remove_grid = new QGrid(2, map_group);
139 add_remove_grid->setMargin(3); 141 add_remove_grid->setMargin(3);
140 add_remove_grid->setSpacing(3); 142 add_remove_grid->setSpacing(3);
141 143
142 add_button = new QPushButton(tr("Add"), add_remove_grid); 144 add_button = new QPushButton(tr("Add"), add_remove_grid);
143 add_button->setFlat(TRUE); 145 add_button->setFlat(TRUE);
144 connect(add_button, SIGNAL(clicked()), SLOT(addMap())); 146 connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
145 147
146 remove_button = new QPushButton(tr("Remove"), add_remove_grid); 148 remove_button = new QPushButton(tr("Remove"), add_remove_grid);
147 remove_button->setFlat(TRUE); 149 remove_button->setFlat(TRUE);
148 if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) 150 if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end())
149 remove_button->setDisabled(true); 151 remove_button->setDisabled(true);
150 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); 152 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
151 153
152 gen_lay->addWidget(map_group); 154 gen_lay->addWidget(map_group);
153 155
154 // make a box that will contain the buttons on the bottom 156 // make a box that will contain the buttons on the bottom
155 QGrid *other_grid = new QGrid(2, gen_box); 157 QGrid *other_grid = new QGrid(2, gen_box);
156 pick_button = new QCheckBox(tr("Pickboard"), other_grid); 158 pick_button = new QCheckBox(tr("Pickboard"), other_grid);
157 159
158 config.setGroup ("general"); 160 config.setGroup ("general");
159 bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed 161 bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed
160 if (pick_open) { 162 if (pick_open) {
161 163
162 pick_button->setChecked(true); 164 pick_button->setChecked(true);
163 } 165 }
164 166
165 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); 167 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid);
166 bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); 168 bool repeat_on = config.readBoolEntry ("useRepeat", TRUE);
167 169
168 if (repeat_on) { 170 if (repeat_on) {
169 171
170 repeat_button->setChecked(true); 172 repeat_button->setChecked(true);
171 } 173 }
172 174
173 gen_lay->addWidget(other_grid); 175 gen_lay->addWidget(other_grid);
174 tabs->addTab(gen_box, tr("General Settings")); 176 tabs->addTab(gen_box, tr("General Settings"));
175 177
176 /* 178 /*
177 * 'color' tab 179 * 'color' tab
178 */ 180 */
179 181
180 QWidget *color_box = new QWidget(tabs, "color_tab"); 182 QWidget *color_box = new QWidget(tabs, "color_tab");
181 183
182 QGridLayout *color_lay = new QGridLayout(color_box); 184 QGridLayout *color_lay = new QGridLayout(color_box);
183 QGrid *color_grid = new QGrid(2, color_box); 185 QGrid *color_grid = new QGrid(2, color_box);
184 color_lay->setAlignment(Qt::AlignTop); 186 color_lay->setAlignment(Qt::AlignTop);
185 color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 187 color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
186 color_grid->layout()->setAlignment(Qt::AlignTop); 188 color_grid->layout()->setAlignment(Qt::AlignTop);
187 color_grid->setMargin(3); 189 color_grid->setMargin(3);
188 color_grid->setSpacing(3); 190 color_grid->setSpacing(3);
189 191
190 QLabel *label; 192 QLabel *label;
191 QStringList color; 193 QStringList color;
192 config.setGroup("colors"); 194 config.setGroup("colors");
193 195
194 label = new QLabel(tr("Key Color"), color_grid); 196 label = new QLabel(tr("Key Color"), color_grid);
195 keycolor_button = new QPushButton(color_grid); 197 keycolor_button = new QPushButton(color_grid);
196 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); 198 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked()));
197 keycolor_button->setFlat(TRUE); 199 keycolor_button->setFlat(TRUE);
198 color = config.readListEntry("keycolor", QChar(',')); 200 color = config.readListEntry("keycolor", QChar(','));
199 /* 201 /*
200 * hopefully not required 202 * hopefully not required
201 203
202 if (color.isEmpty()) { 204 if (color.isEmpty()) {
203 color = QStringList::split(",", "240,240,240"); 205 color = QStringList::split(",", "240,240,240");
204 config.writeEntry("keycolor", color.join(",")); 206 config.writeEntry("keycolor", color.join(","));
205 207
206 } 208 }
207 */ 209 */
208 keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); 210 keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())));
209 211
210 212
211 label = new QLabel(tr("Key Pressed Color"), color_grid); 213 label = new QLabel(tr("Key Pressed Color"), color_grid);
212 keycolor_pressed_button = new QPushButton(color_grid); 214 keycolor_pressed_button = new QPushButton(color_grid);
213 connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); 215 connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked()));
214 keycolor_pressed_button->setFlat(TRUE); 216 keycolor_pressed_button->setFlat(TRUE);
215 color = config.readListEntry("keycolor_pressed", QChar(',')); 217 color = config.readListEntry("keycolor_pressed", QChar(','));
216 keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); 218 keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))));
217 219
218 label = new QLabel(tr("Line Color"), color_grid); 220 label = new QLabel(tr("Line Color"), color_grid);
219 keycolor_lines_button = new QPushButton(color_grid); 221 keycolor_lines_button = new QPushButton(color_grid);
220 connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); 222 connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked()));
221 keycolor_lines_button->setFlat(TRUE); 223 keycolor_lines_button->setFlat(TRUE);
222 color = config.readListEntry("keycolor_lines", QChar(',')); 224 color = config.readListEntry("keycolor_lines", QChar(','));
223 keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); 225 keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))));
224 226
225 227
226 label = new QLabel(tr("Text Color"), color_grid); 228 label = new QLabel(tr("Text Color"), color_grid);
227 textcolor_button = new QPushButton(color_grid); 229 textcolor_button = new QPushButton(color_grid);
228 connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); 230 connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked()));
229 textcolor_button->setFlat(TRUE); 231 textcolor_button->setFlat(TRUE);
230 color = config.readListEntry("textcolor", QChar(',')); 232 color = config.readListEntry("textcolor", QChar(','));
231 textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); 233 textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))));
232 234
233 label = new QLabel("", color_grid); // a spacer so the above buttons dont expand 235 label = new QLabel("", color_grid); // a spacer so the above buttons dont expand
234 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 236 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
235 /* FIXME: hacked spacer height */ 237 /* FIXME: hacked spacer height */
236 QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); 238 QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum);
237 239
238 color_lay->addWidget(color_grid, 0, 0); 240 color_lay->addWidget(color_grid, 0, 0);
239 color_lay->addItem(spacer); 241 color_lay->addItem(spacer);
240 242
241 tabs->addTab(color_box, tr("Colors")); 243 tabs->addTab(color_box, tr("Colors"));
242 base_lay->addWidget(tabs); 244 base_lay->addWidget(tabs);
243} 245}
244 246
245QStringList ConfigDlg::loadSw() 247QStringList ConfigDlg::loadSw()
246{ 248{
247 Config *config = new Config("multikey"); 249 Config *config = new Config("multikey");
248 config->setGroup("keymaps"); 250 config->setGroup("keymaps");
249 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); 251 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap");
250 QStringList d_maps = map_dir.entryList(); // so i can access it in other places 252 QStringList d_maps = map_dir.entryList(); // so i can access it in other places
251 QStringList c_maps = config->readListEntry("maps", QChar('|')); 253 QStringList c_maps = config->readListEntry("maps", QChar('|'));
252 QStringList s_maps = config->readListEntry("sw", QChar('|')); 254 QStringList s_maps = config->readListEntry("sw", QChar('|'));
253 delete config; 255 delete config;
254 256
255 if (!s_maps.count()) 257 if (!s_maps.count())
256 { 258 {
257 s_maps = d_maps+c_maps; 259 s_maps = d_maps+c_maps;
258 } 260 }
259 else 261 else
260 { 262 {
261 /* Clear non existents entries */ 263 /* Clear non existents entries */
262 QStringList s_copy(s_maps); 264 QStringList s_copy(s_maps);
263 for (uint i = 0; i < s_copy.count(); ++i) { 265 for (uint i = 0; i < s_copy.count(); ++i) {
264 if (d_maps.find(s_copy[i]) == d_maps.end() 266 if (d_maps.find(s_copy[i]) == d_maps.end()
265 && c_maps.find(s_copy[i]) == c_maps.end()) { 267 && c_maps.find(s_copy[i]) == c_maps.end()) {
266 s_maps.remove(s_copy[i]); 268 s_maps.remove(s_copy[i]);
267 } 269 }
268 } 270 }
269 /* Update sw_maps from default_maps */ 271 /* Update sw_maps from default_maps */
270 for (uint i = 0; i < d_maps.count(); ++i) { 272 for (uint i = 0; i < d_maps.count(); ++i) {
271 if (s_maps.find(d_maps[i]) == s_maps.end()) { 273 if (s_maps.find(d_maps[i]) == s_maps.end()) {
272 s_maps.append(d_maps[i]); 274 s_maps.append(d_maps[i]);
273 } 275 }
274 } 276 }
275 /* Update sw_maps from custom_maps */ 277 /* Update sw_maps from custom_maps */
276 for (uint i = 0; i < c_maps.count(); ++i) { 278 for (uint i = 0; i < c_maps.count(); ++i) {
277 if (s_maps.find(c_maps[i]) == s_maps.end()) { 279 if (s_maps.find(c_maps[i]) == s_maps.end()) {
278 s_maps.append(c_maps[i]); 280 s_maps.append(c_maps[i]);
279 } 281 }
280 } 282 }
281 } 283 }
282 284
283 return s_maps; 285 return s_maps;
284} 286}
285 287
286void ConfigDlg::accept() 288void ConfigDlg::accept()
287{ 289{
288 /* Writing all stuffs to config */ 290 /* Writing all stuffs to config */
289 Config *config = new Config("multikey"); 291 Config *config = new Config("multikey");
290 config->setGroup("general"); 292 config->setGroup("general");
291 config->writeEntry("usePickboard", pick_button->isChecked()); // default closed 293 config->writeEntry("usePickboard", pick_button->isChecked()); // default closed
292 config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed 294 config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed
293 295
294 config->setGroup("keymaps"); 296 config->setGroup("keymaps");
295 config->writeEntry("sw", sw_maps, QChar('|')); 297 config->writeEntry("sw", sw_maps, QChar('|'));
296 config->writeEntry("maps", custom_maps, QChar('|')); 298 config->writeEntry("maps", custom_maps, QChar('|'));
297 delete config; 299 delete config;
298 300
299 int index = keymaps->currentItem(); 301 int index = keymaps->currentItem();
300 if (index == 0) { 302 if (index == 0) {
301 303
302 remove_button->setDisabled(true); 304 remove_button->setDisabled(true);
303 emit setMapToDefault(); 305 emit setMapToDefault();
304 } 306 }
305 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { 307 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) {
306 308
307 remove_button->setDisabled(true); 309 remove_button->setDisabled(true);
308 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); 310 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]);
309 311
310 } else { 312 } else {
311 313
312 remove_button->setEnabled(true); 314 remove_button->setEnabled(true);
313 emit setMapToFile(sw_maps[index - 1]); 315 emit setMapToFile(sw_maps[index - 1]);
314 } 316 }
315 317
316 emit pickboardToggled(pick_button->isChecked()); 318 emit pickboardToggled(pick_button->isChecked());
317 emit repeatToggled(repeat_button->isChecked()); 319 emit repeatToggled(repeat_button->isChecked());
318 emit reloadSw(); 320 emit reloadSw();
319 321
320 QDialog::accept(); 322 QDialog::accept();
321 emit configDlgClosed(); 323 emit configDlgClosed();
322} 324}
323 325
324void ConfigDlg::moveSelectedUp() 326void ConfigDlg::moveSelectedUp()
325{ 327{
326 int i = keymaps->currentItem(); 328 int i = keymaps->currentItem();
327 /* Ignore Current Language */ 329 /* Ignore Current Language */
328 if (i > 1) { 330 if (i > 1) {
329 QString t = sw_maps[i-1]; 331 QString t = sw_maps[i-1];
330 sw_maps[i-1] = sw_maps[i-2]; 332 sw_maps[i-1] = sw_maps[i-2];
331 sw_maps[i-2] = t; 333 sw_maps[i-2] = t;
332 334
333 QString item = keymaps->currentText(); 335 QString item = keymaps->currentText();
334 keymaps->removeItem(i); 336 keymaps->removeItem(i);
335 keymaps->insertItem(item, i-1); 337 keymaps->insertItem(item, i-1);
336 keymaps->setCurrentItem(i-1); 338 keymaps->setCurrentItem(i-1);
337 } 339 }
338} 340}
339 341
340void ConfigDlg::moveSelectedDown() 342void ConfigDlg::moveSelectedDown()
341{ 343{
342 int i = keymaps->currentItem(); 344 int i = keymaps->currentItem();
343 /* Ignore Current Language */ 345 /* Ignore Current Language */
344 if (i > 0 && i < (int)keymaps->count() - 1) { 346 if (i > 0 && i < (int)keymaps->count() - 1) {
345 QString t = sw_maps[i-1]; 347 QString t = sw_maps[i-1];
346 sw_maps[i-1] = sw_maps[i]; 348 sw_maps[i-1] = sw_maps[i];
347 sw_maps[i] = t; 349 sw_maps[i] = t;
348 350
349 QString item = keymaps->currentText(); 351 QString item = keymaps->currentText();
350 keymaps->removeItem(i); 352 keymaps->removeItem(i);
351 keymaps->insertItem(item, i+1); 353 keymaps->insertItem(item, i+1);
352 keymaps->setCurrentItem(i+1); 354 keymaps->setCurrentItem(i+1);
353 } 355 }
354} 356}
355 357
356void ConfigDlg::closeEvent(QCloseEvent *) { 358void ConfigDlg::closeEvent(QCloseEvent *) {
357 359
358 // tell the parent it was closed, so delete me 360 // tell the parent it was closed, so delete me
359 emit configDlgClosed(); 361 emit configDlgClosed();
360} 362}
361 363
362void ConfigDlg::setMap(int index) { 364void ConfigDlg::setMap(int index) {
363 365
364 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) { 366 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) {
365 remove_button->setDisabled(true); 367 remove_button->setDisabled(true);
366 } else { 368 } else {
367 remove_button->setEnabled(true); 369 remove_button->setEnabled(true);
368 } 370 }
369} 371}
370 372
371// ConfigDlg::addMap() {{{1 373// ConfigDlg::addMap() {{{1
372void ConfigDlg::addMap() { 374void ConfigDlg::addMap() {
373 375
374 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 376 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
375 377
376 if (map.isNull()) return; 378 if (map.isNull()) return;
377 379
378 Config config ("multikey"); 380 Config config ("multikey");
379 config.setGroup("keymaps"); 381 config.setGroup("keymaps");
380 QStringList maps = config.readListEntry("maps", QChar('|')); 382 QStringList maps = config.readListEntry("maps", QChar('|'));
381 maps.append(map); 383 maps.append(map);
382 custom_maps.append(map); 384 custom_maps.append(map);
383 if (sw_maps.find(map) == sw_maps.end()) 385 if (sw_maps.find(map) == sw_maps.end())
384 sw_maps.append(map); 386 sw_maps.append(map);
385 387
386 QFile map_file (map); 388 QFile map_file (map);
387 if (map_file.open(IO_ReadOnly)) { 389 if (map_file.open(IO_ReadOnly)) {
388 390
389 QString line; bool found = 0; 391 QString line; bool found = 0;
390 392
391 map_file.readLine(line, 1024); 393 map_file.readLine(line, 1024);
392 while (!map_file.atEnd()) { 394 while (!map_file.atEnd()) {
393 395
394 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 396 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
395 397
396 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 398 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
397 found = 1; 399 found = 1;
398 break; 400 break;
399 } 401 }
400 map_file.readLine(line, 1024); 402 map_file.readLine(line, 1024);
401 } 403 }
402 if (!found) keymaps->insertItem(map); 404 if (!found) keymaps->insertItem(map);
403 405
404 map_file.close(); 406 map_file.close();
405 } 407 }
406 408
407 keymaps->setSelected(keymaps->count() - 1, true); 409 keymaps->setSelected(keymaps->count() - 1, true);
408} 410}
409 411
410// ConfigDlg::removeMap() {{{1 412// ConfigDlg::removeMap() {{{1
411void ConfigDlg::removeMap() { 413void ConfigDlg::removeMap() {
412 414
413 // move selection up one 415 // move selection up one
414 keymaps->setSelected(keymaps->currentItem() - 1, true); 416 keymaps->setSelected(keymaps->currentItem() - 1, true);
415 // delete the next selected item cus you just moved it up 417 // delete the next selected item cus you just moved it up
416 keymaps->removeItem(keymaps->currentItem() + 1); 418 keymaps->removeItem(keymaps->currentItem() + 1);
417 419
418 custom_maps.remove(sw_maps[keymaps->currentItem()]); 420 custom_maps.remove(sw_maps[keymaps->currentItem()]);
419 sw_maps.remove(sw_maps.at(keymaps->currentItem())); 421 sw_maps.remove(sw_maps.at(keymaps->currentItem()));
420} 422}
421 423
422/* ConfigDlg::slots for the color buttons {{{1 424/* ConfigDlg::slots for the color buttons {{{1
423 * 425 *
424 * these four slots are almost the same, except for the names. i was thinking 426 * these four slots are almost the same, except for the names. i was thinking
425 * of making a map with pointers to the buttons and names of the configEntry 427 * of making a map with pointers to the buttons and names of the configEntry
426 * so it could be one slot, but then there would be no way of telling which 428 * so it could be one slot, but then there would be no way of telling which
427 * of the buttons was clicked if they all connect to the same slot. 429 * of the buttons was clicked if they all connect to the same slot.
428 * 430 *
429 */ 431 */
430 432
431void ConfigDlg::keyColorClicked() { 433void ConfigDlg::keyColorClicked() {
432 434
433 Config config ("multikey"); 435 Config config ("multikey");
434 config.setGroup ("colors"); 436 config.setGroup ("colors");
435 437
436 QStringList color = config.readListEntry("keycolor", QChar(',')); 438 QStringList color = config.readListEntry("keycolor", QChar(','));
437 439
438 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 440 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
439 441
440 color[0].setNum(newcolor.red()); 442 color[0].setNum(newcolor.red());
441 color[1].setNum(newcolor.green()); 443 color[1].setNum(newcolor.green());
442 color[2].setNum(newcolor.blue()); 444 color[2].setNum(newcolor.blue());
443 445
444 config.writeEntry("keycolor", color, QChar(',')); 446 config.writeEntry("keycolor", color, QChar(','));
445 config.write(); 447 config.write();
446 448
447 keycolor_button->setPalette(QPalette(newcolor)); 449 keycolor_button->setPalette(QPalette(newcolor));
448 emit reloadKeyboard(); 450 emit reloadKeyboard();
449} 451}
450void ConfigDlg::keyColorPressedClicked() { 452void ConfigDlg::keyColorPressedClicked() {
451 453
452 Config config ("multikey"); 454 Config config ("multikey");
453 config.setGroup ("colors"); 455 config.setGroup ("colors");
454 456
455 QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); 457 QStringList color = config.readListEntry("keycolor_pressed", QChar(','));
456 458
457 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 459 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
458 460
459 color[0].setNum(newcolor.red()); 461 color[0].setNum(newcolor.red());
460 color[1].setNum(newcolor.green()); 462 color[1].setNum(newcolor.green());
461 color[2].setNum(newcolor.blue()); 463 color[2].setNum(newcolor.blue());
462 464
463 config.writeEntry("keycolor_pressed", color, QChar(',')); 465 config.writeEntry("keycolor_pressed", color, QChar(','));
464 config.write(); 466 config.write();
465 467
466 keycolor_pressed_button->setPalette(QPalette(newcolor)); 468 keycolor_pressed_button->setPalette(QPalette(newcolor));
467 emit reloadKeyboard(); 469 emit reloadKeyboard();
468} 470}
469void ConfigDlg::keyColorLinesClicked() { 471void ConfigDlg::keyColorLinesClicked() {
470 472
471 Config config ("multikey"); 473 Config config ("multikey");
472 config.setGroup ("colors"); 474 config.setGroup ("colors");
473 475
474 QStringList color = config.readListEntry("keycolor_lines", QChar(',')); 476 QStringList color = config.readListEntry("keycolor_lines", QChar(','));
475 477
476 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 478 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
477 479
478 color[0].setNum(newcolor.red()); 480 color[0].setNum(newcolor.red());
479 color[1].setNum(newcolor.green()); 481 color[1].setNum(newcolor.green());
480 color[2].setNum(newcolor.blue()); 482 color[2].setNum(newcolor.blue());
481 483
482 config.writeEntry("keycolor_lines", color, QChar(',')); 484 config.writeEntry("keycolor_lines", color, QChar(','));
483 config.write(); 485 config.write();
484 486
485 keycolor_lines_button->setPalette(QPalette(newcolor)); 487 keycolor_lines_button->setPalette(QPalette(newcolor));
486 emit reloadKeyboard(); 488 emit reloadKeyboard();
487} 489}
488void ConfigDlg::textColorClicked() { 490void ConfigDlg::textColorClicked() {
489 491
490 Config config ("multikey"); 492 Config config ("multikey");
491 config.setGroup ("colors"); 493 config.setGroup ("colors");
492 494
493 QStringList color = config.readListEntry("textcolor", QChar(',')); 495 QStringList color = config.readListEntry("textcolor", QChar(','));
494 496
495 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 497 QColor newcolor = QColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
496 498
497 color[0].setNum(newcolor.red()); 499 color[0].setNum(newcolor.red());
498 color[1].setNum(newcolor.green()); 500 color[1].setNum(newcolor.green());
499 color[2].setNum(newcolor.blue()); 501 color[2].setNum(newcolor.blue());
500 502
501 config.writeEntry("textcolor", color, QChar(',')); 503 config.writeEntry("textcolor", color, QChar(','));
502 config.write(); 504 config.write();
503 505
504 textcolor_button->setPalette(QPalette(newcolor)); 506 textcolor_button->setPalette(QPalette(newcolor));
505 emit reloadKeyboard(); 507 emit reloadKeyboard();
506} 508}
diff --git a/inputmethods/multikey/multikey.pro b/inputmethods/multikey/multikey.pro
index 0901006..3a7de06 100644
--- a/inputmethods/multikey/multikey.pro
+++ b/inputmethods/multikey/multikey.pro
@@ -1,18 +1,18 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on release 2 CONFIG += qt plugin warn_on release
3 HEADERS= keyboard.h \ 3 HEADERS= keyboard.h \
4 configdlg.h \ 4 configdlg.h \
5 keyboardimpl.h 5 keyboardimpl.h
6 SOURCES= keyboard.cpp \ 6 SOURCES= keyboard.cpp \
7 configdlg.cpp \ 7 configdlg.cpp \
8 keyboardimpl.cpp 8 keyboardimpl.cpp
9 TARGET = qmultikey 9 TARGET = qmultikey
10 DESTDIR = $(OPIEDIR)/plugins/inputmethods 10 DESTDIR = $(OPIEDIR)/plugins/inputmethods
11INCLUDEPATH += $(OPIEDIR)/include 11INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += ../$(OPIEDIR)/include ../../launcher 12DEPENDPATH += ../$(OPIEDIR)/include ../../launcher
13LIBS += -lqpe -L$(OPIEDIR)/plugins/inputmethods -lqpickboard 13LIBS += -lqpe -L$(OPIEDIR)/plugins/inputmethods -lqpickboard -lqtaux2 -lopieui2
14 QMAKE_LFLAGS+= -Wl,-rpath,/opt/QtPalmtop/plugins/inputmethods 14 QMAKE_LFLAGS+= -Wl,-rpath,/opt/QtPalmtop/plugins/inputmethods
15 VERSION = 1.0.0 15 VERSION = 1.0.0
16 16
17include ( $(OPIEDIR)/include.pro ) 17include ( $(OPIEDIR)/include.pro )
18target.path = $$prefix/plugins/inputmethods 18target.path = $$prefix/plugins/inputmethods