summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp5
-rw-r--r--inputmethods/multikey/keyboard.cpp4
2 files changed, 4 insertions, 5 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index f6507b4..26c9233 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,102 +1,101 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make a cursor thing 4 * make vertical keys possible
5 * add meta key support for german, etc 5 * make a keymap editor
6 *
7 * 6 *
8 * 7 *
9 */ 8 */
10 9
11#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 11#include <qpe/config.h>
13 12
14#include <qwidget.h> 13#include <qwidget.h>
15#include <qdialog.h> 14#include <qdialog.h>
16#include <qtabwidget.h> 15#include <qtabwidget.h>
17#include <qvbox.h> 16#include <qvbox.h>
18#include <qgrid.h> 17#include <qgrid.h>
19#include <qgroupbox.h> 18#include <qgroupbox.h>
20#include <qlabel.h> 19#include <qlabel.h>
21#include <qcheckbox.h> 20#include <qcheckbox.h>
22#include <qsizepolicy.h> 21#include <qsizepolicy.h>
23#include <qpushbutton.h> 22#include <qpushbutton.h>
24#include <qlistbox.h> 23#include <qlistbox.h>
25#include <qstringlist.h> 24#include <qstringlist.h>
26#include <opie/ofiledialog.h> 25#include <opie/ofiledialog.h>
27#include <opie/colordialog.h> 26#include <opie/colordialog.h>
28#include <qdir.h> 27#include <qdir.h>
29#include <qfileinfo.h> 28#include <qfileinfo.h>
30#include "configdlg.h" 29#include "configdlg.h"
31#include "keyboard.h" 30#include "keyboard.h"
32 31
33// ConfigDlg::ConfigDlg() {{{1 32// ConfigDlg::ConfigDlg() {{{1
34ConfigDlg::ConfigDlg () : QTabWidget () 33ConfigDlg::ConfigDlg () : QTabWidget ()
35{ 34{
36 setCaption( tr("Multikey Configuration") ); 35 setCaption( tr("Multikey Configuration") );
37 Config config ("multikey"); 36 Config config ("multikey");
38 config.setGroup("keymaps"); 37 config.setGroup("keymaps");
39 QString current_map = config.readEntry("current", 0); 38 QString current_map = config.readEntry("current", 0);
40 39
41 /* 40 /*
42 * 'general config' tab 41 * 'general config' tab
43 */ 42 */
44 43
45 QVBox *gen_box = new QVBox (this); 44 QVBox *gen_box = new QVBox (this);
46 gen_box->setMargin(3); 45 gen_box->setMargin(3);
47 addTab(gen_box, tr("General Settings")); 46 addTab(gen_box, tr("General Settings"));
48 47
49 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); 48 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box);
50 49
51 keymaps = new QListBox (map_group); 50 keymaps = new QListBox (map_group);
52 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 51 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
53 52
54 QString cur(tr("Current Language")); 53 QString cur(tr("Current Language"));
55 keymaps->insertItem(cur); 54 keymaps->insertItem(cur);
56 keymaps->setSelected(0, true); 55 keymaps->setSelected(0, true);
57 56
58 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); 57 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap");
59 default_maps = map_dir.entryList(); // so i can access it in other places 58 default_maps = map_dir.entryList(); // so i can access it in other places
60 59
61 for (uint i = 0; i < map_dir.count(); i++) { 60 for (uint i = 0; i < map_dir.count(); i++) {
62 61
63 QFile map (map_dir.absPath() + "/" + map_dir[i]); 62 QFile map (map_dir.absPath() + "/" + map_dir[i]);
64 if (map.open(IO_ReadOnly)) { 63 if (map.open(IO_ReadOnly)) {
65 64
66 QString line; bool found = 0; 65 QString line; bool found = 0;
67 66
68 map.readLine(line, 1024); 67 map.readLine(line, 1024);
69 while (!map.atEnd()) { 68 while (!map.atEnd()) {
70 69
71 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 70 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
72 71
73 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 72 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
74 found = 1; 73 found = 1;
75 break; 74 break;
76 } 75 }
77 map.readLine(line, 1024); 76 map.readLine(line, 1024);
78 } 77 }
79 if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); 78 if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]);
80 79
81 map.close(); 80 map.close();
82 } 81 }
83 if (map_dir.absPath() + "/" + map_dir[i] == current_map) { 82 if (map_dir.absPath() + "/" + map_dir[i] == current_map) {
84 83
85 keymaps->setSelected(i + 1, true); 84 keymaps->setSelected(i + 1, true);
86 } 85 }
87 86
88 } 87 }
89 88
90 custom_maps = config.readListEntry("maps", QChar('|')); 89 custom_maps = config.readListEntry("maps", QChar('|'));
91 90
92 for (uint i = 0; i < custom_maps.count(); i++) { 91 for (uint i = 0; i < custom_maps.count(); i++) {
93 92
94 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) 93 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false)
95 || !QFile::exists(custom_maps[i])) { 94 || !QFile::exists(custom_maps[i])) {
96 95
97 custom_maps.remove(custom_maps.at(i)); 96 custom_maps.remove(custom_maps.at(i));
98 97
99 // remove it from the list too 98 // remove it from the list too
100 config.writeEntry("maps", custom_maps.join("|")); 99 config.writeEntry("maps", custom_maps.join("|"));
101 100
102 101
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 92ea896..4747f59 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,155 +1,155 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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 <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41/* Keyboard::Keyboard {{{1 */ 41/* Keyboard::Keyboard {{{1 */
42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), 43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0),
44 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), 44 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1),
45 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 45 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
46 configdlg(0) 46 configdlg(0)
47 47
48{ 48{
49 49
50 // get the default font 50 // get the default font
51 Config *config = new Config( "qpe" ); 51 Config *config = new Config( "qpe" );
52 config->setGroup( "Appearance" ); 52 config->setGroup( "Appearance" );
53 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 53 QString familyStr = config->readEntry( "FontFamily", "fixed" );
54 delete config; 54 delete config;
55 55
56 config = new Config("multikey"); 56 config = new Config("multikey");
57 config->setGroup ("general"); 57 config->setGroup ("general");
58 usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed 58 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
59 useRepeat = config->readBoolEntry ("useRepeat", "1"); 59 useRepeat = config->readBoolEntry ("useRepeat", 1);
60 delete config; 60 delete config;
61 61
62 62
63 setFont( QFont( familyStr, 10 ) ); 63 setFont( QFont( familyStr, 10 ) );
64 64
65 picks = new KeyboardPicks( this ); 65 picks = new KeyboardPicks( this );
66 picks->setFont( QFont( familyStr, 10 ) ); 66 picks->setFont( QFont( familyStr, 10 ) );
67 picks->initialise(); 67 picks->initialise();
68 if (usePicks) { 68 if (usePicks) {
69 69
70 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 70 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
71 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 71 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
72 72
73 } else picks->hide(); 73 } else picks->hide();
74 74
75 loadKeyboardColors(); 75 loadKeyboardColors();
76 76
77 keys = new Keys(); 77 keys = new Keys();
78 78
79 repeatTimer = new QTimer( this ); 79 repeatTimer = new QTimer( this );
80 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 80 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
81 81
82} 82}
83 83
84Keyboard::~Keyboard() { 84Keyboard::~Keyboard() {
85 85
86 if ( configdlg ) { 86 if ( configdlg ) {
87 delete (ConfigDlg *) configdlg; 87 delete (ConfigDlg *) configdlg;
88 configdlg = 0; 88 configdlg = 0;
89 } 89 }
90 90
91} 91}
92 92
93/* Keyboard::resizeEvent {{{1 */ 93/* Keyboard::resizeEvent {{{1 */
94void Keyboard::resizeEvent(QResizeEvent*) 94void Keyboard::resizeEvent(QResizeEvent*)
95{ 95{
96 int ph = picks->sizeHint().height(); 96 int ph = picks->sizeHint().height();
97 picks->setGeometry( 0, 0, width(), ph ); 97 picks->setGeometry( 0, 0, width(), ph );
98 keyHeight = (height()-(usePicks ? ph : 0))/5; 98 keyHeight = (height()-(usePicks ? ph : 0))/5;
99 99
100 int nk; // number of keys? 100 int nk; // number of keys?
101 if ( useLargeKeys ) { 101 if ( useLargeKeys ) {
102 nk = 15; 102 nk = 15;
103 } else { 103 } else {
104 nk = 19; 104 nk = 19;
105 } 105 }
106 defaultKeyWidth = (width()/nk)/2; 106 defaultKeyWidth = (width()/nk)/2;
107 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 107 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
108 108
109} 109}
110 110
111/* KeyboardPicks::initialize {{{1 */ 111/* KeyboardPicks::initialize {{{1 */
112void KeyboardPicks::initialise() 112void KeyboardPicks::initialise()
113{ 113{
114 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 114 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
115 mode = 0; 115 mode = 0;
116 dc = new KeyboardConfig(this); 116 dc = new KeyboardConfig(this);
117 configs.append(dc); 117 configs.append(dc);
118} 118}
119 119
120/* KeyboardPicks::sizeHint {{{1 */ 120/* KeyboardPicks::sizeHint {{{1 */
121QSize KeyboardPicks::sizeHint() const 121QSize KeyboardPicks::sizeHint() const
122{ 122{
123 return QSize(240,fontMetrics().lineSpacing()); 123 return QSize(240,fontMetrics().lineSpacing());
124} 124}
125 125
126 126
127/* KeyboardConfig::generateText {{{1 */ 127/* KeyboardConfig::generateText {{{1 */
128void KeyboardConfig::generateText(const QString &s) 128void KeyboardConfig::generateText(const QString &s)
129{ 129{
130#if defined(Q_WS_QWS) || defined(_WS_QWS_) 130#if defined(Q_WS_QWS) || defined(_WS_QWS_)
131 for (int i=0; i<(int)backspaces; i++) { 131 for (int i=0; i<(int)backspaces; i++) {
132 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 132 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
133 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 133 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
134 } 134 }
135 for (int i=0; i<(int)s.length(); i++) { 135 for (int i=0; i<(int)s.length(); i++) {
136 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 136 parent->emitKey( s[i].unicode(), 0, 0, true, false );
137 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 137 parent->emitKey( s[i].unicode(), 0, 0, false, false );
138 } 138 }
139 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 139 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
140 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 140 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
141 backspaces = 0; 141 backspaces = 0;
142#endif 142#endif
143} 143}
144 144
145 145
146 146
147 147
148/* Keyboard::paintEvent {{{1 */ 148/* Keyboard::paintEvent {{{1 */
149void Keyboard::paintEvent(QPaintEvent* e) 149void Keyboard::paintEvent(QPaintEvent* e)
150{ 150{
151 QPainter painter(this); 151 QPainter painter(this);
152 painter.setClipRect(e->rect()); 152 painter.setClipRect(e->rect());
153 drawKeyboard( painter ); 153 drawKeyboard( painter );
154 picks->dc->draw( &painter ); 154 picks->dc->draw( &painter );
155} 155}