summaryrefslogtreecommitdiff
path: root/inputmethods/keyboard/keyboard.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/keyboard/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/keyboard/keyboard.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp
index 0f0b188..a85a7b1 100644
--- a/inputmethods/keyboard/keyboard.cpp
+++ b/inputmethods/keyboard/keyboard.cpp
@@ -1,128 +1,129 @@
/**********************************************************************
** 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 <qpe/global.h>
#include <qwindowsystem_qws.h>
#include <qpainter.h>
#include <qfontmetrics.h>
#include <qtimer.h>
#include <ctype.h>
#include <sys/utsname.h>
+using namespace KeyboardInput;
#define USE_SMALL_BACKSPACE
Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE),
alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1),
unicode(-1), qkeycode(0), modifiers(0)
{
// setPalette(QPalette(QColor(240,240,230))); // Beige!
// setFont( QFont( "Helvetica", 8 ) );
// setPalette(QPalette(QColor(200,200,200))); // Gray
setPalette(QPalette(QColor(220,220,220))); // Gray
picks = new KeyboardPicks( this );
picks->setFont( QFont( "smallsmooth", 9 ) );
setFont( QFont( "smallsmooth", 9 ) );
picks->initialise();
QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
repeatTimer = new QTimer( this );
// temporary quick and dirty fix for the "sticky keyboard bug"
// on ipaq.
// struct utsname name;
// if (uname(&name) != -1)
// {
// QString release=name.release;
// qWarning("System release: %s\n", name.release);
// if(release.find("embedix",0,TRUE) !=-1)
// {
connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
// }
// }
}
void Keyboard::resizeEvent(QResizeEvent*)
{
int ph = picks->sizeHint().height();
picks->setGeometry( 0, 0, width(), ph );
keyHeight = (height()-ph)/5;
int nk;
if ( useOptiKeys ) {
nk = 15;
} else if ( useLargeKeys ) {
nk = 15;
} else {
nk = 19;
}
defaultKeyWidth = width()/nk;
xoffs = (width()-defaultKeyWidth*nk)/2;
}
void KeyboardPicks::initialise()
{
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
mode = 0;
dc = new KeyboardConfig(this);
configs.append(dc);
}
QSize KeyboardPicks::sizeHint() const
{
return QSize(240,fontMetrics().lineSpacing());
}
void KeyboardConfig::generateText(const QString &s)
{
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
for (int i=0; i<(int)backspaces; i++) {
parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
}
for (int i=0; i<(int)s.length(); i++) {
parent->emitKey( s[i].unicode(), 0, 0, true, false );
parent->emitKey( s[i].unicode(), 0, 0, false, false );
}
parent->emitKey( 0, Qt::Key_Space, 0, true, false );
parent->emitKey( 0, Qt::Key_Space, 0, false, false );
backspaces = 0;
#endif
}
//PC keyboard layout and scancodes
/*
Format: length, code, length, code, ..., 0
length is measured in half the width of a standard key.
If code < 0x80 we have length/2 consecutive standard keys,
starting with scancode code.
Special keys are hardcoded, one at a time, with length of key
and code >= 0x80, these are NOT standard PC scancodes, but are looked