author | zecke <zecke> | 2004-10-15 02:30:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-15 02:30:08 (UTC) |
commit | 5c3759f02725c17ba0efc386193a83da55a9a5da (patch) (unidiff) | |
tree | b03e604b282de315096b74b6f404851c2bba3ad6 | |
parent | fefeafe35f8dac30f4baab9e3bff8e2ffbd1afd0 (diff) | |
download | opie-5c3759f02725c17ba0efc386193a83da55a9a5da.zip opie-5c3759f02725c17ba0efc386193a83da55a9a5da.tar.gz opie-5c3759f02725c17ba0efc386193a83da55a9a5da.tar.bz2 |
Apply patch from Qtopia1.7 to allow 'Umlaute' in the pickboard
and make 'strings' translatable.
This also fixes #501
-rw-r--r-- | inputmethods/pickboard/pickboard.cpp | 25 | ||||
-rw-r--r-- | inputmethods/pickboard/pickboardcfg.cpp | 69 | ||||
-rw-r--r-- | inputmethods/pickboard/pickboardcfg.h | 19 | ||||
-rw-r--r-- | inputmethods/pickboard/pickboardimpl.cpp | 6 | ||||
-rw-r--r-- | inputmethods/pickboard/pickboardpicks.cpp | 31 |
5 files changed, 91 insertions, 59 deletions
diff --git a/inputmethods/pickboard/pickboard.cpp b/inputmethods/pickboard/pickboard.cpp index 087144e..1611cb0 100644 --- a/inputmethods/pickboard/pickboard.cpp +++ b/inputmethods/pickboard/pickboard.cpp | |||
@@ -1,89 +1,110 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the 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 | #include "pickboard.h" | 20 | #include "pickboard.h" |
21 | #include "pickboardpicks.h" | 21 | #include "pickboardpicks.h" |
22 | #include "pickboardcfg.h" | 22 | #include "pickboardcfg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | 25 | ||
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qbitmap.h> | 28 | #include <qbitmap.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qscrollview.h> | 32 | #include <qscrollview.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
34 | #include <qhbuttongroup.h> | 34 | #include <qhbuttongroup.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #ifdef QWS | ||
37 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | ||
40 | |||
41 | /*! \class Pickboard | ||
42 | \brief The Pickboard class provides an input method | ||
43 | based on a virtual keyboard combined with word-completion. | ||
44 | |||
45 | This version of Pickboard is Dual Licensed Software. However, for you to be | ||
46 | able to license the technology to others, you may require a T9(R) Text | ||
47 | Input license from Tegic Communications Corporation. More information can | ||
48 | be found at http://www.t9.com/. | ||
49 | |||
50 | \legalese | ||
51 | This version of Pickboard is Dual Licensed Software. However, for you to be | ||
52 | able to license the technology to others, you may require a T9(R) Text | ||
53 | Input license from Tegic Communications Corporation. More information can | ||
54 | be found at http://www.t9.com/. | ||
55 | */ | ||
38 | 56 | ||
39 | /* XPM */ | 57 | /* XPM */ |
40 | static const char * const menu_xpm[]={ | 58 | static const char * const menu_xpm[]={ |
41 | "9 9 2 1", | 59 | "9 9 2 1", |
42 | "a c #000000", | 60 | "a c #000000", |
43 | ". c None", | 61 | ". c None", |
44 | ".........", | 62 | ".........", |
45 | ".........", | 63 | ".........", |
46 | ".........", | 64 | ".........", |
47 | "....a....", | 65 | "....a....", |
48 | "...aaa...", | 66 | "...aaa...", |
49 | "..aaaaa..", | 67 | "..aaaaa..", |
50 | ".aaaaaaa.", | 68 | ".aaaaaaa.", |
51 | ".........", | 69 | ".........", |
52 | "........."}; | 70 | "........."}; |
53 | 71 | ||
54 | class PickboardPrivate { | 72 | class PickboardPrivate { |
55 | public: | 73 | public: |
56 | PickboardPrivate(Pickboard* parent) | 74 | PickboardPrivate(Pickboard* parent) |
57 | { | 75 | { |
58 | picks = new PickboardPicks(parent); | 76 | picks = new PickboardPicks(parent); |
59 | picks->initialise(); | 77 | picks->initialise(); |
60 | menu = new QPushButton(parent); | 78 | menu = new QPushButton(parent); |
61 | menu->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding)); | 79 | menu->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding)); |
62 | menu->setPixmap(QPixmap((const char **)menu_xpm)); | 80 | menu->setPixmap(QPixmap((const char **)menu_xpm)); |
63 | QObject::connect(menu,SIGNAL(clicked()),picks,SLOT(doMenu())); | 81 | QObject::connect(menu,SIGNAL(clicked()),picks,SLOT(doMenu())); |
64 | QObject::connect(picks,SIGNAL(key(ushort,ushort,ushort,bool,bool)), | 82 | QObject::connect(picks,SIGNAL(key(ushort,ushort,ushort,bool,bool)), |
65 | parent,SIGNAL(key(ushort,ushort,ushort,bool,bool))); | 83 | parent,SIGNAL(key(ushort,ushort,ushort,bool,bool))); |
66 | } | 84 | } |
67 | 85 | ||
68 | PickboardPicks* picks; | 86 | PickboardPicks* picks; |
69 | QPushButton* menu; | 87 | QPushButton* menu; |
70 | }; | 88 | }; |
71 | 89 | ||
72 | Pickboard::Pickboard(QWidget* parent, const char* name, WFlags f) : | 90 | Pickboard::Pickboard(QWidget* parent, const char* name, WFlags f) : |
73 | QFrame(parent,name,f) | 91 | QFrame(parent,name,f) |
74 | { | 92 | { |
75 | (new QHBoxLayout(this))->setAutoAdd(TRUE); | 93 | (new QHBoxLayout(this))->setAutoAdd(TRUE); |
76 | d = new PickboardPrivate(this); | 94 | d = new PickboardPrivate(this); |
95 | // under Win32 we may not have smallsmooth font | ||
96 | #ifndef Q_OS_WIN32 | ||
77 | setFont( QFont( "smallsmooth", 9 ) ); | 97 | setFont( QFont( "smallsmooth", 9 ) ); |
98 | #endif | ||
78 | } | 99 | } |
79 | 100 | ||
80 | Pickboard::~Pickboard() | 101 | Pickboard::~Pickboard() |
81 | { | 102 | { |
82 | delete d; | 103 | delete d; |
83 | } | 104 | } |
84 | 105 | ||
85 | void Pickboard::resetState() | 106 | void Pickboard::resetState() |
86 | { | 107 | { |
87 | d->picks->resetState(); | 108 | d->picks->resetState(); |
88 | } | 109 | } |
89 | 110 | ||
diff --git a/inputmethods/pickboard/pickboardcfg.cpp b/inputmethods/pickboard/pickboardcfg.cpp index d500266..70a89cd 100644 --- a/inputmethods/pickboard/pickboardcfg.cpp +++ b/inputmethods/pickboard/pickboardcfg.cpp | |||
@@ -1,679 +1,686 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the 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 "pickboardcfg.h" | 21 | #include "pickboardcfg.h" |
22 | #include "pickboardpicks.h" | 22 | #include "pickboardpicks.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | 25 | ||
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qbitmap.h> | 28 | #include <qbitmap.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qscrollview.h> | 32 | #include <qscrollview.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
34 | #include <qhbuttongroup.h> | 34 | #include <qhbuttongroup.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #ifdef QWS | ||
37 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | ||
38 | 40 | ||
39 | static const char * pickboard_help = | 41 | static const char * pickboard_help = |
40 | "<h1>The Pickboard</h1>" | 42 | QT_TRANSLATE_NOOP("PickboardConfig", "<h1>The Pickboard</h1>" |
41 | "<i>The smallest and fastest way to type.</i>" | 43 | "<i>The smallest and fastest way to type.</i>" |
42 | "<p>" | 44 | "<p>" |
43 | "Enter a word by tapping letter-groups and picking the word." | 45 | "Enter a word by tapping letter-groups and picking the word." |
44 | "<br>Enter spaces with \"Space\", or other keys through \"KEY\"." | 46 | "<br>Enter spaces with \"Space\", or other keys through \"KEY\"." |
45 | "<br>Use \"Shift\" to capitalize words that are not normally capitalized." | 47 | "<br>Use \"Shift\" to capitalize words that are not normally capitalized." |
46 | "<br>Press \"Shift\" twice for an all-capitals word." | 48 | "<br>Press \"Shift\" twice for an all-capitals word." |
47 | "<br>Add custom words by picking them, then selecting \"Add...\" from the menu on the right." | 49 | "<br>Add custom words by picking them, then selecting \"Add...\" from the menu on the right." ) |
48 | ; | 50 | ; |
49 | 51 | ||
50 | const int intermatchmargin=5; | 52 | const int intermatchmargin=5; |
51 | 53 | ||
52 | 54 | ||
53 | PickboardConfig::~PickboardConfig() { } | 55 | PickboardConfig::~PickboardConfig() { } |
54 | 56 | ||
55 | void PickboardConfig::updateRows(int from, int to) | 57 | void PickboardConfig::updateRows(int from, int to) |
56 | { | 58 | { |
57 | if ( from != to ) { // (all) | 59 | if ( from != to ) { // (all) |
58 | parent->update(); | 60 | parent->update(); |
59 | } else { | 61 | } else { |
60 | QFontMetrics fm = parent->fontMetrics(); | 62 | QFontMetrics fm = parent->fontMetrics(); |
61 | parent->update(QRect(0,1+fm.descent() + from * fm.lineSpacing(), parent->width(), | 63 | parent->update(QRect(0,1+fm.descent() + from * fm.lineSpacing(), parent->width(), |
62 | fm.lineSpacing())); | 64 | fm.lineSpacing())); |
63 | } | 65 | } |
64 | } | 66 | } |
65 | 67 | ||
66 | void PickboardConfig::updateItem(int r, int) | 68 | void PickboardConfig::updateItem(int r, int) |
67 | { | 69 | { |
68 | updateRows(r,r); | 70 | updateRows(r,r); |
69 | } | 71 | } |
70 | 72 | ||
71 | void PickboardConfig::changeMode(int m) | 73 | void PickboardConfig::changeMode(int m) |
72 | { | 74 | { |
73 | parent->setMode(m); | 75 | parent->setMode(m); |
74 | } | 76 | } |
75 | void PickboardConfig::generateText(const QString& s) | 77 | void PickboardConfig::generateText(const QString& s) |
76 | { | 78 | { |
77 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 79 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
78 | for (int i=0; i<(int)s.length(); i++) { | 80 | for (int i=0; i<(int)s.length(); i++) { |
79 | parent->emitKey(s[i].unicode(), 0, 0, true, false); | 81 | uint code = 0; |
80 | parent->emitKey(s[i].unicode(), 0, 0, false, false); | 82 | if ( s[i].unicode() >= 'a' && s[i].unicode() <= 'z' ) { |
83 | code = s[i].unicode() - 'a' + Key_A; | ||
84 | } | ||
85 | parent->emitKey(s[i].unicode(), code, 0, true, false); | ||
86 | parent->emitKey(s[i].unicode(), code, 0, false, false); | ||
81 | } | 87 | } |
82 | #endif | 88 | #endif |
83 | } | 89 | } |
84 | void PickboardConfig::generateKey( int k ) | 90 | void PickboardConfig::generateKey( int k ) |
85 | { | 91 | { |
86 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 92 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
87 | parent->emitKey(0, k, 0, true, false); | 93 | parent->emitKey(0, k, 0, true, false); |
88 | parent->emitKey(0, k, 0, false, false); | 94 | parent->emitKey(0, k, 0, false, false); |
89 | #endif | 95 | #endif |
90 | } | 96 | } |
91 | 97 | ||
92 | void PickboardConfig::pickPoint(const QPoint& p, bool press) | 98 | void PickboardConfig::pickPoint(const QPoint& p, bool press) |
93 | { | 99 | { |
94 | if ( press ) { | 100 | if ( press ) { |
95 | int ls=parent->height()/nrows; | 101 | int ls=parent->height()/nrows; |
96 | int y=0; | 102 | int y=0; |
97 | pressx = -1; | 103 | pressx = -1; |
98 | for (int r=0; r<nrows; r++) { | 104 | for (int r=0; r<nrows; r++) { |
99 | if ( p.y() >= y && p.y() < y+ls ) { | 105 | if ( p.y() >= y && p.y() < y+ls ) { |
100 | pressrow = r; | 106 | pressrow = r; |
101 | pressx = p.x(); | 107 | pressx = p.x(); |
102 | pickInRow( pressrow, pressx, TRUE ); | 108 | pickInRow( pressrow, pressx, TRUE ); |
103 | return; | 109 | return; |
104 | } | 110 | } |
105 | y += ls; | 111 | y += ls; |
106 | } | 112 | } |
107 | } else if ( pressx >= 0 ) { | 113 | } else if ( pressx >= 0 ) { |
108 | pickInRow( pressrow, pressx, FALSE ); | 114 | pickInRow( pressrow, pressx, FALSE ); |
109 | pressx = -1; | 115 | pressx = -1; |
110 | } | 116 | } |
111 | } | 117 | } |
112 | 118 | ||
113 | void PickboardConfig::fillMenu(QPopupMenu& menu) | 119 | void PickboardConfig::fillMenu(QPopupMenu& menu) |
114 | { | 120 | { |
115 | menu.insertItem("Reset",100); | 121 | menu.insertItem(tr("Reset"),100); |
116 | menu.insertSeparator(); | 122 | menu.insertSeparator(); |
117 | menu.insertItem("Help",1); | 123 | menu.insertItem(tr("Help"),1); |
118 | } | 124 | } |
119 | 125 | ||
120 | void PickboardConfig::doMenu(int i) | 126 | void PickboardConfig::doMenu(int i) |
121 | { | 127 | { |
122 | switch (i) { | 128 | switch (i) { |
123 | case 100: | 129 | case 100: |
124 | if ( parent->currentMode() ) { | 130 | if ( parent->currentMode() ) { |
125 | changeMode(0); | 131 | changeMode(0); |
126 | updateRows(0,1); | 132 | updateRows(0,1); |
127 | } | 133 | } |
128 | break; | 134 | break; |
129 | case 1: { | 135 | case 1: { |
130 | QMessageBox help("Pickboard Help", pickboard_help, | 136 | QMessageBox help(tr("Pickboard Help"), tr(pickboard_help), |
131 | QMessageBox::NoIcon, 1, 0, 0); | 137 | QMessageBox::NoIcon, 1, 0, 0); |
132 | help.showMaximized(); | 138 | help.showMaximized(); |
133 | help.exec(); | 139 | help.exec(); |
134 | } | 140 | } |
135 | } | 141 | } |
136 | } | 142 | } |
137 | 143 | ||
138 | void StringConfig::draw(QPainter* p) | 144 | void StringConfig::draw(QPainter* p) |
139 | { | 145 | { |
140 | QFontMetrics fm = p->fontMetrics(); | 146 | QFontMetrics fm = p->fontMetrics(); |
141 | 147 | ||
142 | for (int r=0; r<nrows; r++) { | 148 | for (int r=0; r<nrows; r++) { |
143 | p->translate(0,fm.lineSpacing()); | 149 | p->translate(0,fm.lineSpacing()); |
144 | p->setPen(rowColor(r)); | 150 | p->setPen(rowColor(r)); |
145 | 151 | ||
146 | int tw=0; | 152 | int tw=0; |
147 | QString s; | 153 | QString s; |
148 | int i=0; | 154 | int i=0; |
149 | for (; !(s=text(r,i)).isNull(); ++i) { | 155 | for (; !(s=text(r,i)).isNull(); ++i) { |
150 | int w = fm.width(s); | 156 | int w = fm.width(s); |
151 | tw += w; | 157 | tw += w; |
152 | } | 158 | } |
153 | bool spread = spreadRow(r);// && parent->width() > tw; | 159 | bool spread = spreadRow(r);// && parent->width() > tw; |
154 | int xw = spread ? (parent->width()-tw)/(i-1) : 3; | 160 | int xw = spread ? (parent->width()-tw)/(i-1) : 3; |
155 | int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; | 161 | int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; |
156 | 162 | ||
157 | i=0; | 163 | i=0; |
158 | for (; !(s=text(r,i)).isNull(); ++i) { | 164 | for (; !(s=text(r,i)).isNull(); ++i) { |
159 | int w = fm.width(s)+xw; | 165 | int w = fm.width(s)+xw; |
160 | if ( highlight(r,i) ) { | 166 | if ( highlight(r,i) ) { |
161 | p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),::Qt::black); | 167 | p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),Qt::black); |
162 | p->setPen(::Qt::white); | 168 | p->setPen(Qt::white); |
163 | }else{ | 169 | }else{ |
164 | p->setPen(::Qt::black); | 170 | p->setPen(Qt::black); |
165 | } | 171 | } |
166 | p->drawText(x,-fm.descent()-1,s); | 172 | p->drawText(x,-fm.descent()-1,s); |
167 | x += w; | 173 | x += w; |
168 | } | 174 | } |
169 | } | 175 | } |
170 | } | 176 | } |
171 | 177 | ||
172 | void StringConfig::pickInRow(int r, int xpos, bool press) | 178 | void StringConfig::pickInRow(int r, int xpos, bool press) |
173 | { | 179 | { |
174 | QFontMetrics fm = parent->fontMetrics(); | 180 | QFontMetrics fm = parent->fontMetrics(); |
175 | 181 | ||
176 | int tw=0; | 182 | int tw=0; |
177 | QString s; | 183 | QString s; |
178 | int i=0; | 184 | int i=0; |
179 | for (; !(s=text(r,i)).isNull(); ++i) { | 185 | for (; !(s=text(r,i)).isNull(); ++i) { |
180 | int w = fm.width(s); | 186 | int w = fm.width(s); |
181 | tw += w; | 187 | tw += w; |
182 | } | 188 | } |
183 | bool spread = spreadRow(r) && parent->width() > tw; | 189 | bool spread = spreadRow(r) && parent->width() > tw; |
184 | int xw = spread ? (parent->width()-tw)/(i-1) : 3; | 190 | int xw = spread ? (parent->width()-tw)/(i-1) : 3; |
185 | int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; | 191 | int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; |
186 | 192 | ||
187 | i=0; | 193 | i=0; |
188 | for (; !(s=text(r,i)).isNull(); ++i) { | 194 | for (; !(s=text(r,i)).isNull(); ++i) { |
189 | int x2 = x + fm.width(s)+xw; | 195 | int x2 = x + fm.width(s)+xw; |
190 | if ( xpos >= x && xpos < x2 ) { | 196 | if ( xpos >= x && xpos < x2 ) { |
191 | pick(press, r, i); | 197 | pick(press, r, i); |
192 | return; | 198 | return; |
193 | } | 199 | } |
194 | x = x2; | 200 | x = x2; |
195 | } | 201 | } |
196 | } | 202 | } |
197 | 203 | ||
198 | void StringConfig::updateItem(int r, int item) | 204 | void StringConfig::updateItem(int r, int item) |
199 | { | 205 | { |
200 | QFontMetrics fm = parent->fontMetrics(); | 206 | QFontMetrics fm = parent->fontMetrics(); |
201 | 207 | ||
202 | int y = r * fm.lineSpacing(); | 208 | int y = r * fm.lineSpacing(); |
203 | 209 | ||
204 | int tw=0; | 210 | int tw=0; |
205 | QString s; | 211 | QString s; |
206 | int i=0; | 212 | int i=0; |
207 | for (; !(s=text(r,i)).isNull(); ++i) { | 213 | for (; !(s=text(r,i)).isNull(); ++i) { |
208 | int w = fm.width(s); | 214 | int w = fm.width(s); |
209 | tw += w; | 215 | tw += w; |
210 | } | 216 | } |
211 | bool spread = spreadRow(r) && parent->width() > tw; | 217 | bool spread = spreadRow(r) && parent->width() > tw; |
212 | int xw = spread ? (parent->width()-tw)/(i-1) : 3; | 218 | int xw = spread ? (parent->width()-tw)/(i-1) : 3; |
213 | int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; | 219 | int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; |
214 | 220 | ||
215 | i=0; | 221 | i=0; |
216 | for (; !(s=text(r,i)).isNull(); ++i) { | 222 | for (; !(s=text(r,i)).isNull(); ++i) { |
217 | int w = fm.width(s)+xw; | 223 | int w = fm.width(s)+xw; |
218 | if ( i == item ) { | 224 | if ( i == item ) { |
219 | parent->update(QRect(x-xw/2,y+1+fm.descent(),w,fm.lineSpacing())); | 225 | parent->update(QRect(x-xw/2,y+1+fm.descent(),w,fm.lineSpacing())); |
220 | return; | 226 | return; |
221 | } | 227 | } |
222 | x += w; | 228 | x += w; |
223 | } | 229 | } |
224 | } | 230 | } |
225 | 231 | ||
226 | bool StringConfig::highlight(int,int) const | 232 | bool StringConfig::highlight(int,int) const |
227 | { | 233 | { |
228 | return FALSE; | 234 | return FALSE; |
229 | } | 235 | } |
230 | 236 | ||
231 | LetterButton::LetterButton(const QChar& letter, QWidget* parent) : | 237 | LetterButton::LetterButton(const QChar& letter, QWidget* parent) : |
232 | QPushButton(letter,parent) | 238 | QPushButton(letter,parent) |
233 | { | 239 | { |
234 | setToggleButton(TRUE); | 240 | setToggleButton(TRUE); |
235 | setAutoDefault(FALSE); | 241 | setAutoDefault(FALSE); |
236 | connect(this,SIGNAL(clicked()),this,SLOT(toggleCase())); | 242 | connect(this,SIGNAL(clicked()),this,SLOT(toggleCase())); |
237 | skip=TRUE; | 243 | skip=TRUE; |
238 | } | 244 | } |
239 | 245 | ||
240 | void LetterButton::toggleCase() | 246 | void LetterButton::toggleCase() |
241 | { | 247 | { |
242 | if ( skip ) { | 248 | if ( skip ) { |
243 | // Don't toggle case the first time | 249 | // Don't toggle case the first time |
244 | skip=FALSE; | 250 | skip=FALSE; |
245 | return; | 251 | return; |
246 | } | 252 | } |
247 | 253 | ||
248 | QChar ch = text()[0]; | 254 | QChar ch = text()[0]; |
249 | QChar nch = ch.lower(); | 255 | QChar nch = ch.lower(); |
250 | if ( ch == nch ) | 256 | if ( ch == nch ) |
251 | nch = ch.upper(); | 257 | nch = ch.upper(); |
252 | setText(nch); | 258 | setText(nch); |
253 | } | 259 | } |
254 | 260 | ||
255 | LetterChoice::LetterChoice(QWidget* parent, const QString& set) : | 261 | LetterChoice::LetterChoice(QWidget* parent, const QString& set) : |
256 | QButtonGroup(parent) | 262 | QButtonGroup(parent) |
257 | { | 263 | { |
258 | QHBoxLayout *l = new QHBoxLayout(this); | 264 | QHBoxLayout *l = new QHBoxLayout(this); |
259 | setFrameStyle(0); | 265 | setFrameStyle(0); |
260 | setExclusive(TRUE); | 266 | setExclusive(TRUE); |
261 | for (int i=0; i<(int)set.length(); i++) { | 267 | for (int i=0; i<(int)set.length(); i++) { |
262 | LetterButton* b = new LetterButton(set[i],this); | 268 | LetterButton* b = new LetterButton(set[i],this); |
263 | l->addWidget(b,1,AlignCenter); | 269 | l->addWidget(b,1,AlignCenter); |
264 | connect(b,SIGNAL(clicked()),this,SLOT(change())); | 270 | connect(b,SIGNAL(clicked()),this,SLOT(change())); |
265 | } | 271 | } |
266 | } | 272 | } |
267 | 273 | ||
268 | void LetterChoice::change() | 274 | void LetterChoice::change() |
269 | { | 275 | { |
270 | LetterButton* b = (LetterButton*)sender(); | 276 | LetterButton* b = (LetterButton*)sender(); |
271 | ch = b->text()[0]; | 277 | ch = b->text()[0]; |
272 | emit changed(); | 278 | emit changed(); |
273 | } | 279 | } |
274 | 280 | ||
275 | 281 | ||
276 | PickboardAdd::PickboardAdd(QWidget* owner, const QStringList& setlist) : | 282 | PickboardAdd::PickboardAdd(QWidget* owner, const QStringList& setlist) : |
277 | QDialog( owner, 0, TRUE ) | 283 | QDialog( owner, 0, TRUE ) |
278 | { | 284 | { |
279 | QVBoxLayout* l = new QVBoxLayout(this); | 285 | QVBoxLayout* l = new QVBoxLayout(this); |
280 | l->setAutoAdd(TRUE); | 286 | l->setAutoAdd(TRUE); |
281 | 287 | ||
282 | QScrollView *sv = new QScrollView(this); | 288 | QScrollView *sv = new QScrollView(this); |
283 | sv->setResizePolicy(QScrollView::AutoOneFit); | 289 | sv->setResizePolicy(QScrollView::AutoOneFit); |
284 | setMaximumHeight(200); // ### QDialog shouldn't allow us to be bigger than the screen | 290 | setMaximumHeight(200); // ### QDialog shouldn't allow us to be bigger than the screen |
285 | QVBox *letters = new QVBox(sv); | 291 | QVBox *letters = new QVBox(sv); |
286 | letters->setSpacing(0); | 292 | letters->setSpacing(0); |
287 | lc = new LetterChoice*[setlist.count()]; | 293 | lc = new LetterChoice*[setlist.count()]; |
288 | nlc = (int)setlist.count(); | 294 | nlc = (int)setlist.count(); |
289 | for (int i=0; i<nlc; i++) { | 295 | for (int i=0; i<nlc; i++) { |
290 | lc[i] = new LetterChoice(letters,setlist[i]); | 296 | lc[i] = new LetterChoice(letters,setlist[i]); |
291 | connect(lc[i],SIGNAL(changed()),this,SLOT(checkAllDone())); | 297 | connect(lc[i],SIGNAL(changed()),this,SLOT(checkAllDone())); |
292 | } | 298 | } |
293 | sv->addChild(letters); | 299 | sv->addChild(letters); |
294 | QHBox* hb = new QHBox(this); | 300 | QHBox* hb = new QHBox(this); |
295 | hb->setSpacing(0); | 301 | hb->setSpacing(0); |
296 | yes = new QPushButton("OK",hb); | 302 | yes = new QPushButton(tr("OK"),hb); |
297 | yes->setEnabled(FALSE); | 303 | yes->setEnabled(FALSE); |
298 | QPushButton *no = new QPushButton("Cancel",hb); | 304 | QPushButton *no = new QPushButton(tr("Cancel"),hb); |
299 | connect(yes, SIGNAL(clicked()), this, SLOT(accept())); | 305 | connect(yes, SIGNAL(clicked()), this, SLOT(accept())); |
300 | connect(no, SIGNAL(clicked()), this, SLOT(reject())); | 306 | connect(no, SIGNAL(clicked()), this, SLOT(reject())); |
301 | } | 307 | } |
302 | 308 | ||
303 | PickboardAdd::~PickboardAdd() | 309 | PickboardAdd::~PickboardAdd() |
304 | { | 310 | { |
305 | delete [] lc; | 311 | delete [] lc; |
306 | } | 312 | } |
307 | 313 | ||
308 | QString PickboardAdd::word() const | 314 | QString PickboardAdd::word() const |
309 | { | 315 | { |
310 | QString str; | 316 | QString str; |
311 | for (int i=0; i<nlc; i++) { | 317 | for (int i=0; i<nlc; i++) { |
312 | str += lc[i]->choice(); | 318 | str += lc[i]->choice(); |
313 | } | 319 | } |
314 | return str; | 320 | return str; |
315 | } | 321 | } |
316 | 322 | ||
317 | bool PickboardAdd::exec() | 323 | bool PickboardAdd::exec() |
318 | { | 324 | { |
319 | QPoint pos = parentWidget()->mapToGlobal(QPoint(0,0)); | 325 | QPoint pos = parentWidget()->mapToGlobal(QPoint(0,0)); |
320 | pos.ry() -= height(); | 326 | pos.ry() -= height(); |
321 | if ( QDialog::exec() ) { | 327 | if ( QDialog::exec() ) { |
322 | Global::addWords(QStringList(word())); | 328 | Global::addWords(QStringList(word())); |
323 | return TRUE; | 329 | return TRUE; |
324 | } else { | 330 | } else { |
325 | return FALSE; | 331 | return FALSE; |
326 | } | 332 | } |
327 | } | 333 | } |
328 | 334 | ||
329 | void PickboardAdd::checkAllDone() | 335 | void PickboardAdd::checkAllDone() |
330 | { | 336 | { |
331 | if ( !yes->isEnabled() ) { | 337 | if ( !yes->isEnabled() ) { |
332 | for (int i=0; i<nlc; i++) { | 338 | for (int i=0; i<nlc; i++) { |
333 | if ( lc[i]->choice().isNull() ) | 339 | if ( lc[i]->choice().isNull() ) |
334 | return; | 340 | return; |
335 | } | 341 | } |
336 | yes->setEnabled(TRUE); | 342 | yes->setEnabled(TRUE); |
337 | } | 343 | } |
338 | } | 344 | } |
339 | 345 | ||
340 | 346 | ||
341 | void DictFilterConfig::doMenu(int i) | 347 | void DictFilterConfig::doMenu(int i) |
342 | { | 348 | { |
343 | switch (i) { | 349 | switch (i) { |
344 | case 300: | 350 | case 300: |
345 | if ( input.count() == 0 ) { | 351 | if ( input.count() == 0 ) { |
346 | QMessageBox::information(0, "Adding Words", | 352 | QMessageBox::information(0, tr("Adding Words"), |
347 | "To add words, pick the letters,\nthen " | 353 | tr("To add words, pick the letters,\nthen " |
348 | "open the Add dialog. In that\ndialog, tap " | 354 | "open the Add dialog. In that\ndialog, tap " |
349 | "the correct letters\nfrom the list " | 355 | "the correct letters\nfrom the list " |
350 | "(tap twice for\ncapitals)."); | 356 | "(tap twice for\ncapitals).")); |
351 | } else { | 357 | } else { |
352 | PickboardAdd add(parent,capitalize(input)); | 358 | PickboardAdd add(parent,capitalize(input)); |
353 | if ( add.exec() ) | 359 | if ( add.exec() ) |
354 | generateText(add.word()); | 360 | generateText(add.word()); |
355 | input.clear(); | 361 | input.clear(); |
356 | matches.clear(); | 362 | matches.clear(); |
357 | updateRows(0,0); | 363 | updateRows(0,0); |
358 | } | 364 | } |
359 | break; | 365 | break; |
360 | case 100: | 366 | case 100: |
361 | if ( !input.isEmpty() ) { | 367 | if ( !input.isEmpty() ) { |
362 | input.clear(); | 368 | input.clear(); |
363 | matches.clear(); | 369 | matches.clear(); |
364 | StringConfig::doMenu(i); | 370 | StringConfig::doMenu(i); |
365 | updateRows(0,1); | 371 | updateRows(0,1); |
366 | break; | 372 | break; |
367 | } // else fall through | 373 | } // else fall through |
368 | default: | 374 | default: |
369 | StringConfig::doMenu(i); | 375 | StringConfig::doMenu(i); |
370 | } | 376 | } |
371 | shift = 0; | 377 | shift = 0; |
372 | lit0 = -1; | 378 | lit0 = -1; |
373 | } | 379 | } |
374 | 380 | ||
375 | QString DictFilterConfig::text(int r, int i) | 381 | QString DictFilterConfig::text(int r, int i) |
376 | { | 382 | { |
377 | QStringList l = r ? sets : input.isEmpty() ? othermodes : matches; | 383 | QStringList l = r ? sets_a : input.isEmpty() ? othermodes : matches; |
378 | return i < (int)l.count() ? | 384 | return i < (int)l.count() ? |
379 | (input.isEmpty() ? l[i] : capitalize(l[i])) | 385 | (input.isEmpty() ? l[i] : capitalize(l[i])) |
380 | : QString::null; | 386 | : QString::null; |
381 | } | 387 | } |
382 | 388 | ||
383 | bool DictFilterConfig::spreadRow(int r) | 389 | bool DictFilterConfig::spreadRow(int r) |
384 | { | 390 | { |
385 | return r ? TRUE : input.isEmpty() ? TRUE : FALSE; | 391 | return r ? TRUE : input.isEmpty() ? TRUE : FALSE; |
386 | } | 392 | } |
387 | 393 | ||
388 | QStringList DictFilterConfig::capitalize(const QStringList& l) | 394 | QStringList DictFilterConfig::capitalize(const QStringList& l) |
389 | { | 395 | { |
390 | switch ( shift ) { | 396 | switch ( shift ) { |
391 | case 1: { | 397 | case 1: { |
392 | QStringList r; | 398 | QStringList r; |
393 | QStringList::ConstIterator it = l.begin(); | 399 | QStringList::ConstIterator it = l.begin(); |
394 | r.append((*it).upper()); | 400 | r.append((*it).upper()); |
395 | for (++it; it != l.end(); ++it) | 401 | for (++it; it != l.end(); ++it) |
396 | r.append(*it); | 402 | r.append(*it); |
397 | return r; | 403 | return r; |
398 | } case 2: { | 404 | } case 2: { |
399 | QStringList r; | 405 | QStringList r; |
400 | for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) | 406 | for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) |
401 | r.append((*it).upper()); | 407 | r.append((*it).upper()); |
402 | return r; | 408 | return r; |
403 | } | 409 | } |
404 | } | 410 | } |
405 | return l; | 411 | return l; |
406 | } | 412 | } |
407 | 413 | ||
408 | QString DictFilterConfig::capitalize(const QString& s) | 414 | QString DictFilterConfig::capitalize(const QString& s) |
409 | { | 415 | { |
410 | switch ( shift ) { | 416 | switch ( shift ) { |
411 | case 1: { | 417 | case 1: { |
412 | QString u = s; | 418 | QString u = s; |
413 | u[0] = u[0].upper(); | 419 | u[0] = u[0].upper(); |
414 | return u; | 420 | return u; |
415 | break; | 421 | break; |
416 | } case 2: | 422 | } case 2: |
417 | return s.upper(); | 423 | return s.upper(); |
418 | break; | 424 | break; |
419 | } | 425 | } |
420 | return s; | 426 | return s; |
421 | } | 427 | } |
422 | 428 | ||
423 | void DictFilterConfig::pick(bool press, int row, int item) | 429 | void DictFilterConfig::pick(bool press, int row, int item) |
424 | { | 430 | { |
425 | if ( row == 0 ) { | 431 | if ( row == 0 ) { |
426 | if ( press ) { | 432 | if ( press ) { |
427 | if ( input.isEmpty() ) { | 433 | if ( input.isEmpty() ) { |
428 | lit0 = item; | 434 | lit0 = item; |
429 | if ( othermodes[item] == "Space" ) { | 435 | if ( othermodes[item] == PickboardPicks::tr("Space") ) { |
430 | updateItem(row,item); | 436 | updateItem(row,item); |
431 | generateText(" "); | 437 | generateText(" "); |
432 | } else if ( othermodes[item] == "Back" ) { | 438 | } else if ( othermodes[item] == PickboardPicks::tr("Back") ) { |
433 | updateItem(row,item); | 439 | updateItem(row,item); |
434 | generateKey(::Qt::Key_Backspace); | 440 | generateKey(::Qt::Key_Backspace); |
435 | } else if ( othermodes[item] == "Enter" ) { | 441 | } else if ( othermodes[item] == PickboardPicks::tr("Enter") ) { |
436 | updateItem(row,item); | 442 | updateItem(row,item); |
437 | generateKey(::Qt::Key_Return); | 443 | generateKey(::Qt::Key_Return); |
438 | } else if ( othermodes[item] == "Shift" ) { | 444 | } else if ( othermodes[item] == PickboardPicks::tr("Shift") ) { |
439 | updateItem(row,item); | 445 | updateItem(row,item); |
440 | shift = (shift+1)%3; | 446 | shift = (shift+1)%3; |
441 | } | 447 | } |
442 | } | 448 | } |
443 | } else { | 449 | } else { |
444 | if ( !input.isEmpty() ) { | 450 | if ( !input.isEmpty() ) { |
445 | input.clear(); | 451 | input.clear(); |
446 | if ( item>=0 ) { | 452 | if ( item>=0 ) { |
447 | generateText(capitalize(matches[item])); | 453 | generateText(capitalize(matches[item])); |
448 | } | 454 | } |
449 | shift = 0; | 455 | shift = 0; |
450 | matches.clear(); | 456 | matches.clear(); |
451 | updateRows(0,0); | 457 | updateRows(0,0); |
452 | } else if ( item < 3 ) { | 458 | } else if ( item < 3 ) { |
453 | lit0 = -1; | 459 | lit0 = -1; |
454 | changeMode(item+1); // I'm mode 0! #### | 460 | changeMode(item+1); // I'm mode 0! #### |
455 | updateRows(0,1); | 461 | updateRows(0,1); |
456 | } | 462 | } |
457 | if ( lit0 >= 0 ) { | 463 | if ( lit0 >= 0 ) { |
458 | if ( !shift || othermodes[lit0] != "Shift" ) { | 464 | if ( !shift || othermodes[lit0] != PickboardPicks::tr("Shift") ) { |
459 | updateItem(0,lit0); | 465 | updateItem(0,lit0); |
460 | lit0 = -1; | 466 | lit0 = -1; |
461 | } | 467 | } |
462 | } | 468 | } |
463 | } | 469 | } |
464 | } else { | 470 | } else { |
465 | lit0 = -1; | 471 | lit0 = -1; |
466 | if ( press && item >= 0 ) { | 472 | if ( press && item >= 0 ) { |
467 | lit1 = item; | 473 | lit1 = item; |
468 | add(sets[item]); | 474 | add(sets[item]); |
469 | updateItem(1,item); | 475 | updateItem(1,item); |
470 | updateRows(0,0); | 476 | updateRows(0,0); |
471 | } else { | 477 | } else { |
472 | updateItem(1,lit1); | 478 | updateItem(1,lit1); |
473 | lit1 = -1; | 479 | lit1 = -1; |
474 | } | 480 | } |
475 | } | 481 | } |
476 | } | 482 | } |
477 | 483 | ||
478 | bool DictFilterConfig::scanMatch(const QString& set, const QChar& l) const | 484 | bool DictFilterConfig::scanMatch(const QString& set, const QChar& l) const |
479 | { | 485 | { |
480 | return set == "?" || set == "*" || set.contains(l); | 486 | return set == "?" || set == "*" || set.contains(l); |
481 | } | 487 | } |
482 | 488 | ||
483 | //static int visit=0; | 489 | //static int visit=0; |
484 | //static int lvisit=0; | 490 | //static int lvisit=0; |
485 | 491 | ||
486 | void DictFilterConfig::scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend) | 492 | void DictFilterConfig::scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend) |
487 | { | 493 | { |
488 | if ( n ) { | 494 | if ( n ) { |
489 | do { | 495 | do { |
490 | //visit++; | 496 | //visit++; |
491 | bool pastend = ipos >= (int)input.count(); | 497 | bool pastend = ipos >= (int)input.count(); |
492 | if ( pastend && extend || !pastend && scanMatch(input[ipos],n->letter().lower()) ) { | 498 | if ( pastend && extend || !pastend && scanMatch(input[ipos],n->letter().lower()) ) { |
493 | if ( length>1 ) { | 499 | if ( length>1 ) { |
494 | if ( !pastend && input[ipos] == "*" ) { | 500 | if ( !pastend && input[ipos] == "*" ) { |
495 | scan(n->jump(),ipos+1,str+n->letter(),length-1,FALSE); | 501 | scan(n->jump(),ipos+1,str+n->letter(),length-1,FALSE); |
496 | scan(n->jump(),ipos,str+n->letter(),length,FALSE); | 502 | scan(n->jump(),ipos,str+n->letter(),length,FALSE); |
497 | } else { | 503 | } else { |
498 | scan(n->jump(),ipos+1,str+n->letter(),length-1,extend); | 504 | scan(n->jump(),ipos+1,str+n->letter(),length-1,extend); |
499 | } | 505 | } |
500 | } else { | 506 | } else { |
501 | if ( n->isWord() ) { | 507 | if ( n->isWord() ) { |
502 | matches.append(str+n->letter()); | 508 | matches.append(str+n->letter()); |
503 | } | 509 | } |
504 | } | 510 | } |
505 | } | 511 | } |
506 | n = n->next(); | 512 | n = n->next(); |
507 | } while (n); | 513 | } while (n); |
508 | } | 514 | } |
509 | } | 515 | } |
510 | 516 | ||
511 | void DictFilterConfig::scanLengths(const QDawg::Node* n, int ipos, int& length_bitarray) | 517 | void DictFilterConfig::scanLengths(const QDawg::Node* n, int ipos, int& length_bitarray) |
512 | { | 518 | { |
513 | if ( n ) { | 519 | if ( n ) { |
514 | do { | 520 | do { |
515 | //lvisit++; | 521 | //lvisit++; |
516 | bool pastend = ipos >= (int)input.count(); | 522 | bool pastend = ipos >= (int)input.count(); |
517 | if ( pastend || scanMatch(input[ipos],n->letter().lower()) ) { | 523 | if ( pastend || scanMatch(input[ipos],n->letter().lower()) ) { |
518 | scanLengths(n->jump(),ipos+1,length_bitarray); | 524 | scanLengths(n->jump(),ipos+1,length_bitarray); |
519 | if ( n->isWord() ) | 525 | if ( n->isWord() ) |
520 | length_bitarray |= (1<<(ipos+1)); | 526 | length_bitarray |= (1<<(ipos+1)); |
521 | } | 527 | } |
522 | n = n->next(); | 528 | n = n->next(); |
523 | } while (n); | 529 | } while (n); |
524 | } | 530 | } |
525 | } | 531 | } |
526 | 532 | ||
527 | void DictFilterConfig::add(const QString& set) | 533 | void DictFilterConfig::add(const QString& set) |
528 | { | 534 | { |
529 | QFontMetrics fm = parent->fontMetrics(); | 535 | QFontMetrics fm = parent->fontMetrics(); |
530 | input.append(set.lower()); | 536 | input.append(set.lower()); |
531 | matches.clear(); | 537 | matches.clear(); |
532 | //visit=0; | 538 | //visit=0; |
533 | //lvisit=0; | 539 | //lvisit=0; |
534 | int length_bitarray = 0; | 540 | int length_bitarray = 0; |
535 | if ( input.count() > 4 ) { | 541 | if ( input.count() > 4 ) { |
536 | scanLengths(Global::addedDawg().root(),0,length_bitarray); | 542 | scanLengths(Global::addedDawg().root(),0,length_bitarray); |
537 | scanLengths(Global::fixedDawg().root(),0,length_bitarray); | 543 | scanLengths(Global::fixedDawg().root(),0,length_bitarray); |
538 | } else { | 544 | } else { |
539 | length_bitarray = 0xffffffff; | 545 | length_bitarray = 0xffffffff; |
540 | } | 546 | } |
541 | for (int len=input.count(); len<22 /* 32 */; ++len) { | 547 | for (int len=input.count(); len<22 /* 32 */; ++len) { |
542 | if ( length_bitarray & (1<<len) ) { | 548 | if ( length_bitarray & (1<<len) ) { |
543 | scan(Global::addedDawg().root(),0,"",len,TRUE); | 549 | scan(Global::addedDawg().root(),0,"",len,TRUE); |
544 | scan(Global::fixedDawg().root(),0,"",len,TRUE); | 550 | scan(Global::fixedDawg().root(),0,"",len,TRUE); |
545 | int x = 2; | 551 | int x = 2; |
546 | for (QStringList::Iterator it=matches.begin(); it!=matches.end(); ++it) { | 552 | for (QStringList::Iterator it=matches.begin(); it!=matches.end(); ++it) { |
547 | x += fm.width(*it)+intermatchmargin; | 553 | x += fm.width(*it)+intermatchmargin; |
548 | if ( x >= parent->width() ) { | 554 | if ( x >= parent->width() ) { |
549 | //qDebug("%d+%d visits",lvisit,visit); | 555 | //qDebug("%d+%d visits",lvisit,visit); |
550 | return; // RETURN - No point finding more | 556 | return; // RETURN - No point finding more |
551 | } | 557 | } |
552 | } | 558 | } |
553 | } | 559 | } |
554 | if ( len == 1 && input.count() == 1 ) { | 560 | if ( len == 1 && input.count() == 1 ) { |
555 | // Allow all single-characters to show as "matches" | 561 | // Allow all single-characters to show as "matches" |
556 | for ( int i=0; i<(int)set.length(); i++ ) { | 562 | for ( int i=0; i<(int)set.length(); i++ ) { |
557 | QChar ch = set[i].lower(); | 563 | QChar ch = set[i].lower(); |
558 | matches.append(ch); | 564 | matches.append(ch); |
559 | } | 565 | } |
560 | } | 566 | } |
561 | } | 567 | } |
562 | //qDebug("%d+%d visits",lvisit,visit); | 568 | //qDebug("%d+%d visits",lvisit,visit); |
563 | } | 569 | } |
564 | 570 | ||
565 | bool DictFilterConfig::highlight(int r,int c) const | 571 | bool DictFilterConfig::highlight(int r,int c) const |
566 | { | 572 | { |
567 | return r == 0 ? c == lit0 : c == lit1; | 573 | return r == 0 ? c == lit0 : c == lit1; |
568 | } | 574 | } |
569 | 575 | ||
570 | 576 | ||
571 | void DictFilterConfig::addSet(const QString& s) | 577 | void DictFilterConfig::addSet(const QString& appearance, const QString& set) |
572 | { | 578 | { |
573 | sets.append(s); | 579 | sets_a.append( appearance ); |
580 | sets.append( set ); | ||
574 | } | 581 | } |
575 | 582 | ||
576 | void DictFilterConfig::addMode(const QString& s) | 583 | void DictFilterConfig::addMode(const QString& s) |
577 | { | 584 | { |
578 | othermodes.append(s); | 585 | othermodes.append(s); |
579 | } | 586 | } |
580 | 587 | ||
581 | void DictFilterConfig::fillMenu(QPopupMenu& menu) | 588 | void DictFilterConfig::fillMenu(QPopupMenu& menu) |
582 | { | 589 | { |
583 | menu.insertItem("Add...",300); | 590 | menu.insertItem(tr("Add..."),300); |
584 | StringConfig::fillMenu(menu); | 591 | StringConfig::fillMenu(menu); |
585 | } | 592 | } |
586 | 593 | ||
587 | QValueList<QPixmap> KeycodeConfig::row(int i) | 594 | QValueList<QPixmap> KeycodeConfig::row(int i) |
588 | { | 595 | { |
589 | return i ? keypm2 : keypm1; | 596 | return i ? keypm2 : keypm1; |
590 | } | 597 | } |
591 | 598 | ||
592 | void KeycodeConfig::pickInRow(int r, int xpos, bool press) | 599 | void KeycodeConfig::pickInRow(int r, int xpos, bool press) |
593 | { | 600 | { |
594 | QValueList<QPixmap> pl = row(r); | 601 | QValueList<QPixmap> pl = row(r); |
595 | QValueList<QPixmap>::Iterator it; | 602 | QValueList<QPixmap>::Iterator it; |
596 | int item=0; | 603 | int item=0; |
597 | int x=xmarg; | 604 | int x=xmarg; |
598 | for (it=pl.begin(); it!=pl.end(); ++it) { | 605 | for (it=pl.begin(); it!=pl.end(); ++it) { |
599 | int x2 = x + (*it).width(); | 606 | int x2 = x + (*it).width(); |
600 | if ( (*it).height() > 1 ) | 607 | if ( (*it).height() > 1 ) |
601 | x2 += xw; | 608 | x2 += xw; |
602 | if ( xpos >= x && xpos < x2 ) { | 609 | if ( xpos >= x && xpos < x2 ) { |
603 | pick(press, r, item); | 610 | pick(press, r, item); |
604 | return; | 611 | return; |
605 | } | 612 | } |
606 | x = x2; | 613 | x = x2; |
607 | item++; | 614 | item++; |
608 | } | 615 | } |
609 | } | 616 | } |
610 | 617 | ||
611 | void KeycodeConfig::pick(bool press, int row, int item) | 618 | void KeycodeConfig::pick(bool press, int row, int item) |
612 | { | 619 | { |
613 | if ( !press ) { | 620 | if ( !press ) { |
614 | if ( item >= 0 ) { | 621 | if ( item >= 0 ) { |
615 | int k = row == 0 ? keys1[item] : keys2[item]; | 622 | int k = row == 0 ? keys1[item] : keys2[item]; |
616 | if ( k ) | 623 | if ( k ) |
617 | generateKey(k); | 624 | generateKey(k); |
618 | } | 625 | } |
619 | changeMode(0); | 626 | changeMode(0); |
620 | updateRows(0,1); | 627 | updateRows(0,1); |
621 | } | 628 | } |
622 | } | 629 | } |
623 | 630 | ||
624 | void KeycodeConfig::draw(QPainter* p) | 631 | void KeycodeConfig::draw(QPainter* p) |
625 | { | 632 | { |
626 | int y=3; | 633 | int y=3; |
627 | QValueList<QPixmap>::Iterator it; | 634 | QValueList<QPixmap>::Iterator it; |
628 | for (int r=0; r<nrows; r++) { | 635 | for (int r=0; r<nrows; r++) { |
629 | QValueList<QPixmap> pl = row(r); | 636 | QValueList<QPixmap> pl = row(r); |
630 | int x = xmarg; | 637 | int x = xmarg; |
631 | for (it=pl.begin(); it!=pl.end(); ++it) { | 638 | for (it=pl.begin(); it!=pl.end(); ++it) { |
632 | if ( (*it).height() == 1 ) { | 639 | if ( (*it).height() == 1 ) { |
633 | // just a gap | 640 | // just a gap |
634 | x += (*it).width(); | 641 | x += (*it).width(); |
635 | } else { | 642 | } else { |
636 | p->drawPixmap(x,y,*it); | 643 | p->drawPixmap(x,y,*it); |
637 | x += (*it).width()+xw; | 644 | x += (*it).width()+xw; |
638 | } | 645 | } |
639 | } | 646 | } |
640 | y += parent->height()/nrows; | 647 | y += parent->height()/nrows; |
641 | } | 648 | } |
642 | } | 649 | } |
643 | 650 | ||
644 | 651 | ||
645 | void KeycodeConfig::addKey(int r, const QPixmap& pm, int code) | 652 | void KeycodeConfig::addKey(int r, const QPixmap& pm, int code) |
646 | { | 653 | { |
647 | if ( r == 0 ) { | 654 | if ( r == 0 ) { |
648 | keypm1.append(pm); | 655 | keypm1.append(pm); |
649 | keys1.append(code); | 656 | keys1.append(code); |
650 | } else { | 657 | } else { |
651 | keypm2.append(pm); | 658 | keypm2.append(pm); |
652 | keys2.append(code); | 659 | keys2.append(code); |
653 | } | 660 | } |
654 | } | 661 | } |
655 | void KeycodeConfig::addGap(int r, int w) | 662 | void KeycodeConfig::addGap(int r, int w) |
656 | { | 663 | { |
657 | QBitmap pm(w,1); // ick. | 664 | QBitmap pm(w,1); // ick. |
658 | addKey(r,pm,0); | 665 | addKey(r,pm,0); |
659 | } | 666 | } |
660 | 667 | ||
661 | QString CharConfig::text(int r, int i) | 668 | QString CharConfig::text(int r, int i) |
662 | { | 669 | { |
663 | QStringList l = r ? chars2 : chars1; | 670 | QStringList l = r ? chars2 : chars1; |
664 | return i < (int)l.count() ? l[i] : QString::null; | 671 | return i < (int)l.count() ? l[i] : QString::null; |
665 | } | 672 | } |
666 | bool CharConfig::spreadRow(int) | 673 | bool CharConfig::spreadRow(int) |
667 | { | 674 | { |
668 | return TRUE; | 675 | return TRUE; |
669 | } | 676 | } |
670 | 677 | ||
671 | void CharConfig::pick(bool press, int row, int item) | 678 | void CharConfig::pick(bool press, int row, int item) |
672 | { | 679 | { |
673 | if ( !press ) { | 680 | if ( !press ) { |
674 | if ( item >= 0 ) { | 681 | if ( item >= 0 ) { |
675 | generateText(row == 0 ? chars1[item] : chars2[item]); | 682 | generateText(row == 0 ? chars1[item] : chars2[item]); |
676 | } | 683 | } |
677 | changeMode(0); | 684 | changeMode(0); |
678 | updateRows(0,1); | 685 | updateRows(0,1); |
679 | } | 686 | } |
diff --git a/inputmethods/pickboard/pickboardcfg.h b/inputmethods/pickboard/pickboardcfg.h index b1913df..92c6420 100644 --- a/inputmethods/pickboard/pickboardcfg.h +++ b/inputmethods/pickboard/pickboardcfg.h | |||
@@ -1,213 +1,218 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the 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 | #ifndef PICKBOARDCFG_H | 20 | #ifndef PICKBOARDCFG_H |
21 | #define PICKBOARDCFG_H | 21 | #define PICKBOARDCFG_H |
22 | 22 | ||
23 | #include <qpe/qdawg.h> | 23 | #include <qpe/qdawg.h> |
24 | 24 | ||
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qhbuttongroup.h> | 26 | #include <qhbuttongroup.h> |
27 | #include <qdialog.h> | 27 | #include <qdialog.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | 29 | ||
30 | // Internal stuff... | 30 | // Internal stuff... |
31 | 31 | ||
32 | class PickboardPicks; | 32 | class PickboardPicks; |
33 | 33 | ||
34 | class LetterButton : public QPushButton { | 34 | class LetterButton : public QPushButton { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | public: |
37 | LetterButton(const QChar& letter, QWidget* parent); | 37 | LetterButton(const QChar& letter, QWidget* parent); |
38 | private slots: | 38 | private slots: |
39 | void toggleCase(); | 39 | void toggleCase(); |
40 | private: | 40 | private: |
41 | bool skip; | 41 | bool skip; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | class LetterChoice : public QButtonGroup { | 44 | class LetterChoice : public QButtonGroup { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | LetterChoice(QWidget* parent, const QString& set); | 47 | LetterChoice(QWidget* parent, const QString& set); |
48 | 48 | ||
49 | QChar choice() { return ch; } | 49 | QChar choice() { return ch; } |
50 | 50 | ||
51 | signals: | 51 | signals: |
52 | void changed(); | 52 | void changed(); |
53 | 53 | ||
54 | private slots: | 54 | private slots: |
55 | void change(); | 55 | void change(); |
56 | 56 | ||
57 | private: | 57 | private: |
58 | QChar ch; | 58 | QChar ch; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class PickboardAdd : public QDialog { | 61 | class PickboardAdd : public QDialog { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | public: | 63 | public: |
64 | PickboardAdd(QWidget* owner, const QStringList& setlist); | 64 | PickboardAdd(QWidget* owner, const QStringList& setlist); |
65 | ~PickboardAdd(); | 65 | ~PickboardAdd(); |
66 | 66 | ||
67 | QString word() const; | 67 | QString word() const; |
68 | bool exec(); | 68 | bool exec(); |
69 | 69 | ||
70 | private slots: | 70 | private slots: |
71 | void checkAllDone(); | 71 | void checkAllDone(); |
72 | 72 | ||
73 | private: | 73 | private: |
74 | QPushButton *yes; | 74 | QPushButton *yes; |
75 | LetterChoice **lc; | 75 | LetterChoice **lc; |
76 | int nlc; | 76 | int nlc; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | class PickboardConfig : QObject { | 79 | class PickboardConfig : public QObject { |
80 | Q_OBJECT | ||
80 | public: | 81 | public: |
81 | PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { } | 82 | PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { } |
82 | virtual ~PickboardConfig(); | 83 | virtual ~PickboardConfig(); |
83 | virtual void pickPoint(const QPoint& p, bool press); | 84 | virtual void pickPoint(const QPoint& p, bool press); |
84 | virtual void draw(QPainter*)=0; | 85 | virtual void draw(QPainter*)=0; |
85 | virtual void fillMenu(QPopupMenu&); | 86 | virtual void fillMenu(QPopupMenu&); |
86 | virtual void doMenu(int); | 87 | virtual void doMenu(int); |
87 | 88 | ||
88 | protected: | 89 | protected: |
89 | void updateRows(int from, int to); | 90 | void updateRows(int from, int to); |
90 | virtual void updateItem(int r, int i); | 91 | virtual void updateItem(int r, int i); |
91 | virtual void pickInRow(int r, int xpos, bool press)=0; | 92 | virtual void pickInRow(int r, int xpos, bool press)=0; |
92 | 93 | ||
93 | void changeMode(int m); | 94 | void changeMode(int m); |
94 | virtual void generateText(const QString& s); | 95 | virtual void generateText(const QString& s); |
95 | void generateKey( int k ); | 96 | void generateKey( int k ); |
96 | 97 | ||
97 | virtual void pick(bool press, int row, int item)=0; | 98 | virtual void pick(bool press, int row, int item)=0; |
98 | 99 | ||
99 | protected: | 100 | protected: |
100 | PickboardPicks* parent; | 101 | PickboardPicks* parent; |
101 | int nrows; | 102 | int nrows; |
102 | private: | 103 | private: |
103 | int pressrow, pressx; | 104 | int pressrow, pressx; |
104 | }; | 105 | }; |
105 | 106 | ||
106 | class StringConfig : public PickboardConfig { | 107 | class StringConfig : public PickboardConfig { |
108 | Q_OBJECT | ||
107 | public: | 109 | public: |
108 | StringConfig(PickboardPicks* p) : PickboardConfig(p) { } | 110 | StringConfig(PickboardPicks* p) : PickboardConfig(p) { } |
109 | 111 | ||
110 | void draw(QPainter* p); | 112 | void draw(QPainter* p); |
111 | 113 | ||
112 | protected: | 114 | protected: |
113 | virtual QString text(int r, int i)=0; | 115 | virtual QString text(int r, int i)=0; |
114 | virtual bool spreadRow(int i)=0; | 116 | virtual bool spreadRow(int i)=0; |
115 | virtual QColor rowColor(int) { return ::Qt::black; } | 117 | virtual QColor rowColor(int) { return Qt::black; } |
116 | virtual void pickInRow(int r, int xpos, bool press); | 118 | virtual void pickInRow(int r, int xpos, bool press); |
117 | virtual void updateItem(int r, int i); | 119 | virtual void updateItem(int r, int i); |
118 | virtual bool highlight(int,int) const; | 120 | virtual bool highlight(int,int) const; |
119 | }; | 121 | }; |
120 | 122 | ||
121 | class CharStringConfig : public StringConfig { | 123 | class CharStringConfig : public StringConfig { |
124 | Q_OBJECT | ||
122 | QString input; | 125 | QString input; |
123 | QStringList chars; | 126 | QStringList chars; |
124 | public: | 127 | public: |
125 | CharStringConfig(PickboardPicks* p) : StringConfig(p) { } | 128 | CharStringConfig(PickboardPicks* p) : StringConfig(p) { } |
126 | 129 | ||
127 | void addChar(const QString& s); | 130 | void addChar(const QString& s); |
128 | virtual void doMenu(int); | 131 | virtual void doMenu(int); |
129 | 132 | ||
130 | protected: | 133 | protected: |
131 | QString text(int r, int i); | 134 | QString text(int r, int i); |
132 | bool spreadRow(int i); | 135 | bool spreadRow(int i); |
133 | void pick(bool press, int row, int item); | 136 | void pick(bool press, int row, int item); |
134 | }; | 137 | }; |
135 | 138 | ||
136 | class DictFilterConfig : public StringConfig { | 139 | class DictFilterConfig : public StringConfig { |
140 | Q_OBJECT | ||
137 | QStringList matches; | 141 | QStringList matches; |
142 | QStringList sets_a; | ||
138 | QStringList sets; | 143 | QStringList sets; |
139 | QStringList othermodes; | 144 | QStringList othermodes; |
140 | int lit0; | 145 | int lit0; |
141 | int lit1; | 146 | int lit1; |
142 | int shift; | 147 | int shift; |
143 | QString capitalize(const QString& s); | 148 | QString capitalize(const QString& s); |
144 | QStringList capitalize(const QStringList& s); | 149 | QStringList capitalize(const QStringList& s); |
145 | 150 | ||
146 | public: | 151 | public: |
147 | QStringList input; | 152 | QStringList input; |
148 | DictFilterConfig(PickboardPicks* p) : StringConfig(p) | 153 | DictFilterConfig(PickboardPicks* p) : StringConfig(p) |
149 | { | 154 | { |
150 | shift = 0; | 155 | shift = 0; |
151 | lit0 = -1; | 156 | lit0 = -1; |
152 | lit1 = -1; | 157 | lit1 = -1; |
153 | } | 158 | } |
154 | 159 | ||
155 | void addSet(const QString& s); | 160 | void addSet(const QString& apperance, const QString& set); |
156 | void addMode(const QString& s); | 161 | void addMode(const QString& s); |
157 | 162 | ||
158 | void fillMenu(QPopupMenu& menu); | 163 | void fillMenu(QPopupMenu& menu); |
159 | void doMenu(int i); | 164 | void doMenu(int i); |
160 | 165 | ||
161 | void add(const QString& set); | 166 | void add(const QString& set); |
162 | 167 | ||
163 | protected: | 168 | protected: |
164 | QString text(int r, int i); | 169 | QString text(int r, int i); |
165 | 170 | ||
166 | bool spreadRow(int i); | 171 | bool spreadRow(int i); |
167 | 172 | ||
168 | void pick(bool press, int row, int item); | 173 | void pick(bool press, int row, int item); |
169 | 174 | ||
170 | bool scanMatch(const QString& set, const QChar& l) const; | 175 | bool scanMatch(const QString& set, const QChar& l) const; |
171 | void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend); | 176 | void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend); |
172 | void scanLengths(const QDawg::Node* n, int ipos, int& bitarray); | 177 | void scanLengths(const QDawg::Node* n, int ipos, int& bitarray); |
173 | 178 | ||
174 | bool highlight(int r,int c) const; | 179 | bool highlight(int r,int c) const; |
175 | }; | 180 | }; |
176 | 181 | ||
177 | class CharConfig : public StringConfig { | 182 | class CharConfig : public StringConfig { |
183 | Q_OBJECT | ||
178 | QStringList chars1; | 184 | QStringList chars1; |
179 | QStringList chars2; | 185 | QStringList chars2; |
180 | public: | 186 | public: |
181 | CharConfig(PickboardPicks* p) : StringConfig(p) { } | 187 | CharConfig(PickboardPicks* p) : StringConfig(p) { } |
182 | void addChar(int r, const QString& s); | 188 | void addChar(int r, const QString& s); |
183 | 189 | ||
184 | protected: | 190 | protected: |
185 | QString text(int r, int i); | 191 | QString text(int r, int i); |
186 | bool spreadRow(int); | 192 | bool spreadRow(int); |
187 | void pick(bool press, int row, int item); | 193 | void pick(bool press, int row, int item); |
188 | }; | 194 | }; |
189 | 195 | ||
190 | class KeycodeConfig : public PickboardConfig { | 196 | class KeycodeConfig : public PickboardConfig { |
191 | QValueList<int> keys1; | 197 | QValueList<int> keys1; |
192 | QValueList<int> keys2; | 198 | QValueList<int> keys2; |
193 | QValueList<QPixmap> keypm1; | 199 | QValueList<QPixmap> keypm1; |
194 | QValueList<QPixmap> keypm2; | 200 | QValueList<QPixmap> keypm2; |
195 | static const int xw = 8; | 201 | enum { xw = 8, xmarg = 8 }; |
196 | static const int xmarg = 8; | ||
197 | 202 | ||
198 | public: | 203 | public: |
199 | KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { } | 204 | KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { } |
200 | void addKey(int r, const QPixmap& pm, int code); | 205 | void addKey(int r, const QPixmap& pm, int code); |
201 | void addGap(int r, int w); | 206 | void addGap(int r, int w); |
202 | 207 | ||
203 | void draw(QPainter* p); | 208 | void draw(QPainter* p); |
204 | 209 | ||
205 | protected: | 210 | protected: |
206 | void pickInRow(int r, int xpos, bool press); | 211 | void pickInRow(int r, int xpos, bool press); |
207 | QValueList<QPixmap> row(int i); | 212 | QValueList<QPixmap> row(int i); |
208 | 213 | ||
209 | void pick(bool press, int row, int item); | 214 | void pick(bool press, int row, int item); |
210 | }; | 215 | }; |
211 | 216 | ||
212 | 217 | ||
213 | #endif | 218 | #endif |
diff --git a/inputmethods/pickboard/pickboardimpl.cpp b/inputmethods/pickboard/pickboardimpl.cpp index 9a21229..f839452 100644 --- a/inputmethods/pickboard/pickboardimpl.cpp +++ b/inputmethods/pickboard/pickboardimpl.cpp | |||
@@ -1,103 +1,103 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the 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 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qobject.h> | 21 | #include <qobject.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include "pickboard.h" | 23 | #include "pickboard.h" |
24 | #include "pickboardimpl.h" | 24 | #include "pickboardimpl.h" |
25 | 25 | ||
26 | /* XPM */ | 26 | /* XPM */ |
27 | static const char * pb_xpm[]={ | 27 | static const char * pb_xpm[]={ |
28 | "28 7 2 1", | 28 | "28 7 2 1", |
29 | "# c #303030", | 29 | "# c #303030", |
30 | " c None", | 30 | " c None", // No tr |
31 | " ########################## ", | 31 | " ########################## ", |
32 | " # # # # # # # ", | 32 | " # # # # # # # ", |
33 | " # # # # # # # ", | 33 | " # # # # # # # ", |
34 | " ########################## ", | 34 | " ########################## ", |
35 | " # # # # # # ", | 35 | " # # # # # # ", |
36 | " # # # # # # ", | 36 | " # # # # # # ", |
37 | " ########################## "}; | 37 | " ########################## "}; |
38 | 38 | ||
39 | 39 | ||
40 | PickboardImpl::PickboardImpl() | 40 | PickboardImpl::PickboardImpl() |
41 | : pickboard(0), icn(0) | 41 | : pickboard(0), icn(0) |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | PickboardImpl::~PickboardImpl() | 45 | PickboardImpl::~PickboardImpl() |
46 | { | 46 | { |
47 | delete pickboard; | 47 | delete pickboard; |
48 | delete icn; | 48 | delete icn; |
49 | } | 49 | } |
50 | 50 | ||
51 | QWidget *PickboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 51 | QWidget *PickboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
52 | { | 52 | { |
53 | if ( !pickboard ) | 53 | if ( !pickboard ) |
54 | pickboard = new Pickboard( parent, "pickboard", f ); | 54 | pickboard = new Pickboard( parent, "pickboard", f ); |
55 | return pickboard; | 55 | return pickboard; |
56 | } | 56 | } |
57 | 57 | ||
58 | void PickboardImpl::resetState() | 58 | void PickboardImpl::resetState() |
59 | { | 59 | { |
60 | if ( pickboard ) | 60 | if ( pickboard ) |
61 | pickboard->resetState(); | 61 | pickboard->resetState(); |
62 | } | 62 | } |
63 | 63 | ||
64 | QPixmap *PickboardImpl::icon() | 64 | QPixmap *PickboardImpl::icon() |
65 | { | 65 | { |
66 | if ( !icn ) | 66 | if ( !icn ) |
67 | icn = new QPixmap( (const char **)pb_xpm ); | 67 | icn = new QPixmap( (const char **)pb_xpm ); |
68 | return icn; | 68 | return icn; |
69 | } | 69 | } |
70 | 70 | ||
71 | QString PickboardImpl::name() | 71 | QString PickboardImpl::name() |
72 | { | 72 | { |
73 | return qApp->translate( "InputMethods", "Pickboard" ); | 73 | return qApp->translate( "InputMethods", "Pickboard" ); |
74 | } | 74 | } |
75 | 75 | ||
76 | void PickboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 76 | void PickboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
77 | { | 77 | { |
78 | if ( pickboard ) | 78 | if ( pickboard ) |
79 | QObject::connect( pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 79 | QObject::connect( pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
80 | } | 80 | } |
81 | 81 | ||
82 | #ifndef QT_NO_COMPONENT | 82 | #ifndef QT_NO_COMPONENT |
83 | QRESULT PickboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 83 | QRESULT PickboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
84 | { | 84 | { |
85 | *iface = 0; | 85 | *iface = 0; |
86 | if ( uuid == IID_QUnknown ) | 86 | if ( uuid == IID_QUnknown ) |
87 | *iface = this; | 87 | *iface = this; |
88 | else if ( uuid == IID_InputMethod ) | 88 | else if ( uuid == IID_InputMethod ) |
89 | *iface = this; | 89 | *iface = this; |
90 | else | 90 | else |
91 | return QS_FALSE; | 91 | return QS_FALSE; |
92 | 92 | ||
93 | if ( *iface ) | 93 | if ( *iface ) |
94 | (*iface)->addRef(); | 94 | (*iface)->addRef(); |
95 | return QS_OK; | 95 | return QS_OK; |
96 | } | 96 | } |
97 | 97 | ||
98 | Q_EXPORT_INTERFACE() | 98 | Q_EXPORT_INTERFACE() |
99 | { | 99 | { |
100 | Q_CREATE_INSTANCE( PickboardImpl ) | 100 | Q_CREATE_INSTANCE( PickboardImpl ) |
101 | } | 101 | } |
102 | #endif | 102 | #endif |
103 | 103 | ||
diff --git a/inputmethods/pickboard/pickboardpicks.cpp b/inputmethods/pickboard/pickboardpicks.cpp index a80bbf8..b9d9928 100644 --- a/inputmethods/pickboard/pickboardpicks.cpp +++ b/inputmethods/pickboard/pickboardpicks.cpp | |||
@@ -1,132 +1,134 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the 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 | #include "pickboardpicks.h" | 20 | #include "pickboardpicks.h" |
21 | #include "pickboardcfg.h" | 21 | #include "pickboardcfg.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qbitmap.h> | 27 | #include <qbitmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qdialog.h> | 30 | #include <qdialog.h> |
31 | #include <qscrollview.h> | 31 | #include <qscrollview.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qhbuttongroup.h> | 33 | #include <qhbuttongroup.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #ifdef QWS | ||
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #endif | ||
37 | 39 | ||
38 | void PickboardPicks::doMenu() | 40 | void PickboardPicks::doMenu() |
39 | { | 41 | { |
40 | QWidget* cause = (QWidget*)sender(); // evil | 42 | QWidget* cause = (QWidget*)sender(); // evil |
41 | 43 | ||
42 | QPopupMenu popup(this); | 44 | QPopupMenu popup(this); |
43 | config()->fillMenu(popup); | 45 | config()->fillMenu(popup); |
44 | 46 | ||
45 | QPoint pos = cause->mapToGlobal(cause->rect().topRight()); | 47 | QPoint pos = cause->mapToGlobal(cause->rect().topRight()); |
46 | QSize sz = popup.sizeHint(); | 48 | QSize sz = popup.sizeHint(); |
47 | pos.ry() -= sz.height(); | 49 | pos.ry() -= sz.height(); |
48 | pos.rx() -= sz.width(); | 50 | pos.rx() -= sz.width(); |
49 | popup.move(pos); | 51 | popup.move(pos); |
50 | config()->doMenu(popup.exec()); | 52 | config()->doMenu(popup.exec()); |
51 | } | 53 | } |
52 | 54 | ||
53 | static const char *BS_xpm[] = { | 55 | static const char *BS_xpm[] = { |
54 | "5 7 2 1", | 56 | "5 7 2 1", |
55 | "a c #000000", | 57 | "a c #000000", |
56 | ". c None", | 58 | ". c None", |
57 | "...aa", | 59 | "...aa", |
58 | "..aaa", | 60 | "..aaa", |
59 | ".aaaa", | 61 | ".aaaa", |
60 | "aaaaa", | 62 | "aaaaa", |
61 | ".aaaa", | 63 | ".aaaa", |
62 | "..aaa", | 64 | "..aaa", |
63 | "...aa", | 65 | "...aa", |
64 | }; | 66 | }; |
65 | static const char *Del_xpm[] = { | 67 | static const char *Del_xpm[] = { |
66 | "14 7 2 1", | 68 | "14 7 2 1", |
67 | "a c #000000", | 69 | "a c #000000", |
68 | ". c None", | 70 | ". c None", |
69 | "aaa..aaaa.a...", | 71 | "aaa..aaaa.a...", |
70 | "a..a.a....a...", | 72 | "a..a.a....a...", |
71 | "a..a.a....a...", | 73 | "a..a.a....a...", |
72 | "a..a.aaa..a...", | 74 | "a..a.aaa..a...", |
73 | "a..a.a....a...", | 75 | "a..a.a....a...", |
74 | "a..a.a....a...", | 76 | "a..a.a....a...", |
75 | "aaa..aaaa.aaaa" | 77 | "aaa..aaaa.aaaa" |
76 | }; | 78 | }; |
77 | static const char *Home_xpm[] = { | 79 | static const char *Home_xpm[] = { |
78 | "20 7 2 1", | 80 | "20 7 2 1", |
79 | "a c #000000", | 81 | "a c #000000", |
80 | ". c None", | 82 | ". c None", |
81 | "a..a..aa..a...a.aaaa", | 83 | "a..a..aa..a...a.aaaa", |
82 | "a..a.a..a.aa.aa.a...", | 84 | "a..a.a..a.aa.aa.a...", |
83 | "a..a.a..a.a.a.a.a...", | 85 | "a..a.a..a.a.a.a.a...", |
84 | "aaaa.a..a.a.a.a.aaa.", | 86 | "aaaa.a..a.a.a.a.aaa.", |
85 | "a..a.a..a.a...a.a...", | 87 | "a..a.a..a.a...a.a...", |
86 | "a..a.a..a.a...a.a...", | 88 | "a..a.a..a.a...a.a...", |
87 | "a..a..aa..a...a.aaaa" | 89 | "a..a..aa..a...a.aaaa" |
88 | }; | 90 | }; |
89 | static const char *PgUp_xpm[] = { | 91 | static const char *PgUp_xpm[] = { |
90 | "20 7 2 1", | 92 | "20 7 2 1", |
91 | "a c #000000", | 93 | "a c #000000", |
92 | ". c None", | 94 | ". c None", |
93 | "aaa.......a..a......", | 95 | "aaa.......a..a......", |
94 | "a..a......a..a......", | 96 | "a..a......a..a......", |
95 | "a..a.aa...a..a.aaa..", | 97 | "a..a.aa...a..a.aaa..", |
96 | "aaa.a.....a..a.a..a.", | 98 | "aaa.a.....a..a.a..a.", |
97 | "a...a.aa..a..a.aaa..", | 99 | "a...a.aa..a..a.aaa..", |
98 | "a...a..a..a..a.a....", | 100 | "a...a..a..a..a.a....", |
99 | "a....aaa...aa..a...." | 101 | "a....aaa...aa..a...." |
100 | }; | 102 | }; |
101 | static const char *PgDn_xpm[] = { | 103 | static const char *PgDn_xpm[] = { |
102 | "20 7 2 1", | 104 | "20 7 2 1", |
103 | "a c #000000", | 105 | "a c #000000", |
104 | ". c None", | 106 | ". c None", |
105 | "aaa.......aaa.......", | 107 | "aaa.......aaa.......", |
106 | "a..a......a..a......", | 108 | "a..a......a..a......", |
107 | "a..a.aa...a..a.a..a.", | 109 | "a..a.aa...a..a.a..a.", |
108 | "aaa.a.....a..a.aa.a.", | 110 | "aaa.a.....a..a.aa.a.", |
109 | "a...a.aa..a..a.a.aa.", | 111 | "a...a.aa..a..a.a.aa.", |
110 | "a...a..a..a..a.a..a.", | 112 | "a...a..a..a..a.a..a.", |
111 | "a....aaa..aaa..a..a." | 113 | "a....aaa..aaa..a..a." |
112 | }; | 114 | }; |
113 | static const char *End_xpm[] = { | 115 | static const char *End_xpm[] = { |
114 | "14 7 2 1", | 116 | "14 7 2 1", |
115 | "a c #000000", | 117 | "a c #000000", |
116 | ". c None", | 118 | ". c None", |
117 | "aaaa.a..a.aaa.", | 119 | "aaaa.a..a.aaa.", |
118 | "a....aa.a.a..a", | 120 | "a....aa.a.a..a", |
119 | "a....a.aa.a..a", | 121 | "a....a.aa.a..a", |
120 | "aaa..a..a.a..a", | 122 | "aaa..a..a.a..a", |
121 | "a....a..a.a..a", | 123 | "a....a..a.a..a", |
122 | "a....a..a.a..a", | 124 | "a....a..a.a..a", |
123 | "aaaa.a..a.aaa." | 125 | "aaaa.a..a.aaa." |
124 | }; | 126 | }; |
125 | static const char *Enter_xpm[] = { | 127 | static const char *Enter_xpm[] = { |
126 | "14 7 2 1", | 128 | "14 7 2 1", |
127 | "a c #000000", | 129 | "a c #000000", |
128 | ". c None", | 130 | ". c None", |
129 | ".............a", | 131 | ".............a", |
130 | ".............a", | 132 | ".............a", |
131 | "..a..........a", | 133 | "..a..........a", |
132 | ".aa.........a.", | 134 | ".aa.........a.", |
@@ -155,216 +157,213 @@ static const char *Ins_xpm[] = { | |||
155 | ".a..a.aa.a...", | 157 | ".a..a.aa.a...", |
156 | ".a..a..a..aa.", | 158 | ".a..a..a..aa.", |
157 | ".a..a..a....a", | 159 | ".a..a..a....a", |
158 | ".a..a..a.a..a", | 160 | ".a..a..a.a..a", |
159 | "aaa.a..a..aa." | 161 | "aaa.a..a..aa." |
160 | }; | 162 | }; |
161 | static const char *Up_xpm[] = { | 163 | static const char *Up_xpm[] = { |
162 | "7 7 2 1", | 164 | "7 7 2 1", |
163 | "a c #000000", | 165 | "a c #000000", |
164 | ". c None", | 166 | ". c None", |
165 | "...a...", | 167 | "...a...", |
166 | "..aaa..", | 168 | "..aaa..", |
167 | ".a.a.a.", | 169 | ".a.a.a.", |
168 | "a..a..a", | 170 | "a..a..a", |
169 | "...a...", | 171 | "...a...", |
170 | "...a...", | 172 | "...a...", |
171 | "...a..." | 173 | "...a..." |
172 | }; | 174 | }; |
173 | static const char *Left_xpm[] = { | 175 | static const char *Left_xpm[] = { |
174 | "7 7 2 1", | 176 | "7 7 2 1", |
175 | "a c #000000", | 177 | "a c #000000", |
176 | ". c None", | 178 | ". c None", |
177 | "...a...", | 179 | "...a...", |
178 | "..a....", | 180 | "..a....", |
179 | ".a.....", | 181 | ".a.....", |
180 | "aaaaaaa", | 182 | "aaaaaaa", |
181 | ".a.....", | 183 | ".a.....", |
182 | "..a....", | 184 | "..a....", |
183 | "...a..." | 185 | "...a..." |
184 | }; | 186 | }; |
185 | static const char *Down_xpm[] = { | 187 | static const char *Down_xpm[] = { |
186 | "7 7 2 1", | 188 | "7 7 2 1", |
187 | "a c #000000", | 189 | "a c #000000", |
188 | ". c None", | 190 | ". c None", |
189 | "...a...", | 191 | "...a...", |
190 | "...a...", | 192 | "...a...", |
191 | "...a...", | 193 | "...a...", |
192 | "a..a..a", | 194 | "a..a..a", |
193 | ".a.a.a.", | 195 | ".a.a.a.", |
194 | "..aaa..", | 196 | "..aaa..", |
195 | "...a..." | 197 | "...a..." |
196 | }; | 198 | }; |
197 | static const char *Right_xpm[] = { | 199 | static const char *Right_xpm[] = { |
198 | "7 7 2 1", | 200 | "7 7 2 1", |
199 | "a c #000000", | 201 | "a c #000000", |
200 | ". c None", | 202 | ". c None", |
201 | "...a...", | 203 | "...a...", |
202 | "....a..", | 204 | "....a..", |
203 | ".....a.", | 205 | ".....a.", |
204 | "aaaaaaa", | 206 | "aaaaaaa", |
205 | ".....a.", | 207 | ".....a.", |
206 | "....a..", | 208 | "....a..", |
207 | "...a..." | 209 | "...a..." |
208 | }; | 210 | }; |
209 | static const char *BackTab_xpm[] = { | 211 | static const char *BackTab_xpm[] = { |
210 | "8 7 2 1", | 212 | "8 7 2 1", |
211 | "a c #000000", | 213 | "a c #000000", |
212 | ". c None", | 214 | ". c None", |
213 | "a.......", | 215 | "a.......", |
214 | "a..a....", | 216 | "a..a....", |
215 | "a.aa....", | 217 | "a.aa....", |
216 | "aaaaaaaa", | 218 | "aaaaaaaa", |
217 | "a.aa....", | 219 | "a.aa....", |
218 | "a..a....", | 220 | "a..a....", |
219 | "a......." | 221 | "a......." |
220 | }; | 222 | }; |
221 | static const char *Tab_xpm[] = { | 223 | static const char *Tab_xpm[] = { |
222 | "8 7 2 1", | 224 | "8 7 2 1", |
223 | "a c #000000", | 225 | "a c #000000", |
224 | ". c None", | 226 | ". c None", |
225 | ".......a", | 227 | ".......a", |
226 | "....a..a", | 228 | "....a..a", |
227 | "....aa.a", | 229 | "....aa.a", |
228 | "aaaaaaaa", | 230 | "aaaaaaaa", |
229 | "....aa.a", | 231 | "....aa.a", |
230 | "....a..a", | 232 | "....a..a", |
231 | ".......a" | 233 | ".......a" |
232 | }; | 234 | }; |
233 | static const char *Space_xpm[] = { | 235 | static const char *Space_xpm[] = { |
234 | "9 9 2 1", | 236 | "9 9 2 1", |
235 | "a c #000000", | 237 | "a c #000000", |
236 | ". c None", | 238 | ". c None", |
237 | "aaaaaaaaa", | 239 | "aaaaaaaaa", |
238 | "a.......a", | 240 | "a.......a", |
239 | "a.......a", | 241 | "a.......a", |
240 | "a.......a", | 242 | "a.......a", |
241 | "a.......a", | 243 | "a.......a", |
242 | "a.......a", | 244 | "a.......a", |
243 | "a.......a", | 245 | "a.......a", |
244 | "a.......a", | 246 | "a.......a", |
245 | "aaaaaaaaa" | 247 | "aaaaaaaaa" |
246 | }; | 248 | }; |
247 | 249 | ||
248 | PickboardPicks::PickboardPicks(QWidget* parent, const char* name, WFlags f ) : | 250 | PickboardPicks::PickboardPicks(QWidget* parent, const char* name, WFlags f ) : |
249 | QFrame(parent,name,f) | 251 | QFrame(parent,name,f) |
250 | { | 252 | { |
253 | configs.setAutoDelete( TRUE ); | ||
251 | } | 254 | } |
252 | 255 | ||
253 | void PickboardPicks::initialise(void) | 256 | void PickboardPicks::initialise(void) |
254 | { | 257 | { |
255 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 258 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
256 | mode = 0; | 259 | mode = 0; |
257 | 260 | ||
258 | DictFilterConfig* dc = new DictFilterConfig(this); | 261 | DictFilterConfig* dc = new DictFilterConfig(this); |
259 | dc->addSet("ABC"); | 262 | QStringList sets_a = QStringList::split(' ',tr("ABC DEF GHI JKL MNO PQR STU VWX YZ-'")); |
260 | dc->addSet("DEF"); | 263 | QStringList sets = QStringList::split(' ', |
261 | dc->addSet("GHI"); | 264 | tr("ABC%/1iso8859-15 DEF%/1iso8859-15 GHI%/1iso8859-15 JKL MNO%/1iso8859-15 PQR%/1iso8859-15 STU%/1iso8859-15 VWX YZ-'%/1iso8859-15")); |
262 | dc->addSet("JKL"); | 265 | for (QStringList::ConstIterator it = sets.begin(), it_a = sets_a.begin(); it!=sets.end(); ++it,++it_a) |
263 | dc->addSet("MNO"); | 266 | dc->addSet(*it_a,*it); |
264 | dc->addSet("PQR"); | ||
265 | dc->addSet("STU"); | ||
266 | dc->addSet("VWX"); | ||
267 | dc->addSet("YZ-'"); | ||
268 | dc->addMode("123"); | 267 | dc->addMode("123"); |
269 | dc->addMode("@*!?"); | 268 | dc->addMode("@*!?"); |
270 | dc->addMode("KEY"); | 269 | dc->addMode(tr("KEY")); |
271 | dc->addMode("Space"); | 270 | dc->addMode(tr("Space")); |
272 | dc->addMode("Back"); | 271 | dc->addMode(tr("Back")); |
273 | dc->addMode("Enter"); | 272 | dc->addMode(tr("Enter")); |
274 | dc->addMode("Shift"); | 273 | dc->addMode(tr("Shift")); |
275 | configs.append(dc); | 274 | configs.append(dc); |
276 | 275 | ||
277 | CharStringConfig* number = new CharStringConfig(this); | 276 | CharStringConfig* number = new CharStringConfig(this); |
278 | number->addChar("0"); | 277 | number->addChar("0"); |
279 | number->addChar("1"); | 278 | number->addChar("1"); |
280 | number->addChar("2"); | 279 | number->addChar("2"); |
281 | number->addChar("3"); | 280 | number->addChar("3"); |
282 | number->addChar("4"); | 281 | number->addChar("4"); |
283 | number->addChar("5"); | 282 | number->addChar("5"); |
284 | number->addChar("6"); | 283 | number->addChar("6"); |
285 | number->addChar("7"); | 284 | number->addChar("7"); |
286 | number->addChar("8"); | 285 | number->addChar("8"); |
287 | number->addChar("9"); | 286 | number->addChar("9"); |
288 | number->addChar("."); // #### or "," in some locales | 287 | number->addChar("."); // #### or "," in some locales |
289 | configs.append(number); | 288 | configs.append(number); |
290 | 289 | ||
291 | CharConfig* punc = new CharConfig(this); | 290 | CharConfig* punc = new CharConfig(this); |
292 | 291 | ||
293 | punc->addChar(0,"\""); | 292 | punc->addChar(0,"\""); |
294 | punc->addChar(0,"`"); | 293 | punc->addChar(0,"`"); |
295 | punc->addChar(0,"'"); | 294 | punc->addChar(0,"'"); |
296 | punc->addChar(0,"\253"); | 295 | punc->addChar(0,"\253"); |
297 | punc->addChar(0,"\273"); | 296 | punc->addChar(0,"\273"); |
298 | punc->addChar(0,"\277"); | 297 | punc->addChar(0,"\277"); |
299 | punc->addChar(1,"("); | 298 | punc->addChar(1,"("); |
300 | punc->addChar(1,")"); | 299 | punc->addChar(1,")"); |
301 | punc->addChar(1,"["); | 300 | punc->addChar(1,"["); |
302 | punc->addChar(1,"]"); | 301 | punc->addChar(1,"]"); |
303 | punc->addChar(1,"{"); | 302 | punc->addChar(1,"{"); |
304 | punc->addChar(1,"}"); | 303 | punc->addChar(1,"}"); |
305 | 304 | ||
306 | punc->addChar(0,"+"); | 305 | punc->addChar(0,"+"); |
307 | punc->addChar(0,"-"); | 306 | punc->addChar(0,"-"); |
308 | punc->addChar(0,"*"); | 307 | punc->addChar(0,"*"); |
309 | punc->addChar(0,"/"); | 308 | punc->addChar(0,"/"); |
310 | punc->addChar(0,"="); | 309 | punc->addChar(0,"="); |
311 | punc->addChar(0,"_"); | 310 | punc->addChar(0,"_"); |
312 | punc->addChar(0,"$"); | 311 | punc->addChar(0,"$"); |
313 | punc->addChar(0,"&"); | 312 | punc->addChar(0,"&"); |
314 | punc->addChar(1,"|"); | 313 | punc->addChar(1,"|"); |
315 | punc->addChar(1,"@"); | 314 | punc->addChar(1,"@"); |
316 | punc->addChar(1,"\\"); | 315 | punc->addChar(1,"\\"); |
317 | punc->addChar(1,"#"); | 316 | punc->addChar(1,"#"); |
318 | punc->addChar(1,"^"); | 317 | punc->addChar(1,"^"); |
319 | punc->addChar(1,"~"); | 318 | punc->addChar(1,"~"); |
320 | punc->addChar(1,"<"); | 319 | punc->addChar(1,"<"); |
321 | punc->addChar(1,">"); | 320 | punc->addChar(1,">"); |
322 | 321 | ||
323 | punc->addChar(0,"."); | 322 | punc->addChar(0,"."); |
324 | punc->addChar(0,"?"); | 323 | punc->addChar(0,"?"); |
325 | punc->addChar(0,"!"); | 324 | punc->addChar(0,"!"); |
326 | punc->addChar(0,","); | 325 | punc->addChar(0,","); |
327 | punc->addChar(0,";"); | 326 | punc->addChar(0,";"); |
328 | punc->addChar(1,":"); | 327 | punc->addChar(1,":"); |
329 | punc->addChar(1,"\267"); | 328 | punc->addChar(1,"\267"); |
330 | punc->addChar(1,"\277"); | 329 | punc->addChar(1,"\277"); |
331 | punc->addChar(1,"\241"); | 330 | punc->addChar(1,"\241"); |
332 | punc->addChar(1,"\367"); | 331 | punc->addChar(1,"\367"); |
333 | 332 | ||
334 | punc->addChar(0,"$"); | 333 | punc->addChar(0,"$"); |
335 | punc->addChar(0,"\242"); | 334 | punc->addChar(0,"\242"); |
336 | punc->addChar(0,"\245"); | 335 | punc->addChar(0,"\245"); |
337 | punc->addChar(1,"\243"); | 336 | punc->addChar(1,"\243"); |
338 | punc->addChar(1,"\244"); | 337 | punc->addChar(1,"\244"); |
339 | punc->addChar(1,"\260"); | 338 | punc->addChar(1,"\260"); |
340 | 339 | ||
341 | configs.append(punc); | 340 | configs.append(punc); |
342 | 341 | ||
343 | KeycodeConfig* keys = new KeycodeConfig(this); | 342 | KeycodeConfig* keys = new KeycodeConfig(this); |
344 | keys->addKey(0,QPixmap(Esc_xpm),Key_Escape); | 343 | keys->addKey(0,QPixmap(Esc_xpm),Key_Escape); |
345 | keys->addKey(0,QPixmap(BS_xpm),Key_Backspace); | 344 | keys->addKey(0,QPixmap(BS_xpm),Key_Backspace); |
346 | keys->addGap(0,10); | 345 | keys->addGap(0,10); |
347 | 346 | ||
348 | keys->addKey(0,QPixmap(Ins_xpm),Key_Insert); | 347 | keys->addKey(0,QPixmap(Ins_xpm),Key_Insert); |
349 | keys->addKey(0,QPixmap(Home_xpm),Key_Home); | 348 | keys->addKey(0,QPixmap(Home_xpm),Key_Home); |
350 | keys->addKey(0,QPixmap(PgUp_xpm),Key_PageUp); | 349 | keys->addKey(0,QPixmap(PgUp_xpm),Key_PageUp); |
351 | 350 | ||
352 | keys->addGap(0,25); | 351 | keys->addGap(0,25); |
353 | keys->addKey(0,QPixmap(Up_xpm),Key_Up); | 352 | keys->addKey(0,QPixmap(Up_xpm),Key_Up); |
354 | keys->addGap(0,15); | 353 | keys->addGap(0,15); |
355 | 354 | ||
356 | keys->addKey(1,QPixmap(BackTab_xpm),Key_Tab); | 355 | keys->addKey(1,QPixmap(BackTab_xpm),Key_Tab); |
357 | keys->addGap(1,3); | 356 | keys->addGap(1,3); |
358 | keys->addKey(1,QPixmap(Tab_xpm),Key_Tab); | 357 | keys->addKey(1,QPixmap(Tab_xpm),Key_Tab); |
359 | keys->addGap(1,10); | 358 | keys->addGap(1,10); |
360 | 359 | ||
361 | keys->addKey(1,QPixmap(Del_xpm),Key_Delete); | 360 | keys->addKey(1,QPixmap(Del_xpm),Key_Delete); |
362 | keys->addGap(1,2); | 361 | keys->addGap(1,2); |
363 | keys->addKey(1,QPixmap(End_xpm),Key_End); | 362 | keys->addKey(1,QPixmap(End_xpm),Key_End); |
364 | keys->addGap(1,3); | 363 | keys->addGap(1,3); |
365 | keys->addKey(1,QPixmap(PgDn_xpm),Key_PageDown); | 364 | keys->addKey(1,QPixmap(PgDn_xpm),Key_PageDown); |
366 | 365 | ||
367 | keys->addGap(1,10); | 366 | keys->addGap(1,10); |
368 | keys->addKey(1,QPixmap(Left_xpm),Key_Left); | 367 | keys->addKey(1,QPixmap(Left_xpm),Key_Left); |
369 | keys->addKey(1,QPixmap(Down_xpm),Key_Down); | 368 | keys->addKey(1,QPixmap(Down_xpm),Key_Down); |
370 | keys->addKey(1,QPixmap(Right_xpm),Key_Right); | 369 | keys->addKey(1,QPixmap(Right_xpm),Key_Right); |