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