summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/configdlg.cpp
Unidiff
Diffstat (limited to 'inputmethods/multikey/configdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp54
1 files changed, 46 insertions, 8 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index ac132d3..1e104a6 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,6 +1,7 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make a cursor thing
4 * 5 *
5 * 6 *
6 * 7 *
@@ -24,11 +25,13 @@
24#include <qlistbox.h> 25#include <qlistbox.h>
25#include <qstringlist.h> 26#include <qstringlist.h>
26#include <opie/ofiledialog.h> 27#include <opie/ofiledialog.h>
28#include <opie/colordialog.h>
27#include <qdir.h> 29#include <qdir.h>
28#include <qfileinfo.h> 30#include <qfileinfo.h>
29#include "configdlg.h" 31#include "configdlg.h"
30#include "keyboard.h" 32#include "keyboard.h"
31 33
34// ConfigDlg::ConfigDlg() {{{1
32ConfigDlg::ConfigDlg () : QTabWidget () 35ConfigDlg::ConfigDlg () : QTabWidget ()
33{ 36{
34 setCaption( tr("Multikey Configuration") ); 37 setCaption( tr("Multikey Configuration") );
@@ -104,6 +107,8 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
104 107
105 remove_button = new QPushButton(tr("Remove"), add_remove_grid); 108 remove_button = new QPushButton(tr("Remove"), add_remove_grid);
106 remove_button->setFlat((bool)1); 109 remove_button->setFlat((bool)1);
110 if ((int)map_dir.count() >= keymaps->currentItem())
111 remove_button->setDisabled(true);
107 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); 112 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
108 113
109 pick_button = new QCheckBox(tr("Pickboard"), gen_box); 114 pick_button = new QCheckBox(tr("Pickboard"), gen_box);
@@ -129,12 +134,25 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
129 addTab(color_box, tr("Colors")); 134 addTab(color_box, tr("Colors"));
130 135
131 QLabel *label; 136 QLabel *label;
137 QStringList color;
132 138
133 label = new QLabel(tr("Key Color"), color_box); 139 label = new QLabel(tr("Key Color"), color_box);
134 QPushButton *button = new QPushButton(color_box); 140 key_color_button = new QPushButton(color_box);
135 button->setFlat((bool)1); 141 connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked()));
142 key_color_button->setFlat((bool)1);
143
144 config.setGroup("colors");
145 color = config.readListEntry("keycolor", QChar(','));
146 if (color.isEmpty()) {
147 color = QStringList::split(",", "240,240,240");
148 config.writeEntry("keycolor", color.join(","));
149
150 }
151 key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
152
153
136 label = new QLabel(tr("Key Pressed Color"), color_box); 154 label = new QLabel(tr("Key Pressed Color"), color_box);
137 button = new QPushButton(color_box); 155 QPushButton *button = new QPushButton(color_box);
138 button->setFlat((bool)1); 156 button->setFlat((bool)1);
139 label = new QLabel(tr("Line Color"), color_box); 157 label = new QLabel(tr("Line Color"), color_box);
140 button = new QPushButton(color_box); 158 button = new QPushButton(color_box);
@@ -164,28 +182,27 @@ void ConfigDlg::pickTog() {
164 * 182 *
165 */ 183 */
166 184
185// ConfigDlg::setMap {{{1
167void ConfigDlg::setMap(int index) { 186void ConfigDlg::setMap(int index) {
168 187
169 if (index == 0) { 188 if (index == 0) {
170 189
171 remove_button->setDisabled(true); 190 remove_button->setDisabled(true);
172
173 emit setMapToDefault(); 191 emit setMapToDefault();
174 } 192 }
175 else if ((uint)index <= default_maps.count()) { 193 else if ((uint)index <= default_maps.count()) {
176 194
177 remove_button->setDisabled(true); 195 remove_button->setDisabled(true);
178
179 emit setMapToFile(keymaps->text(index)); 196 emit setMapToFile(keymaps->text(index));
180 197
181 } else { 198 } else {
182 199
183 remove_button->setEnabled(true); 200 remove_button->setEnabled(true);
184
185 emit setMapToFile(keymaps->text(index)); 201 emit setMapToFile(keymaps->text(index));
186 } 202 }
187} 203}
188 204
205// ConfigDlg::addMap() {{{1
189void ConfigDlg::addMap() { 206void ConfigDlg::addMap() {
190 207
191 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 208 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
@@ -197,11 +214,12 @@ void ConfigDlg::addMap() {
197 keymaps->setSelected(keymaps->count() - 1, true); 214 keymaps->setSelected(keymaps->count() - 1, true);
198 215
199 216
200 config.writeEntry("maps", maps.join("|")); 217 config.writeEntry("maps", maps, QChar('|'));
201 config.writeEntry("current", map); 218 config.writeEntry("current", map);
202 219
203} 220}
204 221
222// ConfigDlg::removeMap() {{{1
205void ConfigDlg::removeMap() { 223void ConfigDlg::removeMap() {
206 224
207 cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n"; 225 cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n";
@@ -217,5 +235,25 @@ void ConfigDlg::removeMap() {
217 // write the changes 235 // write the changes
218 Config config ("multikey"); 236 Config config ("multikey");
219 config.setGroup("keymaps"); 237 config.setGroup("keymaps");
220 config.writeEntry("maps", custom_maps.join("|")); 238 config.writeEntry("maps", custom_maps, QChar('|'));
239}
240
241// ConfigDlg::color {{{1
242void ConfigDlg::keyColorButtonClicked() {
243
244 Config config ("multikey");
245 config.setGroup ("colors");
246
247 QStringList color = config.readListEntry("keycolor", QChar(','));
248
249 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
250
251 color[0].setNum(newcolor.red());
252 color[1].setNum(newcolor.green());
253 color[2].setNum(newcolor.blue());
254
255 config.writeEntry("keycolor", color, QChar(','));
256
257 key_color_button->setBackgroundColor(newcolor);
258 emit reloadKeyboard();
221} 259}