summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp63
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
@@ -40,53 +40,57 @@
#define USE_SMALL_BACKSPACE
/* Keyboard::Keyboard {{{1 */
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;
config = new Config("multikey");
config->setGroup ("pickboard");
usePicks = config->readBoolEntry ("open", "0"); // default closed
delete config;
setFont( QFont( familyStr, 10 ) );
picks = new KeyboardPicks( this );
picks->setFont( QFont( familyStr, 10 ) );
picks->initialise();
if (usePicks) {
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;
}
}
/* Keyboard::resizeEvent {{{1 */
void Keyboard::resizeEvent(QResizeEvent*)
{
@@ -147,56 +151,50 @@ void Keyboard::paintEvent(QPaintEvent* e)
{
QPainter painter(this);
painter.setClipRect(e->rect());
drawKeyboard( painter );
picks->dc->draw( &painter );
}
/* 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++) {
x += keys->width(row, i) * defaultKeyWidth;
}
int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
int keyWidth = keys->width(row, col);
p.fillRect(x + 1, y + 1,
keyWidth * defaultKeyWidth - 1, keyHeight - 1,
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);
+ 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 );
// this fixes the problem that the very right end of the board's vertical line
// gets painted over, because it's one pixel shorter than all other keys
p.setPen(keycolor_lines);
p.drawLine(width() - 1, 0, width() - 1, height());
} else {
@@ -283,24 +281,26 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if ( configdlg ) {
delete (ConfigDlg *) configdlg;
configdlg = 0;
}
else {
configdlg = new ConfigDlg ();
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) {
ctrl = keys->pressedPtr(row, col);
need_repaint = TRUE;
*ctrl = !keys->pressed(row, col);
} else if (qkeycode == Qt::Key_Alt) {
alt = keys->pressedPtr(row, col);
@@ -539,24 +539,73 @@ void Keyboard::setMapToFile(QString map) {
delete config;
delete keys;
if (QFile(map).exists())
keys = new Keys(map);
else
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
*
* make backspace delete one single char, not the whole thing if still
* editing.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*