summaryrefslogtreecommitdiff
path: root/inputmethods
Unidiff
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp2
-rw-r--r--inputmethods/multikey/keyboard.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index a6e4dad..ac132d3 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,219 +1,221 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * 4 *
5 * 5 *
6 * 6 *
7 */ 7 */
8 8
9#include <iostream.h> 9#include <iostream.h>
10 10
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include <qwidget.h> 14#include <qwidget.h>
15#include <qdialog.h> 15#include <qdialog.h>
16#include <qtabwidget.h> 16#include <qtabwidget.h>
17#include <qvbox.h> 17#include <qvbox.h>
18#include <qgrid.h> 18#include <qgrid.h>
19#include <qgroupbox.h> 19#include <qgroupbox.h>
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qcheckbox.h> 21#include <qcheckbox.h>
22#include <qsizepolicy.h> 22#include <qsizepolicy.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qlistbox.h> 24#include <qlistbox.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <opie/ofiledialog.h> 26#include <opie/ofiledialog.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qfileinfo.h> 28#include <qfileinfo.h>
29#include "configdlg.h" 29#include "configdlg.h"
30#include "keyboard.h" 30#include "keyboard.h"
31 31
32ConfigDlg::ConfigDlg () : QTabWidget () 32ConfigDlg::ConfigDlg () : QTabWidget ()
33{ 33{
34 setCaption( tr("Multikey Configuration") ); 34 setCaption( tr("Multikey Configuration") );
35 Config config ("multikey"); 35 Config config ("multikey");
36 config.setGroup("keymaps"); 36 config.setGroup("keymaps");
37 QString current_map = config.readEntry("current", 0); 37 QString current_map = config.readEntry("current", 0);
38 38
39 /* 39 /*
40 * 'general config' tab 40 * 'general config' tab
41 */ 41 */
42 42
43 QVBox *gen_box = new QVBox (this); 43 QVBox *gen_box = new QVBox (this);
44 gen_box->setMargin(3); 44 gen_box->setMargin(3);
45 addTab(gen_box, tr("General Settings")); 45 addTab(gen_box, tr("General Settings"));
46 46
47 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); 47 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box);
48 48
49 keymaps = new QListBox (map_group); 49 keymaps = new QListBox (map_group);
50 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 50 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
51 51
52 QString cur(tr("Current Language")); 52 QString cur(tr("Current Language"));
53 keymaps->insertItem(cur); 53 keymaps->insertItem(cur);
54 keymaps->setSelected(0, true); 54 keymaps->setSelected(0, true);
55 55
56 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); 56 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap");
57 default_maps = map_dir.entryList(); // so i can access it in other places 57 default_maps = map_dir.entryList(); // so i can access it in other places
58 58
59 for (uint i = 0; i <map_dir.count(); i++) { 59 for (uint i = 0; i <map_dir.count(); i++) {
60 60
61 keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); 61 keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]);
62 if (map_dir.absPath() + "/" + map_dir[i] == current_map) { 62 if (map_dir.absPath() + "/" + map_dir[i] == current_map) {
63 63
64 keymaps->setSelected(i + 1, true); 64 keymaps->setSelected(i + 1, true);
65 } 65 }
66 66
67 } 67 }
68 68
69 custom_maps = config.readListEntry("maps", QChar('|')); 69 custom_maps = config.readListEntry("maps", QChar('|'));
70 70
71 for (uint i = 0; i < custom_maps.count(); i++) { 71 for (uint i = 0; i < custom_maps.count(); i++) {
72 72
73 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) 73 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false)
74 || !QFile::exists(custom_maps[i])) { 74 || !QFile::exists(custom_maps[i])) {
75 75
76 custom_maps.remove(custom_maps.at(i)); 76 custom_maps.remove(custom_maps.at(i));
77 77
78 // remove it from the list too 78 // remove it from the list too
79 config.writeEntry("maps", custom_maps.join("|")); 79 config.writeEntry("maps", custom_maps.join("|"));
80 80
81 81
82 } else { 82 } else {
83 83
84 keymaps->insertItem(custom_maps[i]); 84 keymaps->insertItem(custom_maps[i]);
85 if (custom_maps[i] == current_map) { 85 if (custom_maps[i] == current_map) {
86 86
87 keymaps->setSelected(map_dir.count() + i + 1, true); 87 keymaps->setSelected(map_dir.count() + i + 1, true);
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 // have to "+1" because the "current language" listItem... remember? 92 // have to "+1" because the "current language" listItem... remember?
93 93
94 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); 94 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int)));
95 95
96 96
97 QGrid *add_remove_grid = new QGrid(2, map_group); 97 QGrid *add_remove_grid = new QGrid(2, map_group);
98 add_remove_grid->setMargin(3); 98 add_remove_grid->setMargin(3);
99 add_remove_grid->setSpacing(3); 99 add_remove_grid->setSpacing(3);
100 100
101 add_button = new QPushButton(tr("Add"), add_remove_grid); 101 add_button = new QPushButton(tr("Add"), add_remove_grid);
102 add_button->setFlat((bool)1); 102 add_button->setFlat((bool)1);
103 connect(add_button, SIGNAL(clicked()), SLOT(addMap())); 103 connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
104 104
105 remove_button = new QPushButton(tr("Remove"), add_remove_grid); 105 remove_button = new QPushButton(tr("Remove"), add_remove_grid);
106 remove_button->setFlat((bool)1); 106 remove_button->setFlat((bool)1);
107 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); 107 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
108 108
109 pick_button = new QCheckBox(tr("Pickboard"), gen_box); 109 pick_button = new QCheckBox(tr("Pickboard"), gen_box);
110 110
111 config.setGroup ("pickboard"); 111 config.setGroup ("pickboard");
112 bool pick_open = config.readBoolEntry ("open", "0"); // default closed 112 bool pick_open = config.readBoolEntry ("open", "0"); // default closed
113 if (pick_open) { 113 if (pick_open) {
114 114
115 pick_button->setChecked(true); 115 pick_button->setChecked(true);
116 } 116 }
117 117
118 // by connecting it after checking it, the signal isn't emmited 118 // by connecting it after checking it, the signal isn't emmited
119 connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); 119 connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog()));
120 120
121 /* 121 /*
122 * 'color' tab 122 * 'color' tab
123 */ 123 */
124 124
125 QGrid *color_box = new QGrid(2, this); 125 QGrid *color_box = new QGrid(2, this);
126 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 126 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
127 color_box->setMargin(3); 127 color_box->setMargin(3);
128 color_box->setSpacing(3); 128 color_box->setSpacing(3);
129 addTab(color_box, tr("Colors")); 129 addTab(color_box, tr("Colors"));
130 130
131 QLabel *label; 131 QLabel *label;
132 132
133 label = new QLabel(tr("Key Color"), color_box); 133 label = new QLabel(tr("Key Color"), color_box);
134 QPushButton *button = new QPushButton(color_box); 134 QPushButton *button = new QPushButton(color_box);
135 button->setFlat((bool)1); 135 button->setFlat((bool)1);
136 label = new QLabel(tr("Key Pressed Color"), color_box); 136 label = new QLabel(tr("Key Pressed Color"), color_box);
137 button = new QPushButton(color_box); 137 button = new QPushButton(color_box);
138 button->setFlat((bool)1); 138 button->setFlat((bool)1);
139 label = new QLabel(tr("Line Color"), color_box); 139 label = new QLabel(tr("Line Color"), color_box);
140 button = new QPushButton(color_box); 140 button = new QPushButton(color_box);
141 button->setFlat((bool)1); 141 button->setFlat((bool)1);
142 label = new QLabel(tr("Text Color"), color_box); 142 label = new QLabel(tr("Text Color"), color_box);
143 button = new QPushButton(color_box); 143 button = new QPushButton(color_box);
144 button->setFlat((bool)1); 144 button->setFlat((bool)1);
145 145
146 label = new QLabel("", color_box); // a spacer so the above buttons dont expand 146 label = new QLabel("", color_box); // a spacer so the above buttons dont expand
147 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 147 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
148 148
149} 149}
150 150
151void ConfigDlg::pickTog() { 151void ConfigDlg::pickTog() {
152 152
153 Config config ("multikey"); 153 Config config ("multikey");
154 config.setGroup ("pickboard"); 154 config.setGroup ("pickboard");
155 config.writeEntry ("open", pick_button->isChecked()); // default closed 155 config.writeEntry ("open", pick_button->isChecked()); // default closed
156 156
157 emit pickboardToggled(pick_button->isChecked()); 157 emit pickboardToggled(pick_button->isChecked());
158} 158}
159 159
160/* 160/*
161 * the index is kinda screwy, because in the config file, index 0 is just the 161 * the index is kinda screwy, because in the config file, index 0 is just the
162 * first element in the QStringList, but here it's the "Current Language" 162 * first element in the QStringList, but here it's the "Current Language"
163 * listItem. therefor you have to minus one to the index before you access it. 163 * listItem. therefor you have to minus one to the index before you access it.
164 * 164 *
165 */ 165 */
166 166
167void ConfigDlg::setMap(int index) { 167void ConfigDlg::setMap(int index) {
168 168
169 if (index == 0) { 169 if (index == 0) {
170 170
171 remove_button->setDisabled(true); 171 remove_button->setDisabled(true);
172 172
173 emit setMapToDefault(); 173 emit setMapToDefault();
174 } 174 }
175 else if ((uint)index <= default_maps.count()) { 175 else if ((uint)index <= default_maps.count()) {
176 176
177 remove_button->setDisabled(true); 177 remove_button->setDisabled(true);
178 178
179 emit setMapToFile(keymaps->text(index));
180
179 } else { 181 } else {
180 182
181 remove_button->setEnabled(true); 183 remove_button->setEnabled(true);
182 184
183 emit setMapToFile(keymaps->text(index)); 185 emit setMapToFile(keymaps->text(index));
184 } 186 }
185} 187}
186 188
187void ConfigDlg::addMap() { 189void ConfigDlg::addMap() {
188 190
189 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 191 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
190 Config config ("multikey"); 192 Config config ("multikey");
191 config.setGroup("keymaps"); 193 config.setGroup("keymaps");
192 QStringList maps = config.readListEntry("maps", QChar('|')); 194 QStringList maps = config.readListEntry("maps", QChar('|'));
193 maps.append(map); 195 maps.append(map);
194 keymaps->insertItem(map); 196 keymaps->insertItem(map);
195 keymaps->setSelected(keymaps->count() - 1, true); 197 keymaps->setSelected(keymaps->count() - 1, true);
196 198
197 199
198 config.writeEntry("maps", maps.join("|")); 200 config.writeEntry("maps", maps.join("|"));
199 config.writeEntry("current", map); 201 config.writeEntry("current", map);
200 202
201} 203}
202 204
203void ConfigDlg::removeMap() { 205void ConfigDlg::removeMap() {
204 206
205 cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n"; 207 cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n";
206 cout << "currentItem : " << keymaps->currentItem() << "\n"; 208 cout << "currentItem : " << keymaps->currentItem() << "\n";
207 209
208 // move selection up one 210 // move selection up one
209 keymaps->setSelected(keymaps->currentItem() - 1, true); 211 keymaps->setSelected(keymaps->currentItem() - 1, true);
210 // delete the next selected item cus you just moved it up 212 // delete the next selected item cus you just moved it up
211 keymaps->removeItem(keymaps->currentItem() + 1); 213 keymaps->removeItem(keymaps->currentItem() + 1);
212 214
213 custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); 215 custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]);
214 216
215 // write the changes 217 // write the changes
216 Config config ("multikey"); 218 Config config ("multikey");
217 config.setGroup("keymaps"); 219 config.setGroup("keymaps");
218 config.writeEntry("maps", custom_maps.join("|")); 220 config.writeEntry("maps", custom_maps.join("|"));
219} 221}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 805f0ed..8c4e666 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -1,158 +1,158 @@
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#include <qframe.h> 20#include <qframe.h>
21#include <qmap.h> 21#include <qmap.h>
22#include "../pickboard/pickboardcfg.h" 22#include "../pickboard/pickboardcfg.h"
23#include "../pickboard/pickboardpicks.h" 23#include "../pickboard/pickboardpicks.h"
24#include "configdlg.h" 24#include "configdlg.h"
25 25
26class QTimer; 26class QTimer;
27 27
28class KeyboardConfig : public DictFilterConfig 28class KeyboardConfig : public DictFilterConfig
29{ 29{
30public: 30public:
31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } 31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }
32 virtual void generateText(const QString &s); 32 virtual void generateText(const QString &s);
33 void decBackspaces() { if (backspaces) backspaces--; } 33 void decBackspaces() { if (backspaces) backspaces--; }
34 void incBackspaces() { backspaces++; } 34 void incBackspaces() { backspaces++; }
35 void resetBackspaces() { backspaces = 0; } 35 void resetBackspaces() { backspaces = 0; }
36private: 36private:
37 int backspaces; 37 int backspaces;
38}; 38};
39 39
40 40
41class KeyboardPicks : public PickboardPicks 41class KeyboardPicks : public PickboardPicks
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) 45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
46 : PickboardPicks(parent, name, f) { } 46 : PickboardPicks(parent, name, f) { }
47 void initialise(); 47 void initialise();
48 virtual QSize sizeHint() const; 48 virtual QSize sizeHint() const;
49 KeyboardConfig *dc; 49 KeyboardConfig *dc;
50}; 50};
51 51
52 52
53class Keys { 53class Keys {
54public: 54public:
55 55
56 Keys(); 56 Keys();
57 Keys(const char * filename); 57 Keys(const char * filename);
58 ~Keys(); 58 ~Keys();
59 ushort uni(const int row, const int col); 59 ushort uni(const int row, const int col);
60 int qcode(const int row, const int col); 60 int qcode(const int row, const int col);
61 int width(const int row, const int col); 61 int width(const int row, const int col);
62 bool pressed(const int row, const int col); 62 bool pressed(const int row, const int col);
63 bool *pressedPtr(const int row, const int col); 63 bool *pressedPtr(const int row, const int col);
64 ushort shift(const ushort); 64 ushort shift(const ushort);
65 QPixmap *pix(const int row, const int col); 65 QPixmap *pix(const int row, const int col);
66 int numKeys(const int row); 66 int numKeys(const int row);
67 void setKeysFromFile(const char *filename); 67 void setKeysFromFile(const char *filename);
68 void setKey(const int row, const int qcode, const ushort unicode, 68 void setKey(const int row, const int qcode, const ushort unicode,
69 const int width, QPixmap *pix); 69 const int width, QPixmap *pix);
70 void setPressed(const int row, const int col, const bool pressed); 70 void setPressed(const int row, const int col, const bool pressed);
71 QString lang; 71 QString lang;
72 QString title; 72 QString label;
73 73
74private: 74private:
75 75
76 typedef struct Key { 76 typedef struct Key {
77 int qcode; // are qt key codes just unicode values? 77 int qcode; // are qt key codes just unicode values?
78 ushort unicode; 78 ushort unicode;
79 int width; // not pixels but relative key width. normal key is 2 79 int width; // not pixels but relative key width. normal key is 2
80 80
81 // only needed for keys like ctrl that can have multiple keys pressed at once 81 // only needed for keys like ctrl that can have multiple keys pressed at once
82 bool *pressed; 82 bool *pressed;
83 QPixmap *pix; 83 QPixmap *pix;
84 }; 84 };
85 85
86 QList<Key> keys[6]; 86 QList<Key> keys[6];
87 QMap<ushort,ushort> shiftMap; 87 QMap<ushort,ushort> shiftMap;
88 88
89}; 89};
90 90
91class Keyboard : public QFrame 91class Keyboard : public QFrame
92{ 92{
93 Q_OBJECT 93 Q_OBJECT
94public: 94public:
95 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 95 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
96 ~Keyboard(); 96 ~Keyboard();
97 97
98 void resetState(); 98 void resetState();
99 99
100 void mousePressEvent(QMouseEvent*); 100 void mousePressEvent(QMouseEvent*);
101 void mouseReleaseEvent(QMouseEvent*); 101 void mouseReleaseEvent(QMouseEvent*);
102 void resizeEvent(QResizeEvent*); 102 void resizeEvent(QResizeEvent*);
103 void paintEvent(QPaintEvent* e); 103 void paintEvent(QPaintEvent* e);
104 //void timerEvent(QTimerEvent* e); 104 //void timerEvent(QTimerEvent* e);
105 void drawKeyboard( QPainter &p, int row = -1, int col = -1); 105 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
106 106
107 QSize sizeHint() const; 107 QSize sizeHint() const;
108 108
109signals: 109signals:
110 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 110 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
111 111
112private slots: 112private slots:
113 void repeat(); 113 void repeat();
114 void togglePickboard(bool on_off); 114 void togglePickboard(bool on_off);
115 void setMapToDefault(); 115 void setMapToDefault();
116 void setMapToFile(QString map); 116 void setMapToFile(QString map);
117 117
118private: 118private:
119 int getKey( int &w, int j = -1 ); 119 int getKey( int &w, int j = -1 );
120 void clearHighlight(); 120 void clearHighlight();
121 121
122 bool *shift; 122 bool *shift;
123 bool *lock; 123 bool *lock;
124 bool *ctrl; 124 bool *ctrl;
125 bool *alt; 125 bool *alt;
126 uint useLargeKeys:1; 126 uint useLargeKeys:1;
127 uint usePicks:1; 127 uint usePicks:1;
128 128
129 int pressedKeyRow; 129 int pressedKeyRow;
130 int pressedKeyCol; 130 int pressedKeyCol;
131 131
132 KeyboardPicks *picks; 132 KeyboardPicks *picks;
133 133
134 int keyHeight; 134 int keyHeight;
135 int defaultKeyWidth; 135 int defaultKeyWidth;
136 int xoffs; 136 int xoffs;
137 137
138 int unicode; 138 int unicode;
139 int qkeycode; 139 int qkeycode;
140 int modifiers; 140 int modifiers;
141 141
142 int pressTid; 142 int pressTid;
143 bool pressed; 143 bool pressed;
144 144
145 Keys *keys; 145 Keys *keys;
146 146
147 /* for korean input */ 147 /* for korean input */
148 ushort schar, mchar, echar; 148 ushort schar, mchar, echar;
149 ushort parseKoreanInput(ushort c); 149 ushort parseKoreanInput(ushort c);
150 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); 150 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
151 ushort constoe(const ushort c); 151 ushort constoe(const ushort c);
152 152
153 QTimer *repeatTimer; 153 QTimer *repeatTimer;
154 154
155 ConfigDlg *configdlg; 155 ConfigDlg *configdlg;
156}; 156};
157 157
158 158