summaryrefslogtreecommitdiff
authorhash <hash>2002-08-19 17:47:09 (UTC)
committer hash <hash>2002-08-19 17:47:09 (UTC)
commitd68e038d1ba78a816e60990d5a36d6c52d8e11d3 (patch) (side-by-side diff)
tree4b63d843d3a64d35567205d4aa50e1cfc53d99b4
parent9cc94030d7f6a04b79da8db83e6c609c1580a3d3 (diff)
downloadopie-d68e038d1ba78a816e60990d5a36d6c52d8e11d3.zip
opie-d68e038d1ba78a816e60990d5a36d6c52d8e11d3.tar.gz
opie-d68e038d1ba78a816e60990d5a36d6c52d8e11d3.tar.bz2
added simple color changing
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
@@ -2,4 +2,5 @@
* TODO
* make a font selection thing (size too)
+ * make a cursor thing
*
*
@@ -25,4 +26,5 @@
#include <qstringlist.h>
#include <opie/ofiledialog.h>
+#include <opie/colordialog.h>
#include <qdir.h>
#include <qfileinfo.h>
@@ -30,4 +32,5 @@
#include "keyboard.h"
+// ConfigDlg::ConfigDlg() {{{1
ConfigDlg::ConfigDlg () : QTabWidget ()
{
@@ -105,4 +108,6 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
remove_button = new QPushButton(tr("Remove"), add_remove_grid);
remove_button->setFlat((bool)1);
+ if ((int)map_dir.count() >= keymaps->currentItem())
+ remove_button->setDisabled(true);
connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
@@ -130,10 +135,23 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
QLabel *label;
+ QStringList color;
label = new QLabel(tr("Key Color"), color_box);
- QPushButton *button = new QPushButton(color_box);
- button->setFlat((bool)1);
+ key_color_button = new QPushButton(color_box);
+ connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked()));
+ key_color_button->setFlat((bool)1);
+
+ config.setGroup("colors");
+ color = config.readListEntry("keycolor", QChar(','));
+ if (color.isEmpty()) {
+ color = QStringList::split(",", "240,240,240");
+ config.writeEntry("keycolor", color.join(","));
+
+ }
+ key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
+
+
label = new QLabel(tr("Key Pressed Color"), color_box);
- button = new QPushButton(color_box);
+ QPushButton *button = new QPushButton(color_box);
button->setFlat((bool)1);
label = new QLabel(tr("Line Color"), color_box);
@@ -165,4 +183,5 @@ void ConfigDlg::pickTog() {
*/
+// ConfigDlg::setMap {{{1
void ConfigDlg::setMap(int index) {
@@ -170,5 +189,4 @@ void ConfigDlg::setMap(int index) {
remove_button->setDisabled(true);
-
emit setMapToDefault();
}
@@ -176,5 +194,4 @@ void ConfigDlg::setMap(int index) {
remove_button->setDisabled(true);
-
emit setMapToFile(keymaps->text(index));
@@ -182,9 +199,9 @@ void ConfigDlg::setMap(int index) {
remove_button->setEnabled(true);
-
emit setMapToFile(keymaps->text(index));
}
}
+// ConfigDlg::addMap() {{{1
void ConfigDlg::addMap() {
@@ -198,9 +215,10 @@ void ConfigDlg::addMap() {
- config.writeEntry("maps", maps.join("|"));
+ config.writeEntry("maps", maps, QChar('|'));
config.writeEntry("current", map);
}
+// ConfigDlg::removeMap() {{{1
void ConfigDlg::removeMap() {
@@ -218,4 +236,24 @@ void ConfigDlg::removeMap() {
Config config ("multikey");
config.setGroup("keymaps");
- config.writeEntry("maps", custom_maps.join("|"));
+ config.writeEntry("maps", custom_maps, QChar('|'));
+}
+
+// ConfigDlg::color {{{1
+void ConfigDlg::keyColorButtonClicked() {
+
+ Config config ("multikey");
+ config.setGroup ("colors");
+
+ QStringList color = config.readListEntry("keycolor", QChar(','));
+
+ QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
+
+ color[0].setNum(newcolor.red());
+ color[1].setNum(newcolor.green());
+ color[2].setNum(newcolor.blue());
+
+ config.writeEntry("keycolor", color, QChar(','));
+
+ key_color_button->setBackgroundColor(newcolor);
+ emit reloadKeyboard();
}
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:
void setMapToDefault();
void setMapToFile(QString map);
+ void reloadKeyboard();
private slots:
@@ -26,4 +27,7 @@ private slots:
void removeMap();
+ // all those required slots for the color push buttons
+ void keyColorButtonClicked();
+
private:
QCheckBox *pick_button;
@@ -36,4 +40,7 @@ private:
QStringList custom_maps; // maps you added with the 'add' button
+ /* color buttons */
+ QPushButton *key_color_button;
+
};
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) :
{
+
// get the default font
Config *config = new Config( "qpe" );
@@ -73,4 +74,6 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
} else picks->hide();
+ loadKeyboardColors();
+
keys = new Keys();
@@ -79,4 +82,5 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
}
+
Keyboard::~Keyboard() {
@@ -157,9 +161,4 @@ void Keyboard::paintEvent(QPaintEvent* e)
void Keyboard::drawKeyboard(QPainter &p, int row, int col)
{
- QColor keycolor =
- QColor(240,240,240);
- QColor keycolor_pressed = QColor(171,183,198);
- QColor keycolor_lines = QColor(138,148,160);
- QColor textcolor = QColor(43,54,68);
@@ -183,10 +182,9 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
ushort c = keys->uni(row, col);
- if (!pix) {
- p.setPen(textcolor);
+ p.setPen(textcolor);
+ if (!pix)
p.drawText(x, y,
defaultKeyWidth * keyWidth, keyHeight,
AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
- }
else
// center the image in the middle of the key
@@ -293,4 +291,6 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
connect(configdlg, SIGNAL(setMapToFile(QString)),
this, SLOT(setMapToFile(QString)));
+ connect(configdlg, SIGNAL(reloadKeyboard()),
+ this, SLOT(reloadKeyboard()));
configdlg->showMaximized();
configdlg->show();
@@ -549,4 +549,53 @@ void Keyboard::setMapToFile(QString map) {
}
+/* Keybaord::setColor {{{1 */
+void Keyboard::reloadKeyboard() {
+
+ // reload colors and redraw
+ loadKeyboardColors();
+ repaint();
+
+}
+
+void Keyboard::loadKeyboardColors() {
+
+ Config config ("multikey");
+ config.setGroup("colors");
+
+ QStringList color;
+ color = config.readListEntry("keycolor", QChar(','));
+ if (color.isEmpty()) {
+ color = QStringList::split(",", "240,240,240");
+ config.writeEntry("keycolor", color.join(","));
+
+ }
+ keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
+
+ color = config.readListEntry("keycolor_pressed", QChar(','));
+ if (color.isEmpty()) {
+ color = QStringList::split(",", "171,183,198");
+ config.writeEntry("keycolor_pressed", color.join(","));
+
+ }
+ keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
+
+ color = config.readListEntry("keycolor_lines", QChar(','));
+ if (color.isEmpty()) {
+ color = QStringList::split(",", "138,148,160");
+ config.writeEntry("keycolor_lines", color.join(","));
+
+ }
+ keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
+
+ color = config.readListEntry("textcolor", QChar(','));
+ if (color.isEmpty()) {
+ color = QStringList::split(",", "43,54,68");
+ config.writeEntry("textcolor", color.join(","));
+
+ }
+ textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
+
+}
+
/* korean input functions {{{1
*
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
@@ -115,4 +115,7 @@ private slots:
void setMapToDefault();
void setMapToFile(QString map);
+
+ // used to redraw keyboard after edited colors
+ void reloadKeyboard();
private:
@@ -153,4 +156,11 @@ private:
QTimer *repeatTimer;
+ /* colors */
+ void loadKeyboardColors();
+ QColor keycolor;
+ QColor keycolor_pressed;
+ QColor keycolor_lines;
+ QColor textcolor;
+
ConfigDlg *configdlg;
};