summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp65
1 files changed, 57 insertions, 8 deletions
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
@@ -46,12 +46,13 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
QFrame(parent, _name, f), shift(0), lock(0), ctrl(0),
alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1),
unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
configdlg(0)
{
+
// get the default font
Config *config = new Config( "qpe" );
config->setGroup( "Appearance" );
QString familyStr = config->readEntry( "FontFamily", "fixed" );
delete config;
@@ -69,18 +70,21 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
} else picks->hide();
+ loadKeyboardColors();
+
keys = new Keys();
repeatTimer = new QTimer( this );
connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
}
+
Keyboard::~Keyboard() {
if ( configdlg ) {
delete (ConfigDlg *) configdlg;
configdlg = 0;
}
@@ -153,17 +157,12 @@ void Keyboard::paintEvent(QPaintEvent* e)
/* Keyboard::drawKeyboard {{{1 */
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);
if (row != -1 && col != -1) { //just redraw one key
int x = 0;
for (int i = 0; i < col; i++) {
@@ -179,18 +178,17 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
QPixmap *pix = keys->pix(row,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
p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
y + (keyHeight - pix->height())/2 + 1,
*pix );
@@ -289,12 +287,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
connect(configdlg, SIGNAL(pickboardToggled(bool)),
this, SLOT(togglePickboard(bool)));
connect(configdlg, SIGNAL(setMapToDefault()),
this, SLOT(setMapToDefault()));
connect(configdlg, SIGNAL(setMapToFile(QString)),
this, SLOT(setMapToFile(QString)));
+ connect(configdlg, SIGNAL(reloadKeyboard()),
+ this, SLOT(reloadKeyboard()));
configdlg->showMaximized();
configdlg->show();
configdlg->raise();
}
} else if (qkeycode == Qt::Key_Control) {
@@ -545,12 +545,61 @@ void Keyboard::setMapToFile(QString map) {
keys = new Keys();
repaint(FALSE);
}
+/* 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
*
* TODO
* one major problem with this implementation is that you can't move the
* cursor after inputing korean chars, otherwise it will eat up and replace
* the char before the cursor you move to. fix that