-rw-r--r-- | inputmethods/keyboard/keyboard.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp index 9dd24e4..233f08e 100644 --- a/inputmethods/keyboard/keyboard.cpp +++ b/inputmethods/keyboard/keyboard.cpp | |||
@@ -19,46 +19,60 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | #include <sys/utsname.h> | ||
32 | |||
31 | 33 | ||
32 | #define USE_SMALL_BACKSPACE | 34 | #define USE_SMALL_BACKSPACE |
33 | 35 | ||
34 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 36 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
35 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), | 37 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), |
36 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), | 38 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), |
37 | unicode(-1), qkeycode(0), modifiers(0) | 39 | unicode(-1), qkeycode(0), modifiers(0) |
38 | { | 40 | { |
39 | // setPalette(QPalette(QColor(240,240,230))); // Beige! | 41 | // setPalette(QPalette(QColor(240,240,230))); // Beige! |
40 | // setFont( QFont( "Helvetica", 8 ) ); | 42 | // setFont( QFont( "Helvetica", 8 ) ); |
41 | // setPalette(QPalette(QColor(200,200,200))); // Gray | 43 | // setPalette(QPalette(QColor(200,200,200))); // Gray |
42 | setPalette(QPalette(QColor(220,220,220))); // Gray | 44 | setPalette(QPalette(QColor(220,220,220))); // Gray |
43 | 45 | ||
44 | picks = new KeyboardPicks( this ); | 46 | picks = new KeyboardPicks( this ); |
45 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 47 | picks->setFont( QFont( "smallsmooth", 9 ) ); |
46 | setFont( QFont( "smallsmooth", 9 ) ); | 48 | setFont( QFont( "smallsmooth", 9 ) ); |
47 | picks->initialise(); | 49 | picks->initialise(); |
48 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
49 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
50 | 52 | ||
51 | repeatTimer = new QTimer( this ); | 53 | repeatTimer = new QTimer( this ); |
52 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 54 | |
55 | // temporary quick and dirty fix for the "sticky keyboard bug" | ||
56 | // on ipaq. | ||
57 | struct utsname name; | ||
58 | if (uname(&name) != -1) | ||
59 | { | ||
60 | QString release=name.release; | ||
61 | qWarning("System release: %s\n", name.release); | ||
62 | if(release.find("embedix",0,TRUE) !=-1) | ||
63 | { | ||
64 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | ||
65 | } | ||
66 | } | ||
53 | } | 67 | } |
54 | 68 | ||
55 | void Keyboard::resizeEvent(QResizeEvent*) | 69 | void Keyboard::resizeEvent(QResizeEvent*) |
56 | { | 70 | { |
57 | int ph = picks->sizeHint().height(); | 71 | int ph = picks->sizeHint().height(); |
58 | picks->setGeometry( 0, 0, width(), ph ); | 72 | picks->setGeometry( 0, 0, width(), ph ); |
59 | keyHeight = (height()-ph)/5; | 73 | keyHeight = (height()-ph)/5; |
60 | int nk; | 74 | int nk; |
61 | if ( useOptiKeys ) { | 75 | if ( useOptiKeys ) { |
62 | nk = 15; | 76 | nk = 15; |
63 | } else if ( useLargeKeys ) { | 77 | } else if ( useLargeKeys ) { |
64 | nk = 15; | 78 | nk = 15; |
@@ -752,26 +766,27 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*) | |||
752 | void Keyboard::timerEvent(QTimerEvent* e) | 766 | void Keyboard::timerEvent(QTimerEvent* e) |
753 | { | 767 | { |
754 | if ( e->timerId() == pressTid ) { | 768 | if ( e->timerId() == pressTid ) { |
755 | killTimer(pressTid); | 769 | killTimer(pressTid); |
756 | pressTid = 0; | 770 | pressTid = 0; |
757 | if ( !pressed ) | 771 | if ( !pressed ) |
758 | clearHighlight(); | 772 | clearHighlight(); |
759 | } | 773 | } |
760 | } | 774 | } |
761 | 775 | ||
762 | void Keyboard::repeat() | 776 | void Keyboard::repeat() |
763 | { | 777 | { |
764 | repeatTimer->start( 150 ); | 778 | |
765 | emit key( unicode, qkeycode, modifiers, true, true ); | 779 | repeatTimer->start( 200 ); |
780 | emit key( unicode, qkeycode, modifiers, true, true ); | ||
766 | } | 781 | } |
767 | 782 | ||
768 | void Keyboard::clearHighlight() | 783 | void Keyboard::clearHighlight() |
769 | { | 784 | { |
770 | if ( pressedKey >= 0 ) { | 785 | if ( pressedKey >= 0 ) { |
771 | int tmp = pressedKey; | 786 | int tmp = pressedKey; |
772 | pressedKey = -1; | 787 | pressedKey = -1; |
773 | QPainter p(this); | 788 | QPainter p(this); |
774 | drawKeyboard( p, tmp ); | 789 | drawKeyboard( p, tmp ); |
775 | } | 790 | } |
776 | } | 791 | } |
777 | 792 | ||