author | hash <hash> | 2002-08-19 17:47:09 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-19 17:47:09 (UTC) |
commit | d68e038d1ba78a816e60990d5a36d6c52d8e11d3 (patch) (unidiff) | |
tree | 4b63d843d3a64d35567205d4aa50e1cfc53d99b4 | |
parent | 9cc94030d7f6a04b79da8db83e6c609c1580a3d3 (diff) | |
download | opie-d68e038d1ba78a816e60990d5a36d6c52d8e11d3.zip opie-d68e038d1ba78a816e60990d5a36d6c52d8e11d3.tar.gz opie-d68e038d1ba78a816e60990d5a36d6c52d8e11d3.tar.bz2 |
added simple color changing
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 54 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 7 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 63 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 10 |
4 files changed, 119 insertions, 15 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 | |||
@@ -2,4 +2,5 @@ | |||
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 | * |
@@ -25,4 +26,5 @@ | |||
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> |
@@ -30,4 +32,5 @@ | |||
30 | #include "keyboard.h" | 32 | #include "keyboard.h" |
31 | 33 | ||
34 | // ConfigDlg::ConfigDlg() {{{1 | ||
32 | ConfigDlg::ConfigDlg () : QTabWidget () | 35 | ConfigDlg::ConfigDlg () : QTabWidget () |
33 | { | 36 | { |
@@ -105,4 +108,6 @@ ConfigDlg::ConfigDlg () : QTabWidget () | |||
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 | ||
@@ -130,10 +135,23 @@ ConfigDlg::ConfigDlg () : QTabWidget () | |||
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); |
@@ -165,4 +183,5 @@ void ConfigDlg::pickTog() { | |||
165 | */ | 183 | */ |
166 | 184 | ||
185 | // ConfigDlg::setMap {{{1 | ||
167 | void ConfigDlg::setMap(int index) { | 186 | void ConfigDlg::setMap(int index) { |
168 | 187 | ||
@@ -170,5 +189,4 @@ void ConfigDlg::setMap(int index) { | |||
170 | 189 | ||
171 | remove_button->setDisabled(true); | 190 | remove_button->setDisabled(true); |
172 | |||
173 | emit setMapToDefault(); | 191 | emit setMapToDefault(); |
174 | } | 192 | } |
@@ -176,5 +194,4 @@ void ConfigDlg::setMap(int index) { | |||
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 | ||
@@ -182,9 +199,9 @@ void ConfigDlg::setMap(int index) { | |||
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 | ||
189 | void ConfigDlg::addMap() { | 206 | void ConfigDlg::addMap() { |
190 | 207 | ||
@@ -198,9 +215,10 @@ void ConfigDlg::addMap() { | |||
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 | ||
205 | void ConfigDlg::removeMap() { | 223 | void ConfigDlg::removeMap() { |
206 | 224 | ||
@@ -218,4 +236,24 @@ void ConfigDlg::removeMap() { | |||
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 | ||
242 | void 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 | |||
@@ -19,4 +19,5 @@ signals: | |||
19 | void setMapToDefault(); | 19 | void setMapToDefault(); |
20 | void setMapToFile(QString map); | 20 | void setMapToFile(QString map); |
21 | void reloadKeyboard(); | ||
21 | 22 | ||
22 | private slots: | 23 | private slots: |
@@ -26,4 +27,7 @@ private slots: | |||
26 | void removeMap(); | 27 | void removeMap(); |
27 | 28 | ||
29 | // all those required slots for the color push buttons | ||
30 | void keyColorButtonClicked(); | ||
31 | |||
28 | private: | 32 | private: |
29 | QCheckBox *pick_button; | 33 | QCheckBox *pick_button; |
@@ -36,4 +40,7 @@ private: | |||
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 | ||
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 | |||
@@ -50,4 +50,5 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | |||
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" ); |
@@ -73,4 +74,6 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | |||
73 | } else picks->hide(); | 74 | } else picks->hide(); |
74 | 75 | ||
76 | loadKeyboardColors(); | ||
77 | |||
75 | keys = new Keys(); | 78 | keys = new Keys(); |
76 | 79 | ||
@@ -79,4 +82,5 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | |||
79 | 82 | ||
80 | } | 83 | } |
84 | |||
81 | Keyboard::~Keyboard() { | 85 | Keyboard::~Keyboard() { |
82 | 86 | ||
@@ -157,9 +161,4 @@ void Keyboard::paintEvent(QPaintEvent* e) | |||
157 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 161 | void 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 | ||
@@ -183,10 +182,9 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
183 | ushort c = keys->uni(row, col); | 182 | ushort c = keys->uni(row, col); |
184 | 183 | ||
185 | if (!pix) { | ||
186 | p.setPen(textcolor); | 184 | 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 |
@@ -293,4 +291,6 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
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(); |
@@ -549,4 +549,53 @@ void Keyboard::setMapToFile(QString map) { | |||
549 | } | 549 | } |
550 | 550 | ||
551 | /* Keybaord::setColor {{{1 */ | ||
552 | void Keyboard::reloadKeyboard() { | ||
553 | |||
554 | // reload colors and redraw | ||
555 | loadKeyboardColors(); | ||
556 | repaint(); | ||
557 | |||
558 | } | ||
559 | |||
560 | void 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 | * |
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 | |||
@@ -116,4 +116,7 @@ private slots: | |||
116 | void setMapToFile(QString map); | 116 | void setMapToFile(QString map); |
117 | 117 | ||
118 | // used to redraw keyboard after edited colors | ||
119 | void reloadKeyboard(); | ||
120 | |||
118 | private: | 121 | private: |
119 | int getKey( int &w, int j = -1 ); | 122 | int getKey( int &w, int j = -1 ); |
@@ -153,4 +156,11 @@ private: | |||
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 | }; |