-rw-r--r-- | core/launcher/inputmethods.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 24669ac..9e2a11d 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,179 +1,179 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the 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 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | 30 | ||
31 | /* QT */ | 31 | /* QT */ |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
34 | #include <qwidgetstack.h> | 34 | #include <qwidgetstack.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qtl.h> | 37 | #include <qtl.h> |
38 | #ifdef Q_WS_QWS | 38 | #ifdef Q_WS_QWS |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #include <qwsevent_qws.h> | 40 | #include <qwsevent_qws.h> |
41 | #include <qcopchannel_qws.h> | 41 | #include <qcopchannel_qws.h> |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | 46 | ||
47 | /* XPM */ | 47 | /* XPM */ |
48 | static const char * tri_xpm[]={ | 48 | static const char * tri_xpm[]={ |
49 | "9 9 2 1", | 49 | "9 9 2 1", |
50 | "a c #000000", | 50 | "a c #000000", |
51 | ". c None", | 51 | ". c None", |
52 | ".........", | 52 | ".........", |
53 | ".........", | 53 | ".........", |
54 | ".........", | 54 | ".........", |
55 | "....a....", | 55 | "....a....", |
56 | "...aaa...", | 56 | "...aaa...", |
57 | "..aaaaa..", | 57 | "..aaaaa..", |
58 | ".aaaaaaa.", | 58 | ".aaaaaaa.", |
59 | ".........", | 59 | ".........", |
60 | "........."}; | 60 | "........."}; |
61 | 61 | ||
62 | int InputMethod::operator <(const InputMethod& o) const | 62 | int InputMethod::operator <(const InputMethod& o) const |
63 | { | 63 | { |
64 | return name() < o.name(); | 64 | return name() < o.name(); |
65 | } | 65 | } |
66 | int InputMethod::operator >(const InputMethod& o) const | 66 | int InputMethod::operator >(const InputMethod& o) const |
67 | { | 67 | { |
68 | return name() > o.name(); | 68 | return name() > o.name(); |
69 | } | 69 | } |
70 | int InputMethod::operator <=(const InputMethod& o) const | 70 | int InputMethod::operator <=(const InputMethod& o) const |
71 | { | 71 | { |
72 | return name() <= o.name(); | 72 | return name() <= o.name(); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | /* | 76 | /* |
77 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget | 77 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget |
78 | belongs to the IM system, so clicking it should not cause a reset". | 78 | belongs to the IM system, so clicking it should not cause a reset". |
79 | */ | 79 | */ |
80 | class IMToolButton : public QToolButton | 80 | class IMToolButton : public QToolButton |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) | 83 | IMToolButton( QWidget *parent ) : QToolButton( parent ) |
84 | { setWFlags( WStyle_Tool ); | 84 | { setWFlags( WStyle_Tool ); |
85 | setBackgroundOrigin( ParentOrigin ); | 85 | setBackgroundOrigin( ParentOrigin ); |
86 | setBackgroundMode( PaletteBackground ); | 86 | setBackgroundMode( PaletteBackground ); |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | InputMethods::InputMethods( QWidget *parent ) : | 91 | InputMethods::InputMethods( QWidget *parent ) : |
92 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), | 92 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), |
93 | mkeyboard(0), imethod(0) | 93 | mkeyboard(0), imethod(0) |
94 | { | 94 | { |
95 | readConfig(); | 95 | readConfig(); |
96 | 96 | ||
97 | setBackgroundOrigin( ParentOrigin ); | 97 | setBackgroundOrigin( ParentOrigin ); |
98 | setBackgroundMode( PaletteBackground ); | 98 | setBackgroundMode( PaletteBackground ); |
99 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 99 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
100 | 100 | ||
101 | kbdButton = new IMToolButton( this); | 101 | kbdButton = new IMToolButton( this); |
102 | kbdButton->setFocusPolicy(NoFocus); | 102 | kbdButton->setFocusPolicy(NoFocus); |
103 | kbdButton->setToggleButton( TRUE ); | 103 | kbdButton->setToggleButton( TRUE ); |
104 | if (parent->sizeHint().height() > 0) | 104 | if (parent->sizeHint().height() > 0) |
105 | kbdButton->setFixedHeight( parent->sizeHint().height() ); | 105 | kbdButton->setFixedHeight( parent->sizeHint().height() ); |
106 | kbdButton->setFixedWidth( 32 ); | 106 | kbdButton->setFixedWidth( 32 ); |
107 | kbdButton->setAutoRaise( TRUE ); | 107 | kbdButton->setAutoRaise( TRUE ); |
108 | kbdButton->setUsesBigPixmap( TRUE ); | 108 | kbdButton->setUsesBigPixmap( TRUE ); |
109 | hbox->addWidget( kbdButton ); | 109 | hbox->addWidget( kbdButton ); |
110 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); | 110 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); |
111 | 111 | ||
112 | kbdChoice = new IMToolButton( this ); | 112 | kbdChoice = new IMToolButton( this ); |
113 | kbdChoice->setFocusPolicy(NoFocus); | 113 | kbdChoice->setFocusPolicy(NoFocus); |
114 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 114 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
115 | if (parent->sizeHint().height() > 0) | 115 | if (parent->sizeHint().height() > 0) |
116 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); | 116 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); |
117 | kbdChoice->setFixedWidth( 13 ); | 117 | kbdChoice->setFixedWidth( 13 ); |
118 | kbdChoice->setAutoRaise( TRUE ); | 118 | kbdChoice->setAutoRaise( TRUE ); |
119 | hbox->addWidget( kbdChoice ); | 119 | hbox->addWidget( kbdChoice ); |
120 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); | 120 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); |
121 | 121 | ||
122 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), | 122 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), |
123 | this, SLOT(resetStates()) ); | 123 | this, SLOT(resetStates()) ); |
124 | 124 | ||
125 | 125 | ||
126 | imButton = new QWidgetStack( this ); // later a widget stack | 126 | imButton = new QWidgetStack( this ); // later a widget stack |
127 | imButton->setFocusPolicy(NoFocus); | 127 | imButton->setFocusPolicy(NoFocus); |
128 | if (parent->sizeHint().height() > 0) | 128 | if (parent->sizeHint().height() > 0) |
129 | imButton->setFixedHeight( parent->sizeHint().height() ); | 129 | imButton->setFixedHeight( parent->sizeHint().height() ); |
130 | hbox->addWidget(imButton); | 130 | hbox->addWidget(imButton); |
131 | 131 | ||
132 | imChoice = new QToolButton( this ); | 132 | imChoice = new QToolButton( this ); |
133 | imChoice->setFocusPolicy(NoFocus); | 133 | imChoice->setFocusPolicy(NoFocus); |
134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
135 | if (parent->sizeHint().height() > 0) | 135 | if (parent->sizeHint().height() > 0) |
136 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 136 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
137 | imChoice->setFixedWidth( 13 ); | 137 | imChoice->setFixedWidth( 13 ); |
138 | imChoice->setAutoRaise( TRUE ); | 138 | imChoice->setAutoRaise( TRUE ); |
139 | hbox->addWidget( imChoice ); | 139 | hbox->addWidget( imChoice ); |
140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
141 | 141 | ||
142 | loadInputMethods(); | 142 | loadInputMethods(); |
143 | 143 | ||
144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); | 146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); |
147 | } | 147 | } |
148 | 148 | ||
149 | InputMethods::~InputMethods() | 149 | InputMethods::~InputMethods() |
150 | { | 150 | { |
151 | Config cfg("qpe"); | 151 | Config cfg("qpe"); |
152 | cfg.setGroup("InputMethod"); | 152 | cfg.setGroup("InputMethod"); |
153 | if (imethod) | 153 | if (imethod) |
154 | cfg.writeEntry("im", imethod->name() ); | 154 | cfg.writeEntry("im", imethod->name() ); |
155 | if (mkeyboard) | 155 | if (mkeyboard) |
156 | cfg.writeEntry("current", mkeyboard->name() ); | 156 | cfg.writeEntry("current", mkeyboard->name() ); |
157 | 157 | ||
158 | unloadInputMethods(); | 158 | unloadInputMethods(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void InputMethods::hideInputMethod() | 161 | void InputMethods::hideInputMethod() |
162 | { | 162 | { |
163 | kbdButton->setOn( FALSE ); | 163 | kbdButton->setOn( FALSE ); |
164 | } | 164 | } |
165 | 165 | ||
166 | void InputMethods::showInputMethod() | 166 | void InputMethods::showInputMethod() |
167 | { | 167 | { |
168 | kbdButton->setOn( TRUE ); | 168 | kbdButton->setOn( TRUE ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void InputMethods::showInputMethod(const QString& name) | 171 | void InputMethods::showInputMethod(const QString& name) |
172 | { | 172 | { |
173 | int i = 0; | 173 | int i = 0; |
174 | QValueList<InputMethod>::Iterator it; | 174 | QValueList<InputMethod>::Iterator it; |
175 | InputMethod *im = 0; | 175 | InputMethod *im = 0; |
176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
178 | if ( (*it).name() == name || lname == name ) { | 178 | if ( (*it).name() == name || lname == name ) { |
179 | im = &(*it); | 179 | im = &(*it); |