summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp54
-rw-r--r--inputmethods/multikey/configdlg.h7
-rw-r--r--inputmethods/multikey/keyboard.cpp65
-rw-r--r--inputmethods/multikey/keyboard.h10
4 files changed, 120 insertions, 16 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,43 +1,46 @@
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 *
7 */ 8 */
8 9
9#include <iostream.h> 10#include <iostream.h>
10 11
11#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 13#include <qpe/config.h>
13 14
14#include <qwidget.h> 15#include <qwidget.h>
15#include <qdialog.h> 16#include <qdialog.h>
16#include <qtabwidget.h> 17#include <qtabwidget.h>
17#include <qvbox.h> 18#include <qvbox.h>
18#include <qgrid.h> 19#include <qgrid.h>
19#include <qgroupbox.h> 20#include <qgroupbox.h>
20#include <qlabel.h> 21#include <qlabel.h>
21#include <qcheckbox.h> 22#include <qcheckbox.h>
22#include <qsizepolicy.h> 23#include <qsizepolicy.h>
23#include <qpushbutton.h> 24#include <qpushbutton.h>
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") );
35 Config config ("multikey"); 38 Config config ("multikey");
36 config.setGroup("keymaps"); 39 config.setGroup("keymaps");
37 QString current_map = config.readEntry("current", 0); 40 QString current_map = config.readEntry("current", 0);
38 41
39 /* 42 /*
40 * 'general config' tab 43 * 'general config' tab
41 */ 44 */
42 45
43 QVBox *gen_box = new QVBox (this); 46 QVBox *gen_box = new QVBox (this);
@@ -95,24 +98,26 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
95 98
96 99
97 QGrid *add_remove_grid = new QGrid(2, map_group); 100 QGrid *add_remove_grid = new QGrid(2, map_group);
98 add_remove_grid->setMargin(3); 101 add_remove_grid->setMargin(3);
99 add_remove_grid->setSpacing(3); 102 add_remove_grid->setSpacing(3);
100 103
101 add_button = new QPushButton(tr("Add"), add_remove_grid); 104 add_button = new QPushButton(tr("Add"), add_remove_grid);
102 add_button->setFlat((bool)1); 105 add_button->setFlat((bool)1);
103 connect(add_button, SIGNAL(clicked()), SLOT(addMap())); 106 connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
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);
110 115
111 config.setGroup ("pickboard"); 116 config.setGroup ("pickboard");
112 bool pick_open = config.readBoolEntry ("open", "0"); // default closed 117 bool pick_open = config.readBoolEntry ("open", "0"); // default closed
113 if (pick_open) { 118 if (pick_open) {
114 119
115 pick_button->setChecked(true); 120 pick_button->setChecked(true);
116 } 121 }
117 122
118 // by connecting it after checking it, the signal isn't emmited 123 // by connecting it after checking it, the signal isn't emmited
@@ -120,30 +125,43 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
120 125
121 /* 126 /*
122 * 'color' tab 127 * 'color' tab
123 */ 128 */
124 129
125 QGrid *color_box = new QGrid(2, this); 130 QGrid *color_box = new QGrid(2, this);
126 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 131 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
127 color_box->setMargin(3); 132 color_box->setMargin(3);
128 color_box->setSpacing(3); 133 color_box->setSpacing(3);
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);
141 button->setFlat((bool)1); 159 button->setFlat((bool)1);
142 label = new QLabel(tr("Text Color"), color_box); 160 label = new QLabel(tr("Text Color"), color_box);
143 button = new QPushButton(color_box); 161 button = new QPushButton(color_box);
144 button->setFlat((bool)1); 162 button->setFlat((bool)1);
145 163
146 label = new QLabel("", color_box); // a spacer so the above buttons dont expand 164 label = new QLabel("", color_box); // a spacer so the above buttons dont expand
147 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 165 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
148 166
149} 167}
@@ -155,67 +173,87 @@ void ConfigDlg::pickTog() {
155 config.writeEntry ("open", pick_button->isChecked()); // default closed 173 config.writeEntry ("open", pick_button->isChecked()); // default closed
156 174
157 emit pickboardToggled(pick_button->isChecked()); 175 emit pickboardToggled(pick_button->isChecked());
158} 176}
159 177
160/* 178/*
161 * the index is kinda screwy, because in the config file, index 0 is just the 179 * the index is kinda screwy, because in the config file, index 0 is just the
162 * first element in the QStringList, but here it's the "Current Language" 180 * first element in the QStringList, but here it's the "Current Language"
163 * listItem. therefor you have to minus one to the index before you access it. 181 * listItem. therefor you have to minus one to the index before you access it.
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());
192 Config config ("multikey"); 209 Config config ("multikey");
193 config.setGroup("keymaps"); 210 config.setGroup("keymaps");
194 QStringList maps = config.readListEntry("maps", QChar('|')); 211 QStringList maps = config.readListEntry("maps", QChar('|'));
195 maps.append(map); 212 maps.append(map);
196 keymaps->insertItem(map); 213 keymaps->insertItem(map);
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";
208 cout << "currentItem : " << keymaps->currentItem() << "\n"; 226 cout << "currentItem : " << keymaps->currentItem() << "\n";
209 227
210 // move selection up one 228 // move selection up one
211 keymaps->setSelected(keymaps->currentItem() - 1, true); 229 keymaps->setSelected(keymaps->currentItem() - 1, true);
212 // delete the next selected item cus you just moved it up 230 // delete the next selected item cus you just moved it up
213 keymaps->removeItem(keymaps->currentItem() + 1); 231 keymaps->removeItem(keymaps->currentItem() + 1);
214 232
215 custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); 233 custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]);
216 234
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}
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h
index 07d109c..ae7afe2 100644
--- a/inputmethods/multikey/configdlg.h
+++ b/inputmethods/multikey/configdlg.h
@@ -9,32 +9,39 @@
9 9
10class ConfigDlg : public QTabWidget 10class ConfigDlg : public QTabWidget
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 ConfigDlg (); 15 ConfigDlg ();
16 16
17signals: 17signals:
18 void pickboardToggled(bool on_off); 18 void pickboardToggled(bool on_off);
19 void setMapToDefault(); 19 void setMapToDefault();
20 void setMapToFile(QString map); 20 void setMapToFile(QString map);
21 void reloadKeyboard();
21 22
22private slots: 23private slots:
23 void pickTog(); 24 void pickTog();
24 void setMap(int index); 25 void setMap(int index);
25 void addMap(); 26 void addMap();
26 void removeMap(); 27 void removeMap();
27 28
29 // all those required slots for the color push buttons
30 void keyColorButtonClicked();
31
28private: 32private:
29 QCheckBox *pick_button; 33 QCheckBox *pick_button;
30 QListBox *keymaps; 34 QListBox *keymaps;
31 QPushButton *add_button; 35 QPushButton *add_button;
32 QPushButton *remove_button; 36 QPushButton *remove_button;
33 37
34 38
35 QStringList default_maps; // the maps in your share/multikey/ dir 39 QStringList default_maps; // the maps in your share/multikey/ dir
36 QStringList custom_maps; // maps you added with the 'add' button 40 QStringList custom_maps; // maps you added with the 'add' button
37 41
42 /* color buttons */
43 QPushButton *key_color_button;
44
38}; 45};
39 46
40#endif 47#endif
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index ac3d9be..68918a6 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -40,53 +40,57 @@
40 40
41 41
42#define USE_SMALL_BACKSPACE 42#define USE_SMALL_BACKSPACE
43 43
44/* Keyboard::Keyboard {{{1 */ 44/* Keyboard::Keyboard {{{1 */
45Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 45Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
46 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), 46 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0),
47 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), 47 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1),
48 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 48 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
49 configdlg(0) 49 configdlg(0)
50 50
51{ 51{
52
52 // get the default font 53 // get the default font
53 Config *config = new Config( "qpe" ); 54 Config *config = new Config( "qpe" );
54 config->setGroup( "Appearance" ); 55 config->setGroup( "Appearance" );
55 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 56 QString familyStr = config->readEntry( "FontFamily", "fixed" );
56 delete config; 57 delete config;
57 58
58 config = new Config("multikey"); 59 config = new Config("multikey");
59 config->setGroup ("pickboard"); 60 config->setGroup ("pickboard");
60 usePicks = config->readBoolEntry ("open", "0"); // default closed 61 usePicks = config->readBoolEntry ("open", "0"); // default closed
61 delete config; 62 delete config;
62 63
63 setFont( QFont( familyStr, 10 ) ); 64 setFont( QFont( familyStr, 10 ) );
64 65
65 picks = new KeyboardPicks( this ); 66 picks = new KeyboardPicks( this );
66 picks->setFont( QFont( familyStr, 10 ) ); 67 picks->setFont( QFont( familyStr, 10 ) );
67 picks->initialise(); 68 picks->initialise();
68 if (usePicks) { 69 if (usePicks) {
69 70
70 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 71 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
71 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 72 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
72 73
73 } else picks->hide(); 74 } else picks->hide();
74 75
76 loadKeyboardColors();
77
75 keys = new Keys(); 78 keys = new Keys();
76 79
77 repeatTimer = new QTimer( this ); 80 repeatTimer = new QTimer( this );
78 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 81 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
79 82
80} 83}
84
81Keyboard::~Keyboard() { 85Keyboard::~Keyboard() {
82 86
83 if ( configdlg ) { 87 if ( configdlg ) {
84 delete (ConfigDlg *) configdlg; 88 delete (ConfigDlg *) configdlg;
85 configdlg = 0; 89 configdlg = 0;
86 } 90 }
87 91
88} 92}
89 93
90/* Keyboard::resizeEvent {{{1 */ 94/* Keyboard::resizeEvent {{{1 */
91void Keyboard::resizeEvent(QResizeEvent*) 95void Keyboard::resizeEvent(QResizeEvent*)
92{ 96{
@@ -147,56 +151,50 @@ void Keyboard::paintEvent(QPaintEvent* e)
147{ 151{
148 QPainter painter(this); 152 QPainter painter(this);
149 painter.setClipRect(e->rect()); 153 painter.setClipRect(e->rect());
150 drawKeyboard( painter ); 154 drawKeyboard( painter );
151 picks->dc->draw( &painter ); 155 picks->dc->draw( &painter );
152} 156}
153 157
154 158
155/* Keyboard::drawKeyboard {{{1 */ 159/* Keyboard::drawKeyboard {{{1 */
156 160
157void Keyboard::drawKeyboard(QPainter &p, int row, int col) 161void Keyboard::drawKeyboard(QPainter &p, int row, int col)
158{ 162{
159 QColor keycolor =
160 QColor(240,240,240);
161 QColor keycolor_pressed = QColor(171,183,198);
162 QColor keycolor_lines = QColor(138,148,160);
163 QColor textcolor = QColor(43,54,68);
164 163
165 164
166 if (row != -1 && col != -1) { //just redraw one key 165 if (row != -1 && col != -1) { //just redraw one key
167 166
168 int x = 0; 167 int x = 0;
169 for (int i = 0; i < col; i++) { 168 for (int i = 0; i < col; i++) {
170 169
171 x += keys->width(row, i) * defaultKeyWidth; 170 x += keys->width(row, i) * defaultKeyWidth;
172 } 171 }
173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
174 173
175 int keyWidth = keys->width(row, col); 174 int keyWidth = keys->width(row, col);
176 175
177 p.fillRect(x + 1, y + 1, 176 p.fillRect(x + 1, y + 1,
178 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 177 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
180 179
181 QPixmap *pix = keys->pix(row,col); 180 QPixmap *pix = keys->pix(row,col);
182 181
183 ushort c = keys->uni(row, col); 182 ushort c = keys->uni(row, col);
184 183
185 if (!pix) { 184 p.setPen(textcolor);
186 p.setPen(textcolor); 185 if (!pix)
187 p.drawText(x, y, 186 p.drawText(x, y,
188 defaultKeyWidth * keyWidth, keyHeight, 187 defaultKeyWidth * keyWidth, keyHeight,
189 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); 188 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
190 }
191 else 189 else
192 // center the image in the middle of the key 190 // center the image in the middle of the key
193 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 191 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
194 y + (keyHeight - pix->height())/2 + 1, 192 y + (keyHeight - pix->height())/2 + 1,
195 *pix ); 193 *pix );
196 194
197 // this fixes the problem that the very right end of the board's vertical line 195 // this fixes the problem that the very right end of the board's vertical line
198 // gets painted over, because it's one pixel shorter than all other keys 196 // gets painted over, because it's one pixel shorter than all other keys
199 p.setPen(keycolor_lines); 197 p.setPen(keycolor_lines);
200 p.drawLine(width() - 1, 0, width() - 1, height()); 198 p.drawLine(width() - 1, 0, width() - 1, height());
201 199
202 } else { 200 } else {
@@ -283,24 +281,26 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
283 if ( configdlg ) { 281 if ( configdlg ) {
284 delete (ConfigDlg *) configdlg; 282 delete (ConfigDlg *) configdlg;
285 configdlg = 0; 283 configdlg = 0;
286 } 284 }
287 else { 285 else {
288 configdlg = new ConfigDlg (); 286 configdlg = new ConfigDlg ();
289 connect(configdlg, SIGNAL(pickboardToggled(bool)), 287 connect(configdlg, SIGNAL(pickboardToggled(bool)),
290 this, SLOT(togglePickboard(bool))); 288 this, SLOT(togglePickboard(bool)));
291 connect(configdlg, SIGNAL(setMapToDefault()), 289 connect(configdlg, SIGNAL(setMapToDefault()),
292 this, SLOT(setMapToDefault())); 290 this, SLOT(setMapToDefault()));
293 connect(configdlg, SIGNAL(setMapToFile(QString)), 291 connect(configdlg, SIGNAL(setMapToFile(QString)),
294 this, SLOT(setMapToFile(QString))); 292 this, SLOT(setMapToFile(QString)));
293 connect(configdlg, SIGNAL(reloadKeyboard()),
294 this, SLOT(reloadKeyboard()));
295 configdlg->showMaximized(); 295 configdlg->showMaximized();
296 configdlg->show(); 296 configdlg->show();
297 configdlg->raise(); 297 configdlg->raise();
298 } 298 }
299 299
300 } else if (qkeycode == Qt::Key_Control) { 300 } else if (qkeycode == Qt::Key_Control) {
301 ctrl = keys->pressedPtr(row, col); 301 ctrl = keys->pressedPtr(row, col);
302 need_repaint = TRUE; 302 need_repaint = TRUE;
303 *ctrl = !keys->pressed(row, col); 303 *ctrl = !keys->pressed(row, col);
304 304
305 } else if (qkeycode == Qt::Key_Alt) { 305 } else if (qkeycode == Qt::Key_Alt) {
306 alt = keys->pressedPtr(row, col); 306 alt = keys->pressedPtr(row, col);
@@ -539,24 +539,73 @@ void Keyboard::setMapToFile(QString map) {
539 delete config; 539 delete config;
540 540
541 delete keys; 541 delete keys;
542 if (QFile(map).exists()) 542 if (QFile(map).exists())
543 keys = new Keys(map); 543 keys = new Keys(map);
544 else 544 else
545 keys = new Keys(); 545 keys = new Keys();
546 546
547 repaint(FALSE); 547 repaint(FALSE);
548 548
549} 549}
550 550
551/* Keybaord::setColor {{{1 */
552void Keyboard::reloadKeyboard() {
553
554 // reload colors and redraw
555 loadKeyboardColors();
556 repaint();
557
558}
559
560void Keyboard::loadKeyboardColors() {
561
562 Config config ("multikey");
563 config.setGroup("colors");
564
565 QStringList color;
566 color = config.readListEntry("keycolor", QChar(','));
567 if (color.isEmpty()) {
568 color = QStringList::split(",", "240,240,240");
569 config.writeEntry("keycolor", color.join(","));
570
571 }
572 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
573
574 color = config.readListEntry("keycolor_pressed", QChar(','));
575 if (color.isEmpty()) {
576 color = QStringList::split(",", "171,183,198");
577 config.writeEntry("keycolor_pressed", color.join(","));
578
579 }
580 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
581
582 color = config.readListEntry("keycolor_lines", QChar(','));
583 if (color.isEmpty()) {
584 color = QStringList::split(",", "138,148,160");
585 config.writeEntry("keycolor_lines", color.join(","));
586
587 }
588 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
589
590 color = config.readListEntry("textcolor", QChar(','));
591 if (color.isEmpty()) {
592 color = QStringList::split(",", "43,54,68");
593 config.writeEntry("textcolor", color.join(","));
594
595 }
596 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
597
598}
599
551/* korean input functions {{{1 600/* korean input functions {{{1
552 * 601 *
553 * TODO 602 * TODO
554 * one major problem with this implementation is that you can't move the 603 * one major problem with this implementation is that you can't move the
555 * cursor after inputing korean chars, otherwise it will eat up and replace 604 * cursor after inputing korean chars, otherwise it will eat up and replace
556 * the char before the cursor you move to. fix that 605 * the char before the cursor you move to. fix that
557 * 606 *
558 * make backspace delete one single char, not the whole thing if still 607 * make backspace delete one single char, not the whole thing if still
559 * editing. 608 * editing.
560 * 609 *
561 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 610 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
562 * 611 *
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 8c4e666..6e577ab 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -105,24 +105,27 @@ public:
105 void drawKeyboard( QPainter &p, int row = -1, int col = -1); 105 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
106 106
107 QSize sizeHint() const; 107 QSize sizeHint() const;
108 108
109signals: 109signals:
110 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 110 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
111 111
112private slots: 112private slots:
113 void repeat(); 113 void repeat();
114 void togglePickboard(bool on_off); 114 void togglePickboard(bool on_off);
115 void setMapToDefault(); 115 void setMapToDefault();
116 void setMapToFile(QString map); 116 void setMapToFile(QString map);
117
118 // used to redraw keyboard after edited colors
119 void reloadKeyboard();
117 120
118private: 121private:
119 int getKey( int &w, int j = -1 ); 122 int getKey( int &w, int j = -1 );
120 void clearHighlight(); 123 void clearHighlight();
121 124
122 bool *shift; 125 bool *shift;
123 bool *lock; 126 bool *lock;
124 bool *ctrl; 127 bool *ctrl;
125 bool *alt; 128 bool *alt;
126 uint useLargeKeys:1; 129 uint useLargeKeys:1;
127 uint usePicks:1; 130 uint usePicks:1;
128 131
@@ -143,16 +146,23 @@ private:
143 bool pressed; 146 bool pressed;
144 147
145 Keys *keys; 148 Keys *keys;
146 149
147 /* for korean input */ 150 /* for korean input */
148 ushort schar, mchar, echar; 151 ushort schar, mchar, echar;
149 ushort parseKoreanInput(ushort c); 152 ushort parseKoreanInput(ushort c);
150 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); 153 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
151 ushort constoe(const ushort c); 154 ushort constoe(const ushort c);
152 155
153 QTimer *repeatTimer; 156 QTimer *repeatTimer;
154 157
158 /* colors */
159 void loadKeyboardColors();
160 QColor keycolor;
161 QColor keycolor_pressed;
162 QColor keycolor_lines;
163 QColor textcolor;
164
155 ConfigDlg *configdlg; 165 ConfigDlg *configdlg;
156}; 166};
157 167
158 168