Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 63 |
1 files changed, 56 insertions, 7 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 @@ -48,8 +48,9 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 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" ); @@ -71,14 +72,17 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 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; @@ -155,13 +159,8 @@ 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 @@ -181,14 +180,13 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) QPixmap *pix = keys->pix(row,col); ushort c = keys->uni(row, col); - if (!pix) { 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, @@ -291,8 +289,10 @@ void Keyboard::mousePressEvent(QMouseEvent *e) 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(); } @@ -547,8 +547,57 @@ void Keyboard::setMapToFile(QString map) { 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 |