author | hash <hash> | 2002-08-27 17:55:22 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-27 17:55:22 (UTC) |
commit | 48a1af2115e44f44ccc3918ef77f77167d1bbc24 (patch) (unidiff) | |
tree | f6cbd81ac5019c6fc5b38ae9445b1510a9b91845 | |
parent | 83091c400324e103650a709206f6983ebf2a5e22 (diff) | |
download | opie-48a1af2115e44f44ccc3918ef77f77167d1bbc24.zip opie-48a1af2115e44f44ccc3918ef77f77167d1bbc24.tar.gz opie-48a1af2115e44f44ccc3918ef77f77167d1bbc24.tar.bz2 |
pickboard off by default now working
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 5 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 4 |
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,198 +1,197 @@ | |||
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 |
34 | ConfigDlg::ConfigDlg () : QTabWidget () | 33 | ConfigDlg::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 | ||
103 | } else { | 102 | } else { |
104 | 103 | ||
105 | QFile map (custom_maps[i]); | 104 | QFile map (custom_maps[i]); |
106 | if (map.open(IO_ReadOnly)) { | 105 | if (map.open(IO_ReadOnly)) { |
107 | 106 | ||
108 | QString line; bool found = 0; | 107 | QString line; bool found = 0; |
109 | 108 | ||
110 | map.readLine(line, 1024); | 109 | map.readLine(line, 1024); |
111 | while (!map.atEnd()) { | 110 | while (!map.atEnd()) { |
112 | 111 | ||
113 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 112 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
114 | 113 | ||
115 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 114 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
116 | found = 1; | 115 | found = 1; |
117 | break; | 116 | break; |
118 | } | 117 | } |
119 | map.readLine(line, 1024); | 118 | map.readLine(line, 1024); |
120 | } | 119 | } |
121 | if (!found) keymaps->insertItem(custom_maps[i]); | 120 | if (!found) keymaps->insertItem(custom_maps[i]); |
122 | 121 | ||
123 | map.close(); | 122 | map.close(); |
124 | } | 123 | } |
125 | if (custom_maps[i] == current_map) { | 124 | if (custom_maps[i] == current_map) { |
126 | 125 | ||
127 | keymaps->setSelected(map_dir.count() + i + 1, true); | 126 | keymaps->setSelected(map_dir.count() + i + 1, true); |
128 | } | 127 | } |
129 | } | 128 | } |
130 | } | 129 | } |
131 | 130 | ||
132 | // have to "+1" because the "current language" listItem... remember? | 131 | // have to "+1" because the "current language" listItem... remember? |
133 | 132 | ||
134 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 133 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
135 | 134 | ||
136 | 135 | ||
137 | QGrid *add_remove_grid = new QGrid(2, map_group); | 136 | QGrid *add_remove_grid = new QGrid(2, map_group); |
138 | add_remove_grid->setMargin(3); | 137 | add_remove_grid->setMargin(3); |
139 | add_remove_grid->setSpacing(3); | 138 | add_remove_grid->setSpacing(3); |
140 | 139 | ||
141 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 140 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
142 | add_button->setFlat((bool)1); | 141 | add_button->setFlat((bool)1); |
143 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 142 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
144 | 143 | ||
145 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 144 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
146 | remove_button->setFlat((bool)1); | 145 | remove_button->setFlat((bool)1); |
147 | if ((int)map_dir.count() >= keymaps->currentItem()) | 146 | if ((int)map_dir.count() >= keymaps->currentItem()) |
148 | remove_button->setDisabled(true); | 147 | remove_button->setDisabled(true); |
149 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 148 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
150 | 149 | ||
151 | // make a box that will contain the buttons on the bottom | 150 | // make a box that will contain the buttons on the bottom |
152 | QGrid *other_grid = new QGrid(2, gen_box); | 151 | QGrid *other_grid = new QGrid(2, gen_box); |
153 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | 152 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); |
154 | 153 | ||
155 | config.setGroup ("general"); | 154 | config.setGroup ("general"); |
156 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed | 155 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed |
157 | if (pick_open) { | 156 | if (pick_open) { |
158 | 157 | ||
159 | pick_button->setChecked(true); | 158 | pick_button->setChecked(true); |
160 | } | 159 | } |
161 | 160 | ||
162 | // by connecting it after checking it, the signal isn't emmited | 161 | // by connecting it after checking it, the signal isn't emmited |
163 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 162 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
164 | 163 | ||
165 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | 164 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); |
166 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); | 165 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); |
167 | 166 | ||
168 | if (repeat_on) { | 167 | if (repeat_on) { |
169 | 168 | ||
170 | repeat_button->setChecked(true); | 169 | repeat_button->setChecked(true); |
171 | } | 170 | } |
172 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); | 171 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); |
173 | 172 | ||
174 | 173 | ||
175 | /* | 174 | /* |
176 | * 'color' tab | 175 | * 'color' tab |
177 | */ | 176 | */ |
178 | 177 | ||
179 | QGrid *color_box = new QGrid(2, this); | 178 | QGrid *color_box = new QGrid(2, this); |
180 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 179 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
181 | color_box->setMargin(3); | 180 | color_box->setMargin(3); |
182 | color_box->setSpacing(3); | 181 | color_box->setSpacing(3); |
183 | addTab(color_box, tr("Colors")); | 182 | addTab(color_box, tr("Colors")); |
184 | 183 | ||
185 | QLabel *label; | 184 | QLabel *label; |
186 | QStringList color; | 185 | QStringList color; |
187 | config.setGroup("colors"); | 186 | config.setGroup("colors"); |
188 | 187 | ||
189 | label = new QLabel(tr("Key Color"), color_box); | 188 | label = new QLabel(tr("Key Color"), color_box); |
190 | keycolor_button = new QPushButton(color_box); | 189 | keycolor_button = new QPushButton(color_box); |
191 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); | 190 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
192 | keycolor_button->setFlat((bool)1); | 191 | keycolor_button->setFlat((bool)1); |
193 | color = config.readListEntry("keycolor", QChar(',')); | 192 | color = config.readListEntry("keycolor", QChar(',')); |
194 | /* | 193 | /* |
195 | * hopefully not required | 194 | * hopefully not required |
196 | 195 | ||
197 | if (color.isEmpty()) { | 196 | if (color.isEmpty()) { |
198 | color = QStringList::split(",", "240,240,240"); | 197 | color = QStringList::split(",", "240,240,240"); |
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,251 +1,251 @@ | |||
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 */ |
42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 42 | Keyboard::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 | ||
84 | Keyboard::~Keyboard() { | 84 | Keyboard::~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 */ |
94 | void Keyboard::resizeEvent(QResizeEvent*) | 94 | void 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 */ |
112 | void KeyboardPicks::initialise() | 112 | void 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 */ |
121 | QSize KeyboardPicks::sizeHint() const | 121 | QSize 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 */ |
128 | void KeyboardConfig::generateText(const QString &s) | 128 | void 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 */ |
149 | void Keyboard::paintEvent(QPaintEvent* e) | 149 | void 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 | } |
156 | 156 | ||
157 | 157 | ||
158 | /* Keyboard::drawKeyboard {{{1 */ | 158 | /* Keyboard::drawKeyboard {{{1 */ |
159 | 159 | ||
160 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 160 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
161 | { | 161 | { |
162 | 162 | ||
163 | 163 | ||
164 | if (row != -1 && col != -1) { //just redraw one key | 164 | if (row != -1 && col != -1) { //just redraw one key |
165 | 165 | ||
166 | int x = 0; | 166 | int x = 0; |
167 | for (int i = 0; i < col; i++) { | 167 | for (int i = 0; i < col; i++) { |
168 | 168 | ||
169 | x += keys->width(row, i) * defaultKeyWidth; | 169 | x += keys->width(row, i) * defaultKeyWidth; |
170 | } | 170 | } |
171 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 171 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
172 | 172 | ||
173 | int keyWidth = keys->width(row, col); | 173 | int keyWidth = keys->width(row, col); |
174 | 174 | ||
175 | p.fillRect(x + 1, y + 1, | 175 | p.fillRect(x + 1, y + 1, |
176 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 176 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
177 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 177 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
178 | 178 | ||
179 | QImage *pix = keys->pix(row,col); | 179 | QImage *pix = keys->pix(row,col); |
180 | 180 | ||
181 | ushort c = keys->uni(row, col); | 181 | ushort c = keys->uni(row, col); |
182 | 182 | ||
183 | p.setPen(textcolor); | 183 | p.setPen(textcolor); |
184 | if (!pix) { | 184 | if (!pix) { |
185 | if (shift || lock) | 185 | if (shift || lock) |
186 | c = keys->shift(c); | 186 | c = keys->shift(c); |
187 | if (meta) { | 187 | if (meta) { |
188 | 188 | ||
189 | c = keys->meta(c); | 189 | c = keys->meta(c); |
190 | } | 190 | } |
191 | p.drawText(x, y, | 191 | p.drawText(x, y, |
192 | defaultKeyWidth * keyWidth + 3, keyHeight, | 192 | defaultKeyWidth * keyWidth + 3, keyHeight, |
193 | AlignCenter, (QChar)c); | 193 | AlignCenter, (QChar)c); |
194 | } | 194 | } |
195 | else | 195 | else |
196 | // center the image in the middle of the key | 196 | // center the image in the middle of the key |
197 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 197 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
198 | y + (keyHeight - pix->height())/2 + 1, | 198 | y + (keyHeight - pix->height())/2 + 1, |
199 | *pix ); | 199 | *pix ); |
200 | 200 | ||
201 | // this fixes the problem that the very right end of the board's vertical line | 201 | // this fixes the problem that the very right end of the board's vertical line |
202 | // gets painted over, because it's one pixel shorter than all other keys | 202 | // gets painted over, because it's one pixel shorter than all other keys |
203 | p.setPen(keycolor_lines); | 203 | p.setPen(keycolor_lines); |
204 | p.drawLine(width() - 1, 0, width() - 1, height()); | 204 | p.drawLine(width() - 1, 0, width() - 1, height()); |
205 | 205 | ||
206 | } else { | 206 | } else { |
207 | 207 | ||
208 | 208 | ||
209 | p.fillRect(0, 0, width(), height(), keycolor); | 209 | p.fillRect(0, 0, width(), height(), keycolor); |
210 | 210 | ||
211 | for (row = 1; row <= 5; row++) { | 211 | for (row = 1; row <= 5; row++) { |
212 | 212 | ||
213 | int x = 0; | 213 | int x = 0; |
214 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 214 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
215 | 215 | ||
216 | p.setPen(keycolor_lines); | 216 | p.setPen(keycolor_lines); |
217 | p.drawLine(x, y, x + width(), y); | 217 | p.drawLine(x, y, x + width(), y); |
218 | 218 | ||
219 | for (int col = 0; col < keys->numKeys(row); col++) { | 219 | for (int col = 0; col < keys->numKeys(row); col++) { |
220 | 220 | ||
221 | QImage *pix = keys->pix(row, col); | 221 | QImage *pix = keys->pix(row, col); |
222 | int keyWidth = keys->width(row, col); | 222 | int keyWidth = keys->width(row, col); |
223 | 223 | ||
224 | 224 | ||
225 | int keyWidthPix = defaultKeyWidth * keyWidth; | 225 | int keyWidthPix = defaultKeyWidth * keyWidth; |
226 | 226 | ||
227 | if (keys->pressed(row, col)) | 227 | if (keys->pressed(row, col)) |
228 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 228 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
229 | keyHeight - 1, keycolor_pressed); | 229 | keyHeight - 1, keycolor_pressed); |
230 | 230 | ||
231 | ushort c = keys->uni(row, col); | 231 | ushort c = keys->uni(row, col); |
232 | 232 | ||
233 | p.setPen(textcolor); | 233 | p.setPen(textcolor); |
234 | if (!pix) { | 234 | if (!pix) { |
235 | if ((shift || lock) && keys->shift(c)) | 235 | if ((shift || lock) && keys->shift(c)) |
236 | c = keys->shift(c); | 236 | c = keys->shift(c); |
237 | else if (meta && keys->meta(c)) | 237 | else if (meta && keys->meta(c)) |
238 | c = keys->meta(c); | 238 | c = keys->meta(c); |
239 | 239 | ||
240 | p.drawText(x, y, | 240 | p.drawText(x, y, |
241 | keyWidthPix + 3, keyHeight, | 241 | keyWidthPix + 3, keyHeight, |
242 | AlignCenter, (QChar)c); | 242 | AlignCenter, (QChar)c); |
243 | } | 243 | } |
244 | else { | 244 | else { |
245 | // center the image in the middle of the key | 245 | // center the image in the middle of the key |
246 | pix->setColor(1, textcolor.rgb()); | 246 | pix->setColor(1, textcolor.rgb()); |
247 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 247 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
248 | y + (keyHeight - pix->height())/2 + 1, | 248 | y + (keyHeight - pix->height())/2 + 1, |
249 | QImage(*pix) ); | 249 | QImage(*pix) ); |
250 | } | 250 | } |
251 | 251 | ||