Diffstat (limited to 'inputmethods/multikey/configdlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 4 |
1 files changed, 2 insertions, 2 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]; |