summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Unidiff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 2a80f1e..b71f929 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -12,92 +12,99 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "keyboard.h" 21#include "keyboard.h"
22#include "configdlg.h" 22#include "configdlg.h"
23 23
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26 26
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <iostream.h>
37 36
38#include <sys/utsname.h> 37#include <sys/utsname.h>
39 38
40 39
41#define USE_SMALL_BACKSPACE 40#define USE_SMALL_BACKSPACE
42 41
43/* Keyboard::Keyboard {{{1 */ 42/* Keyboard::Keyboard {{{1 */
44Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 43Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
45 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), 44 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0),
46 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), 45 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1),
47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 46 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
48 configdlg(0) 47 configdlg(0)
49 48
50{ 49{
51 // get the default font 50 // get the default font
52 Config *config = new Config( "qpe" ); 51 Config *config = new Config( "qpe" );
53 config->setGroup( "Appearance" ); 52 config->setGroup( "Appearance" );
54 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 53 QString familyStr = config->readEntry( "FontFamily", "fixed" );
55 delete config; 54 delete config;
56 55
57 config = new Config("multikey"); 56 config = new Config("multikey");
58 config->setGroup ("pickboard"); 57 config->setGroup ("pickboard");
59 usePicks = config->readBoolEntry ("open", "0"); // default closed 58 usePicks = config->readBoolEntry ("open", "0"); // default closed
60 delete config; 59 delete config;
61 60
62 setFont( QFont( familyStr, 10 ) ); 61 setFont( QFont( familyStr, 10 ) );
63 62
64 picks = new KeyboardPicks( this ); 63 picks = new KeyboardPicks( this );
65 picks->setFont( QFont( familyStr, 10 ) ); 64 picks->setFont( QFont( familyStr, 10 ) );
66 picks->initialise(); 65 picks->initialise();
67 if (usePicks) { 66 if (usePicks) {
68 67
69 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 68 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
70 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 69 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
71 70
72 } else picks->hide(); 71 } else picks->hide();
73 72
74 keys = new Keys(); 73 keys = new Keys();
75 74
76 repeatTimer = new QTimer( this ); 75 repeatTimer = new QTimer( this );
77 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 76 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
78 77
79} 78}
79Keyboard::~Keyboard() {
80
81 if ( configdlg ) {
82 delete (ConfigDlg *) configdlg;
83 configdlg = 0;
84 }
85
86}
80 87
81/* Keyboard::resizeEvent {{{1 */ 88/* Keyboard::resizeEvent {{{1 */
82void Keyboard::resizeEvent(QResizeEvent*) 89void Keyboard::resizeEvent(QResizeEvent*)
83{ 90{
84 int ph = picks->sizeHint().height(); 91 int ph = picks->sizeHint().height();
85 picks->setGeometry( 0, 0, width(), ph ); 92 picks->setGeometry( 0, 0, width(), ph );
86 keyHeight = (height()-(usePicks ? ph : 0))/5; 93 keyHeight = (height()-(usePicks ? ph : 0))/5;
87 94
88 int nk; // number of keys? 95 int nk; // number of keys?
89 if ( useLargeKeys ) { 96 if ( useLargeKeys ) {
90 nk = 15; 97 nk = 15;
91 } else { 98 } else {
92 nk = 19; 99 nk = 19;
93 } 100 }
94 defaultKeyWidth = (width()/nk)/2; 101 defaultKeyWidth = (width()/nk)/2;
95 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 102 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
96 103
97} 104}
98 105
99/* KeyboardPicks::initialize {{{1 */ 106/* KeyboardPicks::initialize {{{1 */
100void KeyboardPicks::initialise() 107void KeyboardPicks::initialise()
101{ 108{
102 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 109 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
103 mode = 0; 110 mode = 0;
@@ -938,49 +945,48 @@ void Keys::setKeysFromFile(const char * filename) {
938 945
939 QTextStream tmp (buf, IO_ReadOnly); 946 QTextStream tmp (buf, IO_ReadOnly);
940 ushort lower, shift; 947 ushort lower, shift;
941 tmp >> lower >> shift; 948 tmp >> lower >> shift;
942 949
943 shiftMap.insert(lower, shift); 950 shiftMap.insert(lower, shift);
944 951
945 buf = t.readLine(); 952 buf = t.readLine();
946 } 953 }
947 954
948 // other variables like lang & title 955 // other variables like lang & title
949 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 956 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
950 957
951 QTextStream tmp (buf, IO_ReadOnly); 958 QTextStream tmp (buf, IO_ReadOnly);
952 QString name, equals, value; 959 QString name, equals, value;
953 960
954 tmp >> name >> equals >> value; 961 tmp >> name >> equals >> value;
955 962
956 if (name == "lang") { 963 if (name == "lang") {
957 964
958 lang = value; 965 lang = value;
959 966
960 } 967 }
961 968
962 cout << name << " = " << value << "\n";
963 buf = t.readLine(); 969 buf = t.readLine();
964 } 970 }
965 // comments 971 // comments
966 else if (buf.contains(QRegExp("^\\s*#"))) { 972 else if (buf.contains(QRegExp("^\\s*#"))) {
967 973
968 buf = t.readLine(); 974 buf = t.readLine();
969 975
970 } else { // blank line, or garbage 976 } else { // blank line, or garbage
971 977
972 buf = t.readLine(); 978 buf = t.readLine();
973 979
974 } 980 }
975 981
976 } 982 }
977 f.close(); 983 f.close();
978 } 984 }
979 985
980} 986}
981 987
982// Keys::setKey {{{2 988// Keys::setKey {{{2
983void Keys::setKey(const int row, const int qcode, const ushort unicode, 989void Keys::setKey(const int row, const int qcode, const ushort unicode,
984 const int width, QPixmap *pix) { 990 const int width, QPixmap *pix) {
985 991
986 Key * key; 992 Key * key;