author | sandman <sandman> | 2002-11-25 01:14:19 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-25 01:14:19 (UTC) |
commit | 1b4665ddf28fdb59810b90138a5a88f87a2d9bc6 (patch) (unidiff) | |
tree | 14254d02145e88f1970f3c26af4ad006ab00c15a | |
parent | da8050fe68a443773447ee176793a30df256ea9b (diff) | |
download | opie-1b4665ddf28fdb59810b90138a5a88f87a2d9bc6.zip opie-1b4665ddf28fdb59810b90138a5a88f87a2d9bc6.tar.gz opie-1b4665ddf28fdb59810b90138a5a88f87a2d9bc6.tar.bz2 |
*** empty log message ***
-rw-r--r-- | core/launcher/desktop.cpp | 23 | ||||
-rw-r--r-- | core/launcher/desktop.h | 1 | ||||
-rw-r--r-- | core/launcher/startmenu.cpp | 7 |
3 files changed, 10 insertions, 21 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 3e8c731..34b52d2 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,920 +1,905 @@ | |||
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 "desktop.h" | 21 | #include "desktop.h" |
22 | #include "info.h" | 22 | #include "info.h" |
23 | #include "launcher.h" | 23 | #include "launcher.h" |
24 | #include "qcopbridge.h" | 24 | #include "qcopbridge.h" |
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | #include "startmenu.h" | 26 | #include "startmenu.h" |
27 | #include "taskbar.h" | 27 | #include "taskbar.h" |
28 | #include "transferserver.h" | 28 | #include "transferserver.h" |
29 | #include "irserver.h" | 29 | #include "irserver.h" |
30 | #include "packageslave.h" | 30 | #include "packageslave.h" |
31 | #include "screensaver.h" | 31 | #include "screensaver.h" |
32 | 32 | ||
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
35 | #include <qpe/password.h> | 35 | #include <qpe/password.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/network.h> | 40 | #include <qpe/network.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | 42 | ||
43 | #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) | 43 | #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) |
44 | #include <qpe/custom.h> | 44 | #include <qpe/custom.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
48 | 48 | ||
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #include <qmainwindow.h> | 50 | #include <qmainwindow.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qwindowsystem_qws.h> | 53 | #include <qwindowsystem_qws.h> |
54 | 54 | ||
55 | #include <qvaluelist.h> | 55 | #include <qvaluelist.h> |
56 | 56 | ||
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <fcntl.h> | 59 | #include <fcntl.h> |
60 | 60 | ||
61 | using namespace Opie; | 61 | using namespace Opie; |
62 | 62 | ||
63 | class QCopKeyRegister | 63 | class QCopKeyRegister |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | QCopKeyRegister() : keyCode( 0 ) | 66 | QCopKeyRegister() : keyCode( 0 ) |
67 | { } | 67 | { } |
68 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 68 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
69 | : keyCode( k ), channel( c ), message( m ) | 69 | : keyCode( k ), channel( c ), message( m ) |
70 | { } | 70 | { } |
71 | 71 | ||
72 | int getKeyCode() const | 72 | int getKeyCode() const |
73 | { | 73 | { |
74 | return keyCode; | 74 | return keyCode; |
75 | } | 75 | } |
76 | QString getChannel() const | 76 | QString getChannel() const |
77 | { | 77 | { |
78 | return channel; | 78 | return channel; |
79 | } | 79 | } |
80 | QString getMessage() const | 80 | QString getMessage() const |
81 | { | 81 | { |
82 | return message; | 82 | return message; |
83 | } | 83 | } |
84 | 84 | ||
85 | private: | 85 | private: |
86 | int keyCode; | 86 | int keyCode; |
87 | QString channel, message; | 87 | QString channel, message; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 90 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
91 | KeyRegisterList keyRegisterList; | 91 | KeyRegisterList keyRegisterList; |
92 | 92 | ||
93 | static Desktop* qpedesktop = 0; | 93 | static Desktop* qpedesktop = 0; |
94 | static int loggedin = 0; | 94 | static int loggedin = 0; |
95 | static void login( bool at_poweron ) | 95 | static void login( bool at_poweron ) |
96 | { | 96 | { |
97 | if ( !loggedin ) { | 97 | if ( !loggedin ) { |
98 | Global::terminateBuiltin( "calibrate" ); | 98 | Global::terminateBuiltin( "calibrate" ); |
99 | Password::authenticate( at_poweron ); | 99 | Password::authenticate( at_poweron ); |
100 | loggedin = 1; | 100 | loggedin = 1; |
101 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 101 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | bool Desktop::screenLocked() | 105 | bool Desktop::screenLocked() |
106 | { | 106 | { |
107 | return loggedin == 0; | 107 | return loggedin == 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | /* | 110 | /* |
111 | Priority is number of alerts that are needed to pop up | 111 | Priority is number of alerts that are needed to pop up |
112 | alert. | 112 | alert. |
113 | */ | 113 | */ |
114 | class DesktopPowerAlerter : public QMessageBox | 114 | class DesktopPowerAlerter : public QMessageBox |
115 | { | 115 | { |
116 | public: | 116 | public: |
117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
119 | QMessageBox::Critical, | 119 | QMessageBox::Critical, |
120 | QMessageBox::Ok | QMessageBox::Default, | 120 | QMessageBox::Ok | QMessageBox::Default, |
121 | QMessageBox::NoButton, QMessageBox::NoButton, | 121 | QMessageBox::NoButton, QMessageBox::NoButton, |
122 | parent, name, FALSE ) | 122 | parent, name, FALSE ) |
123 | { | 123 | { |
124 | currentPriority = INT_MAX; | 124 | currentPriority = INT_MAX; |
125 | alertCount = 0; | 125 | alertCount = 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | void alert( const QString &text, int priority ); | 128 | void alert( const QString &text, int priority ); |
129 | void hideEvent( QHideEvent * ); | 129 | void hideEvent( QHideEvent * ); |
130 | private: | 130 | private: |
131 | int currentPriority; | 131 | int currentPriority; |
132 | int alertCount; | 132 | int alertCount; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
136 | { | 136 | { |
137 | alertCount++; | 137 | alertCount++; |
138 | if ( alertCount < priority ) | 138 | if ( alertCount < priority ) |
139 | return ; | 139 | return ; |
140 | if ( priority > currentPriority ) | 140 | if ( priority > currentPriority ) |
141 | return ; | 141 | return ; |
142 | currentPriority = priority; | 142 | currentPriority = priority; |
143 | setText( text ); | 143 | setText( text ); |
144 | show(); | 144 | show(); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
149 | { | 149 | { |
150 | QMessageBox::hideEvent( e ); | 150 | QMessageBox::hideEvent( e ); |
151 | alertCount = 0; | 151 | alertCount = 0; |
152 | currentPriority = INT_MAX; | 152 | currentPriority = INT_MAX; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | void DesktopApplication::switchLCD ( bool on ) | 156 | void DesktopApplication::switchLCD ( bool on ) |
157 | { | 157 | { |
158 | if ( qApp ) { | 158 | if ( qApp ) { |
159 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 159 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
160 | 160 | ||
161 | if ( dapp-> m_screensaver ) { | 161 | if ( dapp-> m_screensaver ) { |
162 | if ( on ) { | 162 | if ( on ) { |
163 | dapp-> m_screensaver-> setDisplayState ( true ); | 163 | dapp-> m_screensaver-> setDisplayState ( true ); |
164 | dapp-> m_screensaver-> setBacklight ( -3 ); | 164 | dapp-> m_screensaver-> setBacklight ( -3 ); |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | dapp-> m_screensaver-> setDisplayState ( false ); | 167 | dapp-> m_screensaver-> setDisplayState ( false ); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 174 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
175 | : QPEApplication( argc, argv, appType ) | 175 | : QPEApplication( argc, argv, appType ) |
176 | { | 176 | { |
177 | 177 | ||
178 | Config cfg( "apm" ); | 178 | Config cfg( "apm" ); |
179 | cfg.setGroup( "Warnings" ); | 179 | cfg.setGroup( "Warnings" ); |
180 | //cfg.readNumEntry( "checkinterval", 10000 ) | 180 | //cfg.readNumEntry( "checkinterval", 10000 ) |
181 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 181 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
182 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); | 182 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); |
183 | 183 | ||
184 | m_ps = new PowerStatus; | 184 | m_ps = new PowerStatus; |
185 | m_ps_last = new PowerStatus; | 185 | m_ps_last = new PowerStatus; |
186 | pa = new DesktopPowerAlerter( 0 ); | 186 | pa = new DesktopPowerAlerter( 0 ); |
187 | 187 | ||
188 | m_timer = new QTimer( this ); | 188 | m_timer = new QTimer( this ); |
189 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); | 189 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); |
190 | m_timer->start( 5000 ); | 190 | m_timer->start( 5000 ); |
191 | 191 | ||
192 | channel = new QCopChannel( "QPE/Desktop", this ); | 192 | channel = new QCopChannel( "QPE/Desktop", this ); |
193 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 193 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
194 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 194 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
195 | 195 | ||
196 | channel = new QCopChannel( "QPE/System", this ); | 196 | channel = new QCopChannel( "QPE/System", this ); |
197 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 197 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
198 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 198 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
199 | 199 | ||
200 | m_screensaver = new OpieScreenSaver ( ); | 200 | m_screensaver = new OpieScreenSaver ( ); |
201 | m_screensaver-> setInterval ( -1 ); | 201 | m_screensaver-> setInterval ( -1 ); |
202 | QWSServer::setScreenSaver( m_screensaver ); | 202 | QWSServer::setScreenSaver( m_screensaver ); |
203 | 203 | ||
204 | apmTimeout ( ); | 204 | apmTimeout ( ); |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | DesktopApplication::~DesktopApplication() | 208 | DesktopApplication::~DesktopApplication() |
209 | { | 209 | { |
210 | delete m_ps; | 210 | delete m_ps; |
211 | delete m_ps_last; | 211 | delete m_ps_last; |
212 | delete pa; | 212 | delete pa; |
213 | } | 213 | } |
214 | 214 | ||
215 | void DesktopApplication::apmTimeout() | 215 | void DesktopApplication::apmTimeout() |
216 | { | 216 | { |
217 | qpedesktop->checkMemory(); // in case no events are being generated | 217 | qpedesktop->checkMemory(); // in case no events are being generated |
218 | 218 | ||
219 | *m_ps_last = *m_ps; | 219 | *m_ps_last = *m_ps; |
220 | *m_ps = PowerStatusManager::readStatus(); | 220 | *m_ps = PowerStatusManager::readStatus(); |
221 | 221 | ||
222 | if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) | 222 | if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) |
223 | m_screensaver-> powerStatusChanged ( *m_ps ); | 223 | m_screensaver-> powerStatusChanged ( *m_ps ); |
224 | 224 | ||
225 | if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { | 225 | if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { |
226 | int bat = m_ps-> batteryPercentRemaining ( ); | 226 | int bat = m_ps-> batteryPercentRemaining ( ); |
227 | 227 | ||
228 | if ( bat < m_ps_last-> batteryPercentRemaining ( )) { | 228 | if ( bat < m_ps_last-> batteryPercentRemaining ( )) { |
229 | if ( bat <= m_powerCritical ) | 229 | if ( bat <= m_powerCritical ) |
230 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | 230 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); |
231 | else if ( bat <= m_powerVeryLow ) | 231 | else if ( bat <= m_powerVeryLow ) |
232 | pa->alert( tr( "Battery is running very low." ), 2 ); | 232 | pa->alert( tr( "Battery is running very low." ), 2 ); |
233 | } | 233 | } |
234 | if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) | 234 | if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) |
235 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); | 235 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 239 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
240 | { | 240 | { |
241 | QDataStream stream( data, IO_ReadOnly ); | 241 | QDataStream stream( data, IO_ReadOnly ); |
242 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 242 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
243 | int k; | 243 | int k; |
244 | QString c, m; | 244 | QString c, m; |
245 | stream >> k; | 245 | stream >> k; |
246 | stream >> c; | 246 | stream >> c; |
247 | stream >> m; | 247 | stream >> m; |
248 | 248 | ||
249 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 249 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
250 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 250 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 255 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
256 | { | 256 | { |
257 | QDataStream stream ( data, IO_ReadOnly ); | 257 | QDataStream stream ( data, IO_ReadOnly ); |
258 | 258 | ||
259 | if ( msg == "setScreenSaverInterval(int)" ) { | 259 | if ( msg == "setScreenSaverInterval(int)" ) { |
260 | int time; | 260 | int time; |
261 | stream >> time; | 261 | stream >> time; |
262 | m_screensaver-> setInterval( time ); | 262 | m_screensaver-> setInterval( time ); |
263 | } | 263 | } |
264 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 264 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
265 | int t1, t2, t3; | 265 | int t1, t2, t3; |
266 | stream >> t1 >> t2 >> t3; | 266 | stream >> t1 >> t2 >> t3; |
267 | m_screensaver-> setIntervals( t1, t2, t3 ); | 267 | m_screensaver-> setIntervals( t1, t2, t3 ); |
268 | } | 268 | } |
269 | else if ( msg == "setBacklight(int)" ) { | 269 | else if ( msg == "setBacklight(int)" ) { |
270 | int bright; | 270 | int bright; |
271 | stream >> bright; | 271 | stream >> bright; |
272 | m_screensaver-> setBacklight( bright ); | 272 | m_screensaver-> setBacklight( bright ); |
273 | } | 273 | } |
274 | else if ( msg == "setScreenSaverMode(int)" ) { | 274 | else if ( msg == "setScreenSaverMode(int)" ) { |
275 | int mode; | 275 | int mode; |
276 | stream >> mode; | 276 | stream >> mode; |
277 | m_screensaver-> setMode ( mode ); | 277 | m_screensaver-> setMode ( mode ); |
278 | } | 278 | } |
279 | else if ( msg == "reloadPowerWarnSettings()" ) { | 279 | else if ( msg == "reloadPowerWarnSettings()" ) { |
280 | reloadPowerWarnSettings(); | 280 | reloadPowerWarnSettings(); |
281 | } | 281 | } |
282 | else if ( msg == "setDisplayState(int)" ) { | 282 | else if ( msg == "setDisplayState(int)" ) { |
283 | int state; | 283 | int state; |
284 | stream >> state; | 284 | stream >> state; |
285 | m_screensaver-> setDisplayState ( state != 0 ); | 285 | m_screensaver-> setDisplayState ( state != 0 ); |
286 | } | 286 | } |
287 | else if ( msg == "suspend()" ) { | 287 | else if ( msg == "suspend()" ) { |
288 | emit power(); | 288 | emit power(); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | void DesktopApplication::reloadPowerWarnSettings() { | 292 | void DesktopApplication::reloadPowerWarnSettings() { |
293 | Config cfg( "apm" ); | 293 | Config cfg( "apm" ); |
294 | cfg.setGroup( "Warnings" ); | 294 | cfg.setGroup( "Warnings" ); |
295 | 295 | ||
296 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); | 296 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); |
297 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 297 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
298 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); | 298 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 302 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
303 | 303 | ||
304 | #ifdef Q_WS_QWS | 304 | #ifdef Q_WS_QWS |
305 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 305 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
306 | { | 306 | { |
307 | qpedesktop->checkMemory(); | 307 | qpedesktop->checkMemory(); |
308 | 308 | ||
309 | if ( e->type == QWSEvent::Key ) { | 309 | if ( e->type == QWSEvent::Key ) { |
310 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 310 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
311 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 311 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
312 | return TRUE; | 312 | return TRUE; |
313 | bool press = ke->simpleData.is_press; | 313 | bool press = ke->simpleData.is_press; |
314 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 314 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
315 | 315 | ||
316 | /* | 316 | /* |
317 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 317 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
318 | when user presses key, unless keyboard has been requested from app. | 318 | when user presses key, unless keyboard has been requested from app. |
319 | will not send multiple repeats if user holds key | 319 | will not send multiple repeats if user holds key |
320 | i.e. one shot | 320 | i.e. one shot |
321 | */ | 321 | */ |
322 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | 322 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
323 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | 323 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
324 | KeyRegisterList::Iterator it; | 324 | KeyRegisterList::Iterator it; |
325 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 325 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
326 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | 326 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
327 | if ( press ) | 327 | if ( press ) |
328 | qDebug( "press" ); | 328 | qDebug( "press" ); |
329 | else | 329 | else |
330 | qDebug( "release" ); | 330 | qDebug( "release" ); |
331 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 331 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | if ( !keyboardGrabbed() ) { | 336 | if ( !keyboardGrabbed() ) { |
337 | if ( ke->simpleData.keycode == Key_F9 ) { | 337 | if ( ke->simpleData.keycode == Key_F9 ) { |
338 | if ( press ) | 338 | if ( press ) |
339 | emit datebook(); | 339 | emit datebook(); |
340 | return TRUE; | 340 | return TRUE; |
341 | } | 341 | } |
342 | if ( ke->simpleData.keycode == Key_F10 ) { | 342 | if ( ke->simpleData.keycode == Key_F10 ) { |
343 | if ( !press && cardSendTimer ) { | 343 | if ( !press && cardSendTimer ) { |
344 | emit contacts(); | 344 | emit contacts(); |
345 | delete cardSendTimer; | 345 | delete cardSendTimer; |
346 | } | 346 | } |
347 | else if ( press ) { | 347 | else if ( press ) { |
348 | cardSendTimer = new QTimer(); | 348 | cardSendTimer = new QTimer(); |
349 | cardSendTimer->start( 2000, TRUE ); | 349 | cardSendTimer->start( 2000, TRUE ); |
350 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 350 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
351 | } | 351 | } |
352 | return TRUE; | 352 | return TRUE; |
353 | } | 353 | } |
354 | 354 | ||
355 | // if ( ke->simpleData.keycode == Key_F11 ) { | 355 | if ( ke->simpleData.keycode == Key_F11 ) { |
356 | // if ( press ) emit menu(); | 356 | if ( press ) emit menu(); |
357 | // return TRUE; | 357 | return TRUE; |
358 | // } | 358 | } |
359 | 359 | ||
360 | if ( ke->simpleData.keycode == Key_F12 ) { | 360 | if ( ke->simpleData.keycode == Key_F12 ) { |
361 | while ( activePopupWidget() ) | 361 | while ( activePopupWidget() ) |
362 | activePopupWidget() ->close(); | 362 | activePopupWidget() ->close(); |
363 | if ( press ) | 363 | if ( press ) |
364 | emit launch(); | 364 | emit launch(); |
365 | return TRUE; | 365 | return TRUE; |
366 | } | 366 | } |
367 | if ( ke->simpleData.keycode == Key_F13 ) { | 367 | if ( ke->simpleData.keycode == Key_F13 ) { |
368 | if ( press ) | 368 | if ( press ) |
369 | emit email(); | 369 | emit email(); |
370 | return TRUE; | 370 | return TRUE; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | if ( ke->simpleData.keycode == Key_F34 ) { | 374 | if ( ke->simpleData.keycode == Key_F34 ) { |
375 | if ( press ) | 375 | if ( press ) |
376 | emit power(); | 376 | emit power(); |
377 | return TRUE; | 377 | return TRUE; |
378 | } | 378 | } |
379 | // This was used for the iPAQ PowerButton | 379 | // This was used for the iPAQ PowerButton |
380 | // See main.cpp for new KeyboardFilter | 380 | // See main.cpp for new KeyboardFilter |
381 | // | 381 | // |
382 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 382 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
383 | // if ( press ) emit power(); | 383 | // if ( press ) emit power(); |
384 | // return TRUE; | 384 | // return TRUE; |
385 | // } | 385 | // } |
386 | if ( ke->simpleData.keycode == Key_F35 ) { | 386 | if ( ke->simpleData.keycode == Key_F35 ) { |
387 | if ( press ) | 387 | if ( press ) |
388 | emit backlight(); | 388 | emit backlight(); |
389 | return TRUE; | 389 | return TRUE; |
390 | } | 390 | } |
391 | if ( ke->simpleData.keycode == Key_F32 ) { | 391 | if ( ke->simpleData.keycode == Key_F32 ) { |
392 | if ( press ) | 392 | if ( press ) |
393 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 393 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
394 | return TRUE; | 394 | return TRUE; |
395 | } | 395 | } |
396 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 396 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
397 | if ( press ) | 397 | if ( press ) |
398 | emit symbol(); | 398 | emit symbol(); |
399 | return TRUE; | 399 | return TRUE; |
400 | } | 400 | } |
401 | if ( ke->simpleData.keycode == Key_NumLock ) { | 401 | if ( ke->simpleData.keycode == Key_NumLock ) { |
402 | if ( press ) | 402 | if ( press ) |
403 | emit numLockStateToggle(); | 403 | emit numLockStateToggle(); |
404 | } | 404 | } |
405 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 405 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
406 | if ( press ) | 406 | if ( press ) |
407 | emit capsLockStateToggle(); | 407 | emit capsLockStateToggle(); |
408 | } | 408 | } |
409 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 409 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
410 | qpedesktop->keyClick(); | 410 | qpedesktop->keyClick(); |
411 | } | 411 | } |
412 | else { | 412 | else { |
413 | if ( e->type == QWSEvent::Mouse ) { | 413 | if ( e->type == QWSEvent::Mouse ) { |
414 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 414 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
415 | static bool up = TRUE; | 415 | static bool up = TRUE; |
416 | if ( me->simpleData.state & LeftButton ) { | 416 | if ( me->simpleData.state & LeftButton ) { |
417 | if ( up ) { | 417 | if ( up ) { |
418 | up = FALSE; | 418 | up = FALSE; |
419 | qpedesktop->screenClick(); | 419 | qpedesktop->screenClick(); |
420 | } | 420 | } |
421 | } | 421 | } |
422 | else { | 422 | else { |
423 | up = TRUE; | 423 | up = TRUE; |
424 | } | 424 | } |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | return QPEApplication::qwsEventFilter( e ); | 428 | return QPEApplication::qwsEventFilter( e ); |
429 | } | 429 | } |
430 | #endif | 430 | #endif |
431 | 431 | ||
432 | 432 | ||
433 | void DesktopApplication::sendCard() | 433 | void DesktopApplication::sendCard() |
434 | { | 434 | { |
435 | delete cardSendTimer; | 435 | delete cardSendTimer; |
436 | cardSendTimer = 0; | 436 | cardSendTimer = 0; |
437 | QString card = getenv( "HOME" ); | 437 | QString card = getenv( "HOME" ); |
438 | card += "/Applications/addressbook/businesscard.vcf"; | 438 | card += "/Applications/addressbook/businesscard.vcf"; |
439 | 439 | ||
440 | if ( QFile::exists( card ) ) { | 440 | if ( QFile::exists( card ) ) { |
441 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 441 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
442 | QString mimetype = "text/x-vCard"; | 442 | QString mimetype = "text/x-vCard"; |
443 | e << tr( "business card" ) << card << mimetype; | 443 | e << tr( "business card" ) << card << mimetype; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | #if defined(QPE_HAVE_MEMALERTER) | 447 | #if defined(QPE_HAVE_MEMALERTER) |
448 | QPE_MEMALERTER_IMPL | 448 | QPE_MEMALERTER_IMPL |
449 | #endif | 449 | #endif |
450 | 450 | ||
451 | //=========================================================================== | 451 | //=========================================================================== |
452 | 452 | ||
453 | Desktop::Desktop() : | 453 | Desktop::Desktop() : |
454 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 454 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
455 | qcopBridge( 0 ), | 455 | qcopBridge( 0 ), |
456 | transferServer( 0 ), | 456 | transferServer( 0 ), |
457 | packageSlave( 0 ) | 457 | packageSlave( 0 ) |
458 | { | 458 | { |
459 | qpedesktop = this; | 459 | qpedesktop = this; |
460 | 460 | ||
461 | // bg = new Info( this ); | 461 | // bg = new Info( this ); |
462 | tb = new TaskBar; | 462 | tb = new TaskBar; |
463 | 463 | ||
464 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 464 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
465 | 465 | ||
466 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 466 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
467 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 467 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
468 | 468 | ||
469 | int displayw = qApp->desktop() ->width(); | 469 | int displayw = qApp->desktop() ->width(); |
470 | int displayh = qApp->desktop() ->height(); | 470 | int displayh = qApp->desktop() ->height(); |
471 | 471 | ||
472 | 472 | ||
473 | QSize sz = tb->sizeHint(); | 473 | QSize sz = tb->sizeHint(); |
474 | 474 | ||
475 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 475 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
476 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 476 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
477 | 477 | ||
478 | tb->show(); | 478 | tb->show(); |
479 | launcher->showMaximized(); | 479 | launcher->showMaximized(); |
480 | launcher->show(); | 480 | launcher->show(); |
481 | launcher->raise(); | 481 | launcher->raise(); |
482 | #if defined(QPE_HAVE_MEMALERTER) | 482 | #if defined(QPE_HAVE_MEMALERTER) |
483 | 483 | ||
484 | initMemalerter(); | 484 | initMemalerter(); |
485 | #endif | 485 | #endif |
486 | // start services | 486 | // start services |
487 | startTransferServer(); | 487 | startTransferServer(); |
488 | ( void ) new IrServer( this ); | 488 | ( void ) new IrServer( this ); |
489 | rereadVolumes(); | 489 | rereadVolumes(); |
490 | 490 | ||
491 | packageSlave = new PackageSlave( this ); | 491 | packageSlave = new PackageSlave( this ); |
492 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | 492 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); |
493 | 493 | ||
494 | qApp->installEventFilter( this ); | 494 | qApp->installEventFilter( this ); |
495 | 495 | ||
496 | qApp-> setMainWidget ( launcher ); | 496 | qApp-> setMainWidget ( launcher ); |
497 | } | 497 | } |
498 | 498 | ||
499 | void Desktop::show() | 499 | void Desktop::show() |
500 | { | 500 | { |
501 | login( TRUE ); | 501 | login( TRUE ); |
502 | QWidget::show(); | 502 | QWidget::show(); |
503 | } | 503 | } |
504 | 504 | ||
505 | Desktop::~Desktop() | 505 | Desktop::~Desktop() |
506 | { | 506 | { |
507 | delete launcher; | 507 | delete launcher; |
508 | delete tb; | 508 | delete tb; |
509 | delete qcopBridge; | 509 | delete qcopBridge; |
510 | delete transferServer; | 510 | delete transferServer; |
511 | } | 511 | } |
512 | 512 | ||
513 | bool Desktop::recoverMemory() | 513 | bool Desktop::recoverMemory() |
514 | { | 514 | { |
515 | return tb->recoverMemory(); | 515 | return tb->recoverMemory(); |
516 | } | 516 | } |
517 | 517 | ||
518 | void Desktop::checkMemory() | 518 | void Desktop::checkMemory() |
519 | { | 519 | { |
520 | #if defined(QPE_HAVE_MEMALERTER) | 520 | #if defined(QPE_HAVE_MEMALERTER) |
521 | static bool ignoreNormal = FALSE; | 521 | static bool ignoreNormal = FALSE; |
522 | static bool existingMessage = FALSE; | 522 | static bool existingMessage = FALSE; |
523 | 523 | ||
524 | if ( existingMessage ) | 524 | if ( existingMessage ) |
525 | return ; // don't show a second message while still on first | 525 | return ; // don't show a second message while still on first |
526 | 526 | ||
527 | existingMessage = TRUE; | 527 | existingMessage = TRUE; |
528 | switch ( memstate ) { | 528 | switch ( memstate ) { |
529 | case Unknown: | 529 | case Unknown: |
530 | break; | 530 | break; |
531 | case Low: | 531 | case Low: |
532 | memstate = Unknown; | 532 | memstate = Unknown; |
533 | if ( recoverMemory() ) | 533 | if ( recoverMemory() ) |
534 | ignoreNormal = TRUE; | 534 | ignoreNormal = TRUE; |
535 | else | 535 | else |
536 | QMessageBox::warning( 0 , "Memory Status", | 536 | QMessageBox::warning( 0 , "Memory Status", |
537 | "The memory smacks of shortage. \n" | 537 | "The memory smacks of shortage. \n" |
538 | "Please save data. " ); | 538 | "Please save data. " ); |
539 | break; | 539 | break; |
540 | case Normal: | 540 | case Normal: |
541 | memstate = Unknown; | 541 | memstate = Unknown; |
542 | if ( ignoreNormal ) | 542 | if ( ignoreNormal ) |
543 | ignoreNormal = FALSE; | 543 | ignoreNormal = FALSE; |
544 | // else | 544 | // else |
545 | // QMessageBox::information ( 0 , "Memory Status", | 545 | // QMessageBox::information ( 0 , "Memory Status", |
546 | // "There is enough memory again." ); | 546 | // "There is enough memory again." ); |
547 | break; | 547 | break; |
548 | case VeryLow: | 548 | case VeryLow: |
549 | memstate = Unknown; | 549 | memstate = Unknown; |
550 | QMessageBox::critical( 0 , "Memory Status", | 550 | QMessageBox::critical( 0 , "Memory Status", |
551 | "The memory is very low. \n" | 551 | "The memory is very low. \n" |
552 | "Please end this application \n" | 552 | "Please end this application \n" |
553 | "immediately." ); | 553 | "immediately." ); |
554 | recoverMemory(); | 554 | recoverMemory(); |
555 | } | 555 | } |
556 | existingMessage = FALSE; | 556 | existingMessage = FALSE; |
557 | #endif | 557 | #endif |
558 | } | 558 | } |
559 | 559 | ||
560 | static bool isVisibleWindow( int wid ) | 560 | static bool isVisibleWindow( int wid ) |
561 | { | 561 | { |
562 | #ifdef QWS | 562 | #ifdef QWS |
563 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 563 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
564 | QWSWindow* w; | 564 | QWSWindow* w; |
565 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 565 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
566 | if ( w->winId() == wid ) | 566 | if ( w->winId() == wid ) |
567 | return !w->isFullyObscured(); | 567 | return !w->isFullyObscured(); |
568 | } | 568 | } |
569 | #endif | 569 | #endif |
570 | return FALSE; | 570 | return FALSE; |
571 | } | 571 | } |
572 | 572 | ||
573 | static bool hasVisibleWindow( const QString& clientname ) | 573 | static bool hasVisibleWindow( const QString& clientname ) |
574 | { | 574 | { |
575 | #ifdef QWS | 575 | #ifdef QWS |
576 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 576 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
577 | QWSWindow* w; | 577 | QWSWindow* w; |
578 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 578 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
579 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 579 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
580 | return TRUE; | 580 | return TRUE; |
581 | } | 581 | } |
582 | #endif | 582 | #endif |
583 | return FALSE; | 583 | return FALSE; |
584 | } | 584 | } |
585 | 585 | ||
586 | void Desktop::raiseLauncher() | 586 | void Desktop::raiseLauncher() |
587 | { | 587 | { |
588 | Config cfg( "qpe" ); //F12 'Home' | 588 | Config cfg( "qpe" ); //F12 'Home' |
589 | cfg.setGroup( "AppsKey" ); | 589 | cfg.setGroup( "AppsKey" ); |
590 | QString tempItem; | 590 | QString tempItem; |
591 | tempItem = cfg.readEntry( "Middle", "Home" ); | 591 | tempItem = cfg.readEntry( "Middle", "Home" ); |
592 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | 592 | if ( tempItem == "Home" || tempItem.isEmpty() ) { |
593 | home ( ); | 593 | home ( ); |
594 | } | 594 | } |
595 | else { | 595 | else { |
596 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 596 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
597 | e << tempItem; | 597 | e << tempItem; |
598 | } | 598 | } |
599 | } | 599 | } |
600 | 600 | ||
601 | void Desktop::home ( ) | 601 | void Desktop::home ( ) |
602 | { | 602 | { |
603 | if ( isVisibleWindow( launcher->winId() ) ) | 603 | if ( isVisibleWindow( launcher->winId() ) ) |
604 | launcher->nextView(); | 604 | launcher->nextView(); |
605 | else | 605 | else |
606 | launcher->raise(); | 606 | launcher->raise(); |
607 | } | 607 | } |
608 | 608 | ||
609 | void Desktop::executeOrModify( const QString& appLnkFile ) | 609 | void Desktop::executeOrModify( const QString& appLnkFile ) |
610 | { | 610 | { |
611 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 611 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
612 | if ( lnk.isValid() ) { | 612 | if ( lnk.isValid() ) { |
613 | QCString app = lnk.exec().utf8(); | 613 | QCString app = lnk.exec().utf8(); |
614 | Global::terminateBuiltin( "calibrate" ); | 614 | Global::terminateBuiltin( "calibrate" ); |
615 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 615 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
616 | // MRUList::addTask( &lnk ); | 616 | // MRUList::addTask( &lnk ); |
617 | if ( hasVisibleWindow( app ) ) | 617 | if ( hasVisibleWindow( app ) ) |
618 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 618 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
619 | else | 619 | else |
620 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 620 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
621 | } | 621 | } |
622 | else { | 622 | else { |
623 | lnk.execute(); | 623 | lnk.execute(); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | } | 626 | } |
627 | 627 | ||
628 | void Desktop::raiseDatebook() | 628 | void Desktop::raiseDatebook() |
629 | { | 629 | { |
630 | Config cfg( "qpe" ); //F9 'Activity' | 630 | Config cfg( "qpe" ); //F9 'Activity' |
631 | cfg.setGroup( "AppsKey" ); | 631 | cfg.setGroup( "AppsKey" ); |
632 | QString tempItem; | 632 | QString tempItem; |
633 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 633 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
634 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 634 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
635 | tempItem = "datebook"; | 635 | tempItem = "datebook"; |
636 | } | 636 | } |
637 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 637 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
638 | e << tempItem; | 638 | e << tempItem; |
639 | } | 639 | } |
640 | 640 | ||
641 | void Desktop::raiseContacts() | 641 | void Desktop::raiseContacts() |
642 | { | 642 | { |
643 | Config cfg( "qpe" ); //F10, 'Contacts' | 643 | Config cfg( "qpe" ); //F10, 'Contacts' |
644 | cfg.setGroup( "AppsKey" ); | 644 | cfg.setGroup( "AppsKey" ); |
645 | QString tempItem; | 645 | QString tempItem; |
646 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 646 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
647 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 647 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
648 | tempItem = "addressbook"; | 648 | tempItem = "addressbook"; |
649 | } | 649 | } |
650 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 650 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
651 | e << tempItem; | 651 | e << tempItem; |
652 | } | 652 | } |
653 | 653 | ||
654 | void Desktop::raiseMenu() | 654 | void Desktop::raiseMenu() |
655 | { | 655 | { |
656 | Config cfg( "qpe" ); //F11, 'Menu | 656 | Config cfg( "qpe" ); //F11, 'Menu |
657 | cfg.setGroup( "AppsKey" ); | 657 | cfg.setGroup( "AppsKey" ); |
658 | QString tempItem; | 658 | QString tempItem; |
659 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 659 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
660 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 660 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
661 | Global::terminateBuiltin( "calibrate" ); | 661 | Global::terminateBuiltin( "calibrate" ); |
662 | tb->startMenu() ->launch(); | 662 | tb->startMenu() ->launch(); |
663 | } | 663 | } |
664 | else { | 664 | else { |
665 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 665 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
666 | e << tempItem; | 666 | e << tempItem; |
667 | } | 667 | } |
668 | } | 668 | } |
669 | 669 | ||
670 | void Desktop::raiseEmail() | 670 | void Desktop::raiseEmail() |
671 | { | 671 | { |
672 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | 672 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
673 | cfg.setGroup( "AppsKey" ); | 673 | cfg.setGroup( "AppsKey" ); |
674 | QString tempItem; | 674 | QString tempItem; |
675 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 675 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
676 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 676 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
677 | tempItem = "mail"; | 677 | tempItem = "mail"; |
678 | } | 678 | } |
679 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 679 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
680 | e << tempItem; | 680 | e << tempItem; |
681 | } | 681 | } |
682 | 682 | ||
683 | // autoStarts apps on resume and start | 683 | // autoStarts apps on resume and start |
684 | void Desktop::execAutoStart() | 684 | void Desktop::execAutoStart() |
685 | { | 685 | { |
686 | QString appName; | 686 | QString appName; |
687 | int delay; | 687 | int delay; |
688 | QDateTime now = QDateTime::currentDateTime(); | 688 | QDateTime now = QDateTime::currentDateTime(); |
689 | Config cfg( "autostart" ); | 689 | Config cfg( "autostart" ); |
690 | cfg.setGroup( "AutoStart" ); | 690 | cfg.setGroup( "AutoStart" ); |
691 | appName = cfg.readEntry( "Apps", "" ); | 691 | appName = cfg.readEntry( "Apps", "" ); |
692 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 692 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
693 | // If the time between suspend and resume was longer then the | 693 | // If the time between suspend and resume was longer then the |
694 | // value saved as delay, start the app | 694 | // value saved as delay, start the app |
695 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 695 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
696 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 696 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
697 | e << QString( appName ); | 697 | e << QString( appName ); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | 700 | ||
701 | #if defined(QPE_HAVE_TOGGLELIGHT) | 701 | #if defined(QPE_HAVE_TOGGLELIGHT) |
702 | #include <qpe/config.h> | 702 | #include <qpe/config.h> |
703 | 703 | ||
704 | #include <sys/ioctl.h> | 704 | #include <sys/ioctl.h> |
705 | #include <sys/types.h> | 705 | #include <sys/types.h> |
706 | #include <fcntl.h> | 706 | #include <fcntl.h> |
707 | #include <unistd.h> | 707 | #include <unistd.h> |
708 | #include <errno.h> | 708 | #include <errno.h> |
709 | #include <linux/ioctl.h> | 709 | #include <linux/ioctl.h> |
710 | #include <time.h> | 710 | #include <time.h> |
711 | #endif | 711 | #endif |
712 | 712 | ||
713 | 713 | ||
714 | void Desktop::togglePower() | 714 | void Desktop::togglePower() |
715 | { | 715 | { |
716 | static bool excllock = false; | 716 | static bool excllock = false; |
717 | 717 | ||
718 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | 718 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); |
719 | 719 | ||
720 | if ( excllock ) | 720 | if ( excllock ) |
721 | return; | 721 | return; |
722 | 722 | ||
723 | excllock = true; | 723 | excllock = true; |
724 | 724 | ||
725 | bool wasloggedin = loggedin; | 725 | bool wasloggedin = loggedin; |
726 | loggedin = 0; | 726 | loggedin = 0; |
727 | suspendTime = QDateTime::currentDateTime(); | 727 | suspendTime = QDateTime::currentDateTime(); |
728 | 728 | ||
729 | #ifdef QWS | 729 | #ifdef QWS |
730 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 730 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
731 | // Should use a big black window instead. | 731 | // Should use a big black window instead. |
732 | // But this would not show up fast enough | 732 | // But this would not show up fast enough |
733 | QGfx *g = qt_screen-> screenGfx ( ); | 733 | QGfx *g = qt_screen-> screenGfx ( ); |
734 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 734 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
735 | delete g; | 735 | delete g; |
736 | } | 736 | } |
737 | #endif | 737 | #endif |
738 | 738 | ||
739 | ODevice::inst ( )-> suspend ( ); | 739 | ODevice::inst ( )-> suspend ( ); |
740 | 740 | ||
741 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 741 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
742 | QWSServer::screenSaverActivate ( false ); | 742 | QWSServer::screenSaverActivate ( false ); |
743 | 743 | ||
744 | { | 744 | { |
745 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 745 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
746 | } | 746 | } |
747 | 747 | ||
748 | if ( wasloggedin ) | 748 | if ( wasloggedin ) |
749 | login ( true ); | 749 | login ( true ); |
750 | 750 | ||
751 | execAutoStart(); | 751 | execAutoStart(); |
752 | //qcopBridge->closeOpenConnections(); | 752 | //qcopBridge->closeOpenConnections(); |
753 | 753 | ||
754 | excllock = false; | 754 | excllock = false; |
755 | } | 755 | } |
756 | 756 | ||
757 | void Desktop::toggleLight() | 757 | void Desktop::toggleLight() |
758 | { | 758 | { |
759 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 759 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
760 | e << -2; // toggle | 760 | e << -2; // toggle |
761 | } | 761 | } |
762 | 762 | ||
763 | void Desktop::toggleSymbolInput() | 763 | void Desktop::toggleSymbolInput() |
764 | { | 764 | { |
765 | tb->toggleSymbolInput(); | 765 | tb->toggleSymbolInput(); |
766 | } | 766 | } |
767 | 767 | ||
768 | void Desktop::toggleNumLockState() | 768 | void Desktop::toggleNumLockState() |
769 | { | 769 | { |
770 | tb->toggleNumLockState(); | 770 | tb->toggleNumLockState(); |
771 | } | 771 | } |
772 | 772 | ||
773 | void Desktop::toggleCapsLockState() | 773 | void Desktop::toggleCapsLockState() |
774 | { | 774 | { |
775 | tb->toggleCapsLockState(); | 775 | tb->toggleCapsLockState(); |
776 | } | 776 | } |
777 | 777 | ||
778 | void Desktop::styleChange( QStyle &s ) | 778 | void Desktop::styleChange( QStyle &s ) |
779 | { | 779 | { |
780 | QWidget::styleChange( s ); | 780 | QWidget::styleChange( s ); |
781 | int displayw = qApp->desktop() ->width(); | 781 | int displayw = qApp->desktop() ->width(); |
782 | int displayh = qApp->desktop() ->height(); | 782 | int displayh = qApp->desktop() ->height(); |
783 | 783 | ||
784 | QSize sz = tb->sizeHint(); | 784 | QSize sz = tb->sizeHint(); |
785 | 785 | ||
786 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 786 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
787 | } | 787 | } |
788 | 788 | ||
789 | void DesktopApplication::shutdown() | 789 | void DesktopApplication::shutdown() |
790 | { | 790 | { |
791 | if ( type() != GuiServer ) | 791 | if ( type() != GuiServer ) |
792 | return ; | 792 | return ; |
793 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 793 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
794 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 794 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
795 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 795 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
796 | sd->showMaximized(); | 796 | sd->showMaximized(); |
797 | } | 797 | } |
798 | 798 | ||
799 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 799 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
800 | { | 800 | { |
801 | switch ( t ) { | 801 | switch ( t ) { |
802 | case ShutdownImpl::ShutdownSystem: | 802 | case ShutdownImpl::ShutdownSystem: |
803 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); | 803 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); |
804 | break; | 804 | break; |
805 | case ShutdownImpl::RebootSystem: | 805 | case ShutdownImpl::RebootSystem: |
806 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); | 806 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); |
807 | break; | 807 | break; |
808 | case ShutdownImpl::RestartDesktop: | 808 | case ShutdownImpl::RestartDesktop: |
809 | restart(); | 809 | restart(); |
810 | break; | 810 | break; |
811 | case ShutdownImpl::TerminateDesktop: | 811 | case ShutdownImpl::TerminateDesktop: |
812 | prepareForTermination( FALSE ); | 812 | prepareForTermination( FALSE ); |
813 | 813 | ||
814 | // This is a workaround for a Qt bug | 814 | // This is a workaround for a Qt bug |
815 | // clipboard applet has to stop its poll timer, or Qt/E | 815 | // clipboard applet has to stop its poll timer, or Qt/E |
816 | // will hang on quit() right before it emits aboutToQuit() | 816 | // will hang on quit() right before it emits aboutToQuit() |
817 | emit aboutToQuit ( ); | 817 | emit aboutToQuit ( ); |
818 | 818 | ||
819 | quit(); | 819 | quit(); |
820 | break; | 820 | break; |
821 | } | 821 | } |
822 | } | 822 | } |
823 | 823 | ||
824 | void DesktopApplication::restart() | 824 | void DesktopApplication::restart() |
825 | { | 825 | { |
826 | prepareForTermination( TRUE ); | 826 | prepareForTermination( TRUE ); |
827 | 827 | ||
828 | #ifdef Q_WS_QWS | 828 | #ifdef Q_WS_QWS |
829 | 829 | ||
830 | for ( int fd = 3; fd < 100; fd++ ) | 830 | for ( int fd = 3; fd < 100; fd++ ) |
831 | close( fd ); | 831 | close( fd ); |
832 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 832 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
833 | 833 | ||
834 | execl( "/sbin/init", "qpe", 0 ); | 834 | execl( "/sbin/init", "qpe", 0 ); |
835 | #elif defined(QT_QWS_CASSIOPEIA) | 835 | #elif defined(QT_QWS_CASSIOPEIA) |
836 | 836 | ||
837 | execl( "/bin/sh", "sh", 0 ); | 837 | execl( "/bin/sh", "sh", 0 ); |
838 | #else | 838 | #else |
839 | 839 | ||
840 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 840 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
841 | #endif | 841 | #endif |
842 | 842 | ||
843 | exit( 1 ); | 843 | exit( 1 ); |
844 | #endif | 844 | #endif |
845 | } | 845 | } |
846 | 846 | ||
847 | void Desktop::startTransferServer() | 847 | void Desktop::startTransferServer() |
848 | { | 848 | { |
849 | // start qcop bridge server | 849 | // start qcop bridge server |
850 | qcopBridge = new QCopBridge( 4243 ); | 850 | qcopBridge = new QCopBridge( 4243 ); |
851 | if ( !qcopBridge->ok() ) { | 851 | if ( !qcopBridge->ok() ) { |
852 | delete qcopBridge; | 852 | delete qcopBridge; |
853 | qcopBridge = 0; | 853 | qcopBridge = 0; |
854 | } | 854 | } |
855 | // start transfer server | 855 | // start transfer server |
856 | transferServer = new TransferServer( 4242 ); | 856 | transferServer = new TransferServer( 4242 ); |
857 | if ( !transferServer->ok() ) { | 857 | if ( !transferServer->ok() ) { |
858 | delete transferServer; | 858 | delete transferServer; |
859 | transferServer = 0; | 859 | transferServer = 0; |
860 | } | 860 | } |
861 | if ( !transferServer || !qcopBridge ) | 861 | if ( !transferServer || !qcopBridge ) |
862 | startTimer( 2000 ); | 862 | startTimer( 2000 ); |
863 | } | 863 | } |
864 | 864 | ||
865 | void Desktop::timerEvent( QTimerEvent *e ) | 865 | void Desktop::timerEvent( QTimerEvent *e ) |
866 | { | 866 | { |
867 | killTimer( e->timerId() ); | 867 | killTimer( e->timerId() ); |
868 | startTransferServer(); | 868 | startTransferServer(); |
869 | } | 869 | } |
870 | 870 | ||
871 | void Desktop::terminateServers() | 871 | void Desktop::terminateServers() |
872 | { | 872 | { |
873 | delete transferServer; | 873 | delete transferServer; |
874 | delete qcopBridge; | 874 | delete qcopBridge; |
875 | transferServer = 0; | 875 | transferServer = 0; |
876 | qcopBridge = 0; | 876 | qcopBridge = 0; |
877 | } | 877 | } |
878 | 878 | ||
879 | void Desktop::rereadVolumes() | 879 | void Desktop::rereadVolumes() |
880 | { | 880 | { |
881 | Config cfg( "qpe" ); | 881 | Config cfg( "qpe" ); |
882 | cfg.setGroup( "Volume" ); | 882 | cfg.setGroup( "Volume" ); |
883 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 883 | touchclick = cfg.readBoolEntry( "TouchSound" ); |
884 | keyclick = cfg.readBoolEntry( "KeySound" ); | 884 | keyclick = cfg.readBoolEntry( "KeySound" ); |
885 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 885 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); |
886 | } | 886 | } |
887 | 887 | ||
888 | void Desktop::keyClick() | 888 | void Desktop::keyClick() |
889 | { | 889 | { |
890 | if ( keyclick ) | 890 | if ( keyclick ) |
891 | ODevice::inst ( ) -> keySound ( ); | 891 | ODevice::inst ( ) -> keySound ( ); |
892 | } | 892 | } |
893 | 893 | ||
894 | void Desktop::screenClick() | 894 | void Desktop::screenClick() |
895 | { | 895 | { |
896 | if ( touchclick ) | 896 | if ( touchclick ) |
897 | ODevice::inst ( ) -> touchSound ( ); | 897 | ODevice::inst ( ) -> touchSound ( ); |
898 | } | 898 | } |
899 | 899 | ||
900 | void Desktop::soundAlarm() | 900 | void Desktop::soundAlarm() |
901 | { | 901 | { |
902 | if ( qpedesktop-> alarmsound ) | 902 | if ( qpedesktop-> alarmsound ) |
903 | ODevice::inst ( ) -> alarmSound ( ); | 903 | ODevice::inst ( ) -> alarmSound ( ); |
904 | } | 904 | } |
905 | 905 | ||
906 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | ||
907 | { | ||
908 | if ( ev->type() == QEvent::KeyPress ) { | ||
909 | QKeyEvent *ke = (QKeyEvent *)ev; | ||
910 | if ( ke->key() == Qt::Key_F11 ) { // menu key | ||
911 | QWidget *active = qApp->activeWindow(); | ||
912 | if ( active && active->isPopup() ) { | ||
913 | active->close(); | ||
914 | } | ||
915 | raiseMenu(); | ||
916 | return TRUE; | ||
917 | } | ||
918 | } | ||
919 | return FALSE; | ||
920 | } | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index f6059b8..13f28b3 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -1,153 +1,152 @@ | |||
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 | #ifndef __DESKTOP_H__ | 21 | #ifndef __DESKTOP_H__ |
22 | #define __DESKTOP_H__ | 22 | #define __DESKTOP_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | 31 | ||
32 | class Background; | 32 | class Background; |
33 | class Launcher; | 33 | class Launcher; |
34 | class TaskBar; | 34 | class TaskBar; |
35 | class PowerStatus; | 35 | class PowerStatus; |
36 | class QCopBridge; | 36 | class QCopBridge; |
37 | class TransferServer; | 37 | class TransferServer; |
38 | class DesktopPowerAlerter; | 38 | class DesktopPowerAlerter; |
39 | class PackageSlave; | 39 | class PackageSlave; |
40 | class OpieScreenSaver; | 40 | class OpieScreenSaver; |
41 | 41 | ||
42 | class DesktopApplication : public QPEApplication | 42 | class DesktopApplication : public QPEApplication |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | DesktopApplication( int& argc, char **argv, Type t ); | 46 | DesktopApplication( int& argc, char **argv, Type t ); |
47 | ~DesktopApplication(); | 47 | ~DesktopApplication(); |
48 | 48 | ||
49 | static void switchLCD ( bool on ); // only for togglePower in Desktop | 49 | static void switchLCD ( bool on ); // only for togglePower in Desktop |
50 | 50 | ||
51 | signals: | 51 | signals: |
52 | void menu(); | 52 | void menu(); |
53 | void home(); | 53 | void home(); |
54 | void datebook(); | 54 | void datebook(); |
55 | void contacts(); | 55 | void contacts(); |
56 | void launch(); | 56 | void launch(); |
57 | void email(); | 57 | void email(); |
58 | void backlight(); | 58 | void backlight(); |
59 | void power(); | 59 | void power(); |
60 | void symbol(); | 60 | void symbol(); |
61 | void numLockStateToggle(); | 61 | void numLockStateToggle(); |
62 | void capsLockStateToggle(); | 62 | void capsLockStateToggle(); |
63 | void prepareForRestart(); | 63 | void prepareForRestart(); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | #ifdef Q_WS_QWS | 66 | #ifdef Q_WS_QWS |
67 | 67 | ||
68 | bool qwsEventFilter( QWSEvent * ); | 68 | bool qwsEventFilter( QWSEvent * ); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | void shutdown(); | 71 | void shutdown(); |
72 | void restart(); | 72 | void restart(); |
73 | 73 | ||
74 | public slots: | 74 | public slots: |
75 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); | 75 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); |
76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); | 76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); |
77 | 77 | ||
78 | protected slots: | 78 | protected slots: |
79 | void shutdown( ShutdownImpl::Type ); | 79 | void shutdown( ShutdownImpl::Type ); |
80 | void apmTimeout(); | 80 | void apmTimeout(); |
81 | void sendCard(); | 81 | void sendCard(); |
82 | private: | 82 | private: |
83 | void reloadPowerWarnSettings(); | 83 | void reloadPowerWarnSettings(); |
84 | DesktopPowerAlerter *pa; | 84 | DesktopPowerAlerter *pa; |
85 | PowerStatus *m_ps, *m_ps_last; | 85 | PowerStatus *m_ps, *m_ps_last; |
86 | QTimer *cardSendTimer; | 86 | QTimer *cardSendTimer; |
87 | QCopChannel *channel; | 87 | QCopChannel *channel; |
88 | OpieScreenSaver *m_screensaver; | 88 | OpieScreenSaver *m_screensaver; |
89 | QTimer * m_timer; | 89 | QTimer * m_timer; |
90 | int m_powerVeryLow; | 90 | int m_powerVeryLow; |
91 | int m_powerCritical; | 91 | int m_powerCritical; |
92 | int m_currentPowerLevel; | 92 | int m_currentPowerLevel; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | class Desktop : public QWidget | 96 | class Desktop : public QWidget |
97 | { | 97 | { |
98 | Q_OBJECT | 98 | Q_OBJECT |
99 | public: | 99 | public: |
100 | Desktop(); | 100 | Desktop(); |
101 | ~Desktop(); | 101 | ~Desktop(); |
102 | 102 | ||
103 | static bool screenLocked(); | 103 | static bool screenLocked(); |
104 | 104 | ||
105 | void show(); | 105 | void show(); |
106 | void checkMemory(); | 106 | void checkMemory(); |
107 | 107 | ||
108 | void keyClick(); | 108 | void keyClick(); |
109 | void screenClick(); | 109 | void screenClick(); |
110 | static void soundAlarm(); | 110 | static void soundAlarm(); |
111 | 111 | ||
112 | public slots: | 112 | public slots: |
113 | void raiseDatebook(); | 113 | void raiseDatebook(); |
114 | void raiseContacts(); | 114 | void raiseContacts(); |
115 | void raiseMenu(); | 115 | void raiseMenu(); |
116 | void raiseLauncher(); | 116 | void raiseLauncher(); |
117 | void raiseEmail(); | 117 | void raiseEmail(); |
118 | void execAutoStart(); | 118 | void execAutoStart(); |
119 | void togglePower(); | 119 | void togglePower(); |
120 | void toggleLight(); | 120 | void toggleLight(); |
121 | void toggleNumLockState(); | 121 | void toggleNumLockState(); |
122 | void toggleCapsLockState(); | 122 | void toggleCapsLockState(); |
123 | void toggleSymbolInput(); | 123 | void toggleSymbolInput(); |
124 | void terminateServers(); | 124 | void terminateServers(); |
125 | void rereadVolumes(); | 125 | void rereadVolumes(); |
126 | 126 | ||
127 | void home ( ); | 127 | void home ( ); |
128 | 128 | ||
129 | protected: | 129 | protected: |
130 | void executeOrModify( const QString& appLnkFile ); | 130 | void executeOrModify( const QString& appLnkFile ); |
131 | void styleChange( QStyle & ); | 131 | void styleChange( QStyle & ); |
132 | void timerEvent( QTimerEvent *e ); | 132 | void timerEvent( QTimerEvent *e ); |
133 | bool eventFilter( QObject *, QEvent * ); | ||
134 | 133 | ||
135 | QWidget *bg; | 134 | QWidget *bg; |
136 | Launcher *launcher; | 135 | Launcher *launcher; |
137 | TaskBar *tb; | 136 | TaskBar *tb; |
138 | 137 | ||
139 | private: | 138 | private: |
140 | void startTransferServer(); | 139 | void startTransferServer(); |
141 | bool recoverMemory(); | 140 | bool recoverMemory(); |
142 | 141 | ||
143 | QCopBridge *qcopBridge; | 142 | QCopBridge *qcopBridge; |
144 | TransferServer *transferServer; | 143 | TransferServer *transferServer; |
145 | PackageSlave *packageSlave; | 144 | PackageSlave *packageSlave; |
146 | 145 | ||
147 | QDateTime suspendTime; | 146 | QDateTime suspendTime; |
148 | bool keyclick, touchclick, alarmsound; | 147 | bool keyclick, touchclick, alarmsound; |
149 | }; | 148 | }; |
150 | 149 | ||
151 | 150 | ||
152 | #endif // __DESKTOP_H__ | 151 | #endif // __DESKTOP_H__ |
153 | 152 | ||
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index d9382d2..e663072 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp | |||
@@ -1,386 +1,391 @@ | |||
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 INCLUDE_MENUITEM_DEF | 21 | #define INCLUDE_MENUITEM_DEF |
22 | 22 | ||
23 | #include "startmenu.h" | 23 | #include "startmenu.h" |
24 | #include "sidething.h" | 24 | #include "sidething.h" |
25 | //#include "mrulist.h" | 25 | //#include "mrulist.h" |
26 | #include "info.h" | 26 | #include "info.h" |
27 | 27 | ||
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
33 | #include <qpe/qlibrary.h> | 33 | #include <qpe/qlibrary.h> |
34 | 34 | ||
35 | #include <qintdict.h> | 35 | #include <qintdict.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | 37 | ||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | 39 | ||
40 | 40 | ||
41 | // #define USE_CONFIG_FILE | 41 | // #define USE_CONFIG_FILE |
42 | 42 | ||
43 | 43 | ||
44 | StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) | 44 | StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) |
45 | { | 45 | { |
46 | loadOptions(); | 46 | loadOptions(); |
47 | 47 | ||
48 | int sz = AppLnk::smallIconSize()+3; | 48 | int sz = AppLnk::smallIconSize()+3; |
49 | QPixmap pm; | 49 | QPixmap pm; |
50 | pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz)); | 50 | pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz)); |
51 | setPixmap(pm); | 51 | setPixmap(pm); |
52 | setFocusPolicy( NoFocus ); | 52 | setFocusPolicy( NoFocus ); |
53 | //setFlat( startButtonIsFlat ); | 53 | //setFlat( startButtonIsFlat ); |
54 | 54 | ||
55 | apps = 0; | 55 | apps = 0; |
56 | launchMenu = 0; | 56 | launchMenu = 0; |
57 | applets. setAutoDelete ( true ); | 57 | applets. setAutoDelete ( true ); |
58 | sepId = 0; | 58 | sepId = 0; |
59 | 59 | ||
60 | reloadApps ( ); | 60 | reloadApps ( ); |
61 | reloadApplets ( ); | 61 | reloadApplets ( ); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | void StartMenu::mousePressEvent( QMouseEvent * ) | 65 | void StartMenu::mousePressEvent( QMouseEvent * ) |
66 | { | 66 | { |
67 | launch(); | 67 | launch(); |
68 | if (desktopInfo) | 68 | if (desktopInfo) |
69 | desktopInfo->menuClicked(); | 69 | desktopInfo->menuClicked(); |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | StartMenu::~StartMenu() | 73 | StartMenu::~StartMenu() |
74 | { | 74 | { |
75 | delete apps; | 75 | delete apps; |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | void StartMenu::loadOptions() | 79 | void StartMenu::loadOptions() |
80 | { | 80 | { |
81 | #ifdef USE_CONFIG_FILE | 81 | #ifdef USE_CONFIG_FILE |
82 | // Read configuration file | 82 | // Read configuration file |
83 | Config config("StartMenu"); | 83 | Config config("StartMenu"); |
84 | config.setGroup( "StartMenu" ); | 84 | config.setGroup( "StartMenu" ); |
85 | QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); | 85 | QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); |
86 | useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; | 86 | useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; |
87 | QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); | 87 | QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); |
88 | startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; | 88 | startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; |
89 | QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); | 89 | QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); |
90 | popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); | 90 | popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); |
91 | startButtonPixmap = config.readEntry( "StartButtonPixmap", "launcher/start_button" ); | 91 | startButtonPixmap = config.readEntry( "StartButtonPixmap", "launcher/start_button" ); |
92 | #else | 92 | #else |
93 | // Basically just #include the .qpe_menu.conf file settings | 93 | // Basically just #include the .qpe_menu.conf file settings |
94 | useWidePopupMenu = FALSE; | 94 | useWidePopupMenu = FALSE; |
95 | popupMenuSidePixmap = "launcher/sidebar"; | 95 | popupMenuSidePixmap = "launcher/sidebar"; |
96 | startButtonIsFlat = TRUE; | 96 | startButtonIsFlat = TRUE; |
97 | startButtonPixmap = "launcher/start_button"; // No tr | 97 | startButtonPixmap = "launcher/start_button"; // No tr |
98 | #endif | 98 | #endif |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void StartMenu::createMenu() | 102 | void StartMenu::createMenu() |
103 | { | 103 | { |
104 | delete launchMenu; | 104 | delete launchMenu; |
105 | if ( useWidePopupMenu ) | 105 | if ( useWidePopupMenu ) |
106 | launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); | 106 | launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); |
107 | else | 107 | else |
108 | launchMenu = new StartPopupMenu( this ); | 108 | launchMenu = new StartPopupMenu( this ); |
109 | 109 | ||
110 | loadMenu ( apps, launchMenu ); | 110 | loadMenu ( apps, launchMenu ); |
111 | loadApplets ( ); | 111 | loadApplets ( ); |
112 | 112 | ||
113 | connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 113 | connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void StartMenu::reloadApps() | 116 | void StartMenu::reloadApps() |
117 | { | 117 | { |
118 | Config cfg("StartMenu"); | 118 | Config cfg("StartMenu"); |
119 | cfg.setGroup("Menu"); | 119 | cfg.setGroup("Menu"); |
120 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); | 120 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); |
121 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); | 121 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); |
122 | bool lt = ltabs || lot; | 122 | bool lt = ltabs || lot; |
123 | if ( launchMenu && apps && !lt ) | 123 | if ( launchMenu && apps && !lt ) |
124 | return; // nothing to do | 124 | return; // nothing to do |
125 | 125 | ||
126 | if ( lt ) { | 126 | if ( lt ) { |
127 | delete apps; | 127 | delete apps; |
128 | apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); | 128 | apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); |
129 | } | 129 | } |
130 | if ( launchMenu ) { | 130 | if ( launchMenu ) { |
131 | launchMenu-> hide ( ); | 131 | launchMenu-> hide ( ); |
132 | 132 | ||
133 | for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { | 133 | for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { |
134 | launchMenu-> removeItem ( it. currentKey ( )); | 134 | launchMenu-> removeItem ( it. currentKey ( )); |
135 | delete it.current ( ); | 135 | delete it.current ( ); |
136 | } | 136 | } |
137 | tabdict. clear ( ); | 137 | tabdict. clear ( ); |
138 | loadMenu(apps,launchMenu); | 138 | loadMenu(apps,launchMenu); |
139 | } else { | 139 | } else { |
140 | createMenu(); | 140 | createMenu(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void StartMenu::reloadApplets() | 144 | void StartMenu::reloadApplets() |
145 | { | 145 | { |
146 | if ( launchMenu ) { | 146 | if ( launchMenu ) { |
147 | clearApplets ( ); | 147 | clearApplets ( ); |
148 | loadApplets ( ); | 148 | loadApplets ( ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | createMenu ( ); | 151 | createMenu ( ); |
152 | } | 152 | } |
153 | 153 | ||
154 | void StartMenu::itemSelected( int id ) | 154 | void StartMenu::itemSelected( int id ) |
155 | { | 155 | { |
156 | const AppLnk *app = apps->find( id ); | 156 | const AppLnk *app = apps->find( id ); |
157 | if ( app ) | 157 | if ( app ) |
158 | app->execute(); | 158 | app->execute(); |
159 | else { | 159 | else { |
160 | MenuApplet *applet = applets. find ( id ); | 160 | MenuApplet *applet = applets. find ( id ); |
161 | 161 | ||
162 | if ( applet ) | 162 | if ( applet ) |
163 | applet-> iface-> activated ( ); | 163 | applet-> iface-> activated ( ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) | 167 | bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) |
168 | { | 168 | { |
169 | bool result = FALSE; | 169 | bool result = FALSE; |
170 | 170 | ||
171 | Config cfg("StartMenu"); | 171 | Config cfg("StartMenu"); |
172 | cfg.setGroup("Menu"); | 172 | cfg.setGroup("Menu"); |
173 | 173 | ||
174 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); | 174 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); |
175 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); | 175 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); |
176 | 176 | ||
177 | tabdict. clear ( ); | 177 | tabdict. clear ( ); |
178 | 178 | ||
179 | if ( sepId ) | 179 | if ( sepId ) |
180 | menu-> removeItem ( sepId ); | 180 | menu-> removeItem ( sepId ); |
181 | sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; | 181 | sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; |
182 | 182 | ||
183 | if ( ltabs || lot ) { | 183 | if ( ltabs || lot ) { |
184 | QDict<QPopupMenu> typpop; | 184 | QDict<QPopupMenu> typpop; |
185 | QStringList typs = folder->types(); | 185 | QStringList typs = folder->types(); |
186 | for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { | 186 | for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { |
187 | if ( !(*tit).isEmpty() ) { | 187 | if ( !(*tit).isEmpty() ) { |
188 | QPopupMenu *new_menu; | 188 | QPopupMenu *new_menu; |
189 | if ( ltabs ) { | 189 | if ( ltabs ) { |
190 | new_menu = new StartPopupMenu( menu ); | 190 | new_menu = new StartPopupMenu( menu ); |
191 | connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 191 | connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
192 | int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); | 192 | int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); |
193 | tabdict. insert ( id, new_menu ); | 193 | tabdict. insert ( id, new_menu ); |
194 | } else { | 194 | } else { |
195 | new_menu = (QPopupMenu*)1; | 195 | new_menu = (QPopupMenu*)1; |
196 | } | 196 | } |
197 | typpop.insert(*tit, new_menu); | 197 | typpop.insert(*tit, new_menu); |
198 | } | 198 | } |
199 | if ( tit == typs. begin ( )) | 199 | if ( tit == typs. begin ( )) |
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | QListIterator<AppLnk> it( folder->children() ); | 202 | QListIterator<AppLnk> it( folder->children() ); |
203 | bool f=TRUE; | 203 | bool f=TRUE; |
204 | for ( ; it.current(); ++it ) { | 204 | for ( ; it.current(); ++it ) { |
205 | AppLnk *app = it.current(); | 205 | AppLnk *app = it.current(); |
206 | if ( app->type() == "Separator" ) { // No tr | 206 | if ( app->type() == "Separator" ) { // No tr |
207 | if ( lot ) { | 207 | if ( lot ) { |
208 | menu->insertSeparator(); | 208 | menu->insertSeparator(); |
209 | } | 209 | } |
210 | } else { | 210 | } else { |
211 | f = FALSE; | 211 | f = FALSE; |
212 | QString t = app->type(); | 212 | QString t = app->type(); |
213 | QPopupMenu* pmenu = typpop.find(t); | 213 | QPopupMenu* pmenu = typpop.find(t); |
214 | if ( ltabs ) { | 214 | if ( ltabs ) { |
215 | if ( !pmenu && lot ) | 215 | if ( !pmenu && lot ) |
216 | pmenu = menu; | 216 | pmenu = menu; |
217 | } else { | 217 | } else { |
218 | if ( !pmenu ) | 218 | if ( !pmenu ) |
219 | pmenu = menu; | 219 | pmenu = menu; |
220 | else | 220 | else |
221 | pmenu = 0; | 221 | pmenu = 0; |
222 | } | 222 | } |
223 | if ( pmenu ) { | 223 | if ( pmenu ) { |
224 | QString t = app->name(); | 224 | QString t = app->name(); |
225 | t.replace(QRegExp("&"),"&&"); // escape shortcut character | 225 | t.replace(QRegExp("&"),"&&"); // escape shortcut character |
226 | pmenu->insertItem( app->pixmap(), t, app->id() ); | 226 | pmenu->insertItem( app->pixmap(), t, app->id() ); |
227 | } | 227 | } |
228 | result=TRUE; | 228 | result=TRUE; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries | 233 | if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries |
234 | menu-> removeItem ( sepId ); | 234 | menu-> removeItem ( sepId ); |
235 | sepId = 0; | 235 | sepId = 0; |
236 | } | 236 | } |
237 | if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later | 237 | if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later |
238 | sepId = menu-> insertSeparator ( ); | 238 | sepId = menu-> insertSeparator ( ); |
239 | 239 | ||
240 | return result; | 240 | return result; |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | void StartMenu::launch() | 244 | void StartMenu::launch() |
245 | { | 245 | { |
246 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); | 246 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); |
247 | 247 | ||
248 | if ( launchMenu->isVisible() ) | 248 | if ( launchMenu->isVisible() ) |
249 | launchMenu->hide(); | 249 | launchMenu->hide(); |
250 | else | 250 | else { |
251 | QWidget *active = qApp->activeWindow(); | ||
252 | if ( active && active->isPopup() ) | ||
253 | active->close(); | ||
254 | |||
251 | launchMenu->popup( QPoint( 1, y ) ); | 255 | launchMenu->popup( QPoint( 1, y ) ); |
256 | } | ||
252 | } | 257 | } |
253 | 258 | ||
254 | const AppLnk* StartMenu::execToLink(const QString& appname) | 259 | const AppLnk* StartMenu::execToLink(const QString& appname) |
255 | { | 260 | { |
256 | const AppLnk* a = apps->findExec( appname ); | 261 | const AppLnk* a = apps->findExec( appname ); |
257 | return a; | 262 | return a; |
258 | } | 263 | } |
259 | 264 | ||
260 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) | 265 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) |
261 | { | 266 | { |
262 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { | 267 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { |
263 | // "OK" button, little hacky | 268 | // "OK" button, little hacky |
264 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); | 269 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); |
265 | QPopupMenu::keyPressEvent( &ke ); | 270 | QPopupMenu::keyPressEvent( &ke ); |
266 | } else { | 271 | } else { |
267 | QPopupMenu::keyPressEvent( e ); | 272 | QPopupMenu::keyPressEvent( e ); |
268 | } | 273 | } |
269 | } | 274 | } |
270 | 275 | ||
271 | static int compareAppletPositions(const void *a, const void *b) | 276 | static int compareAppletPositions(const void *a, const void *b) |
272 | { | 277 | { |
273 | const MenuApplet* aa = *(const MenuApplet**)a; | 278 | const MenuApplet* aa = *(const MenuApplet**)a; |
274 | const MenuApplet* ab = *(const MenuApplet**)b; | 279 | const MenuApplet* ab = *(const MenuApplet**)b; |
275 | int d = aa->iface->position() - ab->iface->position(); | 280 | int d = aa->iface->position() - ab->iface->position(); |
276 | if ( d ) return d; | 281 | if ( d ) return d; |
277 | return QString::compare(aa->library->library(),ab->library->library()); | 282 | return QString::compare(aa->library->library(),ab->library->library()); |
278 | } | 283 | } |
279 | 284 | ||
280 | void StartMenu::clearApplets() | 285 | void StartMenu::clearApplets() |
281 | { | 286 | { |
282 | launchMenu-> hide(); | 287 | launchMenu-> hide(); |
283 | 288 | ||
284 | for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { | 289 | for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { |
285 | MenuApplet *applet = it. current ( ); | 290 | MenuApplet *applet = it. current ( ); |
286 | if ( launchMenu ) { | 291 | if ( launchMenu ) { |
287 | launchMenu-> removeItem ( applet-> id ); | 292 | launchMenu-> removeItem ( applet-> id ); |
288 | delete applet-> popup; | 293 | delete applet-> popup; |
289 | } | 294 | } |
290 | 295 | ||
291 | applet-> iface-> release(); | 296 | applet-> iface-> release(); |
292 | applet-> library-> unload(); | 297 | applet-> library-> unload(); |
293 | delete applet-> library; | 298 | delete applet-> library; |
294 | } | 299 | } |
295 | applets.clear(); | 300 | applets.clear(); |
296 | } | 301 | } |
297 | 302 | ||
298 | 303 | ||
299 | 304 | ||
300 | void StartMenu::loadApplets() | 305 | void StartMenu::loadApplets() |
301 | { | 306 | { |
302 | Config cfg( "StartMenu" ); | 307 | Config cfg( "StartMenu" ); |
303 | cfg.setGroup( "Applets" ); | 308 | cfg.setGroup( "Applets" ); |
304 | 309 | ||
305 | // SafeMode causes too much problems, so we disable it for now -- | 310 | // SafeMode causes too much problems, so we disable it for now -- |
306 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 | 311 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 |
307 | 312 | ||
308 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); | 313 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); |
309 | if ( safe && !safety_tid ) | 314 | if ( safe && !safety_tid ) |
310 | return; | 315 | return; |
311 | cfg.writeEntry("SafeMode",TRUE); | 316 | cfg.writeEntry("SafeMode",TRUE); |
312 | cfg.write(); | 317 | cfg.write(); |
313 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 318 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
314 | 319 | ||
315 | QString lang = getenv( "LANG" ); | 320 | QString lang = getenv( "LANG" ); |
316 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 321 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
317 | QDir dir( path, "lib*.so" ); | 322 | QDir dir( path, "lib*.so" ); |
318 | QStringList list = dir.entryList(); | 323 | QStringList list = dir.entryList(); |
319 | QStringList::Iterator it; | 324 | QStringList::Iterator it; |
320 | int napplets=0; | 325 | int napplets=0; |
321 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; | 326 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; |
322 | for ( it = list.begin(); it != list.end(); ++it ) { | 327 | for ( it = list.begin(); it != list.end(); ++it ) { |
323 | if ( exclude.find( *it ) != exclude.end() ) | 328 | if ( exclude.find( *it ) != exclude.end() ) |
324 | continue; | 329 | continue; |
325 | MenuAppletInterface *iface = 0; | 330 | MenuAppletInterface *iface = 0; |
326 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 331 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
327 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 332 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
328 | MenuApplet *applet = new MenuApplet; | 333 | MenuApplet *applet = new MenuApplet; |
329 | xapplets[napplets++] = applet; | 334 | xapplets[napplets++] = applet; |
330 | applet->library = lib; | 335 | applet->library = lib; |
331 | applet->iface = iface; | 336 | applet->iface = iface; |
332 | 337 | ||
333 | QTranslator *trans = new QTranslator(qApp); | 338 | QTranslator *trans = new QTranslator(qApp); |
334 | QString type = (*it).left( (*it).find(".") ); | 339 | QString type = (*it).left( (*it).find(".") ); |
335 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 340 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
336 | if ( trans->load( tfn )) | 341 | if ( trans->load( tfn )) |
337 | qApp->installTranslator( trans ); | 342 | qApp->installTranslator( trans ); |
338 | else | 343 | else |
339 | delete trans; | 344 | delete trans; |
340 | } else { | 345 | } else { |
341 | exclude += *it; | 346 | exclude += *it; |
342 | delete lib; | 347 | delete lib; |
343 | } | 348 | } |
344 | } | 349 | } |
345 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 350 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
346 | qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); | 351 | qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); |
347 | 352 | ||
348 | if ( sepId ) | 353 | if ( sepId ) |
349 | launchMenu-> removeItem ( sepId ); | 354 | launchMenu-> removeItem ( sepId ); |
350 | sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; | 355 | sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; |
351 | 356 | ||
352 | while (napplets--) { | 357 | while (napplets--) { |
353 | MenuApplet *applet = xapplets[napplets]; | 358 | MenuApplet *applet = xapplets[napplets]; |
354 | 359 | ||
355 | applet-> popup = applet-> iface-> popup ( this ); | 360 | applet-> popup = applet-> iface-> popup ( this ); |
356 | 361 | ||
357 | if ( applet-> popup ) | 362 | if ( applet-> popup ) |
358 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); | 363 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); |
359 | else | 364 | else |
360 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); | 365 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); |
361 | applets.insert ( applet-> id, new MenuApplet(*applet)); | 366 | applets.insert ( applet-> id, new MenuApplet(*applet)); |
362 | } | 367 | } |
363 | delete [] xapplets; | 368 | delete [] xapplets; |
364 | 369 | ||
365 | if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets | 370 | if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets |
366 | launchMenu-> removeItem ( sepId ); | 371 | launchMenu-> removeItem ( sepId ); |
367 | sepId = 0; | 372 | sepId = 0; |
368 | } | 373 | } |
369 | if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later | 374 | if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later |
370 | sepId = launchMenu-> insertSeparator ( ); | 375 | sepId = launchMenu-> insertSeparator ( ); |
371 | 376 | ||
372 | if ( !safety_tid ) | 377 | if ( !safety_tid ) |
373 | safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) | 378 | safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) |
374 | } | 379 | } |
375 | 380 | ||
376 | void StartMenu::timerEvent(QTimerEvent* e) | 381 | void StartMenu::timerEvent(QTimerEvent* e) |
377 | { | 382 | { |
378 | if ( e->timerId() == safety_tid ) { | 383 | if ( e->timerId() == safety_tid ) { |
379 | Config cfg( "StartMenu" ); | 384 | Config cfg( "StartMenu" ); |
380 | cfg.setGroup( "Applets" ); | 385 | cfg.setGroup( "Applets" ); |
381 | cfg.writeEntry( "SafeMode", FALSE ); | 386 | cfg.writeEntry( "SafeMode", FALSE ); |
382 | killTimer(safety_tid); | 387 | killTimer(safety_tid); |
383 | safety_tid = 0; | 388 | safety_tid = 0; |
384 | } | 389 | } |
385 | } | 390 | } |
386 | 391 | ||