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.cpp67
1 files changed, 47 insertions, 20 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 8f4d562..a19f07a 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,74 +1,82 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "keyboard.h"
+#include "configdlg.h"
#include <qpe/global.h>
+#include <qpe/qcopenvelope_qws.h>
#include <qwindowsystem_qws.h>
#include <qpainter.h>
#include <qfontmetrics.h>
#include <qtimer.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <ctype.h>
#include <qfile.h>
#include <qtextstream.h>
#include <sys/utsname.h>
#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), LANG("ko"), schar(0), mchar(0), echar(0)
+ unicode(-1), qkeycode(0), modifiers(0), LANG("ko"), schar(0), mchar(0), echar(0),
+ configdlg(0)
+
{
// get the default font
Config qpeConfig( "qpe" );
qpeConfig.setGroup( "Appearance" );
QString familyStr = qpeConfig.readEntry( "FontFamily", "fixed" );
+ Config multiConfig ("multikey");
+ multiConfig.setGroup ("pickboard");
+ usePicks = multiConfig.readBoolEntry ("open", "0"); // default closed
+
setFont( QFont( familyStr, 8 ) );
picks = new KeyboardPicks( this );
picks->setFont( QFont( familyStr, 8 ) );
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();
Config config("locale");
config.setGroup( "Language" );
LANG = config.readEntry( "Language", "en" );
repeatTimer = new QTimer( this );
connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
}
/* Keyboard::resizeEvent {{{1 */
void Keyboard::resizeEvent(QResizeEvent*)
{
@@ -241,69 +249,61 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
{
int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
if (row > 5) row = 5;
// figure out the column
int col = 0;
for (int w = 0; e->x() >= w; col++)
if (col < keys.numKeys(row)) // it segfaults if it trys to read past numKeys
w += keys.width(row,col) * defaultKeyWidth;
else break;
col --; // rewind one...
qkeycode = keys.qcode(row, col);
unicode = keys.uni(row, col);
// might need to repaint if two or more of the same keys.
// should be faster if just paint one key even though multiple keys exist.
bool need_repaint = FALSE;
if (unicode == 0) { // either Qt char, or nothing
if (qkeycode == Qt::Key_F1) { // toggle the pickboard
- usePicks = !usePicks;
- if (usePicks) {
- picks->show();
- move(x(), y() - picks->height());
- adjustSize();
- QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
- this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
- } else {
-
- picks->hide();
- picks->resetState();
- move(x(), y() + picks->height());
- adjustSize();
- QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
- this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
-
+ if ( configdlg ) {
+ delete (ConfigDlg *) configdlg;
+ configdlg = 0;
+ }
+ else {
+ configdlg = new ConfigDlg ();
+ connect(configdlg, SIGNAL(pickboardToggled(bool)),
+ this, SLOT(togglePickboard(bool)));
+ configdlg->showMaximized();
+ configdlg->show();
+ configdlg->raise();
}
- keys.setPressed(row, col, usePicks);
- need_repaint = TRUE;
- qkeycode = 0; // don't need to emit Key_F1
} 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);
need_repaint = TRUE;
*alt = !keys.pressed(row, col);
} else if (qkeycode == Qt::Key_Shift) {
need_repaint = TRUE;
if (shift) {
*shift = 0;
shift = 0;
}
else {
shift = keys.pressedPtr(row, col);
*shift = 1;
if (lock) {
*lock = 0;
lock = 0;
}
@@ -441,48 +441,75 @@ void Keyboard::clearHighlight()
pressedKeyCol = -1;
QPainter p(this);
drawKeyboard(p, tmpRow, tmpCol);
}
}
/* Keyboard::sizeHint {{{1 */
QSize Keyboard::sizeHint() const
{
QFontMetrics fm=fontMetrics();
int keyHeight = fm.lineSpacing();
return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
}
void Keyboard::resetState()
{
schar = mchar = echar = 0;
picks->resetState();
}
+/* Keyboard::togglePickboard {{{1 */
+void Keyboard::togglePickboard(bool on_off)
+{
+ usePicks = on_off;
+ if (usePicks) {
+ picks->show();
+ //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
+ //adjustSize();
+ QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
+ this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
+ } else {
+
+ picks->hide();
+ picks->resetState();
+ //move(x(), y() + picks->height());
+ //adjustSize();
+ QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
+ this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
+
+ }
+ /*
+ * this closes && opens the input method
+ */
+ QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
+ QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
+}
+
/* 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.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* how korean input works
*
* all following chars means unicode char value and are in hex
*
* ÃÊÀ½ = schar (start char)
* ÁßÀ½ = mchar (middle char)
* ³¡À½ = echar (end char)
*
* there are 19 schars. unicode position is at 1100 - 1112
* there are 21 mchars. unicode position is at 1161 - 1175
* there are 27 echars. unicode position is at 11a8 - 11c2
*