author | zecke <zecke> | 2004-08-22 21:35:22 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-08-22 21:35:22 (UTC) |
commit | 8b5ab9a283c219aaba84a8b23adc6c3d29cef7d5 (patch) (unidiff) | |
tree | caf4d5d4cab240f2e7653b394666c5e2fb178798 | |
parent | 2304c546ec73f2643621f04d61128c2686812cd1 (diff) | |
download | opie-8b5ab9a283c219aaba84a8b23adc6c3d29cef7d5.zip opie-8b5ab9a283c219aaba84a8b23adc6c3d29cef7d5.tar.gz opie-8b5ab9a283c219aaba84a8b23adc6c3d29cef7d5.tar.bz2 |
Reload InputMethods when LauncherSettings changed InputMethod Options
-rw-r--r-- | core/launcher/inputmethods.cpp | 20 | ||||
-rw-r--r-- | core/launcher/inputmethods.h | 1 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 13 | ||||
-rw-r--r-- | core/launcher/taskbar.h | 5 | ||||
-rw-r--r-- | core/settings/launcher/inputmethodsettings.cpp | 29 | ||||
-rw-r--r-- | core/settings/launcher/inputmethodsettings.h | 9 |
6 files changed, 58 insertions, 19 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index a0e8939..7e99796 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,224 +1,220 @@ | |||
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::IMToolButton( QWidget *parent ) : QToolButton( parent ) |
84 | { setWFlags( WStyle_Tool ); } | 84 | { setWFlags( WStyle_Tool ); } |
85 | }; | 85 | }; |
86 | 86 | ||
87 | 87 | ||
88 | InputMethods::InputMethods( QWidget *parent ) : | 88 | InputMethods::InputMethods( QWidget *parent ) : |
89 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), | 89 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), |
90 | mkeyboard(0), imethod(0) | 90 | mkeyboard(0), imethod(0) |
91 | { | 91 | { |
92 | Config cfg( "Launcher" ); | 92 | readConfig(); |
93 | cfg.setGroup( "InputMethods" ); | ||
94 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; | ||
95 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; | ||
96 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); | ||
97 | 93 | ||
98 | setBackgroundMode( PaletteBackground ); | 94 | setBackgroundMode( PaletteBackground ); |
99 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 95 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
100 | 96 | ||
101 | kbdButton = new IMToolButton( this); | 97 | kbdButton = new IMToolButton( this); |
102 | kbdButton->setFocusPolicy(NoFocus); | 98 | kbdButton->setFocusPolicy(NoFocus); |
103 | kbdButton->setToggleButton( TRUE ); | 99 | kbdButton->setToggleButton( TRUE ); |
104 | if (parent->sizeHint().height() > 0) | 100 | if (parent->sizeHint().height() > 0) |
105 | kbdButton->setFixedHeight( parent->sizeHint().height() ); | 101 | kbdButton->setFixedHeight( parent->sizeHint().height() ); |
106 | kbdButton->setFixedWidth( 32 ); | 102 | kbdButton->setFixedWidth( 32 ); |
107 | kbdButton->setAutoRaise( TRUE ); | 103 | kbdButton->setAutoRaise( TRUE ); |
108 | kbdButton->setUsesBigPixmap( TRUE ); | 104 | kbdButton->setUsesBigPixmap( TRUE ); |
109 | hbox->addWidget( kbdButton ); | 105 | hbox->addWidget( kbdButton ); |
110 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); | 106 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); |
111 | 107 | ||
112 | kbdChoice = new IMToolButton( this ); | 108 | kbdChoice = new IMToolButton( this ); |
113 | kbdChoice->setFocusPolicy(NoFocus); | 109 | kbdChoice->setFocusPolicy(NoFocus); |
114 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 110 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
115 | if (parent->sizeHint().height() > 0) | 111 | if (parent->sizeHint().height() > 0) |
116 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); | 112 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); |
117 | kbdChoice->setFixedWidth( 13 ); | 113 | kbdChoice->setFixedWidth( 13 ); |
118 | kbdChoice->setAutoRaise( TRUE ); | 114 | kbdChoice->setAutoRaise( TRUE ); |
119 | hbox->addWidget( kbdChoice ); | 115 | hbox->addWidget( kbdChoice ); |
120 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); | 116 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); |
121 | 117 | ||
122 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), | 118 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), |
123 | this, SLOT(resetStates()) ); | 119 | this, SLOT(resetStates()) ); |
124 | 120 | ||
125 | 121 | ||
126 | imButton = new QWidgetStack( this ); // later a widget stack | 122 | imButton = new QWidgetStack( this ); // later a widget stack |
127 | imButton->setFocusPolicy(NoFocus); | 123 | imButton->setFocusPolicy(NoFocus); |
128 | if (parent->sizeHint().height() > 0) | 124 | if (parent->sizeHint().height() > 0) |
129 | imButton->setFixedHeight( parent->sizeHint().height() ); | 125 | imButton->setFixedHeight( parent->sizeHint().height() ); |
130 | hbox->addWidget(imButton); | 126 | hbox->addWidget(imButton); |
131 | 127 | ||
132 | imChoice = new QToolButton( this ); | 128 | imChoice = new QToolButton( this ); |
133 | imChoice->setFocusPolicy(NoFocus); | 129 | imChoice->setFocusPolicy(NoFocus); |
134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 130 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
135 | if (parent->sizeHint().height() > 0) | 131 | if (parent->sizeHint().height() > 0) |
136 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 132 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
137 | imChoice->setFixedWidth( 13 ); | 133 | imChoice->setFixedWidth( 13 ); |
138 | imChoice->setAutoRaise( TRUE ); | 134 | imChoice->setAutoRaise( TRUE ); |
139 | hbox->addWidget( imChoice ); | 135 | hbox->addWidget( imChoice ); |
140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 136 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
141 | 137 | ||
142 | loadInputMethods(); | 138 | loadInputMethods(); |
143 | 139 | ||
144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 140 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 141 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); | 142 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); |
147 | } | 143 | } |
148 | 144 | ||
149 | InputMethods::~InputMethods() | 145 | InputMethods::~InputMethods() |
150 | { | 146 | { |
151 | Config cfg("qpe"); | 147 | Config cfg("qpe"); |
152 | cfg.setGroup("InputMethod"); | 148 | cfg.setGroup("InputMethod"); |
153 | if (imethod) | 149 | if (imethod) |
154 | cfg.writeEntry("im", imethod->name() ); | 150 | cfg.writeEntry("im", imethod->name() ); |
155 | if (mkeyboard) | 151 | if (mkeyboard) |
156 | cfg.writeEntry("current", mkeyboard->name() ); | 152 | cfg.writeEntry("current", mkeyboard->name() ); |
157 | 153 | ||
158 | unloadInputMethods(); | 154 | unloadInputMethods(); |
159 | } | 155 | } |
160 | 156 | ||
161 | void InputMethods::hideInputMethod() | 157 | void InputMethods::hideInputMethod() |
162 | { | 158 | { |
163 | kbdButton->setOn( FALSE ); | 159 | kbdButton->setOn( FALSE ); |
164 | } | 160 | } |
165 | 161 | ||
166 | void InputMethods::showInputMethod() | 162 | void InputMethods::showInputMethod() |
167 | { | 163 | { |
168 | kbdButton->setOn( TRUE ); | 164 | kbdButton->setOn( TRUE ); |
169 | } | 165 | } |
170 | 166 | ||
171 | void InputMethods::showInputMethod(const QString& name) | 167 | void InputMethods::showInputMethod(const QString& name) |
172 | { | 168 | { |
173 | int i = 0; | 169 | int i = 0; |
174 | QValueList<InputMethod>::Iterator it; | 170 | QValueList<InputMethod>::Iterator it; |
175 | InputMethod *im = 0; | 171 | InputMethod *im = 0; |
176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 172 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 173 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
178 | if ( (*it).name() == name || lname == name ) { | 174 | if ( (*it).name() == name || lname == name ) { |
179 | im = &(*it); | 175 | im = &(*it); |
180 | break; | 176 | break; |
181 | } | 177 | } |
182 | } | 178 | } |
183 | if ( im ) | 179 | if ( im ) |
184 | chooseKeyboard(im); | 180 | chooseKeyboard(im); |
185 | } | 181 | } |
186 | 182 | ||
187 | void InputMethods::resetStates() | 183 | void InputMethods::resetStates() |
188 | { | 184 | { |
189 | if ( mkeyboard && !mkeyboard->newIM ) | 185 | if ( mkeyboard && !mkeyboard->newIM ) |
190 | mkeyboard->interface->resetState(); | 186 | mkeyboard->interface->resetState(); |
191 | } | 187 | } |
192 | 188 | ||
193 | QRect InputMethods::inputRect() const | 189 | QRect InputMethods::inputRect() const |
194 | { | 190 | { |
195 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) | 191 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) |
196 | return QRect(); | 192 | return QRect(); |
197 | else | 193 | else |
198 | return mkeyboard->widget->geometry(); | 194 | return mkeyboard->widget->geometry(); |
199 | } | 195 | } |
200 | 196 | ||
201 | void InputMethods::unloadInputMethods() | 197 | void InputMethods::unloadInputMethods() |
202 | { | 198 | { |
203 | unloadMethod( inputMethodList ); | 199 | unloadMethod( inputMethodList ); |
204 | unloadMethod( inputModifierList ); | 200 | unloadMethod( inputModifierList ); |
205 | inputMethodList.clear(); | 201 | inputMethodList.clear(); |
206 | inputModifierList.clear(); | 202 | inputModifierList.clear(); |
207 | 203 | ||
208 | } | 204 | } |
209 | 205 | ||
210 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { | 206 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { |
211 | QValueList<InputMethod>::Iterator it; | 207 | QValueList<InputMethod>::Iterator it; |
212 | 208 | ||
213 | for (it = list.begin(); it != list.end(); ++it ) | 209 | for (it = list.begin(); it != list.end(); ++it ) |
214 | (*it).releaseInterface(); | 210 | (*it).releaseInterface(); |
215 | 211 | ||
216 | } | 212 | } |
217 | 213 | ||
218 | 214 | ||
219 | QStringList InputMethods::plugins()const { | 215 | QStringList InputMethods::plugins()const { |
220 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 216 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
221 | #ifdef Q_OS_MACX | 217 | #ifdef Q_OS_MACX |
222 | QDir dir( path, "lib*.dylib" ); | 218 | QDir dir( path, "lib*.dylib" ); |
223 | #else | 219 | #else |
224 | QDir dir( path, "lib*.so" ); | 220 | QDir dir( path, "lib*.so" ); |
@@ -407,215 +403,225 @@ void InputMethods::chooseIm() | |||
407 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); | 403 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); |
408 | QSize s = pop.sizeHint(); | 404 | QSize s = pop.sizeHint(); |
409 | pt.ry() -= s.height(); | 405 | pt.ry() -= s.height(); |
410 | pt.rx() -= s.width(); | 406 | pt.rx() -= s.width(); |
411 | i = pop.exec( pt ); | 407 | i = pop.exec( pt ); |
412 | if ( i == -1 ) | 408 | if ( i == -1 ) |
413 | return; | 409 | return; |
414 | InputMethod *im = &inputModifierList[i]; | 410 | InputMethod *im = &inputModifierList[i]; |
415 | 411 | ||
416 | chooseMethod(im); | 412 | chooseMethod(im); |
417 | } | 413 | } |
418 | 414 | ||
419 | void InputMethods::chooseKeyboard(InputMethod* im) | 415 | void InputMethods::chooseKeyboard(InputMethod* im) |
420 | { | 416 | { |
421 | if ( im != mkeyboard ) { | 417 | if ( im != mkeyboard ) { |
422 | if ( mkeyboard && mkeyboard->widget->isVisible() ) | 418 | if ( mkeyboard && mkeyboard->widget->isVisible() ) |
423 | mkeyboard->widget->hide(); | 419 | mkeyboard->widget->hide(); |
424 | mkeyboard = im; | 420 | mkeyboard = im; |
425 | kbdButton->setPixmap( *mkeyboard->icon() ); | 421 | kbdButton->setPixmap( *mkeyboard->icon() ); |
426 | } | 422 | } |
427 | if ( !kbdButton->isOn() ) | 423 | if ( !kbdButton->isOn() ) |
428 | kbdButton->setOn( TRUE ); | 424 | kbdButton->setOn( TRUE ); |
429 | else | 425 | else |
430 | showKbd( TRUE ); | 426 | showKbd( TRUE ); |
431 | } | 427 | } |
432 | 428 | ||
433 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) | 429 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) |
434 | { | 430 | { |
435 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) | 431 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) |
436 | return TRUE; | 432 | return TRUE; |
437 | 433 | ||
438 | if ( keyb->extInterface->compatible().contains(imname) ) | 434 | if ( keyb->extInterface->compatible().contains(imname) ) |
439 | return TRUE; | 435 | return TRUE; |
440 | 436 | ||
441 | return FALSE; | 437 | return FALSE; |
442 | } | 438 | } |
443 | 439 | ||
444 | // Updates the display of the soft keyboards available to the current input method | 440 | // Updates the display of the soft keyboards available to the current input method |
445 | void InputMethods::updateKeyboards(InputMethod *im ) | 441 | void InputMethods::updateKeyboards(InputMethod *im ) |
446 | { | 442 | { |
447 | uint count; | 443 | uint count; |
448 | 444 | ||
449 | if ( im ) { | 445 | if ( im ) { |
450 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); | 446 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); |
451 | 447 | ||
452 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { | 448 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { |
453 | kbdButton->setOn( FALSE ); | 449 | kbdButton->setOn( FALSE ); |
454 | showKbd( FALSE ); | 450 | showKbd( FALSE ); |
455 | mkeyboard = 0; | 451 | mkeyboard = 0; |
456 | } | 452 | } |
457 | 453 | ||
458 | count = 0; | 454 | count = 0; |
459 | 455 | ||
460 | QValueList<InputMethod>::Iterator it; | 456 | QValueList<InputMethod>::Iterator it; |
461 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { | 457 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { |
462 | if ( keyboardCompatible( &(*it), imname ) ) { | 458 | if ( keyboardCompatible( &(*it), imname ) ) { |
463 | if ( !mkeyboard ) { | 459 | if ( !mkeyboard ) { |
464 | mkeyboard = &(*it); | 460 | mkeyboard = &(*it); |
465 | kbdButton->setPixmap( *mkeyboard->icon() ); | 461 | kbdButton->setPixmap( *mkeyboard->icon() ); |
466 | } | 462 | } |
467 | 463 | ||
468 | count++; | 464 | count++; |
469 | } | 465 | } |
470 | } | 466 | } |
471 | } else { | 467 | } else { |
472 | count = inputMethodList.count(); | 468 | count = inputMethodList.count(); |
473 | if ( count && !mkeyboard ) { | 469 | if ( count && !mkeyboard ) { |
474 | mkeyboard = &inputMethodList[0]; | 470 | mkeyboard = &inputMethodList[0]; |
475 | kbdButton->setPixmap( *mkeyboard->icon() ); | 471 | kbdButton->setPixmap( *mkeyboard->icon() ); |
476 | } else if (!count){ | 472 | } else if (!count){ |
477 | mkeyboard = 0; //might be redundant | 473 | mkeyboard = 0; //might be redundant |
478 | } | 474 | } |
479 | } | 475 | } |
480 | 476 | ||
481 | if ( count > 1 ) | 477 | if ( count > 1 ) |
482 | kbdChoice->show(); | 478 | kbdChoice->show(); |
483 | else | 479 | else |
484 | kbdChoice->hide(); | 480 | kbdChoice->hide(); |
485 | 481 | ||
486 | if ( count ) | 482 | if ( count ) |
487 | kbdButton->show(); | 483 | kbdButton->show(); |
488 | else | 484 | else |
489 | kbdButton->hide(); | 485 | kbdButton->hide(); |
490 | } | 486 | } |
491 | 487 | ||
492 | void InputMethods::chooseMethod(InputMethod* im) | 488 | void InputMethods::chooseMethod(InputMethod* im) |
493 | { | 489 | { |
494 | if ( im != imethod ) { | 490 | if ( im != imethod ) { |
495 | updateKeyboards( im ); | 491 | updateKeyboards( im ); |
496 | 492 | ||
497 | Config cfg("qpe"); | 493 | Config cfg("qpe"); |
498 | cfg.setGroup("InputMethod"); | 494 | cfg.setGroup("InputMethod"); |
499 | if (im ) | 495 | if (im ) |
500 | cfg.writeEntry("im", im->name() ); | 496 | cfg.writeEntry("im", im->name() ); |
501 | if (mkeyboard) | 497 | if (mkeyboard) |
502 | cfg.writeEntry("current", mkeyboard->name() ); | 498 | cfg.writeEntry("current", mkeyboard->name() ); |
503 | 499 | ||
504 | QWSServer::setCurrentInputMethod( 0 ); | 500 | QWSServer::setCurrentInputMethod( 0 ); |
505 | imethod = im; | 501 | imethod = im; |
506 | if ( imethod && imethod->newIM ) | 502 | if ( imethod && imethod->newIM ) |
507 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 503 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
508 | else | 504 | else |
509 | QWSServer::setCurrentInputMethod( 0 ); | 505 | QWSServer::setCurrentInputMethod( 0 ); |
510 | 506 | ||
511 | if ( im ) | 507 | if ( im ) |
512 | imButton->raiseWidget(im->widget); | 508 | imButton->raiseWidget(im->widget); |
513 | else | 509 | else |
514 | imButton->hide(); //### good UI? make sure it is shown again! | 510 | imButton->hide(); //### good UI? make sure it is shown again! |
515 | } | 511 | } |
516 | } | 512 | } |
517 | 513 | ||
518 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) | 514 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) |
519 | { | 515 | { |
520 | if ( imethod && imethod->newIM ) | 516 | if ( imethod && imethod->newIM ) |
521 | imethod->extInterface->qcopReceive( msg, data ); | 517 | imethod->extInterface->qcopReceive( msg, data ); |
522 | } | 518 | } |
523 | 519 | ||
524 | 520 | ||
525 | void InputMethods::showKbd( bool on ) | 521 | void InputMethods::showKbd( bool on ) |
526 | { | 522 | { |
527 | if ( !mkeyboard ) | 523 | if ( !mkeyboard ) |
528 | return; | 524 | return; |
529 | 525 | ||
530 | if ( on ) | 526 | if ( on ) |
531 | { | 527 | { |
532 | mkeyboard->resetState(); | 528 | mkeyboard->resetState(); |
533 | 529 | ||
534 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); | 530 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); |
535 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); | 531 | int width = static_cast<int>( qApp->desktop()->width() * (inputWidgetWidth*0.01) ); |
536 | int left = 0; | 532 | int left = 0; |
537 | int top = mapToGlobal( QPoint() ).y() - height; | 533 | int top = mapToGlobal( QPoint() ).y() - height; |
538 | 534 | ||
539 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | 535 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
540 | { | 536 | { |
541 | odebug << "InputMethods: reading geometry." << oendl; | 537 | odebug << "InputMethods: reading geometry." << oendl; |
542 | Config cfg( "Launcher" ); | 538 | Config cfg( "Launcher" ); |
543 | cfg.setGroup( "InputMethods" ); | 539 | cfg.setGroup( "InputMethods" ); |
544 | int l = cfg.readNumEntry( "absX", -1 ); | 540 | int l = cfg.readNumEntry( "absX", -1 ); |
545 | int t = cfg.readNumEntry( "absY", -1 ); | 541 | int t = cfg.readNumEntry( "absY", -1 ); |
546 | int w = cfg.readNumEntry( "absWidth", -1 ); | 542 | int w = cfg.readNumEntry( "absWidth", -1 ); |
547 | int h = cfg.readNumEntry( "absHeight", -1 ); | 543 | int h = cfg.readNumEntry( "absHeight", -1 ); |
548 | 544 | ||
549 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) | 545 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) |
550 | { | 546 | { |
551 | odebug << "InputMethods: config values ( " << l << ", " << t << ", " << w << ", " << h << " ) are ok." << oendl; | 547 | odebug << "InputMethods: config values ( " << l << ", " << t << ", " << w << ", " << h << " ) are ok." << oendl; |
552 | left = l; | 548 | left = l; |
553 | top = t; | 549 | top = t; |
554 | width = w; | 550 | width = w; |
555 | height = h; | 551 | height = h; |
556 | } | 552 | } |
557 | else | 553 | else |
558 | { | 554 | { |
559 | odebug << "InputMethods: config values are new or not ok." << oendl; | 555 | odebug << "InputMethods: config values are new or not ok." << oendl; |
560 | } | 556 | } |
561 | } | 557 | } |
562 | else | 558 | else |
563 | { | 559 | { |
564 | odebug << "InputMethods: no floating selected." << oendl; | 560 | odebug << "InputMethods: no floating selected." << oendl; |
565 | } | 561 | } |
566 | mkeyboard->widget->resize( width, height ); | 562 | mkeyboard->widget->resize( width, height ); |
567 | mkeyboard->widget->move( left, top ); | 563 | mkeyboard->widget->move( left, top ); |
568 | mkeyboard->widget->show(); | 564 | mkeyboard->widget->show(); |
569 | mkeyboard->widget->installEventFilter( this ); | 565 | mkeyboard->widget->installEventFilter( this ); |
570 | } | 566 | } |
571 | else | 567 | else |
572 | { | 568 | { |
573 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | 569 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
574 | { | 570 | { |
575 | QPoint pos = mkeyboard->widget->pos(); | 571 | QPoint pos = mkeyboard->widget->pos(); |
576 | QSize siz = mkeyboard->widget->size(); | 572 | QSize siz = mkeyboard->widget->size(); |
577 | odebug << "InputMethods: saving geometry." << oendl; | 573 | odebug << "InputMethods: saving geometry." << oendl; |
578 | Config cfg( "Launcher" ); | 574 | Config cfg( "Launcher" ); |
579 | cfg.setGroup( "InputMethods" ); | 575 | cfg.setGroup( "InputMethods" ); |
580 | cfg.writeEntry( "absX", pos.x() ); | 576 | cfg.writeEntry( "absX", pos.x() ); |
581 | cfg.writeEntry( "absY", pos.y() ); | 577 | cfg.writeEntry( "absY", pos.y() ); |
582 | cfg.writeEntry( "absWidth", siz.width() ); | 578 | cfg.writeEntry( "absWidth", siz.width() ); |
583 | cfg.writeEntry( "absHeight", siz.height() ); | 579 | cfg.writeEntry( "absHeight", siz.height() ); |
584 | cfg.write(); | 580 | cfg.write(); |
585 | mkeyboard->widget->removeEventFilter( this ); | 581 | mkeyboard->widget->removeEventFilter( this ); |
586 | } | 582 | } |
587 | mkeyboard->widget->hide(); | 583 | mkeyboard->widget->hide(); |
588 | } | 584 | } |
589 | 585 | ||
590 | emit inputToggled( on ); | 586 | emit inputToggled( on ); |
591 | } | 587 | } |
592 | 588 | ||
593 | bool InputMethods::shown() const | 589 | bool InputMethods::shown() const |
594 | { | 590 | { |
595 | return mkeyboard && mkeyboard->widget->isVisible(); | 591 | return mkeyboard && mkeyboard->widget->isVisible(); |
596 | } | 592 | } |
597 | 593 | ||
598 | QString InputMethods::currentShown() const | 594 | QString InputMethods::currentShown() const |
599 | { | 595 | { |
600 | return mkeyboard && mkeyboard->widget->isVisible() | 596 | return mkeyboard && mkeyboard->widget->isVisible() |
601 | ? mkeyboard->name() : QString::null; | 597 | ? mkeyboard->name() : QString::null; |
602 | } | 598 | } |
603 | 599 | ||
604 | void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) | 600 | void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) |
605 | { | 601 | { |
606 | #if defined(Q_WS_QWS) | 602 | #if defined(Q_WS_QWS) |
607 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); | 603 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); |
608 | #endif | 604 | #endif |
609 | } | 605 | } |
610 | 606 | ||
611 | bool InputMethods::eventFilter( QObject* o, QEvent* e ) | 607 | bool InputMethods::eventFilter( QObject* , QEvent* e ) |
612 | { | 608 | { |
613 | if ( e->type() == QEvent::Close ) | 609 | if ( e->type() == QEvent::Close ) |
614 | { | 610 | { |
615 | ( (QCloseEvent*) e )->ignore(); | 611 | ( (QCloseEvent*) e )->ignore(); |
616 | showKbd( false ); | 612 | showKbd( false ); |
617 | kbdButton->setOn( false ); | 613 | kbdButton->setOn( false ); |
618 | return true; | 614 | return true; |
619 | } | 615 | } |
620 | return false; | 616 | return false; |
621 | } | 617 | } |
618 | |||
619 | void InputMethods::readConfig() { | ||
620 | Config cfg( "Launcher" ); | ||
621 | cfg.setGroup( "InputMethods" ); | ||
622 | |||
623 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; | ||
624 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? | ||
625 | QWidget::WStyle_DialogBorder : 0; | ||
626 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); | ||
627 | } | ||
diff --git a/core/launcher/inputmethods.h b/core/launcher/inputmethods.h index 55ac020..2e0b1e8 100644 --- a/core/launcher/inputmethods.h +++ b/core/launcher/inputmethods.h | |||
@@ -1,113 +1,114 @@ | |||
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 | #ifndef __INPUT_METHODS_H__ | 21 | #ifndef __INPUT_METHODS_H__ |
22 | #define __INPUT_METHODS_H__ | 22 | #define __INPUT_METHODS_H__ |
23 | 23 | ||
24 | #include <qtopia/qlibrary.h> | 24 | #include <qtopia/qlibrary.h> |
25 | #include <qtopia/inputmethodinterface.h> | 25 | #include <qtopia/inputmethodinterface.h> |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | class QToolButton; | 30 | class QToolButton; |
31 | class QWidgetStack; | 31 | class QWidgetStack; |
32 | 32 | ||
33 | struct InputMethod | 33 | struct InputMethod |
34 | { | 34 | { |
35 | #ifndef QT_NO_COMPONENT | 35 | #ifndef QT_NO_COMPONENT |
36 | QLibrary *library; | 36 | QLibrary *library; |
37 | #endif | 37 | #endif |
38 | QWidget *widget; | 38 | QWidget *widget; |
39 | QString libName; | 39 | QString libName; |
40 | bool newIM; | 40 | bool newIM; |
41 | union { | 41 | union { |
42 | InputMethodInterface *interface; | 42 | InputMethodInterface *interface; |
43 | ExtInputMethodInterface *extInterface; | 43 | ExtInputMethodInterface *extInterface; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | inline void releaseInterface() { | 46 | inline void releaseInterface() { |
47 | newIM ? (void)extInterface->release() : (void)interface->release(); | 47 | newIM ? (void)extInterface->release() : (void)interface->release(); |
48 | library->unload(); | 48 | library->unload(); |
49 | delete library; library = 0l; | 49 | delete library; library = 0l; |
50 | } | 50 | } |
51 | inline QString name() const { return newIM ? extInterface->name() : interface->name(); } | 51 | inline QString name() const { return newIM ? extInterface->name() : interface->name(); } |
52 | inline QPixmap *icon() const { return newIM ? extInterface->icon() : interface->icon(); } | 52 | inline QPixmap *icon() const { return newIM ? extInterface->icon() : interface->icon(); } |
53 | inline QUnknownInterface *iface() { return newIM ? (QUnknownInterface *)extInterface : (QUnknownInterface *)interface; } | 53 | inline QUnknownInterface *iface() { return newIM ? (QUnknownInterface *)extInterface : (QUnknownInterface *)interface; } |
54 | inline void resetState() { if ( !newIM ) interface->resetState(); } | 54 | inline void resetState() { if ( !newIM ) interface->resetState(); } |
55 | 55 | ||
56 | int operator <(const InputMethod& o) const; | 56 | int operator <(const InputMethod& o) const; |
57 | int operator >(const InputMethod& o) const; | 57 | int operator >(const InputMethod& o) const; |
58 | int operator <=(const InputMethod& o) const; | 58 | int operator <=(const InputMethod& o) const; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class InputMethods : public QWidget | 61 | class InputMethods : public QWidget |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | InputMethods( QWidget * ); | 65 | InputMethods( QWidget * ); |
66 | ~InputMethods(); | 66 | ~InputMethods(); |
67 | 67 | ||
68 | QRect inputRect() const; | 68 | QRect inputRect() const; |
69 | bool shown() const; | 69 | bool shown() const; |
70 | QString currentShown() const; // name of interface | 70 | QString currentShown() const; // name of interface |
71 | void showInputMethod(const QString& id); | 71 | void showInputMethod(const QString& id); |
72 | void showInputMethod(); | 72 | void showInputMethod(); |
73 | void hideInputMethod(); | 73 | void hideInputMethod(); |
74 | void unloadInputMethods(); | 74 | void unloadInputMethods(); |
75 | void loadInputMethods(); | 75 | void loadInputMethods(); |
76 | virtual bool eventFilter( QObject *, QEvent * ); | 76 | virtual bool eventFilter( QObject *, QEvent * ); |
77 | void readConfig(); | ||
77 | 78 | ||
78 | signals: | 79 | signals: |
79 | void inputToggled( bool on ); | 80 | void inputToggled( bool on ); |
80 | 81 | ||
81 | private slots: | 82 | private slots: |
82 | void chooseKbd(); | 83 | void chooseKbd(); |
83 | void chooseIm(); | 84 | void chooseIm(); |
84 | void showKbd( bool ); | 85 | void showKbd( bool ); |
85 | void resetStates(); | 86 | void resetStates(); |
86 | void sendKey( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); | 87 | void sendKey( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); |
87 | void qcopReceive( const QCString &msg, const QByteArray &data ); | 88 | void qcopReceive( const QCString &msg, const QByteArray &data ); |
88 | 89 | ||
89 | private: | 90 | private: |
90 | void setPreferedHandlers(); | 91 | void setPreferedHandlers(); |
91 | /*static */QStringList plugins()const; | 92 | /*static */QStringList plugins()const; |
92 | /*static */void installTranslator( const QString& ); | 93 | /*static */void installTranslator( const QString& ); |
93 | void unloadMethod( QValueList<InputMethod>& ); | 94 | void unloadMethod( QValueList<InputMethod>& ); |
94 | void chooseMethod(InputMethod* im); | 95 | void chooseMethod(InputMethod* im); |
95 | void chooseKeyboard(InputMethod* im); | 96 | void chooseKeyboard(InputMethod* im); |
96 | void updateKeyboards(InputMethod *im); | 97 | void updateKeyboards(InputMethod *im); |
97 | 98 | ||
98 | private: | 99 | private: |
99 | QToolButton *kbdButton; | 100 | QToolButton *kbdButton; |
100 | QToolButton *kbdChoice; | 101 | QToolButton *kbdChoice; |
101 | QWidgetStack *imButton; // later will be widget stack | 102 | QWidgetStack *imButton; // later will be widget stack |
102 | QToolButton *imChoice; | 103 | QToolButton *imChoice; |
103 | InputMethod *mkeyboard; | 104 | InputMethod *mkeyboard; |
104 | InputMethod *imethod; | 105 | InputMethod *imethod; |
105 | QValueList<InputMethod> inputMethodList; | 106 | QValueList<InputMethod> inputMethodList; |
106 | QValueList<InputMethod> inputModifierList; | 107 | QValueList<InputMethod> inputModifierList; |
107 | int inputWidgetStyle; | 108 | int inputWidgetStyle; |
108 | int inputWidgetWidth; | 109 | int inputWidgetWidth; |
109 | }; | 110 | }; |
110 | 111 | ||
111 | 112 | ||
112 | #endif // __INPUT_METHODS_H__ | 113 | #endif // __INPUT_METHODS_H__ |
113 | 114 | ||
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index abe238f..63361fe 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp | |||
@@ -51,330 +51,337 @@ using namespace Opie::Core; | |||
51 | #include <qwsdisplay_qws.h> | 51 | #include <qwsdisplay_qws.h> |
52 | #include <qgfx_qws.h> | 52 | #include <qgfx_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | static bool initNumLock() | 56 | static bool initNumLock() |
57 | { | 57 | { |
58 | #ifdef QPE_INITIAL_NUMLOCK_STATE | 58 | #ifdef QPE_INITIAL_NUMLOCK_STATE |
59 | QPE_INITIAL_NUMLOCK_STATE | 59 | QPE_INITIAL_NUMLOCK_STATE |
60 | #endif | 60 | #endif |
61 | return FALSE; | 61 | return FALSE; |
62 | } | 62 | } |
63 | 63 | ||
64 | //--------------------------------------------------------------------------- | 64 | //--------------------------------------------------------------------------- |
65 | 65 | ||
66 | class SafeMode : public QWidget | 66 | class SafeMode : public QWidget |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) | 70 | SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) |
71 | { | 71 | { |
72 | message = tr("Safe Mode"); | 72 | message = tr("Safe Mode"); |
73 | QFont f( font() ); | 73 | QFont f( font() ); |
74 | f.setWeight( QFont::Bold ); | 74 | f.setWeight( QFont::Bold ); |
75 | setFont( f ); | 75 | setFont( f ); |
76 | } | 76 | } |
77 | 77 | ||
78 | void mousePressEvent( QMouseEvent *); | 78 | void mousePressEvent( QMouseEvent *); |
79 | QSize sizeHint() const; | 79 | QSize sizeHint() const; |
80 | void paintEvent( QPaintEvent* ); | 80 | void paintEvent( QPaintEvent* ); |
81 | 81 | ||
82 | private slots: | 82 | private slots: |
83 | void action(int i); | 83 | void action(int i); |
84 | 84 | ||
85 | private: | 85 | private: |
86 | QString message; | 86 | QString message; |
87 | QPopupMenu *menu; | 87 | QPopupMenu *menu; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | void SafeMode::mousePressEvent( QMouseEvent *) | 90 | void SafeMode::mousePressEvent( QMouseEvent *) |
91 | { | 91 | { |
92 | if ( !menu ) { | 92 | if ( !menu ) { |
93 | menu = new QPopupMenu(this); | 93 | menu = new QPopupMenu(this); |
94 | menu->insertItem( tr("Plugin Manager..."), 0 ); | 94 | menu->insertItem( tr("Plugin Manager..."), 0 ); |
95 | menu->insertItem( tr("Restart Qtopia"), 1 ); | 95 | menu->insertItem( tr("Restart Qtopia"), 1 ); |
96 | menu->insertItem( tr("Help..."), 2 ); | 96 | menu->insertItem( tr("Help..."), 2 ); |
97 | connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); | 97 | connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); |
98 | } | 98 | } |
99 | QPoint curPos = mapToGlobal( QPoint(0,0) ); | 99 | QPoint curPos = mapToGlobal( QPoint(0,0) ); |
100 | QSize sh = menu->sizeHint(); | 100 | QSize sh = menu->sizeHint(); |
101 | menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); | 101 | menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); |
102 | } | 102 | } |
103 | 103 | ||
104 | void SafeMode::action(int i) | 104 | void SafeMode::action(int i) |
105 | { | 105 | { |
106 | switch (i) { | 106 | switch (i) { |
107 | case 0: | 107 | case 0: |
108 | Global::execute( "pluginmanager" ); | 108 | Global::execute( "pluginmanager" ); |
109 | break; | 109 | break; |
110 | case 1: | 110 | case 1: |
111 | Global::restart(); | 111 | Global::restart(); |
112 | break; | 112 | break; |
113 | case 2: | 113 | case 2: |
114 | Global::execute( "helpbrowser", "safemode.html" ); | 114 | Global::execute( "helpbrowser", "safemode.html" ); |
115 | break; | 115 | break; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | QSize SafeMode::sizeHint() const | 119 | QSize SafeMode::sizeHint() const |
120 | { | 120 | { |
121 | QFontMetrics fm = fontMetrics(); | 121 | QFontMetrics fm = fontMetrics(); |
122 | 122 | ||
123 | return QSize( fm.width(message), fm.height() ); | 123 | return QSize( fm.width(message), fm.height() ); |
124 | } | 124 | } |
125 | 125 | ||
126 | void SafeMode::paintEvent( QPaintEvent* ) | 126 | void SafeMode::paintEvent( QPaintEvent* ) |
127 | { | 127 | { |
128 | QPainter p(this); | 128 | QPainter p(this); |
129 | p.drawText( rect(), AlignCenter, message ); | 129 | p.drawText( rect(), AlignCenter, message ); |
130 | } | 130 | } |
131 | 131 | ||
132 | //--------------------------------------------------------------------------- | 132 | //--------------------------------------------------------------------------- |
133 | 133 | ||
134 | class LockKeyState : public QWidget | 134 | class LockKeyState : public QWidget |
135 | { | 135 | { |
136 | public: | 136 | public: |
137 | LockKeyState( QWidget *parent ) : | 137 | LockKeyState( QWidget *parent ) : |
138 | QWidget(parent), | 138 | QWidget(parent), |
139 | nl(initNumLock()), cl(FALSE) | 139 | nl(initNumLock()), cl(FALSE) |
140 | { | 140 | { |
141 | nl_pm = Resource::loadPixmap("numlock"); | 141 | nl_pm = Resource::loadPixmap("numlock"); |
142 | cl_pm = Resource::loadPixmap("capslock"); | 142 | cl_pm = Resource::loadPixmap("capslock"); |
143 | } | 143 | } |
144 | QSize sizeHint() const | 144 | QSize sizeHint() const |
145 | { | 145 | { |
146 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); | 146 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); |
147 | } | 147 | } |
148 | void toggleNumLockState() | 148 | void toggleNumLockState() |
149 | { | 149 | { |
150 | nl = !nl; repaint(); | 150 | nl = !nl; repaint(); |
151 | } | 151 | } |
152 | void toggleCapsLockState() | 152 | void toggleCapsLockState() |
153 | { | 153 | { |
154 | cl = !cl; repaint(); | 154 | cl = !cl; repaint(); |
155 | } | 155 | } |
156 | void paintEvent( QPaintEvent * ) | 156 | void paintEvent( QPaintEvent * ) |
157 | { | 157 | { |
158 | int y = (height()-sizeHint().height())/2; | 158 | int y = (height()-sizeHint().height())/2; |
159 | QPainter p(this); | 159 | QPainter p(this); |
160 | if ( nl ) | 160 | if ( nl ) |
161 | p.drawPixmap(1,y,nl_pm); | 161 | p.drawPixmap(1,y,nl_pm); |
162 | if ( cl ) | 162 | if ( cl ) |
163 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); | 163 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); |
164 | } | 164 | } |
165 | private: | 165 | private: |
166 | QPixmap nl_pm, cl_pm; | 166 | QPixmap nl_pm, cl_pm; |
167 | bool nl, cl; | 167 | bool nl, cl; |
168 | }; | 168 | }; |
169 | 169 | ||
170 | //--------------------------------------------------------------------------- | 170 | //--------------------------------------------------------------------------- |
171 | 171 | ||
172 | TaskBar::~TaskBar() | 172 | TaskBar::~TaskBar() |
173 | { | 173 | { |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) | 177 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) |
178 | { | 178 | { |
179 | Config cfg( "Launcher" ); | 179 | /* Read InputMethod Config */ |
180 | cfg.setGroup( "InputMethods" ); | 180 | readConfig(); |
181 | resizeRunningApp = cfg.readBoolEntry( "Resize", true ); | ||
182 | 181 | ||
183 | sm = new StartMenu( this ); | 182 | sm = new StartMenu( this ); |
184 | connect( sm, SIGNAL(tabSelected(const QString&)), this, | 183 | connect( sm, SIGNAL(tabSelected(const QString&)), this, |
185 | SIGNAL(tabSelected(const QString&)) ); | 184 | SIGNAL(tabSelected(const QString&)) ); |
186 | 185 | ||
187 | inputMethods = new InputMethods( this ); | 186 | inputMethods = new InputMethods( this ); |
188 | connect( inputMethods, SIGNAL(inputToggled(bool)), | 187 | connect( inputMethods, SIGNAL(inputToggled(bool)), |
189 | this, SLOT(calcMaxWindowRect()) ); | 188 | this, SLOT(calcMaxWindowRect()) ); |
190 | 189 | ||
191 | stack = new QWidgetStack( this ); | 190 | stack = new QWidgetStack( this ); |
192 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 191 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
193 | label = new QLabel(stack); | 192 | label = new QLabel(stack); |
194 | 193 | ||
195 | runningAppBar = new RunningAppBar(stack); | 194 | runningAppBar = new RunningAppBar(stack); |
196 | stack->raiseWidget(runningAppBar); | 195 | stack->raiseWidget(runningAppBar); |
197 | 196 | ||
198 | waitIcon = new Wait( this ); | 197 | waitIcon = new Wait( this ); |
199 | (void) new AppIcons( this ); | 198 | (void) new AppIcons( this ); |
200 | 199 | ||
201 | sysTray = new SysTray( this ); | 200 | sysTray = new SysTray( this ); |
202 | 201 | ||
203 | /* ### FIXME plugin loader and safe mode */ | 202 | /* ### FIXME plugin loader and safe mode */ |
204 | #if 0 | 203 | #if 0 |
205 | if (PluginLoader::inSafeMode()) | 204 | if (PluginLoader::inSafeMode()) |
206 | (void)new SafeMode( this ); | 205 | (void)new SafeMode( this ); |
207 | #endif | 206 | #endif |
208 | 207 | ||
209 | // ## make customizable in some way? | 208 | // ## make customizable in some way? |
210 | #ifdef OPIE_TASKBAR_LOCK_KEY_STATE | 209 | #ifdef OPIE_TASKBAR_LOCK_KEY_STATE |
211 | lockState = new LockKeyState( this ); | 210 | lockState = new LockKeyState( this ); |
212 | #else | 211 | #else |
213 | lockState = 0; | 212 | lockState = 0; |
214 | #endif | 213 | #endif |
215 | 214 | ||
216 | #if defined(Q_WS_QWS) | 215 | #if defined(Q_WS_QWS) |
217 | #if !defined(QT_NO_COP) | 216 | #if !defined(QT_NO_COP) |
218 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); | 217 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); |
219 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 218 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
220 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 219 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
221 | #endif | 220 | #endif |
222 | #endif | 221 | #endif |
223 | waitTimer = new QTimer( this ); | 222 | waitTimer = new QTimer( this ); |
224 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); | 223 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); |
225 | clearer = new QTimer( this ); | 224 | clearer = new QTimer( this ); |
226 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); | 225 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); |
227 | 226 | ||
228 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); | 227 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); |
229 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); | 228 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); |
230 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); | 229 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); |
231 | } | 230 | } |
232 | 231 | ||
233 | void TaskBar::setStatusMessage( const QString &text ) | 232 | void TaskBar::setStatusMessage( const QString &text ) |
234 | { | 233 | { |
235 | if ( !text.isEmpty() ) { | 234 | if ( !text.isEmpty() ) { |
236 | label->setText( text ); | 235 | label->setText( text ); |
237 | stack->raiseWidget( label ); | 236 | stack->raiseWidget( label ); |
238 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) | 237 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) |
239 | sysTray->hide(); | 238 | sysTray->hide(); |
240 | clearer->start( 3000, TRUE ); | 239 | clearer->start( 3000, TRUE ); |
241 | } else { | 240 | } else { |
242 | clearStatusBar(); | 241 | clearStatusBar(); |
243 | } | 242 | } |
244 | } | 243 | } |
245 | 244 | ||
246 | void TaskBar::clearStatusBar() | 245 | void TaskBar::clearStatusBar() |
247 | { | 246 | { |
248 | label->clear(); | 247 | label->clear(); |
249 | stack->raiseWidget(runningAppBar); | 248 | stack->raiseWidget(runningAppBar); |
250 | if ( sysTray ) | 249 | if ( sysTray ) |
251 | sysTray->show(); | 250 | sysTray->show(); |
252 | // stack->raiseWidget( mru ); | 251 | // stack->raiseWidget( mru ); |
253 | } | 252 | } |
254 | 253 | ||
255 | void TaskBar::startWait() | 254 | void TaskBar::startWait() |
256 | { | 255 | { |
257 | waitIcon->setWaiting( true ); | 256 | waitIcon->setWaiting( true ); |
258 | // a catchall stop after 10 seconds... | 257 | // a catchall stop after 10 seconds... |
259 | waitTimer->start( 10 * 1000, true ); | 258 | waitTimer->start( 10 * 1000, true ); |
260 | } | 259 | } |
261 | 260 | ||
262 | void TaskBar::stopWait(const QString&) | 261 | void TaskBar::stopWait(const QString&) |
263 | { | 262 | { |
264 | waitTimer->stop(); | 263 | waitTimer->stop(); |
265 | waitIcon->setWaiting( false ); | 264 | waitIcon->setWaiting( false ); |
266 | } | 265 | } |
267 | 266 | ||
268 | void TaskBar::stopWait() | 267 | void TaskBar::stopWait() |
269 | { | 268 | { |
270 | waitTimer->stop(); | 269 | waitTimer->stop(); |
271 | waitIcon->setWaiting( false ); | 270 | waitIcon->setWaiting( false ); |
272 | } | 271 | } |
273 | 272 | ||
274 | /* | 273 | /* |
275 | * This resizeEvent will be captured by | 274 | * This resizeEvent will be captured by |
276 | * the ServerInterface and it'll layout | 275 | * the ServerInterface and it'll layout |
277 | * and calc rect. Now if we go from bigger | 276 | * and calc rect. Now if we go from bigger |
278 | * to smaller screen the SysTray is out of | 277 | * to smaller screen the SysTray is out of |
279 | * bounds and repaint() won't trigger an Event | 278 | * bounds and repaint() won't trigger an Event |
280 | */ | 279 | */ |
281 | void TaskBar::resizeEvent( QResizeEvent *e ) | 280 | void TaskBar::resizeEvent( QResizeEvent *e ) |
282 | { | 281 | { |
283 | if ( sysTray ) | 282 | if ( sysTray ) |
284 | sysTray->hide(); | 283 | sysTray->hide(); |
285 | 284 | ||
286 | QHBox::resizeEvent( e ); | 285 | QHBox::resizeEvent( e ); |
287 | 286 | ||
288 | if ( sysTray ) | 287 | if ( sysTray ) |
289 | sysTray->show(); | 288 | sysTray->show(); |
290 | 289 | ||
291 | owarn << "TaskBar::resize event" << oendl; | 290 | owarn << "TaskBar::resize event" << oendl; |
292 | } | 291 | } |
293 | 292 | ||
294 | void TaskBar::styleChange( QStyle &s ) | 293 | void TaskBar::styleChange( QStyle &s ) |
295 | { | 294 | { |
296 | QHBox::styleChange( s ); | 295 | QHBox::styleChange( s ); |
297 | calcMaxWindowRect(); | 296 | calcMaxWindowRect(); |
298 | } | 297 | } |
299 | 298 | ||
300 | void TaskBar::calcMaxWindowRect() | 299 | void TaskBar::calcMaxWindowRect() |
301 | { | 300 | { |
302 | if ( resizeRunningApp ) | 301 | if ( resizeRunningApp ) |
303 | { | 302 | { |
304 | #if defined(Q_WS_QWS) | 303 | #if defined(Q_WS_QWS) |
305 | QRect wr; | 304 | QRect wr; |
306 | int displayWidth = qApp->desktop()->width(); | 305 | int displayWidth = qApp->desktop()->width(); |
307 | QRect ir = inputMethods->inputRect(); | 306 | QRect ir = inputMethods->inputRect(); |
308 | if ( ir.isValid() ) { | 307 | if ( ir.isValid() ) { |
309 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 308 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
310 | } else { | 309 | } else { |
311 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); | 310 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); |
312 | } | 311 | } |
313 | #if QT_VERSION < 0x030000 | 312 | #if QT_VERSION < 0x030000 |
314 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); | 313 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); |
315 | #else | 314 | #else |
316 | QWSServer::setMaxWindowRect( wr ); | 315 | QWSServer::setMaxWindowRect( wr ); |
317 | #endif | 316 | #endif |
318 | #endif | 317 | #endif |
319 | } | 318 | } |
320 | } | 319 | } |
321 | 320 | ||
322 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) | 321 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) |
323 | { | 322 | { |
324 | QDataStream stream( data, IO_ReadOnly ); | 323 | QDataStream stream( data, IO_ReadOnly ); |
325 | if ( msg == "message(QString)" ) { | 324 | if ( msg == "message(QString)" ) { |
326 | QString text; | 325 | QString text; |
327 | stream >> text; | 326 | stream >> text; |
328 | setStatusMessage( text ); | 327 | setStatusMessage( text ); |
329 | } else if ( msg == "hideInputMethod()" ) { | 328 | } else if ( msg == "hideInputMethod()" ) { |
330 | inputMethods->hideInputMethod(); | 329 | inputMethods->hideInputMethod(); |
331 | } else if ( msg == "showInputMethod()" ) { | 330 | } else if ( msg == "showInputMethod()" ) { |
332 | inputMethods->showInputMethod(); | 331 | inputMethods->showInputMethod(); |
333 | } else if ( msg == "showInputMethod(QString)" ) { | 332 | } else if ( msg == "showInputMethod(QString)" ) { |
334 | QString name; | 333 | QString name; |
335 | stream >> name; | 334 | stream >> name; |
336 | inputMethods->showInputMethod(name); | 335 | inputMethods->showInputMethod(name); |
337 | } else if ( msg == "reloadInputMethods()" ) { | 336 | } else if ( msg == "reloadInputMethods()" ) { |
337 | readConfig(); | ||
338 | inputMethods->readConfig(); | ||
338 | inputMethods->loadInputMethods(); | 339 | inputMethods->loadInputMethods(); |
339 | } else if ( msg == "reloadApplets()" ) { | 340 | } else if ( msg == "reloadApplets()" ) { |
340 | sysTray->clearApplets(); | 341 | sysTray->clearApplets(); |
341 | sm->createMenu(); | 342 | sm->createMenu(); |
342 | sysTray->addApplets(); | 343 | sysTray->addApplets(); |
343 | }else if ( msg == "toggleMenu()" ) { | 344 | }else if ( msg == "toggleMenu()" ) { |
344 | if ( sm-> launchMenu-> isVisible() ) | 345 | if ( sm-> launchMenu-> isVisible() ) |
345 | sm-> launch(); | 346 | sm-> launch(); |
346 | else | 347 | else |
347 | QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); | 348 | QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); |
348 | }else if ( msg == "toggleStartMenu()" ) | 349 | }else if ( msg == "toggleStartMenu()" ) |
349 | sm->launch(); | 350 | sm->launch(); |
350 | } | 351 | } |
351 | 352 | ||
352 | void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) | 353 | void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) |
353 | { | 354 | { |
354 | if ( state == ServerInterface::Launching ) | 355 | if ( state == ServerInterface::Launching ) |
355 | runningAppBar->applicationLaunched( name ); | 356 | runningAppBar->applicationLaunched( name ); |
356 | else if ( state == ServerInterface::Terminated ) | 357 | else if ( state == ServerInterface::Terminated ) |
357 | runningAppBar->applicationTerminated( name ); | 358 | runningAppBar->applicationTerminated( name ); |
358 | } | 359 | } |
359 | 360 | ||
360 | void TaskBar::toggleNumLockState() | 361 | void TaskBar::toggleNumLockState() |
361 | { | 362 | { |
362 | if ( lockState ) lockState->toggleNumLockState(); | 363 | if ( lockState ) lockState->toggleNumLockState(); |
363 | } | 364 | } |
364 | 365 | ||
365 | void TaskBar::toggleCapsLockState() | 366 | void TaskBar::toggleCapsLockState() |
366 | { | 367 | { |
367 | if ( lockState ) lockState->toggleCapsLockState(); | 368 | if ( lockState ) lockState->toggleCapsLockState(); |
368 | } | 369 | } |
369 | 370 | ||
370 | void TaskBar::toggleSymbolInput() | 371 | void TaskBar::toggleSymbolInput() |
371 | { | 372 | { |
372 | QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); | 373 | QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); |
373 | if ( inputMethods->currentShown() == unicodeInput ) { | 374 | if ( inputMethods->currentShown() == unicodeInput ) { |
374 | inputMethods->hideInputMethod(); | 375 | inputMethods->hideInputMethod(); |
375 | } else { | 376 | } else { |
376 | inputMethods->showInputMethod( unicodeInput ); | 377 | inputMethods->showInputMethod( unicodeInput ); |
377 | } | 378 | } |
378 | } | 379 | } |
379 | 380 | ||
381 | void TaskBar::readConfig() { | ||
382 | Config cfg( "Launcher" ); | ||
383 | cfg.setGroup( "InputMethods" ); | ||
384 | resizeRunningApp = cfg.readBoolEntry( "Resize", true ); | ||
385 | } | ||
386 | |||
380 | #include "taskbar.moc" | 387 | #include "taskbar.moc" |
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h index ed558b1..be5fda8 100644 --- a/core/launcher/taskbar.h +++ b/core/launcher/taskbar.h | |||
@@ -1,87 +1,90 @@ | |||
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 | #ifndef TASKBAR_H | 21 | #ifndef TASKBAR_H |
22 | #define TASKBAR_H | 22 | #define TASKBAR_H |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include "serverinterface.h" | 25 | #include "serverinterface.h" |
26 | #include "startmenu.h" | 26 | #include "startmenu.h" |
27 | 27 | ||
28 | class QLabel; | 28 | class QLabel; |
29 | class QTimer; | 29 | class QTimer; |
30 | class InputMethods; | 30 | class InputMethods; |
31 | class Wait; | 31 | class Wait; |
32 | class SysTray; | 32 | class SysTray; |
33 | class RunningAppBar; | 33 | class RunningAppBar; |
34 | class QWidgetStack; | 34 | class QWidgetStack; |
35 | class QTimer; | 35 | class QTimer; |
36 | class QLabel; | 36 | class QLabel; |
37 | class LockKeyState; | 37 | class LockKeyState; |
38 | class AppLnkSet; | 38 | class AppLnkSet; |
39 | 39 | ||
40 | class TaskBar : public QHBox { | 40 | class TaskBar : public QHBox { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | TaskBar(); | 43 | TaskBar(); |
44 | ~TaskBar(); | 44 | ~TaskBar(); |
45 | 45 | ||
46 | void launchStartMenu() { if (sm) sm->launch(); } | 46 | void launchStartMenu() { if (sm) sm->launch(); } |
47 | void refreshStartMenu() { if (sm) sm->refreshMenu(); } | 47 | void refreshStartMenu() { if (sm) sm->refreshMenu(); } |
48 | void setApplicationState( const QString &name, ServerInterface::ApplicationState state ); | 48 | void setApplicationState( const QString &name, ServerInterface::ApplicationState state ); |
49 | 49 | ||
50 | signals: | 50 | signals: |
51 | void tabSelected(const QString&); | 51 | void tabSelected(const QString&); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void startWait(); | 54 | void startWait(); |
55 | void stopWait(const QString&); | 55 | void stopWait(const QString&); |
56 | void stopWait(); | 56 | void stopWait(); |
57 | 57 | ||
58 | void clearStatusBar(); | 58 | void clearStatusBar(); |
59 | void toggleNumLockState(); | 59 | void toggleNumLockState(); |
60 | void toggleCapsLockState(); | 60 | void toggleCapsLockState(); |
61 | void toggleSymbolInput(); | 61 | void toggleSymbolInput(); |
62 | void calcMaxWindowRect(); | 62 | void calcMaxWindowRect(); |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | void resizeEvent( QResizeEvent * ); | 65 | void resizeEvent( QResizeEvent * ); |
66 | void styleChange( QStyle & ); | 66 | void styleChange( QStyle & ); |
67 | void setStatusMessage( const QString &text ); | 67 | void setStatusMessage( const QString &text ); |
68 | 68 | ||
69 | private slots: | 69 | private slots: |
70 | void receive( const QCString &msg, const QByteArray &data ); | 70 | void receive( const QCString &msg, const QByteArray &data ); |
71 | 71 | ||
72 | private: | 72 | private: |
73 | void readConfig(); | ||
74 | |||
75 | private: | ||
73 | QTimer *waitTimer; | 76 | QTimer *waitTimer; |
74 | Wait *waitIcon; | 77 | Wait *waitIcon; |
75 | InputMethods *inputMethods; | 78 | InputMethods *inputMethods; |
76 | SysTray *sysTray; | 79 | SysTray *sysTray; |
77 | RunningAppBar* runningAppBar; | 80 | RunningAppBar* runningAppBar; |
78 | QWidgetStack *stack; | 81 | QWidgetStack *stack; |
79 | QTimer *clearer; | 82 | QTimer *clearer; |
80 | QLabel *label; | 83 | QLabel *label; |
81 | LockKeyState* lockState; | 84 | LockKeyState* lockState; |
82 | StartMenu *sm; | 85 | StartMenu *sm; |
83 | bool resizeRunningApp; | 86 | bool resizeRunningApp; |
84 | }; | 87 | }; |
85 | 88 | ||
86 | 89 | ||
87 | #endif // TASKBAR_H | 90 | #endif // TASKBAR_H |
diff --git a/core/settings/launcher/inputmethodsettings.cpp b/core/settings/launcher/inputmethodsettings.cpp index 0422075..125b178 100644 --- a/core/settings/launcher/inputmethodsettings.cpp +++ b/core/settings/launcher/inputmethodsettings.cpp | |||
@@ -1,88 +1,107 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> | 4 | .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "inputmethodsettings.h" | 29 | #include "inputmethodsettings.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | #include <qpe/qcopenvelope_qws.h> | ||
34 | 35 | ||
35 | /* QT */ | 36 | /* QT */ |
36 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
37 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
38 | #include <qlayout.h> | 39 | #include <qlayout.h> |
39 | #include <qlabel.h> | 40 | #include <qlabel.h> |
40 | #include <qwhatsthis.h> | 41 | #include <qwhatsthis.h> |
41 | 42 | ||
42 | 43 | ||
43 | InputMethodSettings::InputMethodSettings( QWidget *parent, const char *name ):QWidget( parent, name ) | 44 | InputMethodSettings::InputMethodSettings( QWidget *parent, const char *name ):QWidget( parent, name ) |
44 | { | 45 | { |
45 | QBoxLayout *lay = new QVBoxLayout( this, 4, 4 ); | 46 | QBoxLayout *lay = new QVBoxLayout( this, 4, 4 ); |
46 | 47 | ||
47 | _resize = new QCheckBox( tr( "Resize application on Popup" ), this ); | 48 | _resize = new QCheckBox( tr( "Resize application on Popup" ), this ); |
48 | _float = new QCheckBox( tr( "Enable floating and resizing" ), this ); | 49 | _float = new QCheckBox( tr( "Enable floating and resizing" ), this ); |
49 | 50 | ||
50 | QHBoxLayout* hbox = new QHBoxLayout( lay, 4 ); | 51 | QHBoxLayout* hbox = new QHBoxLayout( lay, 4 ); |
51 | hbox->addWidget( new QLabel( "Initial Width:", this ) ); | 52 | hbox->addWidget( new QLabel( "Initial Width:", this ) ); |
52 | _size = new QSpinBox( 10, 100, 10, this ); | 53 | _size = new QSpinBox( 10, 100, 10, this ); |
53 | _size->setSuffix( "%" ); | 54 | _size->setSuffix( "%" ); |
54 | hbox->addWidget( _size ); | 55 | hbox->addWidget( _size ); |
55 | hbox->addStretch(); | 56 | hbox->addStretch(); |
56 | 57 | ||
57 | Config cfg( "Launcher" ); | 58 | Config cfg( "Launcher" ); |
58 | cfg.setGroup( "InputMethods" ); | 59 | cfg.setGroup( "InputMethods" ); |
59 | _resize->setChecked( cfg.readBoolEntry( "Resize", true ) ); | 60 | |
60 | _float->setChecked( cfg.readBoolEntry( "Float", false ) ); | 61 | /* |
61 | _size->setValue( cfg.readNumEntry( "Width", 100 ) ); | 62 | * load the values to see if something was changed |
63 | */ | ||
64 | _wasResize = cfg.readBoolEntry( "Resize", true ); | ||
65 | _wasFloat = cfg.readBoolEntry( "Float", false ); | ||
66 | _wasWidth = cfg.readNumEntry( "Width", 100 ); | ||
67 | |||
68 | _resize->setChecked( _wasResize ); | ||
69 | _float ->setChecked( _wasFloat ); | ||
70 | _size ->setValue( _wasWidth ); | ||
62 | 71 | ||
63 | lay->addWidget( _resize ); | 72 | lay->addWidget( _resize ); |
64 | lay->addWidget( _float ); | 73 | lay->addWidget( _float ); |
65 | lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) ); | 74 | lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) ); |
66 | 75 | ||
67 | lay->addStretch(); | 76 | lay->addStretch(); |
68 | 77 | ||
69 | QWhatsThis::add( _resize, tr( "Check, if you want the application to be automatically resized if the input method pops up." ) ); | 78 | QWhatsThis::add( _resize, tr( "Check, if you want the application to be automatically resized if the input method pops up." ) ); |
70 | QWhatsThis::add( _float, tr( "Check, if you want to move and/or resize input methods" ) ); | 79 | QWhatsThis::add( _float, tr( "Check, if you want to move and/or resize input methods" ) ); |
71 | QWhatsThis::add( _size, tr( "Specify the percentage of the screen width for the input method" ) ); | 80 | QWhatsThis::add( _size, tr( "Specify the percentage of the screen width for the input method" ) ); |
72 | } | 81 | } |
73 | 82 | ||
74 | void InputMethodSettings::appletChanged() | 83 | bool InputMethodSettings::changed()const{ |
75 | { | 84 | if ( _wasResize != _resize->isChecked() ) |
85 | return true; | ||
86 | else if ( _wasFloat != _float->isChecked() ) | ||
87 | return true; | ||
88 | else if ( _wasWidth != _size->value() ) | ||
89 | return true; | ||
90 | else | ||
91 | return false; | ||
76 | } | 92 | } |
77 | 93 | ||
78 | void InputMethodSettings::accept() | 94 | void InputMethodSettings::accept() |
79 | { | 95 | { |
80 | odebug << "InputMethodSettings::accept()" << oendl; | 96 | odebug << "InputMethodSettings::accept()" << oendl; |
81 | Config cfg( "Launcher" ); | 97 | Config cfg( "Launcher" ); |
82 | cfg.setGroup( "InputMethods" ); | 98 | cfg.setGroup( "InputMethods" ); |
83 | cfg.writeEntry( "Resize", _resize->isChecked() ); | 99 | cfg.writeEntry( "Resize", _resize->isChecked() ); |
84 | cfg.writeEntry( "Float", _float->isChecked() ); | 100 | cfg.writeEntry( "Float", _float->isChecked() ); |
85 | cfg.writeEntry( "Width", _size->value() ); | 101 | cfg.writeEntry( "Width", _size->value() ); |
86 | cfg.write(); | 102 | cfg.write(); |
103 | |||
104 | if ( changed() ) | ||
105 | QCopEnvelope( "QPE/TaskBar", "reloadInputMethods()" ); | ||
87 | } | 106 | } |
88 | 107 | ||
diff --git a/core/settings/launcher/inputmethodsettings.h b/core/settings/launcher/inputmethodsettings.h index 486ee5e..2ae43f2 100644 --- a/core/settings/launcher/inputmethodsettings.h +++ b/core/settings/launcher/inputmethodsettings.h | |||
@@ -1,57 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> | 3 | .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef __IMETHOD_SETTINGS_H__ | 28 | #ifndef __IMETHOD_SETTINGS_H__ |
29 | #define __IMETHOD_SETTINGS_H__ | 29 | #define __IMETHOD_SETTINGS_H__ |
30 | 30 | ||
31 | #include <qwidget.h> | 31 | #include <qwidget.h> |
32 | 32 | ||
33 | class QCheckBox; | 33 | class QCheckBox; |
34 | class QSpinBox; | 34 | class QSpinBox; |
35 | 35 | ||
36 | class InputMethodSettings : public QWidget | 36 | class InputMethodSettings : public QWidget |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | InputMethodSettings ( QWidget *parent = 0, const char *name = 0 ); | 41 | InputMethodSettings ( QWidget *parent = 0, const char *name = 0 ); |
42 | 42 | ||
43 | void accept ( ); | 43 | void accept ( ); |
44 | 44 | ||
45 | protected slots: | ||
46 | void appletChanged ( ); | ||
47 | |||
48 | protected: | 45 | protected: |
49 | void init ( ); | 46 | void init ( ); |
50 | 47 | ||
51 | private: | 48 | private: |
52 | QCheckBox* _resize; | 49 | QCheckBox* _resize; |
53 | QCheckBox* _float; | 50 | QCheckBox* _float; |
54 | QSpinBox* _size; | 51 | QSpinBox* _size; |
52 | |||
53 | private: | ||
54 | bool changed()const; | ||
55 | bool _wasResize : 1; | ||
56 | bool _wasFloat : 1; | ||
57 | int _wasWidth; | ||
55 | }; | 58 | }; |
56 | 59 | ||
57 | #endif | 60 | #endif |