author | zecke <zecke> | 2004-10-16 00:01:01 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-16 00:01:01 (UTC) |
commit | df14f647ff1a60ca82e0fa9bd91458be146153b8 (patch) (unidiff) | |
tree | 4859961352851a4392e1442f2080c15bff8ad7bc /inputmethods | |
parent | 419f9710c488f56a7a117eb1529970d3371e0094 (diff) | |
download | opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.zip opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.tar.gz opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.tar.bz2 |
Replace QPEApplication::qpeDir() + "/ with
QPEApplication::qpeDir() + "
as it is guranteed that qpeDir() will have '/' as the last
charachter
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 4 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 1fba9bc..fe5051d 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,347 +1,347 @@ | |||
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 <opie2/ofiledialog.h> | 29 | #include <opie2/ofiledialog.h> |
30 | #include <opie2/qcolordialog.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 | ||
36 | using namespace Opie; | 36 | using namespace Opie; |
37 | using namespace Opie::Ui; | 37 | using namespace Opie::Ui; |
38 | // ConfigDlg::ConfigDlg() {{{1 | 38 | // ConfigDlg::ConfigDlg() {{{1 |
39 | ConfigDlg::ConfigDlg () : QDialog () | 39 | ConfigDlg::ConfigDlg () : QDialog () |
40 | { | 40 | { |
41 | setCaption( tr("Multikey Configuration") ); | 41 | setCaption( tr("Multikey Configuration") ); |
42 | Config config ("multikey"); | 42 | Config config ("multikey"); |
43 | config.setGroup("keymaps"); | 43 | config.setGroup("keymaps"); |
44 | QString current_map = config.readEntry("current", 0); | 44 | QString current_map = config.readEntry("current", 0); |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * 'general config' tab | 47 | * 'general config' tab |
48 | */ | 48 | */ |
49 | 49 | ||
50 | QVBoxLayout *base_lay = new QVBoxLayout(this); | 50 | QVBoxLayout *base_lay = new QVBoxLayout(this); |
51 | 51 | ||
52 | QTabWidget *tabs = new QTabWidget(this, "tabs"); | 52 | QTabWidget *tabs = new QTabWidget(this, "tabs"); |
53 | 53 | ||
54 | QWidget *gen_box = new QWidget(tabs, "gen_tab"); | 54 | QWidget *gen_box = new QWidget(tabs, "gen_tab"); |
55 | QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); | 55 | QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); |
56 | gen_lay->setMargin(3); | 56 | gen_lay->setMargin(3); |
57 | 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); |
58 | 58 | ||
59 | QHBox *hbox1 = new QHBox(map_group); | 59 | QHBox *hbox1 = new QHBox(map_group); |
60 | keymaps = new QListBox(hbox1); | 60 | keymaps = new QListBox(hbox1); |
61 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 61 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
62 | QVBox *vbox1 = new QVBox(hbox1); | 62 | QVBox *vbox1 = new QVBox(hbox1); |
63 | 63 | ||
64 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); | 64 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); |
65 | tb1->setPixmap(Resource::loadPixmap("up")); | 65 | tb1->setPixmap(Resource::loadPixmap("up")); |
66 | tb1->setAutoRaise(TRUE); | 66 | tb1->setAutoRaise(TRUE); |
67 | tb1->setFocusPolicy(QWidget::NoFocus); | 67 | tb1->setFocusPolicy(QWidget::NoFocus); |
68 | tb1->setToggleButton(FALSE); | 68 | tb1->setToggleButton(FALSE); |
69 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); | 69 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); |
70 | 70 | ||
71 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); | 71 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); |
72 | tb2->setPixmap(Resource::loadPixmap("down")); | 72 | tb2->setPixmap(Resource::loadPixmap("down")); |
73 | tb2->setAutoRaise(TRUE); | 73 | tb2->setAutoRaise(TRUE); |
74 | tb2->setFocusPolicy(QWidget::NoFocus); | 74 | tb2->setFocusPolicy(QWidget::NoFocus); |
75 | tb2->setToggleButton(FALSE); | 75 | tb2->setToggleButton(FALSE); |
76 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); | 76 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); |
77 | 77 | ||
78 | QString cur(tr("Current Language")); | 78 | QString cur(tr("Current Language")); |
79 | keymaps->insertItem(cur); | 79 | keymaps->insertItem(cur); |
80 | keymaps->setSelected(0, true); | 80 | keymaps->setSelected(0, true); |
81 | 81 | ||
82 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 82 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); |
83 | 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 |
84 | custom_maps = config.readListEntry("maps", QChar('|')); | 84 | custom_maps = config.readListEntry("maps", QChar('|')); |
85 | sw_maps = ConfigDlg::loadSw(); | 85 | sw_maps = ConfigDlg::loadSw(); |
86 | 86 | ||
87 | QStringList sw_copy(sw_maps); | 87 | QStringList sw_copy(sw_maps); |
88 | for (uint i = 0; i < sw_copy.count(); i++) { | 88 | for (uint i = 0; i < sw_copy.count(); i++) { |
89 | 89 | ||
90 | QString keymap_map; | 90 | QString keymap_map; |
91 | if (sw_copy[i][0] != '/') { /* share/multikey */ | 91 | if (sw_copy[i][0] != '/') { /* share/multikey */ |
92 | 92 | ||
93 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; | 93 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; |
94 | } else { | 94 | } else { |
95 | 95 | ||
96 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) | 96 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) |
97 | || !QFile::exists(sw_copy[i])) { | 97 | || !QFile::exists(sw_copy[i])) { |
98 | 98 | ||
99 | custom_maps.remove(sw_copy[i]); | 99 | custom_maps.remove(sw_copy[i]); |
100 | sw_maps.remove(sw_copy[i]); | 100 | sw_maps.remove(sw_copy[i]); |
101 | 101 | ||
102 | // remove it from the list too | 102 | // remove it from the list too |
103 | config.writeEntry("maps", custom_maps.join("|")); | 103 | config.writeEntry("maps", custom_maps.join("|")); |
104 | 104 | ||
105 | continue; | 105 | continue; |
106 | } | 106 | } |
107 | keymap_map = sw_copy[i]; | 107 | keymap_map = sw_copy[i]; |
108 | } | 108 | } |
109 | 109 | ||
110 | QFile map(keymap_map); | 110 | QFile map(keymap_map); |
111 | if (map.open(IO_ReadOnly)) { | 111 | if (map.open(IO_ReadOnly)) { |
112 | 112 | ||
113 | QString line; bool found = 0; | 113 | QString line; bool found = 0; |
114 | 114 | ||
115 | map.readLine(line, 1024); | 115 | map.readLine(line, 1024); |
116 | while (!map.atEnd()) { | 116 | while (!map.atEnd()) { |
117 | 117 | ||
118 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 118 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
119 | 119 | ||
120 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 120 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
121 | found = 1; | 121 | found = 1; |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | map.readLine(line, 1024); | 124 | map.readLine(line, 1024); |
125 | } | 125 | } |
126 | if (!found) | 126 | if (!found) |
127 | keymaps->insertItem(keymap_map); | 127 | keymaps->insertItem(keymap_map); |
128 | 128 | ||
129 | map.close(); | 129 | map.close(); |
130 | } | 130 | } |
131 | 131 | ||
132 | if (keymap_map == current_map) { | 132 | if (keymap_map == current_map) { |
133 | keymaps->setSelected(i + 1, true); | 133 | keymaps->setSelected(i + 1, true); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | // have to "+1" because the "current language" listItem... remember? | 137 | // have to "+1" because the "current language" listItem... remember? |
138 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 138 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
139 | 139 | ||
140 | QGrid *add_remove_grid = new QGrid(2, map_group); | 140 | QGrid *add_remove_grid = new QGrid(2, map_group); |
141 | add_remove_grid->setMargin(3); | 141 | add_remove_grid->setMargin(3); |
142 | add_remove_grid->setSpacing(3); | 142 | add_remove_grid->setSpacing(3); |
143 | 143 | ||
144 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 144 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
145 | add_button->setFlat(TRUE); | 145 | add_button->setFlat(TRUE); |
146 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 146 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
147 | 147 | ||
148 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 148 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
149 | remove_button->setFlat(TRUE); | 149 | remove_button->setFlat(TRUE); |
150 | 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()) |
151 | remove_button->setDisabled(true); | 151 | remove_button->setDisabled(true); |
152 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 152 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
153 | 153 | ||
154 | gen_lay->addWidget(map_group); | 154 | gen_lay->addWidget(map_group); |
155 | 155 | ||
156 | // make a box that will contain the buttons on the bottom | 156 | // make a box that will contain the buttons on the bottom |
157 | QGrid *other_grid = new QGrid(2, gen_box); | 157 | QGrid *other_grid = new QGrid(2, gen_box); |
158 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | 158 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); |
159 | 159 | ||
160 | config.setGroup ("general"); | 160 | config.setGroup ("general"); |
161 | bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed | 161 | bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed |
162 | if (pick_open) { | 162 | if (pick_open) { |
163 | 163 | ||
164 | pick_button->setChecked(true); | 164 | pick_button->setChecked(true); |
165 | } | 165 | } |
166 | 166 | ||
167 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | 167 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); |
168 | bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); | 168 | bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); |
169 | 169 | ||
170 | if (repeat_on) { | 170 | if (repeat_on) { |
171 | 171 | ||
172 | repeat_button->setChecked(true); | 172 | repeat_button->setChecked(true); |
173 | } | 173 | } |
174 | 174 | ||
175 | gen_lay->addWidget(other_grid); | 175 | gen_lay->addWidget(other_grid); |
176 | tabs->addTab(gen_box, tr("General Settings")); | 176 | tabs->addTab(gen_box, tr("General Settings")); |
177 | 177 | ||
178 | /* | 178 | /* |
179 | * 'color' tab | 179 | * 'color' tab |
180 | */ | 180 | */ |
181 | 181 | ||
182 | QWidget *color_box = new QWidget(tabs, "color_tab"); | 182 | QWidget *color_box = new QWidget(tabs, "color_tab"); |
183 | 183 | ||
184 | QGridLayout *color_lay = new QGridLayout(color_box); | 184 | QGridLayout *color_lay = new QGridLayout(color_box); |
185 | QGrid *color_grid = new QGrid(2, color_box); | 185 | QGrid *color_grid = new QGrid(2, color_box); |
186 | color_lay->setAlignment(Qt::AlignTop); | 186 | color_lay->setAlignment(Qt::AlignTop); |
187 | color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 187 | color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
188 | color_grid->layout()->setAlignment(Qt::AlignTop); | 188 | color_grid->layout()->setAlignment(Qt::AlignTop); |
189 | color_grid->setMargin(3); | 189 | color_grid->setMargin(3); |
190 | color_grid->setSpacing(3); | 190 | color_grid->setSpacing(3); |
191 | 191 | ||
192 | QLabel *label; | 192 | QLabel *label; |
193 | QStringList color; | 193 | QStringList color; |
194 | config.setGroup("colors"); | 194 | config.setGroup("colors"); |
195 | 195 | ||
196 | label = new QLabel(tr("Key Color"), color_grid); | 196 | label = new QLabel(tr("Key Color"), color_grid); |
197 | keycolor_button = new QPushButton(color_grid); | 197 | keycolor_button = new QPushButton(color_grid); |
198 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); | 198 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
199 | keycolor_button->setFlat(TRUE); | 199 | keycolor_button->setFlat(TRUE); |
200 | color = config.readListEntry("keycolor", QChar(',')); | 200 | color = config.readListEntry("keycolor", QChar(',')); |
201 | /* | 201 | /* |
202 | * hopefully not required | 202 | * hopefully not required |
203 | 203 | ||
204 | if (color.isEmpty()) { | 204 | if (color.isEmpty()) { |
205 | color = QStringList::split(",", "240,240,240"); | 205 | color = QStringList::split(",", "240,240,240"); |
206 | config.writeEntry("keycolor", color.join(",")); | 206 | config.writeEntry("keycolor", color.join(",")); |
207 | 207 | ||
208 | } | 208 | } |
209 | */ | 209 | */ |
210 | 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()))); |
211 | 211 | ||
212 | 212 | ||
213 | label = new QLabel(tr("Key Pressed Color"), color_grid); | 213 | label = new QLabel(tr("Key Pressed Color"), color_grid); |
214 | keycolor_pressed_button = new QPushButton(color_grid); | 214 | keycolor_pressed_button = new QPushButton(color_grid); |
215 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); | 215 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
216 | keycolor_pressed_button->setFlat(TRUE); | 216 | keycolor_pressed_button->setFlat(TRUE); |
217 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 217 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
218 | 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())))); |
219 | 219 | ||
220 | label = new QLabel(tr("Line Color"), color_grid); | 220 | label = new QLabel(tr("Line Color"), color_grid); |
221 | keycolor_lines_button = new QPushButton(color_grid); | 221 | keycolor_lines_button = new QPushButton(color_grid); |
222 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); | 222 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
223 | keycolor_lines_button->setFlat(TRUE); | 223 | keycolor_lines_button->setFlat(TRUE); |
224 | color = config.readListEntry("keycolor_lines", QChar(',')); | 224 | color = config.readListEntry("keycolor_lines", QChar(',')); |
225 | 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())))); |
226 | 226 | ||
227 | 227 | ||
228 | label = new QLabel(tr("Text Color"), color_grid); | 228 | label = new QLabel(tr("Text Color"), color_grid); |
229 | textcolor_button = new QPushButton(color_grid); | 229 | textcolor_button = new QPushButton(color_grid); |
230 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); | 230 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
231 | textcolor_button->setFlat(TRUE); | 231 | textcolor_button->setFlat(TRUE); |
232 | color = config.readListEntry("textcolor", QChar(',')); | 232 | color = config.readListEntry("textcolor", QChar(',')); |
233 | 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())))); |
234 | 234 | ||
235 | 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 |
236 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 236 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
237 | /* FIXME: hacked spacer height */ | 237 | /* FIXME: hacked spacer height */ |
238 | QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); | 238 | QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); |
239 | 239 | ||
240 | color_lay->addWidget(color_grid, 0, 0); | 240 | color_lay->addWidget(color_grid, 0, 0); |
241 | color_lay->addItem(spacer); | 241 | color_lay->addItem(spacer); |
242 | 242 | ||
243 | tabs->addTab(color_box, tr("Colors")); | 243 | tabs->addTab(color_box, tr("Colors")); |
244 | base_lay->addWidget(tabs); | 244 | base_lay->addWidget(tabs); |
245 | } | 245 | } |
246 | 246 | ||
247 | QStringList ConfigDlg::loadSw() | 247 | QStringList ConfigDlg::loadSw() |
248 | { | 248 | { |
249 | Config *config = new Config("multikey"); | 249 | Config *config = new Config("multikey"); |
250 | config->setGroup("keymaps"); | 250 | config->setGroup("keymaps"); |
251 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 251 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); |
252 | 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 |
253 | QStringList c_maps = config->readListEntry("maps", QChar('|')); | 253 | QStringList c_maps = config->readListEntry("maps", QChar('|')); |
254 | QStringList s_maps = config->readListEntry("sw", QChar('|')); | 254 | QStringList s_maps = config->readListEntry("sw", QChar('|')); |
255 | delete config; | 255 | delete config; |
256 | 256 | ||
257 | if (!s_maps.count()) | 257 | if (!s_maps.count()) |
258 | { | 258 | { |
259 | s_maps = d_maps+c_maps; | 259 | s_maps = d_maps+c_maps; |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | /* Clear non existents entries */ | 263 | /* Clear non existents entries */ |
264 | QStringList s_copy(s_maps); | 264 | QStringList s_copy(s_maps); |
265 | for (uint i = 0; i < s_copy.count(); ++i) { | 265 | for (uint i = 0; i < s_copy.count(); ++i) { |
266 | if (d_maps.find(s_copy[i]) == d_maps.end() | 266 | if (d_maps.find(s_copy[i]) == d_maps.end() |
267 | && c_maps.find(s_copy[i]) == c_maps.end()) { | 267 | && c_maps.find(s_copy[i]) == c_maps.end()) { |
268 | s_maps.remove(s_copy[i]); | 268 | s_maps.remove(s_copy[i]); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | /* Update sw_maps from default_maps */ | 271 | /* Update sw_maps from default_maps */ |
272 | for (uint i = 0; i < d_maps.count(); ++i) { | 272 | for (uint i = 0; i < d_maps.count(); ++i) { |
273 | if (s_maps.find(d_maps[i]) == s_maps.end()) { | 273 | if (s_maps.find(d_maps[i]) == s_maps.end()) { |
274 | s_maps.append(d_maps[i]); | 274 | s_maps.append(d_maps[i]); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | /* Update sw_maps from custom_maps */ | 277 | /* Update sw_maps from custom_maps */ |
278 | for (uint i = 0; i < c_maps.count(); ++i) { | 278 | for (uint i = 0; i < c_maps.count(); ++i) { |
279 | if (s_maps.find(c_maps[i]) == s_maps.end()) { | 279 | if (s_maps.find(c_maps[i]) == s_maps.end()) { |
280 | s_maps.append(c_maps[i]); | 280 | s_maps.append(c_maps[i]); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | return s_maps; | 285 | return s_maps; |
286 | } | 286 | } |
287 | 287 | ||
288 | void ConfigDlg::accept() | 288 | void ConfigDlg::accept() |
289 | { | 289 | { |
290 | /* Writing all stuffs to config */ | 290 | /* Writing all stuffs to config */ |
291 | Config *config = new Config("multikey"); | 291 | Config *config = new Config("multikey"); |
292 | config->setGroup("general"); | 292 | config->setGroup("general"); |
293 | config->writeEntry("usePickboard", pick_button->isChecked()); // default closed | 293 | config->writeEntry("usePickboard", pick_button->isChecked()); // default closed |
294 | config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed | 294 | config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed |
295 | 295 | ||
296 | config->setGroup("keymaps"); | 296 | config->setGroup("keymaps"); |
297 | config->writeEntry("sw", sw_maps, QChar('|')); | 297 | config->writeEntry("sw", sw_maps, QChar('|')); |
298 | config->writeEntry("maps", custom_maps, QChar('|')); | 298 | config->writeEntry("maps", custom_maps, QChar('|')); |
299 | delete config; | 299 | delete config; |
300 | 300 | ||
301 | int index = keymaps->currentItem(); | 301 | int index = keymaps->currentItem(); |
302 | if (index == 0) { | 302 | if (index == 0) { |
303 | 303 | ||
304 | remove_button->setDisabled(true); | 304 | remove_button->setDisabled(true); |
305 | emit setMapToDefault(); | 305 | emit setMapToDefault(); |
306 | } | 306 | } |
307 | 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()) { |
308 | 308 | ||
309 | remove_button->setDisabled(true); | 309 | remove_button->setDisabled(true); |
310 | emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); | 310 | emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); |
311 | 311 | ||
312 | } else { | 312 | } else { |
313 | 313 | ||
314 | remove_button->setEnabled(true); | 314 | remove_button->setEnabled(true); |
315 | emit setMapToFile(sw_maps[index - 1]); | 315 | emit setMapToFile(sw_maps[index - 1]); |
316 | } | 316 | } |
317 | 317 | ||
318 | emit pickboardToggled(pick_button->isChecked()); | 318 | emit pickboardToggled(pick_button->isChecked()); |
319 | emit repeatToggled(repeat_button->isChecked()); | 319 | emit repeatToggled(repeat_button->isChecked()); |
320 | emit reloadSw(); | 320 | emit reloadSw(); |
321 | 321 | ||
322 | QDialog::accept(); | 322 | QDialog::accept(); |
323 | emit configDlgClosed(); | 323 | emit configDlgClosed(); |
324 | } | 324 | } |
325 | 325 | ||
326 | void ConfigDlg::moveSelectedUp() | 326 | void ConfigDlg::moveSelectedUp() |
327 | { | 327 | { |
328 | int i = keymaps->currentItem(); | 328 | int i = keymaps->currentItem(); |
329 | /* Ignore Current Language */ | 329 | /* Ignore Current Language */ |
330 | if (i > 1) { | 330 | if (i > 1) { |
331 | QString t = sw_maps[i-1]; | 331 | QString t = sw_maps[i-1]; |
332 | sw_maps[i-1] = sw_maps[i-2]; | 332 | sw_maps[i-1] = sw_maps[i-2]; |
333 | sw_maps[i-2] = t; | 333 | sw_maps[i-2] = t; |
334 | 334 | ||
335 | QString item = keymaps->currentText(); | 335 | QString item = keymaps->currentText(); |
336 | keymaps->removeItem(i); | 336 | keymaps->removeItem(i); |
337 | keymaps->insertItem(item, i-1); | 337 | keymaps->insertItem(item, i-1); |
338 | keymaps->setCurrentItem(i-1); | 338 | keymaps->setCurrentItem(i-1); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void ConfigDlg::moveSelectedDown() | 342 | void ConfigDlg::moveSelectedDown() |
343 | { | 343 | { |
344 | int i = keymaps->currentItem(); | 344 | int i = keymaps->currentItem(); |
345 | /* Ignore Current Language */ | 345 | /* Ignore Current Language */ |
346 | if (i > 0 && i < (int)keymaps->count() - 1) { | 346 | if (i > 0 && i < (int)keymaps->count() - 1) { |
347 | QString t = sw_maps[i-1]; | 347 | QString t = sw_maps[i-1]; |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 7ddfd3e..f8cafd5 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1284,198 +1284,198 @@ ushort Keyboard::parseKoreanInput (ushort c) { | |||
1284 | return combineKoreanChars(schar, mchar, 0); | 1284 | return combineKoreanChars(schar, mchar, 0); |
1285 | 1285 | ||
1286 | } | 1286 | } |
1287 | else { | 1287 | else { |
1288 | schar = 0; mchar = 0; echar = 0; | 1288 | schar = 0; mchar = 0; echar = 0; |
1289 | return c; | 1289 | return c; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | } | 1292 | } |
1293 | else /*if (c == ' ')*/ return c; | 1293 | else /*if (c == ' ')*/ return c; |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | // and now... finally delete previous char, and return new char | 1296 | // and now... finally delete previous char, and return new char |
1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | return combineKoreanChars( schar, mchar, echar); | 1300 | return combineKoreanChars( schar, mchar, echar); |
1301 | 1301 | ||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1305 | 1305 | ||
1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1307 | 1307 | ||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | ushort Keyboard::constoe(const ushort c) { | 1310 | ushort Keyboard::constoe(const ushort c) { |
1311 | 1311 | ||
1312 | // converts schars to echars if possible | 1312 | // converts schars to echars if possible |
1313 | 1313 | ||
1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1315 | 1315 | ||
1316 | switch (c) { | 1316 | switch (c) { |
1317 | case 0x1100: return 0x11a8; | 1317 | case 0x1100: return 0x11a8; |
1318 | case 0x1101: return 0x11a9; | 1318 | case 0x1101: return 0x11a9; |
1319 | case 0x1102: return 0x11ab; | 1319 | case 0x1102: return 0x11ab; |
1320 | case 0x1103: return 0x11ae; | 1320 | case 0x1103: return 0x11ae; |
1321 | case 0x1105: return 0x11af; | 1321 | case 0x1105: return 0x11af; |
1322 | case 0x1106: return 0x11b7; | 1322 | case 0x1106: return 0x11b7; |
1323 | case 0x1107: return 0x11b8; | 1323 | case 0x1107: return 0x11b8; |
1324 | case 0x1109: return 0x11ba; | 1324 | case 0x1109: return 0x11ba; |
1325 | case 0x110a: return 0x11bb; | 1325 | case 0x110a: return 0x11bb; |
1326 | case 0x110b: return 0x11bc; | 1326 | case 0x110b: return 0x11bc; |
1327 | case 0x110c: return 0x11bd; | 1327 | case 0x110c: return 0x11bd; |
1328 | case 0x110e: return 0x11be; | 1328 | case 0x110e: return 0x11be; |
1329 | case 0x110f: return 0x11bf; | 1329 | case 0x110f: return 0x11bf; |
1330 | case 0x1110: return 0x11c0; | 1330 | case 0x1110: return 0x11c0; |
1331 | case 0x1111: return 0x11c1; | 1331 | case 0x1111: return 0x11c1; |
1332 | case 0x1112: return 0x11c2; | 1332 | case 0x1112: return 0x11c2; |
1333 | default: return 0; | 1333 | default: return 0; |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | } else { //echar to schar | 1337 | } else { //echar to schar |
1338 | 1338 | ||
1339 | switch (c) { | 1339 | switch (c) { |
1340 | case 0x11a8: return 0x1100; | 1340 | case 0x11a8: return 0x1100; |
1341 | case 0x11a9: return 0x1101; | 1341 | case 0x11a9: return 0x1101; |
1342 | case 0x11ab: return 0x1102; | 1342 | case 0x11ab: return 0x1102; |
1343 | case 0x11ae: return 0x1103; | 1343 | case 0x11ae: return 0x1103; |
1344 | case 0x11af: return 0x1105; | 1344 | case 0x11af: return 0x1105; |
1345 | case 0x11b7: return 0x1106; | 1345 | case 0x11b7: return 0x1106; |
1346 | case 0x11b8: return 0x1107; | 1346 | case 0x11b8: return 0x1107; |
1347 | case 0x11ba: return 0x1109; | 1347 | case 0x11ba: return 0x1109; |
1348 | case 0x11bb: return 0x110a; | 1348 | case 0x11bb: return 0x110a; |
1349 | case 0x11bc: return 0x110b; | 1349 | case 0x11bc: return 0x110b; |
1350 | case 0x11bd: return 0x110c; | 1350 | case 0x11bd: return 0x110c; |
1351 | case 0x11be: return 0x110e; | 1351 | case 0x11be: return 0x110e; |
1352 | case 0x11bf: return 0x110f; | 1352 | case 0x11bf: return 0x110f; |
1353 | case 0x11c0: return 0x1110; | 1353 | case 0x11c0: return 0x1110; |
1354 | case 0x11c1: return 0x1111; | 1354 | case 0x11c1: return 0x1111; |
1355 | case 0x11c2: return 0x1112; | 1355 | case 0x11c2: return 0x1112; |
1356 | default: return 0; | 1356 | default: return 0; |
1357 | 1357 | ||
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | 1363 | ||
1364 | // Keys::Keys {{{1 | 1364 | // Keys::Keys {{{1 |
1365 | 1365 | ||
1366 | Keys::Keys() { | 1366 | Keys::Keys() { |
1367 | 1367 | ||
1368 | Config *config = new Config ("multikey"); | 1368 | Config *config = new Config ("multikey"); |
1369 | config->setGroup( "keymaps" ); | 1369 | config->setGroup( "keymaps" ); |
1370 | QString map = config->readEntry( "current" ); | 1370 | QString map = config->readEntry( "current" ); |
1371 | delete config; | 1371 | delete config; |
1372 | 1372 | ||
1373 | if (map.isNull() || !(QFile(map).exists())) { | 1373 | if (map.isNull() || !(QFile(map).exists())) { |
1374 | 1374 | ||
1375 | Config *config = new Config("locale"); | 1375 | Config *config = new Config("locale"); |
1376 | config->setGroup( "Language" ); | 1376 | config->setGroup( "Language" ); |
1377 | QString l = config->readEntry( "Language" , "en" ); | 1377 | QString l = config->readEntry( "Language" , "en" ); |
1378 | delete config; | 1378 | delete config; |
1379 | 1379 | ||
1380 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1380 | map = QPEApplication::qpeDir() + "share/multikey/" |
1381 | + l + ".keymap"; | 1381 | + l + ".keymap"; |
1382 | 1382 | ||
1383 | } | 1383 | } |
1384 | if (map.isNull() || !(QFile(map).exists())) { | 1384 | if (map.isNull() || !(QFile(map).exists())) { |
1385 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; | 1385 | map = QPEApplication::qpeDir() + "share/multikey/en.keymap"; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | setKeysFromFile(map); | 1388 | setKeysFromFile(map); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | Keys::Keys(const char * filename) { | 1391 | Keys::Keys(const char * filename) { |
1392 | 1392 | ||
1393 | setKeysFromFile(filename); | 1393 | setKeysFromFile(filename); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | // Keys::setKeysFromFile {{{2 | 1396 | // Keys::setKeysFromFile {{{2 |
1397 | void Keys::setKeysFromFile(const char * filename) { | 1397 | void Keys::setKeysFromFile(const char * filename) { |
1398 | 1398 | ||
1399 | QFile f(filename); | 1399 | QFile f(filename); |
1400 | 1400 | ||
1401 | if (f.open(IO_ReadOnly)) { | 1401 | if (f.open(IO_ReadOnly)) { |
1402 | 1402 | ||
1403 | QTextStream t(&f); | 1403 | QTextStream t(&f); |
1404 | int row; | 1404 | int row; |
1405 | int qcode; | 1405 | int qcode; |
1406 | ushort unicode; | 1406 | ushort unicode; |
1407 | int width; | 1407 | int width; |
1408 | QString buf; | 1408 | QString buf; |
1409 | QString comment; | 1409 | QString comment; |
1410 | char * xpm[256]; //couldnt be larger than that... could it? | 1410 | char * xpm[256]; //couldnt be larger than that... could it? |
1411 | QImage *xpm2pix = 0; | 1411 | QImage *xpm2pix = 0; |
1412 | 1412 | ||
1413 | buf = t.readLine(); | 1413 | buf = t.readLine(); |
1414 | while (buf) { | 1414 | while (buf) { |
1415 | 1415 | ||
1416 | // get rid of comments | 1416 | // get rid of comments |
1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1418 | 1418 | ||
1419 | // key definition | 1419 | // key definition |
1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1421 | // no $1 type referencing!!! this implementation of regexp sucks | 1421 | // no $1 type referencing!!! this implementation of regexp sucks |
1422 | 1422 | ||
1423 | // dont know of any sscanf() type funcs in Qt lib | 1423 | // dont know of any sscanf() type funcs in Qt lib |
1424 | QTextStream tmp (buf, IO_ReadOnly); | 1424 | QTextStream tmp (buf, IO_ReadOnly); |
1425 | tmp >> row >> qcode >> unicode >> width >> comment; | 1425 | tmp >> row >> qcode >> unicode >> width >> comment; |
1426 | 1426 | ||
1427 | buf = t.readLine(); | 1427 | buf = t.readLine(); |
1428 | int xpmLineCount = 0; | 1428 | int xpmLineCount = 0; |
1429 | xpm2pix = 0; | 1429 | xpm2pix = 0; |
1430 | 1430 | ||
1431 | // erase blank space | 1431 | // erase blank space |
1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1433 | 1433 | ||
1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1435 | 1435 | ||
1436 | QString xpmBuf = buf.stripWhiteSpace(); | 1436 | QString xpmBuf = buf.stripWhiteSpace(); |
1437 | 1437 | ||
1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1439 | 1439 | ||
1440 | int j = 0; | 1440 | int j = 0; |
1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1442 | if (xpmBuf[i].latin1() != '"') { | 1442 | if (xpmBuf[i].latin1() != '"') { |
1443 | 1443 | ||
1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1445 | j++; | 1445 | j++; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | } | 1448 | } |
1449 | // have to close that facker up | 1449 | // have to close that facker up |
1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1451 | 1451 | ||
1452 | xpmLineCount++; | 1452 | xpmLineCount++; |
1453 | buf = t.readLine(); | 1453 | buf = t.readLine(); |
1454 | } | 1454 | } |
1455 | if (xpmLineCount) { | 1455 | if (xpmLineCount) { |
1456 | 1456 | ||
1457 | xpm2pix = new QImage((const char **)xpm); | 1457 | xpm2pix = new QImage((const char **)xpm); |
1458 | for (int i = 0; i < xpmLineCount; i++) | 1458 | for (int i = 0; i < xpmLineCount; i++) |
1459 | 1459 | ||
1460 | delete [] (xpm[i]); | 1460 | delete [] (xpm[i]); |
1461 | 1461 | ||
1462 | } | 1462 | } |
1463 | setKey(row, qcode, unicode, width, xpm2pix); | 1463 | setKey(row, qcode, unicode, width, xpm2pix); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | // shift map | 1466 | // shift map |
1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1468 | 1468 | ||
1469 | QTextStream tmp (buf, IO_ReadOnly); | 1469 | QTextStream tmp (buf, IO_ReadOnly); |
1470 | ushort lower, shift; | 1470 | ushort lower, shift; |
1471 | tmp >> lower >> shift; | 1471 | tmp >> lower >> shift; |
1472 | 1472 | ||
1473 | shiftMap.insert(lower, shift); | 1473 | shiftMap.insert(lower, shift); |
1474 | 1474 | ||
1475 | buf = t.readLine(); | 1475 | buf = t.readLine(); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | // meta key map | 1478 | // meta key map |
1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1480 | 1480 | ||
1481 | QTextStream tmp (buf, IO_ReadOnly); | 1481 | QTextStream tmp (buf, IO_ReadOnly); |