author | hash <hash> | 2002-08-15 19:29:19 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-15 19:29:19 (UTC) |
commit | d9cc9bedf72e921f8f7d8edeb189db127c5651e3 (patch) (unidiff) | |
tree | e43631d8b74db204d9c60c34b0782aa37df185c2 | |
parent | f568b83e0ef16a0e3b46d41b2cfaa5fdda9d1d45 (diff) | |
download | opie-d9cc9bedf72e921f8f7d8edeb189db127c5651e3.zip opie-d9cc9bedf72e921f8f7d8edeb189db127c5651e3.tar.gz opie-d9cc9bedf72e921f8f7d8edeb189db127c5651e3.tar.bz2 |
changed the keymap selector widget style
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 60 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 9 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 10 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 1 |
4 files changed, 56 insertions, 24 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index f23bf1c..7bea589 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,123 +1,143 @@ | |||
1 | /* | 1 | /* |
2 | * TODO | 2 | * TODO |
3 | * make a font selection thing | 3 | * make a font selection thing (size too) |
4 | * | 4 | * |
5 | * FIXME | ||
6 | * if you open the config dialog and close it from the little (x) button on the title bar, | ||
7 | * you have to hit the button on the keyboard twice for it to open the next time | ||
8 | * | 5 | * |
9 | * | 6 | * |
10 | */ | 7 | */ |
11 | 8 | ||
12 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
14 | 11 | ||
15 | #include <qwidget.h> | 12 | #include <qwidget.h> |
16 | #include <qdialog.h> | 13 | #include <qdialog.h> |
17 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
18 | #include <qvbox.h> | 15 | #include <qvbox.h> |
19 | #include <qgrid.h> | 16 | #include <qgrid.h> |
20 | #include <qgroupbox.h> | 17 | #include <qgroupbox.h> |
21 | #include <qlabel.h> | 18 | #include <qlabel.h> |
22 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
23 | #include <qsizepolicy.h> | 20 | #include <qsizepolicy.h> |
24 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
25 | #include <qcombobox.h> | 22 | #include <qlistbox.h> |
26 | #include "configdlg.h" | 23 | #include "configdlg.h" |
27 | #include "keyboard.h" | 24 | #include "keyboard.h" |
28 | 25 | ||
29 | ConfigDlg::ConfigDlg () : QTabWidget () | 26 | ConfigDlg::ConfigDlg () : QTabWidget () |
30 | { | 27 | { |
31 | setCaption( tr("Multikey Configuration") ); | 28 | setCaption( tr("Multikey Configuration") ); |
32 | 29 | ||
33 | /* | 30 | /* |
34 | * 'general config' tab | 31 | * 'general config' tab |
35 | */ | 32 | */ |
36 | 33 | ||
37 | QVBox *gen_box = new QVBox (this); | 34 | QVBox *gen_box = new QVBox (this); |
38 | gen_box->setMargin(3); | 35 | gen_box->setMargin(3); |
39 | addTab(gen_box, tr("General Settings")); | 36 | addTab(gen_box, tr("General Settings")); |
40 | 37 | ||
41 | QGroupBox *map_group = new QGroupBox (2, Qt::Horizontal, tr("Keymap File"), gen_box); | 38 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
42 | 39 | ||
43 | map_combo = new QComboBox ((bool)0, map_group); | 40 | keymaps = new QListBox (map_group); |
44 | map_combo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 41 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
42 | //keymaps->setMaximumHeight(150); | ||
45 | 43 | ||
46 | QString cur(tr("Current Language")); | 44 | QString cur(tr("Current Language")); |
47 | map_combo->insertItem(cur); | 45 | keymaps->insertItem(cur); |
48 | connect(map_combo, SIGNAL(activated(int)), SLOT(setMap(int))); | 46 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
49 | 47 | ||
50 | QString ko(tr(QPEApplication::qpeDir() + "/share/multikey/ko.keymap")); | 48 | QString ko(QPEApplication::qpeDir() + "/share/multikey/ko.keymap"); |
51 | map_combo->insertItem(ko); | 49 | keymaps->insertItem(ko); |
52 | 50 | ||
53 | QString en(tr(QPEApplication::qpeDir() + "/share/multikey/en.keymap")); | 51 | QString en(QPEApplication::qpeDir() + "/share/multikey/en.keymap"); |
54 | map_combo->insertItem(en); | 52 | keymaps->insertItem(en); |
55 | 53 | ||
56 | QString de(tr(QPEApplication::qpeDir() + "/share/multikey/de.keymap")); | 54 | QString de(QPEApplication::qpeDir() + "/share/multikey/de.keymap"); |
57 | map_combo->insertItem(de); | 55 | keymaps->insertItem(de); |
58 | 56 | ||
59 | QPushButton *button = new QPushButton(tr("Browse..."), map_group); | 57 | QGrid *add_remove_grid = new QGrid(2, map_group); |
60 | button->setFlat((bool)1); | 58 | add_remove_grid->setMargin(3); |
59 | add_remove_grid->setSpacing(3); | ||
60 | |||
61 | add_button = new QPushButton(tr("Add"), add_remove_grid); | ||
62 | add_button->setFlat((bool)1); | ||
63 | |||
64 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | ||
65 | remove_button->setFlat((bool)1); | ||
61 | 66 | ||
62 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); | 67 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); |
63 | 68 | ||
64 | Config config ("multikey"); | 69 | Config config ("multikey"); |
65 | config.setGroup ("pickboard"); | 70 | config.setGroup ("pickboard"); |
66 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed | 71 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed |
67 | if (pick_open) { | 72 | if (pick_open) { |
68 | 73 | ||
69 | pick_button->setChecked(true); | 74 | pick_button->setChecked(true); |
70 | } | 75 | } |
71 | 76 | ||
72 | // by connecting it after checking it, the signal isn't emmited | 77 | // by connecting it after checking it, the signal isn't emmited |
73 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 78 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
74 | 79 | ||
75 | /* | 80 | /* |
76 | * 'color' tab | 81 | * 'color' tab |
77 | */ | 82 | */ |
78 | 83 | ||
79 | QGrid *color_box = new QGrid(2, this); | 84 | QGrid *color_box = new QGrid(2, this); |
80 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 85 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
81 | color_box->setMargin(3); | 86 | color_box->setMargin(3); |
87 | color_box->setSpacing(3); | ||
82 | addTab(color_box, tr("Colors")); | 88 | addTab(color_box, tr("Colors")); |
83 | 89 | ||
84 | QLabel *label; | 90 | QLabel *label; |
85 | 91 | ||
86 | label = new QLabel(tr("Key Color"), color_box); | 92 | label = new QLabel(tr("Key Color"), color_box); |
87 | button = new QPushButton(color_box); | 93 | QPushButton *button = new QPushButton(color_box); |
88 | button->setFlat((bool)1); | 94 | button->setFlat((bool)1); |
89 | label = new QLabel(tr("Key Pressed Color"), color_box); | 95 | label = new QLabel(tr("Key Pressed Color"), color_box); |
90 | button = new QPushButton(color_box); | 96 | button = new QPushButton(color_box); |
91 | button->setFlat((bool)1); | 97 | button->setFlat((bool)1); |
92 | label = new QLabel(tr("Line Color"), color_box); | 98 | label = new QLabel(tr("Line Color"), color_box); |
93 | button = new QPushButton(color_box); | 99 | button = new QPushButton(color_box); |
94 | button->setFlat((bool)1); | 100 | button->setFlat((bool)1); |
95 | label = new QLabel(tr("Text Color"), color_box); | 101 | label = new QLabel(tr("Text Color"), color_box); |
96 | button = new QPushButton(color_box); | 102 | button = new QPushButton(color_box); |
97 | button->setFlat((bool)1); | 103 | button->setFlat((bool)1); |
98 | 104 | ||
99 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 105 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
100 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 106 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
101 | 107 | ||
102 | } | 108 | } |
103 | 109 | ||
104 | void ConfigDlg::pickTog() { | 110 | void ConfigDlg::pickTog() { |
105 | 111 | ||
106 | Config config ("multikey"); | 112 | Config config ("multikey"); |
107 | config.setGroup ("pickboard"); | 113 | config.setGroup ("pickboard"); |
108 | config.writeEntry ("open", pick_button->isChecked()); // default closed | 114 | config.writeEntry ("open", pick_button->isChecked()); // default closed |
109 | 115 | ||
110 | emit pickboardToggled(pick_button->isChecked()); | 116 | emit pickboardToggled(pick_button->isChecked()); |
111 | } | 117 | } |
112 | 118 | ||
113 | void ConfigDlg::setMap(int index) { | 119 | void ConfigDlg::setMap(int index) { |
114 | 120 | ||
115 | if (index == 0) { | 121 | if (index == 0) { |
116 | 122 | ||
123 | if (remove_button->isEnabled()) | ||
124 | remove_button->setDisabled(true); | ||
125 | |||
117 | emit setMapToDefault(); | 126 | emit setMapToDefault(); |
118 | } | 127 | } |
119 | else { | 128 | else { |
120 | 129 | ||
121 | emit setMapToFile(map_combo->text(index)); | 130 | if (!remove_button->isEnabled()) |
131 | remove_button->setEnabled(true); | ||
132 | |||
133 | emit setMapToFile(keymaps->text(index)); | ||
122 | } | 134 | } |
123 | } | 135 | } |
136 | |||
137 | void ConfigDlg::addMap() { | ||
138 | |||
139 | } | ||
140 | |||
141 | void ConfigDlg::removeMap(int index) { | ||
142 | |||
143 | } | ||
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h index 54127a0..1a64764 100644 --- a/inputmethods/multikey/configdlg.h +++ b/inputmethods/multikey/configdlg.h | |||
@@ -1,31 +1,36 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qtabwidget.h> | 2 | #include <qtabwidget.h> |
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qlistbox.h> |
5 | #include <qpushbutton.h> | ||
5 | 6 | ||
6 | #ifndef CONFIGDLG_H | 7 | #ifndef CONFIGDLG_H |
7 | #define CONFIGDLG_H | 8 | #define CONFIGDLG_H |
8 | 9 | ||
9 | class ConfigDlg : public QTabWidget | 10 | class ConfigDlg : public QTabWidget |
10 | { | 11 | { |
11 | Q_OBJECT | 12 | Q_OBJECT |
12 | 13 | ||
13 | public: | 14 | public: |
14 | ConfigDlg (); | 15 | ConfigDlg (); |
15 | 16 | ||
16 | signals: | 17 | signals: |
17 | void pickboardToggled(bool on_off); | 18 | void pickboardToggled(bool on_off); |
18 | void setMapToDefault(); | 19 | void setMapToDefault(); |
19 | void setMapToFile(QString file); | 20 | void setMapToFile(QString file); |
20 | 21 | ||
21 | private slots: | 22 | private slots: |
22 | void pickTog(); | 23 | void pickTog(); |
23 | void setMap(int index); | 24 | void setMap(int index); |
25 | void addMap(); | ||
26 | void removeMap(int index); | ||
24 | 27 | ||
25 | private: | 28 | private: |
26 | QCheckBox *pick_button; | 29 | QCheckBox *pick_button; |
27 | QComboBox *map_combo; | 30 | QListBox *keymaps; |
31 | QPushButton *add_button; | ||
32 | QPushButton *remove_button; | ||
28 | 33 | ||
29 | }; | 34 | }; |
30 | 35 | ||
31 | #endif | 36 | #endif |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 2a80f1e..b71f929 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,127 +1,134 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <iostream.h> | ||
37 | 36 | ||
38 | #include <sys/utsname.h> | 37 | #include <sys/utsname.h> |
39 | 38 | ||
40 | 39 | ||
41 | #define USE_SMALL_BACKSPACE | 40 | #define USE_SMALL_BACKSPACE |
42 | 41 | ||
43 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
44 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
45 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
46 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), |
47 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
48 | configdlg(0) | 47 | configdlg(0) |
49 | 48 | ||
50 | { | 49 | { |
51 | // get the default font | 50 | // get the default font |
52 | Config *config = new Config( "qpe" ); | 51 | Config *config = new Config( "qpe" ); |
53 | config->setGroup( "Appearance" ); | 52 | config->setGroup( "Appearance" ); |
54 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 53 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
55 | delete config; | 54 | delete config; |
56 | 55 | ||
57 | config = new Config("multikey"); | 56 | config = new Config("multikey"); |
58 | config->setGroup ("pickboard"); | 57 | config->setGroup ("pickboard"); |
59 | usePicks = config->readBoolEntry ("open", "0"); // default closed | 58 | usePicks = config->readBoolEntry ("open", "0"); // default closed |
60 | delete config; | 59 | delete config; |
61 | 60 | ||
62 | setFont( QFont( familyStr, 10 ) ); | 61 | setFont( QFont( familyStr, 10 ) ); |
63 | 62 | ||
64 | picks = new KeyboardPicks( this ); | 63 | picks = new KeyboardPicks( this ); |
65 | picks->setFont( QFont( familyStr, 10 ) ); | 64 | picks->setFont( QFont( familyStr, 10 ) ); |
66 | picks->initialise(); | 65 | picks->initialise(); |
67 | if (usePicks) { | 66 | if (usePicks) { |
68 | 67 | ||
69 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 68 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
70 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 69 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
71 | 70 | ||
72 | } else picks->hide(); | 71 | } else picks->hide(); |
73 | 72 | ||
74 | keys = new Keys(); | 73 | keys = new Keys(); |
75 | 74 | ||
76 | repeatTimer = new QTimer( this ); | 75 | repeatTimer = new QTimer( this ); |
77 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 76 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
78 | 77 | ||
79 | } | 78 | } |
79 | Keyboard::~Keyboard() { | ||
80 | |||
81 | if ( configdlg ) { | ||
82 | delete (ConfigDlg *) configdlg; | ||
83 | configdlg = 0; | ||
84 | } | ||
85 | |||
86 | } | ||
80 | 87 | ||
81 | /* Keyboard::resizeEvent {{{1 */ | 88 | /* Keyboard::resizeEvent {{{1 */ |
82 | void Keyboard::resizeEvent(QResizeEvent*) | 89 | void Keyboard::resizeEvent(QResizeEvent*) |
83 | { | 90 | { |
84 | int ph = picks->sizeHint().height(); | 91 | int ph = picks->sizeHint().height(); |
85 | picks->setGeometry( 0, 0, width(), ph ); | 92 | picks->setGeometry( 0, 0, width(), ph ); |
86 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 93 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
87 | 94 | ||
88 | int nk; // number of keys? | 95 | int nk; // number of keys? |
89 | if ( useLargeKeys ) { | 96 | if ( useLargeKeys ) { |
90 | nk = 15; | 97 | nk = 15; |
91 | } else { | 98 | } else { |
92 | nk = 19; | 99 | nk = 19; |
93 | } | 100 | } |
94 | defaultKeyWidth = (width()/nk)/2; | 101 | defaultKeyWidth = (width()/nk)/2; |
95 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 102 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
96 | 103 | ||
97 | } | 104 | } |
98 | 105 | ||
99 | /* KeyboardPicks::initialize {{{1 */ | 106 | /* KeyboardPicks::initialize {{{1 */ |
100 | void KeyboardPicks::initialise() | 107 | void KeyboardPicks::initialise() |
101 | { | 108 | { |
102 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 109 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
103 | mode = 0; | 110 | mode = 0; |
104 | dc = new KeyboardConfig(this); | 111 | dc = new KeyboardConfig(this); |
105 | configs.append(dc); | 112 | configs.append(dc); |
106 | } | 113 | } |
107 | 114 | ||
108 | /* KeyboardPicks::sizeHint {{{1 */ | 115 | /* KeyboardPicks::sizeHint {{{1 */ |
109 | QSize KeyboardPicks::sizeHint() const | 116 | QSize KeyboardPicks::sizeHint() const |
110 | { | 117 | { |
111 | return QSize(240,fontMetrics().lineSpacing()); | 118 | return QSize(240,fontMetrics().lineSpacing()); |
112 | } | 119 | } |
113 | 120 | ||
114 | 121 | ||
115 | /* KeyboardConfig::generateText {{{1 */ | 122 | /* KeyboardConfig::generateText {{{1 */ |
116 | void KeyboardConfig::generateText(const QString &s) | 123 | void KeyboardConfig::generateText(const QString &s) |
117 | { | 124 | { |
118 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 125 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
119 | for (int i=0; i<(int)backspaces; i++) { | 126 | for (int i=0; i<(int)backspaces; i++) { |
120 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 127 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
121 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 128 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
122 | } | 129 | } |
123 | for (int i=0; i<(int)s.length(); i++) { | 130 | for (int i=0; i<(int)s.length(); i++) { |
124 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 131 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
125 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 132 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
126 | } | 133 | } |
127 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 134 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
@@ -914,97 +921,96 @@ void Keys::setKeysFromFile(const char * filename) { | |||
914 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 921 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
915 | j++; | 922 | j++; |
916 | } | 923 | } |
917 | 924 | ||
918 | } | 925 | } |
919 | // have to close that facker up | 926 | // have to close that facker up |
920 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 927 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
921 | 928 | ||
922 | xpmLineCount++; | 929 | xpmLineCount++; |
923 | buf = t.readLine(); | 930 | buf = t.readLine(); |
924 | } | 931 | } |
925 | if (xpmLineCount) { | 932 | if (xpmLineCount) { |
926 | 933 | ||
927 | xpm2pix = new QPixmap((const char **)xpm); | 934 | xpm2pix = new QPixmap((const char **)xpm); |
928 | for (int i = 0; i < xpmLineCount; i++) | 935 | for (int i = 0; i < xpmLineCount; i++) |
929 | 936 | ||
930 | delete [] (xpm[i]); | 937 | delete [] (xpm[i]); |
931 | 938 | ||
932 | } | 939 | } |
933 | setKey(row, qcode, unicode, width, xpm2pix); | 940 | setKey(row, qcode, unicode, width, xpm2pix); |
934 | } | 941 | } |
935 | 942 | ||
936 | // shift map | 943 | // shift map |
937 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 944 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
938 | 945 | ||
939 | QTextStream tmp (buf, IO_ReadOnly); | 946 | QTextStream tmp (buf, IO_ReadOnly); |
940 | ushort lower, shift; | 947 | ushort lower, shift; |
941 | tmp >> lower >> shift; | 948 | tmp >> lower >> shift; |
942 | 949 | ||
943 | shiftMap.insert(lower, shift); | 950 | shiftMap.insert(lower, shift); |
944 | 951 | ||
945 | buf = t.readLine(); | 952 | buf = t.readLine(); |
946 | } | 953 | } |
947 | 954 | ||
948 | // other variables like lang & title | 955 | // other variables like lang & title |
949 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 956 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
950 | 957 | ||
951 | QTextStream tmp (buf, IO_ReadOnly); | 958 | QTextStream tmp (buf, IO_ReadOnly); |
952 | QString name, equals, value; | 959 | QString name, equals, value; |
953 | 960 | ||
954 | tmp >> name >> equals >> value; | 961 | tmp >> name >> equals >> value; |
955 | 962 | ||
956 | if (name == "lang") { | 963 | if (name == "lang") { |
957 | 964 | ||
958 | lang = value; | 965 | lang = value; |
959 | 966 | ||
960 | } | 967 | } |
961 | 968 | ||
962 | cout << name << " = " << value << "\n"; | ||
963 | buf = t.readLine(); | 969 | buf = t.readLine(); |
964 | } | 970 | } |
965 | // comments | 971 | // comments |
966 | else if (buf.contains(QRegExp("^\\s*#"))) { | 972 | else if (buf.contains(QRegExp("^\\s*#"))) { |
967 | 973 | ||
968 | buf = t.readLine(); | 974 | buf = t.readLine(); |
969 | 975 | ||
970 | } else { // blank line, or garbage | 976 | } else { // blank line, or garbage |
971 | 977 | ||
972 | buf = t.readLine(); | 978 | buf = t.readLine(); |
973 | 979 | ||
974 | } | 980 | } |
975 | 981 | ||
976 | } | 982 | } |
977 | f.close(); | 983 | f.close(); |
978 | } | 984 | } |
979 | 985 | ||
980 | } | 986 | } |
981 | 987 | ||
982 | // Keys::setKey {{{2 | 988 | // Keys::setKey {{{2 |
983 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 989 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
984 | const int width, QPixmap *pix) { | 990 | const int width, QPixmap *pix) { |
985 | 991 | ||
986 | Key * key; | 992 | Key * key; |
987 | key = new Key; | 993 | key = new Key; |
988 | key->qcode = qcode; | 994 | key->qcode = qcode; |
989 | key->unicode = unicode; | 995 | key->unicode = unicode; |
990 | key->width = width; | 996 | key->width = width; |
991 | 997 | ||
992 | // share key->pressed between same keys | 998 | // share key->pressed between same keys |
993 | bool found = 0; | 999 | bool found = 0; |
994 | for (int i = 1; i <= 5; i++) { | 1000 | for (int i = 1; i <= 5; i++) { |
995 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1001 | for (unsigned int j = 0; j < keys[i].count(); j++) |
996 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1002 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
997 | 1003 | ||
998 | key->pressed = keys[i].at(j)->pressed; | 1004 | key->pressed = keys[i].at(j)->pressed; |
999 | found = 1; | 1005 | found = 1; |
1000 | } | 1006 | } |
1001 | 1007 | ||
1002 | } | 1008 | } |
1003 | if (!found) { | 1009 | if (!found) { |
1004 | 1010 | ||
1005 | key->pressed = new bool; | 1011 | key->pressed = new bool; |
1006 | *(key->pressed) = 0; | 1012 | *(key->pressed) = 0; |
1007 | } | 1013 | } |
1008 | 1014 | ||
1009 | key->pix = pix; | 1015 | key->pix = pix; |
1010 | 1016 | ||
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index c2efe10..8ca50ea 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -47,96 +47,97 @@ public: | |||
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 | ||
53 | class Keys { | 53 | class Keys { |
54 | public: | 54 | public: |
55 | 55 | ||
56 | Keys(); | 56 | Keys(); |
57 | Keys(const char * filename); | 57 | Keys(const char * filename); |
58 | ushort uni(const int row, const int col); | 58 | ushort uni(const int row, const int col); |
59 | int qcode(const int row, const int col); | 59 | int qcode(const int row, const int col); |
60 | int width(const int row, const int col); | 60 | int width(const int row, const int col); |
61 | bool pressed(const int row, const int col); | 61 | bool pressed(const int row, const int col); |
62 | bool *pressedPtr(const int row, const int col); | 62 | bool *pressedPtr(const int row, const int col); |
63 | ushort shift(const ushort); | 63 | ushort shift(const ushort); |
64 | QPixmap *pix(const int row, const int col); | 64 | QPixmap *pix(const int row, const int col); |
65 | int numKeys(const int row); | 65 | int numKeys(const int row); |
66 | void setKeysFromFile(const char *filename); | 66 | void setKeysFromFile(const char *filename); |
67 | void setKey(const int row, const int qcode, const ushort unicode, | 67 | void setKey(const int row, const int qcode, const ushort unicode, |
68 | const int width, QPixmap *pix); | 68 | const int width, QPixmap *pix); |
69 | void setPressed(const int row, const int col, const bool pressed); | 69 | void setPressed(const int row, const int col, const bool pressed); |
70 | QString lang; | 70 | QString lang; |
71 | QString title; | 71 | QString title; |
72 | 72 | ||
73 | private: | 73 | private: |
74 | 74 | ||
75 | typedef struct Key { | 75 | typedef struct Key { |
76 | int qcode; // are qt key codes just unicode values? | 76 | int qcode; // are qt key codes just unicode values? |
77 | ushort unicode; | 77 | ushort unicode; |
78 | int width; // not pixels but relative key width. normal key is 2 | 78 | int width; // not pixels but relative key width. normal key is 2 |
79 | 79 | ||
80 | // only needed for keys like ctrl that can have multiple keys pressed at once | 80 | // only needed for keys like ctrl that can have multiple keys pressed at once |
81 | bool *pressed; | 81 | bool *pressed; |
82 | QPixmap *pix; | 82 | QPixmap *pix; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | QList<Key> keys[6]; | 85 | QList<Key> keys[6]; |
86 | QMap<ushort,ushort> shiftMap; | 86 | QMap<ushort,ushort> shiftMap; |
87 | 87 | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | class Keyboard : public QFrame | 90 | class Keyboard : public QFrame |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 94 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
95 | ~Keyboard(); | ||
95 | 96 | ||
96 | void resetState(); | 97 | void resetState(); |
97 | 98 | ||
98 | void mousePressEvent(QMouseEvent*); | 99 | void mousePressEvent(QMouseEvent*); |
99 | void mouseReleaseEvent(QMouseEvent*); | 100 | void mouseReleaseEvent(QMouseEvent*); |
100 | void resizeEvent(QResizeEvent*); | 101 | void resizeEvent(QResizeEvent*); |
101 | void paintEvent(QPaintEvent* e); | 102 | void paintEvent(QPaintEvent* e); |
102 | //void timerEvent(QTimerEvent* e); | 103 | //void timerEvent(QTimerEvent* e); |
103 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 104 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
104 | 105 | ||
105 | QSize sizeHint() const; | 106 | QSize sizeHint() const; |
106 | 107 | ||
107 | signals: | 108 | signals: |
108 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 109 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
109 | 110 | ||
110 | private slots: | 111 | private slots: |
111 | void repeat(); | 112 | void repeat(); |
112 | void togglePickboard(bool on_off); | 113 | void togglePickboard(bool on_off); |
113 | void setMapToDefault(); | 114 | void setMapToDefault(); |
114 | void setMapToFile(QString file); | 115 | void setMapToFile(QString file); |
115 | 116 | ||
116 | private: | 117 | private: |
117 | int getKey( int &w, int j = -1 ); | 118 | int getKey( int &w, int j = -1 ); |
118 | void clearHighlight(); | 119 | void clearHighlight(); |
119 | 120 | ||
120 | bool *shift; | 121 | bool *shift; |
121 | bool *lock; | 122 | bool *lock; |
122 | bool *ctrl; | 123 | bool *ctrl; |
123 | bool *alt; | 124 | bool *alt; |
124 | uint useLargeKeys:1; | 125 | uint useLargeKeys:1; |
125 | uint usePicks:1; | 126 | uint usePicks:1; |
126 | 127 | ||
127 | int pressedKeyRow; | 128 | int pressedKeyRow; |
128 | int pressedKeyCol; | 129 | int pressedKeyCol; |
129 | 130 | ||
130 | KeyboardPicks *picks; | 131 | KeyboardPicks *picks; |
131 | 132 | ||
132 | int keyHeight; | 133 | int keyHeight; |
133 | int defaultKeyWidth; | 134 | int defaultKeyWidth; |
134 | int xoffs; | 135 | int xoffs; |
135 | 136 | ||
136 | int unicode; | 137 | int unicode; |
137 | int qkeycode; | 138 | int qkeycode; |
138 | int modifiers; | 139 | int modifiers; |
139 | 140 | ||
140 | int pressTid; | 141 | int pressTid; |
141 | bool pressed; | 142 | bool pressed; |
142 | 143 | ||