-rw-r--r-- | core/launcher/desktop.cpp | 1070 | ||||
-rw-r--r-- | core/launcher/desktop.h | 149 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 7 | ||||
-rw-r--r-- | core/launcher/main.cpp | 5 | ||||
-rw-r--r-- | core/launcher/opie-taskbar.control | 2 | ||||
-rw-r--r-- | core/launcher/runningappbar.cpp | 9 | ||||
-rw-r--r-- | core/launcher/startmenu.cpp | 19 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 12 |
8 files changed, 608 insertions, 665 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 6c67056..fa9736f 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,905 +1,841 @@ | |||
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 | |||
61 | using namespace Opie; | 62 | using namespace Opie; |
62 | 63 | ||
63 | class QCopKeyRegister | 64 | class QCopKeyRegister |
64 | { | 65 | { |
65 | public: | 66 | public: |
66 | QCopKeyRegister() : keyCode( 0 ) | 67 | QCopKeyRegister() : keyCode( 0 ) |
67 | { } | 68 | { } |
68 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 69 | QCopKeyRegister( int k, const QCString &c, const QCString &m ) |
69 | : keyCode( k ), channel( c ), message( m ) | 70 | : keyCode( k ), channel( c ), message( m ) |
70 | { } | 71 | { } |
71 | 72 | ||
72 | int getKeyCode() const | 73 | int getKeyCode() const |
73 | { | 74 | { |
74 | return keyCode; | 75 | return keyCode; |
75 | } | 76 | } |
76 | QString getChannel() const | 77 | QCString getChannel() const |
77 | { | 78 | { |
78 | return channel; | 79 | return channel; |
79 | } | 80 | } |
80 | QString getMessage() const | 81 | QCString getMessage() const |
81 | { | 82 | { |
82 | return message; | 83 | return message; |
83 | } | 84 | } |
84 | 85 | ||
85 | private: | 86 | private: |
86 | int keyCode; | 87 | int keyCode; |
87 | QString channel, message; | 88 | QCString channel, message; |
88 | }; | 89 | }; |
89 | 90 | ||
90 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 91 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
91 | KeyRegisterList keyRegisterList; | 92 | KeyRegisterList keyRegisterList; |
92 | 93 | ||
93 | static Desktop* qpedesktop = 0; | 94 | static Desktop* qpedesktop = 0; |
94 | static int loggedin = 0; | 95 | static int loggedin = 0; |
95 | static void login( bool at_poweron ) | 96 | static void login( bool at_poweron ) |
96 | { | 97 | { |
97 | if ( !loggedin ) { | 98 | if ( !loggedin ) { |
98 | Global::terminateBuiltin( "calibrate" ); | 99 | Global::terminateBuiltin( "calibrate" ); |
99 | Password::authenticate( at_poweron ); | 100 | Password::authenticate( at_poweron ); |
100 | loggedin = 1; | 101 | loggedin = 1; |
101 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 102 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 | ||
105 | bool Desktop::screenLocked() | 106 | bool Desktop::screenLocked() |
106 | { | 107 | { |
107 | return loggedin == 0; | 108 | return loggedin == 0; |
108 | } | 109 | } |
109 | 110 | ||
110 | /* | 111 | /* |
111 | Priority is number of alerts that are needed to pop up | 112 | Priority is number of alerts that are needed to pop up |
112 | alert. | 113 | alert. |
113 | */ | 114 | */ |
114 | class DesktopPowerAlerter : public QMessageBox | 115 | class DesktopPowerAlerter : public QMessageBox |
115 | { | 116 | { |
116 | public: | 117 | public: |
117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 118 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 119 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
119 | QMessageBox::Critical, | 120 | QMessageBox::Critical, |
120 | QMessageBox::Ok | QMessageBox::Default, | 121 | QMessageBox::Ok | QMessageBox::Default, |
121 | QMessageBox::NoButton, QMessageBox::NoButton, | 122 | QMessageBox::NoButton, QMessageBox::NoButton, |
122 | parent, name, FALSE ) | 123 | parent, name, FALSE ) |
123 | { | 124 | { |
124 | currentPriority = INT_MAX; | 125 | currentPriority = INT_MAX; |
125 | alertCount = 0; | 126 | alertCount = 0; |
126 | } | 127 | } |
127 | 128 | ||
128 | void alert( const QString &text, int priority ); | 129 | void alert( const QString &text, int priority ); |
129 | void hideEvent( QHideEvent * ); | 130 | void hideEvent( QHideEvent * ); |
130 | private: | 131 | private: |
131 | int currentPriority; | 132 | int currentPriority; |
132 | int alertCount; | 133 | int alertCount; |
133 | }; | 134 | }; |
134 | 135 | ||
135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 136 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
136 | { | 137 | { |
137 | alertCount++; | 138 | alertCount++; |
138 | if ( alertCount < priority ) | 139 | if ( alertCount < priority ) |
139 | return ; | 140 | return ; |
140 | if ( priority > currentPriority ) | 141 | if ( priority > currentPriority ) |
141 | return ; | 142 | return ; |
142 | currentPriority = priority; | 143 | currentPriority = priority; |
143 | setText( text ); | 144 | setText( text ); |
144 | show(); | 145 | show(); |
145 | } | 146 | } |
146 | 147 | ||
147 | 148 | ||
148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 149 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
149 | { | 150 | { |
150 | QMessageBox::hideEvent( e ); | 151 | QMessageBox::hideEvent( e ); |
151 | alertCount = 0; | 152 | alertCount = 0; |
152 | currentPriority = INT_MAX; | 153 | currentPriority = INT_MAX; |
153 | } | 154 | } |
154 | 155 | ||
155 | 156 | ||
156 | void DesktopApplication::switchLCD ( bool on ) | 157 | void DesktopApplication::switchLCD ( bool on ) |
157 | { | 158 | { |
158 | if ( qApp ) { | 159 | if ( qApp ) { |
159 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 160 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
160 | 161 | ||
161 | if ( dapp-> m_screensaver ) { | 162 | if ( dapp-> m_screensaver ) { |
162 | if ( on ) { | 163 | if ( on ) { |
163 | dapp-> m_screensaver-> setDisplayState ( true ); | 164 | dapp-> m_screensaver-> setDisplayState ( true ); |
164 | dapp-> m_screensaver-> setBacklight ( -3 ); | 165 | dapp-> m_screensaver-> setBacklight ( -3 ); |
165 | } | 166 | } |
166 | else { | 167 | else { |
167 | dapp-> m_screensaver-> setDisplayState ( false ); | 168 | dapp-> m_screensaver-> setDisplayState ( false ); |
168 | } | 169 | } |
169 | } | 170 | } |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
173 | 174 | ||
174 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 175 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
175 | : QPEApplication( argc, argv, appType ) | 176 | : QPEApplication( argc, argv, appType ) |
176 | { | 177 | { |
177 | 178 | ||
178 | Config cfg( "apm" ); | 179 | Config cfg( "apm" ); |
179 | cfg.setGroup( "Warnings" ); | 180 | cfg.setGroup( "Warnings" ); |
180 | //cfg.readNumEntry( "checkinterval", 10000 ) | 181 | //cfg.readNumEntry( "checkinterval", 10000 ) |
181 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 182 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
182 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); | 183 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); |
183 | 184 | ||
184 | m_ps = new PowerStatus; | 185 | m_ps = new PowerStatus; |
185 | m_ps_last = new PowerStatus; | 186 | m_ps_last = new PowerStatus; |
186 | pa = new DesktopPowerAlerter( 0 ); | 187 | pa = new DesktopPowerAlerter( 0 ); |
187 | 188 | ||
188 | m_timer = new QTimer( this ); | 189 | m_timer = new QTimer( this ); |
189 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); | 190 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); |
190 | m_timer->start( 5000 ); | 191 | m_timer->start( 5000 ); |
191 | |||
192 | channel = new QCopChannel( "QPE/Desktop", this ); | ||
193 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | ||
194 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | ||
195 | 192 | ||
193 | m_last_button = 0; | ||
194 | m_button_timer = new QTimer ( ); | ||
195 | connect ( m_button_timer, SIGNAL( timeout ( )), this, SLOT( sendHeldAction ( ))); | ||
196 | |||
196 | channel = new QCopChannel( "QPE/System", this ); | 197 | channel = new QCopChannel( "QPE/System", this ); |
197 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 198 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
198 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 199 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
199 | 200 | ||
201 | channel = new QCopChannel( "QPE/Launcher", this ); | ||
202 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | ||
203 | this, SLOT( launcherMessage( const QCString&, const QByteArray& ) ) ); | ||
204 | |||
200 | m_screensaver = new OpieScreenSaver ( ); | 205 | m_screensaver = new OpieScreenSaver ( ); |
201 | m_screensaver-> setInterval ( -1 ); | 206 | m_screensaver-> setInterval ( -1 ); |
202 | QWSServer::setScreenSaver( m_screensaver ); | 207 | QWSServer::setScreenSaver( m_screensaver ); |
208 | |||
209 | rereadVolumes(); | ||
210 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | ||
203 | 211 | ||
204 | apmTimeout ( ); | 212 | apmTimeout ( ); |
213 | |||
214 | grabKeyboard ( ); | ||
205 | } | 215 | } |
206 | 216 | ||
207 | 217 | ||
208 | DesktopApplication::~DesktopApplication() | 218 | DesktopApplication::~DesktopApplication() |
209 | { | 219 | { |
220 | ungrabKeyboard ( ); | ||
221 | |||
210 | delete m_ps; | 222 | delete m_ps; |
211 | delete m_ps_last; | 223 | delete m_ps_last; |
212 | delete pa; | 224 | delete pa; |
213 | } | 225 | } |
214 | 226 | ||
215 | void DesktopApplication::apmTimeout() | 227 | void DesktopApplication::apmTimeout() |
216 | { | 228 | { |
217 | qpedesktop->checkMemory(); // in case no events are being generated | 229 | qpedesktop->checkMemory(); // in case no events are being generated |
218 | 230 | ||
219 | *m_ps_last = *m_ps; | 231 | *m_ps_last = *m_ps; |
220 | *m_ps = PowerStatusManager::readStatus(); | 232 | *m_ps = PowerStatusManager::readStatus(); |
221 | 233 | ||
222 | if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) | 234 | if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) |
223 | m_screensaver-> powerStatusChanged ( *m_ps ); | 235 | m_screensaver-> powerStatusChanged ( *m_ps ); |
224 | 236 | ||
225 | if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { | 237 | if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { |
226 | int bat = m_ps-> batteryPercentRemaining ( ); | 238 | int bat = m_ps-> batteryPercentRemaining ( ); |
227 | 239 | ||
228 | if ( bat < m_ps_last-> batteryPercentRemaining ( )) { | 240 | if ( bat < m_ps_last-> batteryPercentRemaining ( )) { |
229 | if ( bat <= m_powerCritical ) | 241 | if ( bat <= m_powerCritical ) |
230 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | 242 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); |
231 | else if ( bat <= m_powerVeryLow ) | 243 | else if ( bat <= m_powerVeryLow ) |
232 | pa->alert( tr( "Battery is running very low." ), 2 ); | 244 | pa->alert( tr( "Battery is running very low." ), 2 ); |
233 | } | 245 | } |
234 | if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) | 246 | if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) |
235 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); | 247 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); |
236 | } | 248 | } |
237 | } | 249 | } |
238 | 250 | ||
239 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 251 | |
252 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | ||
240 | { | 253 | { |
241 | QDataStream stream( data, IO_ReadOnly ); | 254 | QDataStream stream ( data, IO_ReadOnly ); |
242 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | ||
243 | int k; | ||
244 | QString c, m; | ||
245 | stream >> k; | ||
246 | stream >> c; | ||
247 | stream >> m; | ||
248 | 255 | ||
249 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 256 | if ( msg == "setScreenSaverInterval(int)" ) { |
250 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 257 | int time; |
251 | } | 258 | stream >> time; |
259 | m_screensaver-> setInterval( time ); | ||
260 | } | ||
261 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | ||
262 | int t1, t2, t3; | ||
263 | stream >> t1 >> t2 >> t3; | ||
264 | m_screensaver-> setIntervals( t1, t2, t3 ); | ||
265 | } | ||
266 | else if ( msg == "setBacklight(int)" ) { | ||
267 | int bright; | ||
268 | stream >> bright; | ||
269 | m_screensaver-> setBacklight( bright ); | ||
270 | } | ||
271 | else if ( msg == "setScreenSaverMode(int)" ) { | ||
272 | int mode; | ||
273 | stream >> mode; | ||
274 | m_screensaver-> setMode ( mode ); | ||
275 | } | ||
276 | else if ( msg == "reloadPowerWarnSettings()" ) { | ||
277 | reloadPowerWarnSettings(); | ||
278 | } | ||
279 | else if ( msg == "setDisplayState(int)" ) { | ||
280 | int state; | ||
281 | stream >> state; | ||
282 | m_screensaver-> setDisplayState ( state != 0 ); | ||
283 | } | ||
284 | else if ( msg == "suspend()" ) { | ||
285 | emit power(); | ||
286 | } | ||
287 | else if ( msg == "sendBusinessCard()" ) { | ||
288 | QString card = ::getenv ( "HOME" ); | ||
289 | card += "/Applications/addressbook/businesscard.vcf"; | ||
290 | |||
291 | if ( QFile::exists( card ) ) { | ||
292 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | ||
293 | QString mimetype = "text/x-vCard"; | ||
294 | e << tr( "business card" ) << card << mimetype; | ||
295 | } | ||
296 | } | ||
252 | } | 297 | } |
253 | 298 | ||
254 | 299 | void DesktopApplication::reloadPowerWarnSettings() | |
255 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | ||
256 | { | 300 | { |
257 | QDataStream stream ( data, IO_ReadOnly ); | 301 | Config cfg( "apm" ); |
258 | 302 | cfg.setGroup( "Warnings" ); | |
259 | if ( msg == "setScreenSaverInterval(int)" ) { | 303 | |
260 | int time; | 304 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); |
261 | stream >> time; | 305 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
262 | m_screensaver-> setInterval( time ); | 306 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); |
263 | } | ||
264 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | ||
265 | int t1, t2, t3; | ||
266 | stream >> t1 >> t2 >> t3; | ||
267 | m_screensaver-> setIntervals( t1, t2, t3 ); | ||
268 | } | ||
269 | else if ( msg == "setBacklight(int)" ) { | ||
270 | int bright; | ||
271 | stream >> bright; | ||
272 | m_screensaver-> setBacklight( bright ); | ||
273 | } | ||
274 | else if ( msg == "setScreenSaverMode(int)" ) { | ||
275 | int mode; | ||
276 | stream >> mode; | ||
277 | m_screensaver-> setMode ( mode ); | ||
278 | } | ||
279 | else if ( msg == "reloadPowerWarnSettings()" ) { | ||
280 | reloadPowerWarnSettings(); | ||
281 | } | ||
282 | else if ( msg == "setDisplayState(int)" ) { | ||
283 | int state; | ||
284 | stream >> state; | ||
285 | m_screensaver-> setDisplayState ( state != 0 ); | ||
286 | } | ||
287 | else if ( msg == "suspend()" ) { | ||
288 | emit power(); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | void DesktopApplication::reloadPowerWarnSettings() { | ||
293 | Config cfg( "apm" ); | ||
294 | cfg.setGroup( "Warnings" ); | ||
295 | |||
296 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); | ||
297 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | ||
298 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); | ||
299 | } | 307 | } |
300 | 308 | ||
301 | 309 | ||
302 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 310 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
303 | 311 | ||
304 | #ifdef Q_WS_QWS | 312 | |
305 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 313 | void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
314 | { | ||
315 | QDataStream stream ( data, IO_ReadOnly ); | ||
316 | |||
317 | if ( msg == "deviceButton(int,int,int)" ) { | ||
318 | int keycode, press, autoRepeat; | ||
319 | stream >> keycode >> press >> autoRepeat; | ||
320 | |||
321 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); | ||
322 | |||
323 | if ( db ) | ||
324 | checkButtonAction ( db, keycode, press, autoRepeat ); | ||
325 | } | ||
326 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | ||
327 | int k; | ||
328 | QCString c, m; | ||
329 | stream >> k >> c >> m; | ||
330 | |||
331 | keyRegisterList.append ( QCopKeyRegister ( k, c, m )); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | void DesktopApplication::sendHeldAction ( ) | ||
306 | { | 336 | { |
307 | qpedesktop->checkMemory(); | 337 | if ( m_last_button ) { |
308 | 338 | m_last_button-> heldAction ( ). send ( ); | |
309 | if ( e->type == QWSEvent::Key ) { | 339 | m_last_button = 0; |
310 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 340 | } |
311 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | ||
312 | return TRUE; | ||
313 | bool press = ke->simpleData.is_press; | ||
314 | bool autoRepeat = ke->simpleData.is_auto_repeat; | ||
315 | |||
316 | /* | ||
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. | ||
319 | will not send multiple repeats if user holds key | ||
320 | i.e. one shot | ||
321 | */ | ||
322 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | ||
323 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | ||
324 | KeyRegisterList::Iterator it; | ||
325 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | ||
326 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | ||
327 | if ( press ) | ||
328 | qDebug( "press" ); | ||
329 | else | ||
330 | qDebug( "release" ); | ||
331 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | if ( !keyboardGrabbed() ) { | ||
337 | if ( ke->simpleData.keycode == Key_F9 ) { | ||
338 | if ( press ) | ||
339 | emit datebook(); | ||
340 | return TRUE; | ||
341 | } | ||
342 | if ( ke->simpleData.keycode == Key_F10 ) { | ||
343 | if ( !press && cardSendTimer ) { | ||
344 | emit contacts(); | ||
345 | delete cardSendTimer; | ||
346 | } | ||
347 | else if ( press ) { | ||
348 | cardSendTimer = new QTimer(); | ||
349 | cardSendTimer->start( 2000, TRUE ); | ||
350 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | ||
351 | } | ||
352 | return TRUE; | ||
353 | } | ||
354 | |||
355 | if ( ke->simpleData.keycode == Key_F11 ) { | ||
356 | if ( press ) emit menu(); | ||
357 | return TRUE; | ||
358 | } | ||
359 | |||
360 | if ( ke->simpleData.keycode == Key_F12 ) { | ||
361 | while ( activePopupWidget() ) | ||
362 | activePopupWidget() ->close(); | ||
363 | if ( press ) | ||
364 | emit launch(); | ||
365 | return TRUE; | ||
366 | } | ||
367 | if ( ke->simpleData.keycode == Key_F13 ) { | ||
368 | if ( press ) | ||
369 | emit email(); | ||
370 | return TRUE; | ||
371 | } | ||
372 | } | ||
373 | |||
374 | if ( ke->simpleData.keycode == Key_F34 ) { | ||
375 | if ( press ) | ||
376 | emit power(); | ||
377 | return TRUE; | ||
378 | } | ||
379 | // This was used for the iPAQ PowerButton | ||
380 | // See main.cpp for new KeyboardFilter | ||
381 | // | ||
382 | // if ( ke->simpleData.keycode == Key_SysReq ) { | ||
383 | // if ( press ) emit power(); | ||
384 | // return TRUE; | ||
385 | // } | ||
386 | if ( ke->simpleData.keycode == Key_F35 ) { | ||
387 | if ( press ) | ||
388 | emit backlight(); | ||
389 | return TRUE; | ||
390 | } | ||
391 | if ( ke->simpleData.keycode == Key_F32 ) { | ||
392 | if ( press ) | ||
393 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | ||
394 | return TRUE; | ||
395 | } | ||
396 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | ||
397 | if ( press ) | ||
398 | emit symbol(); | ||
399 | return TRUE; | ||
400 | } | ||
401 | if ( ke->simpleData.keycode == Key_NumLock ) { | ||
402 | if ( press ) | ||
403 | emit numLockStateToggle(); | ||
404 | } | ||
405 | if ( ke->simpleData.keycode == Key_CapsLock ) { | ||
406 | if ( press ) | ||
407 | emit capsLockStateToggle(); | ||
408 | } | ||
409 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | ||
410 | qpedesktop->keyClick(); | ||
411 | } | ||
412 | else { | ||
413 | if ( e->type == QWSEvent::Mouse ) { | ||
414 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | ||
415 | static bool up = TRUE; | ||
416 | if ( me->simpleData.state & LeftButton ) { | ||
417 | if ( up ) { | ||
418 | up = FALSE; | ||
419 | qpedesktop->screenClick(); | ||
420 | } | ||
421 | } | ||
422 | else { | ||
423 | up = TRUE; | ||
424 | } | ||
425 | } | ||
426 | } | ||
427 | |||
428 | return QPEApplication::qwsEventFilter( e ); | ||
429 | } | 341 | } |
430 | #endif | ||
431 | 342 | ||
432 | 343 | ||
433 | void DesktopApplication::sendCard() | 344 | |
345 | void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int keycode, bool press, bool autoRepeat ) | ||
346 | { | ||
347 | if ( db ) { | ||
348 | if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { | ||
349 | m_button_timer-> stop ( ); | ||
350 | if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) { | ||
351 | db-> pressedAction ( ). send ( ); | ||
352 | } | ||
353 | } | ||
354 | else if ( press && !autoRepeat ) { | ||
355 | m_button_timer-> stop ( ); | ||
356 | |||
357 | if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) { | ||
358 | m_last_button = db; | ||
359 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | ||
360 | } | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | |||
365 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) | ||
434 | { | 366 | { |
435 | delete cardSendTimer; | 367 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { |
436 | cardSendTimer = 0; | 368 | QKeyEvent *ke = (QKeyEvent *) e; |
437 | QString card = getenv( "HOME" ); | 369 | |
438 | card += "/Applications/addressbook/businesscard.vcf"; | 370 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); |
371 | |||
372 | if ( db ) { | ||
373 | checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); | ||
374 | return true; | ||
375 | } | ||
376 | } | ||
377 | return QPEApplication::eventFilter ( o, e ); | ||
378 | } | ||
379 | |||
380 | #ifdef Q_WS_QWS | ||
381 | |||
382 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | ||
383 | { | ||
384 | qpedesktop->checkMemory(); | ||
385 | |||
386 | if ( e->type == QWSEvent::Key ) { | ||
387 | QWSKeyEvent * ke = (QWSKeyEvent *) e; | ||
388 | ushort keycode = ke-> simpleData. keycode; | ||
389 | |||
390 | if ( !loggedin && keycode != Key_F34 ) | ||
391 | return true; | ||
392 | |||
393 | bool press = ke-> simpleData. is_press; | ||
394 | bool autoRepeat = ke-> simpleData. is_auto_repeat; | ||
395 | |||
396 | if ( !keyboardGrabbed ( )) { | ||
397 | // app that registers key/message to be sent back to the app, when it doesn't have focus, | ||
398 | // when user presses key, unless keyboard has been requested from app. | ||
399 | // will not send multiple repeats if user holds key | ||
400 | // i.e. one shot | ||
401 | |||
402 | if ( keycode != 0 && press && !autoRepeat ) { | ||
403 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | ||
404 | if (( *it ). getKeyCode ( ) == keycode ) { | ||
405 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); | ||
406 | return true; | ||
407 | } | ||
408 | } | ||
409 | } | ||
410 | } | ||
411 | |||
412 | if ( keycode == HardKey_Suspend ) { | ||
413 | if ( press ) | ||
414 | emit power ( ); | ||
415 | return true; | ||
416 | } | ||
417 | else if ( keycode == HardKey_Backlight ) { | ||
418 | if ( press ) | ||
419 | emit backlight ( ); | ||
420 | return true; | ||
421 | } | ||
422 | else if ( keycode == Key_F32 ) { | ||
423 | if ( press ) | ||
424 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | ||
425 | return true; | ||
426 | } | ||
427 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM | ||
428 | if ( press ) | ||
429 | emit symbol ( ); | ||
430 | return true; | ||
431 | } | ||
432 | else if ( keycode == Key_NumLock ) { | ||
433 | if ( press ) | ||
434 | emit numLockStateToggle ( ); | ||
435 | } | ||
436 | else if ( keycode == Key_CapsLock ) { | ||
437 | if ( press ) | ||
438 | emit capsLockStateToggle(); | ||
439 | } | ||
440 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { | ||
441 | if ( m_keyclick_sound ) | ||
442 | ODevice::inst ( )-> keySound ( ); | ||
443 | } | ||
444 | } | ||
445 | else if ( e-> type == QWSEvent::Mouse ) { | ||
446 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | ||
447 | static bool up = true; | ||
448 | |||
449 | if ( me-> simpleData. state & LeftButton ) { | ||
450 | if ( up ) { | ||
451 | up = false; | ||
452 | if ( m_screentap_sound ) | ||
453 | ODevice::inst ( ) -> touchSound ( ); | ||
454 | } | ||
455 | } | ||
456 | else { | ||
457 | up = true; | ||
458 | } | ||
459 | } | ||
439 | 460 | ||
440 | if ( QFile::exists( card ) ) { | 461 | return QPEApplication::qwsEventFilter ( e ); |
441 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | ||
442 | QString mimetype = "text/x-vCard"; | ||
443 | e << tr( "business card" ) << card << mimetype; | ||
444 | } | ||
445 | } | 462 | } |
463 | #endif | ||
464 | |||
465 | |||
446 | 466 | ||
447 | #if defined(QPE_HAVE_MEMALERTER) | 467 | #if defined(QPE_HAVE_MEMALERTER) |
448 | QPE_MEMALERTER_IMPL | 468 | QPE_MEMALERTER_IMPL |
449 | #endif | 469 | #endif |
450 | 470 | ||
451 | //=========================================================================== | 471 | //=========================================================================== |
452 | 472 | ||
453 | Desktop::Desktop() : | 473 | Desktop::Desktop() : |
454 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 474 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
455 | qcopBridge( 0 ), | 475 | qcopBridge( 0 ), |
456 | transferServer( 0 ), | 476 | transferServer( 0 ), |
457 | packageSlave( 0 ) | 477 | packageSlave( 0 ) |
458 | { | 478 | { |
459 | qpedesktop = this; | 479 | qpedesktop = this; |
460 | 480 | ||
461 | // bg = new Info( this ); | 481 | // bg = new Info( this ); |
462 | tb = new TaskBar; | 482 | tb = new TaskBar; |
463 | 483 | ||
464 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 484 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
465 | 485 | ||
466 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 486 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
467 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 487 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
468 | 488 | ||
469 | int displayw = qApp->desktop() ->width(); | 489 | int displayw = qApp->desktop() ->width(); |
470 | int displayh = qApp->desktop() ->height(); | 490 | int displayh = qApp->desktop() ->height(); |
471 | 491 | ||
472 | 492 | ||
473 | QSize sz = tb->sizeHint(); | 493 | QSize sz = tb->sizeHint(); |
474 | 494 | ||
475 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 495 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
476 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 496 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
477 | 497 | ||
478 | tb->show(); | 498 | tb->show(); |
479 | launcher->showMaximized(); | 499 | launcher->showMaximized(); |
480 | launcher->show(); | 500 | launcher->show(); |
481 | launcher->raise(); | 501 | launcher->raise(); |
482 | #if defined(QPE_HAVE_MEMALERTER) | 502 | #if defined(QPE_HAVE_MEMALERTER) |
483 | 503 | ||
484 | initMemalerter(); | 504 | initMemalerter(); |
485 | #endif | 505 | #endif |
486 | // start services | 506 | // start services |
487 | startTransferServer(); | 507 | startTransferServer(); |
488 | ( void ) new IrServer( this ); | 508 | ( void ) new IrServer( this ); |
489 | rereadVolumes(); | ||
490 | 509 | ||
491 | packageSlave = new PackageSlave( this ); | 510 | packageSlave = new PackageSlave( this ); |
492 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | ||
493 | 511 | ||
494 | qApp->installEventFilter( this ); | 512 | qApp->installEventFilter( this ); |
495 | 513 | ||
496 | qApp-> setMainWidget ( launcher ); | 514 | qApp-> setMainWidget ( launcher ); |
497 | } | 515 | } |
498 | 516 | ||
499 | void Desktop::show() | 517 | void Desktop::show() |
500 | { | 518 | { |
501 | login( TRUE ); | 519 | login( TRUE ); |
502 | QWidget::show(); | 520 | QWidget::show(); |
503 | } | 521 | } |
504 | 522 | ||
505 | Desktop::~Desktop() | 523 | Desktop::~Desktop() |
506 | { | 524 | { |
507 | delete launcher; | 525 | delete launcher; |
508 | delete tb; | 526 | delete tb; |
509 | delete qcopBridge; | 527 | delete qcopBridge; |
510 | delete transferServer; | 528 | delete transferServer; |
511 | } | 529 | } |
512 | 530 | ||
513 | bool Desktop::recoverMemory() | 531 | bool Desktop::recoverMemory() |
514 | { | 532 | { |
515 | return tb->recoverMemory(); | 533 | return tb->recoverMemory(); |
516 | } | 534 | } |
517 | 535 | ||
518 | void Desktop::checkMemory() | 536 | void Desktop::checkMemory() |
519 | { | 537 | { |
520 | #if defined(QPE_HAVE_MEMALERTER) | 538 | #if defined(QPE_HAVE_MEMALERTER) |
521 | static bool ignoreNormal = FALSE; | 539 | static bool ignoreNormal = FALSE; |
522 | static bool existingMessage = FALSE; | 540 | static bool existingMessage = FALSE; |
523 | 541 | ||
524 | if ( existingMessage ) | 542 | if ( existingMessage ) |
525 | return ; // don't show a second message while still on first | 543 | return ; // don't show a second message while still on first |
526 | 544 | ||
527 | existingMessage = TRUE; | 545 | existingMessage = TRUE; |
528 | switch ( memstate ) { | 546 | switch ( memstate ) { |
529 | case Unknown: | 547 | case Unknown: |
530 | break; | 548 | break; |
531 | case Low: | 549 | case Low: |
532 | memstate = Unknown; | 550 | memstate = Unknown; |
533 | if ( recoverMemory() ) | 551 | if ( recoverMemory() ) |
534 | ignoreNormal = TRUE; | 552 | ignoreNormal = TRUE; |
535 | else | 553 | else |
536 | QMessageBox::warning( 0 , "Memory Status", | 554 | QMessageBox::warning( 0 , "Memory Status", |
537 | "The memory smacks of shortage. \n" | 555 | "The memory smacks of shortage. \n" |
538 | "Please save data. " ); | 556 | "Please save data. " ); |
539 | break; | 557 | break; |
540 | case Normal: | 558 | case Normal: |
541 | memstate = Unknown; | 559 | memstate = Unknown; |
542 | if ( ignoreNormal ) | 560 | if ( ignoreNormal ) |
543 | ignoreNormal = FALSE; | 561 | ignoreNormal = FALSE; |
544 | // else | 562 | // else |
545 | // QMessageBox::information ( 0 , "Memory Status", | 563 | // QMessageBox::information ( 0 , "Memory Status", |
546 | // "There is enough memory again." ); | 564 | // "There is enough memory again." ); |
547 | break; | 565 | break; |
548 | case VeryLow: | 566 | case VeryLow: |
549 | memstate = Unknown; | 567 | memstate = Unknown; |
550 | QMessageBox::critical( 0 , "Memory Status", | 568 | QMessageBox::critical( 0 , "Memory Status", |
551 | "The memory is very low. \n" | 569 | "The memory is very low. \n" |
552 | "Please end this application \n" | 570 | "Please end this application \n" |
553 | "immediately." ); | 571 | "immediately." ); |
554 | recoverMemory(); | 572 | recoverMemory(); |
555 | } | 573 | } |
556 | existingMessage = FALSE; | 574 | existingMessage = FALSE; |
557 | #endif | 575 | #endif |
558 | } | 576 | } |
559 | 577 | ||
560 | static bool isVisibleWindow( int wid ) | 578 | static bool isVisibleWindow( int wid ) |
561 | { | 579 | { |
562 | #ifdef QWS | 580 | #ifdef QWS |
563 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 581 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
564 | QWSWindow* w; | 582 | QWSWindow* w; |
565 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 583 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
566 | if ( w->winId() == wid ) | 584 | if ( w->winId() == wid ) |
567 | return !w->isFullyObscured(); | 585 | return !w->isFullyObscured(); |
568 | } | 586 | } |
569 | #endif | 587 | #endif |
570 | return FALSE; | 588 | return FALSE; |
571 | } | 589 | } |
572 | 590 | ||
573 | static bool hasVisibleWindow( const QString& clientname ) | 591 | static bool hasVisibleWindow( const QString& clientname ) |
574 | { | 592 | { |
575 | #ifdef QWS | 593 | #ifdef QWS |
576 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 594 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
577 | QWSWindow* w; | 595 | QWSWindow* w; |
578 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 596 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
579 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 597 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
580 | return TRUE; | 598 | return TRUE; |
581 | } | 599 | } |
582 | #endif | 600 | #endif |
583 | return FALSE; | 601 | return FALSE; |
584 | } | 602 | } |
585 | 603 | ||
586 | void Desktop::raiseLauncher() | ||
587 | { | ||
588 | Config cfg( "qpe" ); //F12 'Home' | ||
589 | cfg.setGroup( "AppsKey" ); | ||
590 | QString tempItem; | ||
591 | tempItem = cfg.readEntry( "Middle", "Home" ); | ||
592 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | ||
593 | home ( ); | ||
594 | } | ||
595 | else { | ||
596 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
597 | e << tempItem; | ||
598 | } | ||
599 | } | ||
600 | |||
601 | void Desktop::home ( ) | ||
602 | { | ||
603 | if ( isVisibleWindow( launcher->winId() ) ) | ||
604 | launcher->nextView(); | ||
605 | else | ||
606 | launcher->raise(); | ||
607 | } | ||
608 | 604 | ||
609 | void Desktop::executeOrModify( const QString& appLnkFile ) | 605 | void Desktop::executeOrModify( const QString& appLnkFile ) |
610 | { | 606 | { |
611 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 607 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
612 | if ( lnk.isValid() ) { | 608 | if ( lnk.isValid() ) { |
613 | QCString app = lnk.exec().utf8(); | 609 | QCString app = lnk.exec().utf8(); |
614 | Global::terminateBuiltin( "calibrate" ); | 610 | Global::terminateBuiltin( "calibrate" ); |
615 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 611 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
616 | // MRUList::addTask( &lnk ); | 612 | // MRUList::addTask( &lnk ); |
617 | if ( hasVisibleWindow( app ) ) | 613 | if ( hasVisibleWindow( app ) ) |
618 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 614 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
619 | else | 615 | else |
620 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 616 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
621 | } | 617 | } |
622 | else { | 618 | else { |
623 | lnk.execute(); | 619 | lnk.execute(); |
624 | } | 620 | } |
625 | } | 621 | } |
626 | } | ||
627 | |||
628 | void Desktop::raiseDatebook() | ||
629 | { | ||
630 | Config cfg( "qpe" ); //F9 'Activity' | ||
631 | cfg.setGroup( "AppsKey" ); | ||
632 | QString tempItem; | ||
633 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | ||
634 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | ||
635 | tempItem = "datebook"; | ||
636 | } | ||
637 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
638 | e << tempItem; | ||
639 | } | ||
640 | |||
641 | void Desktop::raiseContacts() | ||
642 | { | ||
643 | Config cfg( "qpe" ); //F10, 'Contacts' | ||
644 | cfg.setGroup( "AppsKey" ); | ||
645 | QString tempItem; | ||
646 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | ||
647 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | ||
648 | tempItem = "addressbook"; | ||
649 | } | ||
650 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
651 | e << tempItem; | ||
652 | } | ||
653 | |||
654 | void Desktop::raiseMenu() | ||
655 | { | ||
656 | Config cfg( "qpe" ); //F11, 'Menu | ||
657 | cfg.setGroup( "AppsKey" ); | ||
658 | QString tempItem; | ||
659 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | ||
660 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | ||
661 | Global::terminateBuiltin( "calibrate" ); | ||
662 | tb->startMenu() ->launch(); | ||
663 | } | ||
664 | else { | ||
665 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
666 | e << tempItem; | ||
667 | } | ||
668 | } | ||
669 | |||
670 | void Desktop::raiseEmail() | ||
671 | { | ||
672 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | ||
673 | cfg.setGroup( "AppsKey" ); | ||
674 | QString tempItem; | ||
675 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | ||
676 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | ||
677 | tempItem = "mail"; | ||
678 | } | ||
679 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
680 | e << tempItem; | ||
681 | } | 622 | } |
682 | 623 | ||
683 | // autoStarts apps on resume and start | 624 | // autoStarts apps on resume and start |
684 | void Desktop::execAutoStart() | 625 | void Desktop::execAutoStart() |
685 | { | 626 | { |
686 | QString appName; | 627 | QString appName; |
687 | int delay; | 628 | int delay; |
688 | QDateTime now = QDateTime::currentDateTime(); | 629 | QDateTime now = QDateTime::currentDateTime(); |
689 | Config cfg( "autostart" ); | 630 | Config cfg( "autostart" ); |
690 | cfg.setGroup( "AutoStart" ); | 631 | cfg.setGroup( "AutoStart" ); |
691 | appName = cfg.readEntry( "Apps", "" ); | 632 | appName = cfg.readEntry( "Apps", "" ); |
692 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 633 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
693 | // If the time between suspend and resume was longer then the | 634 | // If the time between suspend and resume was longer then the |
694 | // value saved as delay, start the app | 635 | // value saved as delay, start the app |
695 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 636 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
696 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 637 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
697 | e << QString( appName ); | 638 | e << QString( appName ); |
698 | } | 639 | } |
699 | } | 640 | } |
700 | 641 | ||
701 | #if defined(QPE_HAVE_TOGGLELIGHT) | 642 | #if defined(QPE_HAVE_TOGGLELIGHT) |
702 | #include <qpe/config.h> | 643 | #include <qpe/config.h> |
703 | 644 | ||
704 | #include <sys/ioctl.h> | 645 | #include <sys/ioctl.h> |
705 | #include <sys/types.h> | 646 | #include <sys/types.h> |
706 | #include <fcntl.h> | 647 | #include <fcntl.h> |
707 | #include <unistd.h> | 648 | #include <unistd.h> |
708 | #include <errno.h> | 649 | #include <errno.h> |
709 | #include <linux/ioctl.h> | 650 | #include <linux/ioctl.h> |
710 | #include <time.h> | 651 | #include <time.h> |
711 | #endif | 652 | #endif |
712 | 653 | ||
713 | 654 | ||
714 | void Desktop::togglePower() | 655 | void Desktop::togglePower() |
715 | { | 656 | { |
716 | static bool excllock = false; | 657 | static bool excllock = false; |
717 | 658 | ||
718 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | 659 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); |
719 | 660 | ||
720 | if ( excllock ) | 661 | if ( excllock ) |
721 | return; | 662 | return ; |
722 | 663 | ||
723 | excllock = true; | 664 | excllock = true; |
724 | 665 | ||
725 | bool wasloggedin = loggedin; | 666 | bool wasloggedin = loggedin; |
726 | loggedin = 0; | 667 | loggedin = 0; |
727 | suspendTime = QDateTime::currentDateTime(); | 668 | suspendTime = QDateTime::currentDateTime(); |
728 | 669 | ||
729 | #ifdef QWS | 670 | #ifdef QWS |
730 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 671 | |
731 | // Should use a big black window instead. | 672 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
732 | // But this would not show up fast enough | 673 | // Should use a big black window instead. |
733 | QGfx *g = qt_screen-> screenGfx ( ); | 674 | // But this would not show up fast enough |
734 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 675 | QGfx *g = qt_screen-> screenGfx ( ); |
735 | delete g; | 676 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
736 | } | 677 | delete g; |
678 | } | ||
737 | #endif | 679 | #endif |
738 | 680 | ||
739 | ODevice::inst ( )-> suspend ( ); | 681 | ODevice::inst ( )-> suspend ( ); |
740 | 682 | ||
741 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 683 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
742 | QWSServer::screenSaverActivate ( false ); | 684 | QWSServer::screenSaverActivate ( false ); |
743 | 685 | ||
744 | { | 686 | { |
745 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 687 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
746 | } | 688 | } |
747 | 689 | ||
748 | if ( wasloggedin ) | 690 | if ( wasloggedin ) |
749 | login ( true ); | 691 | login ( true ); |
750 | 692 | ||
751 | execAutoStart(); | 693 | execAutoStart(); |
752 | //qcopBridge->closeOpenConnections(); | 694 | //qcopBridge->closeOpenConnections(); |
753 | 695 | ||
754 | excllock = false; | 696 | excllock = false; |
755 | } | 697 | } |
756 | 698 | ||
757 | void Desktop::toggleLight() | 699 | void Desktop::toggleLight() |
758 | { | 700 | { |
759 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 701 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
760 | e << -2; // toggle | 702 | e << -2; // toggle |
761 | } | 703 | } |
762 | 704 | ||
763 | void Desktop::toggleSymbolInput() | 705 | void Desktop::toggleSymbolInput() |
764 | { | 706 | { |
765 | tb->toggleSymbolInput(); | 707 | tb->toggleSymbolInput(); |
766 | } | 708 | } |
767 | 709 | ||
768 | void Desktop::toggleNumLockState() | 710 | void Desktop::toggleNumLockState() |
769 | { | 711 | { |
770 | tb->toggleNumLockState(); | 712 | tb->toggleNumLockState(); |
771 | } | 713 | } |
772 | 714 | ||
773 | void Desktop::toggleCapsLockState() | 715 | void Desktop::toggleCapsLockState() |
774 | { | 716 | { |
775 | tb->toggleCapsLockState(); | 717 | tb->toggleCapsLockState(); |
776 | } | 718 | } |
777 | 719 | ||
778 | void Desktop::styleChange( QStyle &s ) | 720 | void Desktop::styleChange( QStyle &s ) |
779 | { | 721 | { |
780 | QWidget::styleChange( s ); | 722 | QWidget::styleChange( s ); |
781 | int displayw = qApp->desktop() ->width(); | 723 | int displayw = qApp->desktop() ->width(); |
782 | int displayh = qApp->desktop() ->height(); | 724 | int displayh = qApp->desktop() ->height(); |
783 | 725 | ||
784 | QSize sz = tb->sizeHint(); | 726 | QSize sz = tb->sizeHint(); |
785 | 727 | ||
786 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 728 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
787 | } | 729 | } |
788 | 730 | ||
789 | void DesktopApplication::shutdown() | 731 | void DesktopApplication::shutdown() |
790 | { | 732 | { |
791 | if ( type() != GuiServer ) | 733 | if ( type() != GuiServer ) |
792 | return ; | 734 | return ; |
793 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 735 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
794 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 736 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
795 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 737 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
796 | sd->showMaximized(); | 738 | sd->showMaximized(); |
797 | } | 739 | } |
798 | 740 | ||
799 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 741 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
800 | { | 742 | { |
801 | switch ( t ) { | 743 | switch ( t ) { |
802 | case ShutdownImpl::ShutdownSystem: | 744 | case ShutdownImpl::ShutdownSystem: |
803 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); | 745 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); |
804 | break; | 746 | break; |
805 | case ShutdownImpl::RebootSystem: | 747 | case ShutdownImpl::RebootSystem: |
806 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); | 748 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); |
807 | break; | 749 | break; |
808 | case ShutdownImpl::RestartDesktop: | 750 | case ShutdownImpl::RestartDesktop: |
809 | restart(); | 751 | restart(); |
810 | break; | 752 | break; |
811 | case ShutdownImpl::TerminateDesktop: | 753 | case ShutdownImpl::TerminateDesktop: |
812 | prepareForTermination( FALSE ); | 754 | prepareForTermination( FALSE ); |
813 | 755 | ||
814 | // This is a workaround for a Qt bug | 756 | // This is a workaround for a Qt bug |
815 | // clipboard applet has to stop its poll timer, or Qt/E | 757 | // clipboard applet has to stop its poll timer, or Qt/E |
816 | // will hang on quit() right before it emits aboutToQuit() | 758 | // will hang on quit() right before it emits aboutToQuit() |
817 | emit aboutToQuit ( ); | 759 | emit aboutToQuit ( ); |
818 | 760 | ||
819 | quit(); | 761 | quit(); |
820 | break; | 762 | break; |
821 | } | 763 | } |
822 | } | 764 | } |
823 | 765 | ||
824 | void DesktopApplication::restart() | 766 | void DesktopApplication::restart() |
825 | { | 767 | { |
826 | prepareForTermination( TRUE ); | 768 | prepareForTermination( TRUE ); |
827 | 769 | ||
828 | #ifdef Q_WS_QWS | 770 | #ifdef Q_WS_QWS |
829 | 771 | ||
830 | for ( int fd = 3; fd < 100; fd++ ) | 772 | for ( int fd = 3; fd < 100; fd++ ) |
831 | close( fd ); | 773 | close( fd ); |
832 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 774 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
833 | 775 | ||
834 | execl( "/sbin/init", "qpe", 0 ); | 776 | execl( "/sbin/init", "qpe", 0 ); |
835 | #elif defined(QT_QWS_CASSIOPEIA) | 777 | #elif defined(QT_QWS_CASSIOPEIA) |
836 | 778 | ||
837 | execl( "/bin/sh", "sh", 0 ); | 779 | execl( "/bin/sh", "sh", 0 ); |
838 | #else | 780 | #else |
839 | 781 | ||
840 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 782 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
841 | #endif | 783 | #endif |
842 | 784 | ||
843 | exit( 1 ); | 785 | exit( 1 ); |
844 | #endif | 786 | #endif |
845 | } | 787 | } |
846 | 788 | ||
847 | void Desktop::startTransferServer() | 789 | void Desktop::startTransferServer() |
848 | { | 790 | { |
849 | // start qcop bridge server | 791 | // start qcop bridge server |
850 | qcopBridge = new QCopBridge( 4243 ); | 792 | qcopBridge = new QCopBridge( 4243 ); |
851 | if ( !qcopBridge->ok() ) { | 793 | if ( !qcopBridge->ok() ) { |
852 | delete qcopBridge; | 794 | delete qcopBridge; |
853 | qcopBridge = 0; | 795 | qcopBridge = 0; |
854 | } | 796 | } |
855 | // start transfer server | 797 | // start transfer server |
856 | transferServer = new TransferServer( 4242 ); | 798 | transferServer = new TransferServer( 4242 ); |
857 | if ( !transferServer->ok() ) { | 799 | if ( !transferServer->ok() ) { |
858 | delete transferServer; | 800 | delete transferServer; |
859 | transferServer = 0; | 801 | transferServer = 0; |
860 | } | 802 | } |
861 | if ( !transferServer || !qcopBridge ) | 803 | if ( !transferServer || !qcopBridge ) |
862 | startTimer( 2000 ); | 804 | startTimer( 2000 ); |
863 | } | 805 | } |
864 | 806 | ||
865 | void Desktop::timerEvent( QTimerEvent *e ) | 807 | void Desktop::timerEvent( QTimerEvent *e ) |
866 | { | 808 | { |
867 | killTimer( e->timerId() ); | 809 | killTimer( e->timerId() ); |
868 | startTransferServer(); | 810 | startTransferServer(); |
869 | } | 811 | } |
870 | 812 | ||
871 | void Desktop::terminateServers() | 813 | void Desktop::terminateServers() |
872 | { | 814 | { |
873 | delete transferServer; | 815 | delete transferServer; |
874 | delete qcopBridge; | 816 | delete qcopBridge; |
875 | transferServer = 0; | 817 | transferServer = 0; |
876 | qcopBridge = 0; | 818 | qcopBridge = 0; |
877 | } | 819 | } |
878 | 820 | ||
879 | void Desktop::rereadVolumes() | 821 | void DesktopApplication::rereadVolumes() |
880 | { | 822 | { |
881 | Config cfg( "qpe" ); | 823 | Config cfg( "qpe" ); |
882 | cfg.setGroup( "Volume" ); | 824 | cfg. setGroup ( "Volume" ); |
883 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 825 | |
884 | keyclick = cfg.readBoolEntry( "KeySound" ); | 826 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
885 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 827 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); |
886 | } | 828 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); |
887 | |||
888 | void Desktop::keyClick() | ||
889 | { | ||
890 | if ( keyclick ) | ||
891 | ODevice::inst ( ) -> keySound ( ); | ||
892 | } | 829 | } |
893 | 830 | ||
894 | void Desktop::screenClick() | 831 | void DesktopApplication::soundAlarm() |
895 | { | 832 | { |
896 | if ( touchclick ) | 833 | if ( me ( )-> m_alarm_sound ) |
897 | ODevice::inst ( ) -> touchSound ( ); | 834 | ODevice::inst ( )-> alarmSound ( ); |
898 | } | 835 | } |
899 | 836 | ||
900 | void Desktop::soundAlarm() | 837 | DesktopApplication *DesktopApplication::me ( ) |
901 | { | 838 | { |
902 | if ( qpedesktop-> alarmsound ) | 839 | return (DesktopApplication *) qApp; |
903 | ODevice::inst ( ) -> alarmSound ( ); | ||
904 | } | 840 | } |
905 | 841 | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index 1f8daa0..6cb7ab2 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -1,152 +1,155 @@ | |||
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 | #include <opie/odevicebutton.h> | ||
28 | 29 | ||
29 | #include <qwidget.h> | 30 | #include <qwidget.h> |
30 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
31 | 32 | ||
32 | class Background; | 33 | class Background; |
33 | class Launcher; | 34 | class Launcher; |
34 | class TaskBar; | 35 | class TaskBar; |
35 | class PowerStatus; | 36 | class PowerStatus; |
36 | class QCopBridge; | 37 | class QCopBridge; |
37 | class TransferServer; | 38 | class TransferServer; |
38 | class DesktopPowerAlerter; | 39 | class DesktopPowerAlerter; |
39 | class PackageSlave; | 40 | class PackageSlave; |
40 | class OpieScreenSaver; | 41 | class OpieScreenSaver; |
41 | 42 | ||
42 | class DesktopApplication : public QPEApplication | 43 | class DesktopApplication : public QPEApplication |
43 | { | 44 | { |
44 | Q_OBJECT | 45 | Q_OBJECT |
45 | public: | 46 | public: |
46 | DesktopApplication( int& argc, char **argv, Type t ); | 47 | DesktopApplication( int& argc, char **argv, Type t ); |
47 | ~DesktopApplication(); | 48 | ~DesktopApplication(); |
49 | |||
50 | static void switchLCD ( bool on ); // only for togglePower in Desktop | ||
48 | 51 | ||
49 | static void switchLCD ( bool on ); // only for togglePower in Desktop | 52 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar |
50 | 53 | ||
51 | signals: | 54 | signals: |
52 | void menu(); | 55 | void menu(); |
53 | void home(); | 56 | void home(); |
54 | void datebook(); | 57 | void launch(); |
55 | void contacts(); | 58 | void backlight(); |
56 | void launch(); | 59 | void power(); |
57 | void email(); | 60 | void symbol(); |
58 | void backlight(); | 61 | void numLockStateToggle(); |
59 | void power(); | 62 | void capsLockStateToggle(); |
60 | void symbol(); | 63 | void prepareForRestart(); |
61 | void numLockStateToggle(); | ||
62 | void capsLockStateToggle(); | ||
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 systemMessage ( const QCString &msg, const QByteArray &data ); |
76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); | 76 | virtual void launcherMessage ( const QCString &msg, const QByteArray &data ); |
77 | void rereadVolumes(); | ||
77 | 78 | ||
78 | protected slots: | 79 | protected slots: |
79 | void shutdown( ShutdownImpl::Type ); | 80 | void shutdown ( ShutdownImpl::Type ); |
80 | void apmTimeout(); | 81 | void apmTimeout ( ); |
81 | void sendCard(); | 82 | void sendHeldAction ( ); |
83 | |||
84 | protected: | ||
85 | virtual bool eventFilter ( QObject *o, QEvent *e ); | ||
86 | void checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); | ||
87 | |||
88 | private: | ||
89 | static DesktopApplication *me ( ); | ||
90 | |||
82 | private: | 91 | private: |
83 | void reloadPowerWarnSettings(); | 92 | void reloadPowerWarnSettings(); |
84 | DesktopPowerAlerter *pa; | 93 | DesktopPowerAlerter *pa; |
85 | PowerStatus *m_ps, *m_ps_last; | 94 | PowerStatus *m_ps, *m_ps_last; |
86 | QTimer *cardSendTimer; | 95 | QTimer *cardSendTimer; |
87 | QCopChannel *channel; | 96 | QCopChannel *channel; |
88 | OpieScreenSaver *m_screensaver; | 97 | OpieScreenSaver *m_screensaver; |
89 | QTimer * m_timer; | 98 | QTimer * m_timer; |
90 | int m_powerVeryLow; | 99 | int m_powerVeryLow; |
91 | int m_powerCritical; | 100 | int m_powerCritical; |
92 | int m_currentPowerLevel; | 101 | int m_currentPowerLevel; |
102 | |||
103 | const Opie::ODeviceButton *m_last_button; | ||
104 | QTimer *m_button_timer; | ||
105 | |||
106 | bool m_keyclick_sound : 1; | ||
107 | bool m_screentap_sound : 1; | ||
108 | bool m_alarm_sound : 1; | ||
93 | }; | 109 | }; |
94 | 110 | ||
95 | 111 | ||
96 | class Desktop : public QWidget | 112 | class Desktop : public QWidget |
97 | { | 113 | { |
98 | Q_OBJECT | 114 | Q_OBJECT |
99 | public: | 115 | public: |
100 | Desktop(); | 116 | Desktop(); |
101 | ~Desktop(); | 117 | ~Desktop(); |
102 | |||
103 | static bool screenLocked(); | ||
104 | 118 | ||
105 | void show(); | 119 | static bool screenLocked(); |
106 | void checkMemory(); | ||
107 | 120 | ||
108 | void keyClick(); | 121 | void show(); |
109 | void screenClick(); | 122 | void checkMemory(); |
110 | static void soundAlarm(); | ||
111 | 123 | ||
112 | public slots: | 124 | public slots: |
113 | void raiseDatebook(); | 125 | void execAutoStart(); |
114 | void raiseContacts(); | 126 | void togglePower(); |
115 | void raiseMenu(); | 127 | void toggleLight(); |
116 | void raiseLauncher(); | 128 | void toggleNumLockState(); |
117 | void raiseEmail(); | 129 | void toggleCapsLockState(); |
118 | void execAutoStart(); | 130 | void toggleSymbolInput(); |
119 | void togglePower(); | 131 | void terminateServers(); |
120 | void toggleLight(); | ||
121 | void toggleNumLockState(); | ||
122 | void toggleCapsLockState(); | ||
123 | void toggleSymbolInput(); | ||
124 | void terminateServers(); | ||
125 | void rereadVolumes(); | ||
126 | |||
127 | void home ( ); | ||
128 | 132 | ||
129 | protected: | 133 | protected: |
130 | void executeOrModify( const QString& appLnkFile ); | 134 | void executeOrModify( const QString& appLnkFile ); |
131 | void styleChange( QStyle & ); | 135 | void styleChange( QStyle & ); |
132 | void timerEvent( QTimerEvent *e ); | 136 | void timerEvent( QTimerEvent *e ); |
133 | 137 | ||
134 | QWidget *bg; | 138 | QWidget *bg; |
135 | Launcher *launcher; | 139 | Launcher *launcher; |
136 | TaskBar *tb; | 140 | TaskBar *tb; |
137 | 141 | ||
138 | private: | 142 | private: |
139 | void startTransferServer(); | 143 | void startTransferServer(); |
140 | bool recoverMemory(); | 144 | bool recoverMemory(); |
141 | 145 | ||
142 | QCopBridge *qcopBridge; | 146 | QCopBridge *qcopBridge; |
143 | TransferServer *transferServer; | 147 | TransferServer *transferServer; |
144 | PackageSlave *packageSlave; | 148 | PackageSlave *packageSlave; |
145 | 149 | ||
146 | QDateTime suspendTime; | 150 | QDateTime suspendTime; |
147 | bool keyclick, touchclick, alarmsound; | ||
148 | }; | 151 | }; |
149 | 152 | ||
150 | 153 | ||
151 | #endif // __DESKTOP_H__ | 154 | #endif // __DESKTOP_H__ |
152 | 155 | ||
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 767efb2..6764338 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,1253 +1,1260 @@ | |||
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 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
22 | // have this class. | 22 | // have this class. |
23 | #define QTOPIA_INTERNAL_FSLP | 23 | #define QTOPIA_INTERNAL_FSLP |
24 | 24 | ||
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
30 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
31 | #include <qpe/mimetype.h> | 31 | #include <qpe/mimetype.h> |
32 | #include <qpe/storage.h> | 32 | #include <qpe/storage.h> |
33 | #include <qpe/palmtoprecord.h> | 33 | #include <qpe/palmtoprecord.h> |
34 | 34 | ||
35 | #include <qpe/version.h> | 35 | #include <qpe/version.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #ifdef QWS | 38 | #ifdef QWS |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #endif | 40 | #endif |
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
43 | #include <qvbox.h> | 43 | #include <qvbox.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qstyle.h> | 45 | #include <qstyle.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | #include <qtabbar.h> | 47 | #include <qtabbar.h> |
48 | #include <qwidgetstack.h> | 48 | #include <qwidgetstack.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qregexp.h> | 50 | #include <qregexp.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qframe.h> | 52 | #include <qframe.h> |
53 | #include <qpainter.h> | 53 | #include <qpainter.h> |
54 | #include <qlabel.h> | 54 | #include <qlabel.h> |
55 | #include <qtextstream.h> | 55 | #include <qtextstream.h> |
56 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
57 | 57 | ||
58 | #include "launcherview.h" | 58 | #include "launcherview.h" |
59 | #include "launcher.h" | 59 | #include "launcher.h" |
60 | #include "syncdialog.h" | 60 | #include "syncdialog.h" |
61 | #include "desktop.h" | 61 | #include "desktop.h" |
62 | #include <qpe/lnkproperties.h> | 62 | #include <qpe/lnkproperties.h> |
63 | //#include "mrulist.h" | 63 | //#include "mrulist.h" |
64 | #include "qrsync.h" | 64 | #include "qrsync.h" |
65 | #include <stdlib.h> | 65 | #include <stdlib.h> |
66 | #include <unistd.h> | 66 | #include <unistd.h> |
67 | 67 | ||
68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
69 | #include <stdio.h> | 69 | #include <stdio.h> |
70 | #include <sys/vfs.h> | 70 | #include <sys/vfs.h> |
71 | #include <mntent.h> | 71 | #include <mntent.h> |
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | #include <qpe/storage.h> | 74 | #include <qpe/storage.h> |
75 | #include "mediummountgui.h" | 75 | #include "mediummountgui.h" |
76 | 76 | ||
77 | namespace { | 77 | namespace { |
78 | QStringList configToMime( Config *cfg ){ | 78 | QStringList configToMime( Config *cfg ){ |
79 | QStringList mimes; | 79 | QStringList mimes; |
80 | bool tmpMime = true; | 80 | bool tmpMime = true; |
81 | cfg->setGroup("mimetypes" ); | 81 | cfg->setGroup("mimetypes" ); |
82 | tmpMime = cfg->readBoolEntry("all" ,true); | 82 | tmpMime = cfg->readBoolEntry("all" ,true); |
83 | if( tmpMime ){ | 83 | if( tmpMime ){ |
84 | mimes << QString::null; | 84 | mimes << QString::null; |
85 | return mimes; | 85 | return mimes; |
86 | }else{ | 86 | }else{ |
87 | tmpMime = cfg->readBoolEntry("audio", true ); | 87 | tmpMime = cfg->readBoolEntry("audio", true ); |
88 | if(tmpMime ) | 88 | if(tmpMime ) |
89 | mimes.append("audio/*" ); | 89 | mimes.append("audio/*" ); |
90 | 90 | ||
91 | tmpMime = cfg->readBoolEntry("image", true ); | 91 | tmpMime = cfg->readBoolEntry("image", true ); |
92 | if(tmpMime ) | 92 | if(tmpMime ) |
93 | mimes.append("image/*" ); | 93 | mimes.append("image/*" ); |
94 | 94 | ||
95 | tmpMime = cfg->readBoolEntry("text", true ); | 95 | tmpMime = cfg->readBoolEntry("text", true ); |
96 | if(tmpMime ) | 96 | if(tmpMime ) |
97 | mimes.append("text/*"); | 97 | mimes.append("text/*"); |
98 | 98 | ||
99 | tmpMime = cfg->readBoolEntry("video", true ); | 99 | tmpMime = cfg->readBoolEntry("video", true ); |
100 | if(tmpMime ) | 100 | if(tmpMime ) |
101 | mimes.append("video/*" ); | 101 | mimes.append("video/*" ); |
102 | } | 102 | } |
103 | return mimes; | 103 | return mimes; |
104 | } | 104 | } |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | //#define SHOW_ALL | 110 | //#define SHOW_ALL |
111 | 111 | ||
112 | class CategoryTab : public QTab | 112 | class CategoryTab : public QTab |
113 | { | 113 | { |
114 | public: | 114 | public: |
115 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) | 115 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) |
116 | : QTab( icon, text ) | 116 | : QTab( icon, text ) |
117 | { | 117 | { |
118 | } | 118 | } |
119 | 119 | ||
120 | QColor bgColor; | 120 | QColor bgColor; |
121 | QColor fgColor; | 121 | QColor fgColor; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | //=========================================================================== | 124 | //=========================================================================== |
125 | 125 | ||
126 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 126 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
127 | QVBox( parent ) | 127 | QVBox( parent ) |
128 | { | 128 | { |
129 | categoryBar = 0; | 129 | categoryBar = 0; |
130 | stack = 0; | 130 | stack = 0; |
131 | } | 131 | } |
132 | 132 | ||
133 | void CategoryTabWidget::prevTab() | 133 | void CategoryTabWidget::prevTab() |
134 | { | 134 | { |
135 | if ( categoryBar ) { | 135 | if ( categoryBar ) { |
136 | int n = categoryBar->count(); | 136 | int n = categoryBar->count(); |
137 | int tab = categoryBar->currentTab(); | 137 | int tab = categoryBar->currentTab(); |
138 | if ( tab >= 0 ) | 138 | if ( tab >= 0 ) |
139 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 139 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | void CategoryTabWidget::nextTab() | 143 | void CategoryTabWidget::nextTab() |
144 | { | 144 | { |
145 | if ( categoryBar ) { | 145 | if ( categoryBar ) { |
146 | int n = categoryBar->count(); | 146 | int n = categoryBar->count(); |
147 | int tab = categoryBar->currentTab(); | 147 | int tab = categoryBar->currentTab(); |
148 | categoryBar->setCurrentTab( (tab + 1)%n ); | 148 | categoryBar->setCurrentTab( (tab + 1)%n ); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | void CategoryTabWidget::addItem( const QString& linkfile ) | 152 | void CategoryTabWidget::addItem( const QString& linkfile ) |
153 | { | 153 | { |
154 | int i=0; | 154 | int i=0; |
155 | AppLnk *app = new AppLnk(linkfile); | 155 | AppLnk *app = new AppLnk(linkfile); |
156 | if ( !app->isValid() ) { | 156 | if ( !app->isValid() ) { |
157 | delete app; | 157 | delete app; |
158 | app=0; | 158 | app=0; |
159 | } | 159 | } |
160 | if ( !app || !app->file().isEmpty() ) { | 160 | if ( !app || !app->file().isEmpty() ) { |
161 | // A document | 161 | // A document |
162 | delete app; | 162 | delete app; |
163 | app = new DocLnk(linkfile); | 163 | app = new DocLnk(linkfile); |
164 | if ( app->fileKnown() ) { | 164 | if ( app->fileKnown() ) { |
165 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 165 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
166 | } else { | 166 | } else { |
167 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); | 167 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); |
168 | delete app; | 168 | delete app; |
169 | } | 169 | } |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | // An application | 172 | // An application |
173 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 173 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
174 | if ( !(*it).isEmpty() ) { | 174 | if ( !(*it).isEmpty() ) { |
175 | QRegExp tf(*it,FALSE,TRUE); | 175 | QRegExp tf(*it,FALSE,TRUE); |
176 | if ( tf.match(app->type()) >= 0 ) { | 176 | if ( tf.match(app->type()) >= 0 ) { |
177 | ((LauncherView*)stack->widget(i))->addItem(app); | 177 | ((LauncherView*)stack->widget(i))->addItem(app); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | i++; | 180 | i++; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); | 184 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); |
185 | } | 185 | } |
186 | 186 | ||
187 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 187 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
188 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 188 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
189 | { | 189 | { |
190 | delete categoryBar; | 190 | delete categoryBar; |
191 | categoryBar = new CategoryTabBar( this ); | 191 | categoryBar = new CategoryTabBar( this ); |
192 | QPalette pal = categoryBar->palette(); | 192 | QPalette pal = categoryBar->palette(); |
193 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 193 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
194 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 194 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
195 | categoryBar->setPalette( pal ); | 195 | categoryBar->setPalette( pal ); |
196 | 196 | ||
197 | delete stack; | 197 | delete stack; |
198 | stack = new QWidgetStack(this); | 198 | stack = new QWidgetStack(this); |
199 | tabs=0; | 199 | tabs=0; |
200 | 200 | ||
201 | ids.clear(); | 201 | ids.clear(); |
202 | 202 | ||
203 | Config cfg("Launcher"); | 203 | Config cfg("Launcher"); |
204 | 204 | ||
205 | QStringList types = rootFolder->types(); | 205 | QStringList types = rootFolder->types(); |
206 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 206 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
207 | if ( !(*it).isEmpty() ) { | 207 | if ( !(*it).isEmpty() ) { |
208 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 208 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
209 | setTabAppearance( *it, cfg ); | 209 | setTabAppearance( *it, cfg ); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | QListIterator<AppLnk> it( rootFolder->children() ); | 212 | QListIterator<AppLnk> it( rootFolder->children() ); |
213 | AppLnk* l; | 213 | AppLnk* l; |
214 | while ( (l=it.current()) ) { | 214 | while ( (l=it.current()) ) { |
215 | if ( l->type() == "Separator" ) { // No tr | 215 | if ( l->type() == "Separator" ) { // No tr |
216 | rootFolder->remove(l); | 216 | rootFolder->remove(l); |
217 | delete l; | 217 | delete l; |
218 | } else { | 218 | } else { |
219 | int i=0; | 219 | int i=0; |
220 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 220 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
221 | if ( *it == l->type() ) | 221 | if ( *it == l->type() ) |
222 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 222 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
223 | i++; | 223 | i++; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | ++it; | 226 | ++it; |
227 | } | 227 | } |
228 | rootFolder->detachChildren(); | 228 | rootFolder->detachChildren(); |
229 | for (int i=0; i<tabs; i++) | 229 | for (int i=0; i<tabs; i++) |
230 | ((LauncherView*)stack->widget(i))->sort(); | 230 | ((LauncherView*)stack->widget(i))->sort(); |
231 | 231 | ||
232 | // all documents | 232 | // all documents |
233 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 233 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
234 | QPixmap pm; | 234 | QPixmap pm; |
235 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 235 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
236 | docview = newView( "Documents", // No tr | 236 | docview = newView( "Documents", // No tr |
237 | pm, tr("Documents")); | 237 | pm, tr("Documents")); |
238 | docview->populate( docFolder, QString::null ); | 238 | docview->populate( docFolder, QString::null ); |
239 | docFolder->detachChildren(); | 239 | docFolder->detachChildren(); |
240 | docview->setFileSystems(fs); | 240 | docview->setFileSystems(fs); |
241 | docview->setToolsEnabled(TRUE); | 241 | docview->setToolsEnabled(TRUE); |
242 | setTabAppearance( "Documents", cfg ); // No tr | 242 | setTabAppearance( "Documents", cfg ); // No tr |
243 | 243 | ||
244 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 244 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
245 | 245 | ||
246 | ((LauncherView*)stack->widget(0))->setFocus(); | 246 | ((LauncherView*)stack->widget(0))->setFocus(); |
247 | 247 | ||
248 | cfg. setGroup ( "GUI" ); | 248 | cfg. setGroup ( "GUI" ); |
249 | setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); | 249 | setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); |
250 | 250 | ||
251 | categoryBar->show(); | 251 | categoryBar->show(); |
252 | stack->show(); | 252 | stack->show(); |
253 | } | 253 | } |
254 | 254 | ||
255 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) | 255 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) |
256 | { | 256 | { |
257 | QString grp( "Tab %1" ); // No tr | 257 | QString grp( "Tab %1" ); // No tr |
258 | cfg.setGroup( grp.arg(id) ); | 258 | cfg.setGroup( grp.arg(id) ); |
259 | LauncherView *v = view( id ); | 259 | LauncherView *v = view( id ); |
260 | int idx = ids.findIndex( id ); | 260 | int idx = ids.findIndex( id ); |
261 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); | 261 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); |
262 | 262 | ||
263 | // View | 263 | // View |
264 | QString view = cfg.readEntry( "View", "Icon" ); | 264 | QString view = cfg.readEntry( "View", "Icon" ); |
265 | if ( view == "List" ) // No tr | 265 | if ( view == "List" ) // No tr |
266 | v->setViewMode( LauncherView::List ); | 266 | v->setViewMode( LauncherView::List ); |
267 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 267 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
268 | if ( bgType == "Image" ) { // No tr | 268 | if ( bgType == "Image" ) { // No tr |
269 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 269 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
270 | v->setBackgroundType( LauncherView::Image, pm ); | 270 | v->setBackgroundType( LauncherView::Image, pm ); |
271 | } else if ( bgType == "SolidColor" ) { | 271 | } else if ( bgType == "SolidColor" ) { |
272 | QString c = cfg.readEntry( "BackgroundColor" ); | 272 | QString c = cfg.readEntry( "BackgroundColor" ); |
273 | v->setBackgroundType( LauncherView::SolidColor, c ); | 273 | v->setBackgroundType( LauncherView::SolidColor, c ); |
274 | } | 274 | } |
275 | QString textCol = cfg.readEntry( "TextColor" ); | 275 | QString textCol = cfg.readEntry( "TextColor" ); |
276 | if ( textCol.isEmpty() ) | 276 | if ( textCol.isEmpty() ) |
277 | v->setTextColor( QColor() ); | 277 | v->setTextColor( QColor() ); |
278 | else | 278 | else |
279 | v->setTextColor( QColor(textCol) ); | 279 | v->setTextColor( QColor(textCol) ); |
280 | QStringList font = cfg.readListEntry( "Font", ',' ); | 280 | QStringList font = cfg.readListEntry( "Font", ',' ); |
281 | if ( font.count() == 4 ) | 281 | if ( font.count() == 4 ) |
282 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 282 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
283 | 283 | ||
284 | // Tabs | 284 | // Tabs |
285 | QString tabCol = cfg.readEntry( "TabColor" ); | 285 | QString tabCol = cfg.readEntry( "TabColor" ); |
286 | if ( tabCol.isEmpty() ) | 286 | if ( tabCol.isEmpty() ) |
287 | tab->bgColor = QColor(); | 287 | tab->bgColor = QColor(); |
288 | else | 288 | else |
289 | tab->bgColor = QColor(tabCol); | 289 | tab->bgColor = QColor(tabCol); |
290 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 290 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
291 | if ( tabTextCol.isEmpty() ) | 291 | if ( tabTextCol.isEmpty() ) |
292 | tab->fgColor = QColor(); | 292 | tab->fgColor = QColor(); |
293 | else | 293 | else |
294 | tab->fgColor = QColor(tabTextCol); | 294 | tab->fgColor = QColor(tabTextCol); |
295 | } | 295 | } |
296 | 296 | ||
297 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 297 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
298 | { | 298 | { |
299 | docview->populate( docFolder, QString::null ); | 299 | docview->populate( docFolder, QString::null ); |
300 | docFolder->detachChildren(); | 300 | docFolder->detachChildren(); |
301 | docview->setFileSystems(fs); | 301 | docview->setFileSystems(fs); |
302 | docview->updateTools(); | 302 | docview->updateTools(); |
303 | } | 303 | } |
304 | 304 | ||
305 | void CategoryTabWidget::tabProperties() | 305 | void CategoryTabWidget::tabProperties() |
306 | { | 306 | { |
307 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); | 307 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); |
308 | QPopupMenu *m = new QPopupMenu( this ); | 308 | QPopupMenu *m = new QPopupMenu( this ); |
309 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 309 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
310 | m->insertItem( tr("List View"), LauncherView::List ); | 310 | m->insertItem( tr("List View"), LauncherView::List ); |
311 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 311 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
312 | int rv = m->exec( QCursor::pos() ); | 312 | int rv = m->exec( QCursor::pos() ); |
313 | if ( rv >= 0 && rv != view->viewMode() ) { | 313 | if ( rv >= 0 && rv != view->viewMode() ) { |
314 | view->setViewMode( (LauncherView::ViewMode)rv ); | 314 | view->setViewMode( (LauncherView::ViewMode)rv ); |
315 | } | 315 | } |
316 | 316 | ||
317 | delete m; | 317 | delete m; |
318 | } | 318 | } |
319 | 319 | ||
320 | QString CategoryTabWidget::getAllDocLinkInfo() const | 320 | QString CategoryTabWidget::getAllDocLinkInfo() const |
321 | { | 321 | { |
322 | return docview->getAllDocLinkInfo(); | 322 | return docview->getAllDocLinkInfo(); |
323 | } | 323 | } |
324 | 324 | ||
325 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 325 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
326 | { | 326 | { |
327 | LauncherView* view = new LauncherView( stack ); | 327 | LauncherView* view = new LauncherView( stack ); |
328 | connect( view, SIGNAL(clicked(const AppLnk*)), | 328 | connect( view, SIGNAL(clicked(const AppLnk*)), |
329 | this, SIGNAL(clicked(const AppLnk*))); | 329 | this, SIGNAL(clicked(const AppLnk*))); |
330 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 330 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
331 | this, SIGNAL(rightPressed(AppLnk*))); | 331 | this, SIGNAL(rightPressed(AppLnk*))); |
332 | ids.append(id); | 332 | ids.append(id); |
333 | categoryBar->addTab( new CategoryTab( pm, label ) ); | 333 | categoryBar->addTab( new CategoryTab( pm, label ) ); |
334 | stack->addWidget( view, tabs++ ); | 334 | stack->addWidget( view, tabs++ ); |
335 | return view; | 335 | return view; |
336 | } | 336 | } |
337 | 337 | ||
338 | void CategoryTabWidget::updateLink(const QString& linkfile) | 338 | void CategoryTabWidget::updateLink(const QString& linkfile) |
339 | { | 339 | { |
340 | int i=0; | 340 | int i=0; |
341 | LauncherView* view; | 341 | LauncherView* view; |
342 | while ((view = (LauncherView*)stack->widget(i++))) { | 342 | while ((view = (LauncherView*)stack->widget(i++))) { |
343 | if ( view->removeLink(linkfile) ) | 343 | if ( view->removeLink(linkfile) ) |
344 | break; | 344 | break; |
345 | } | 345 | } |
346 | addItem(linkfile); | 346 | addItem(linkfile); |
347 | docview->updateTools(); | 347 | docview->updateTools(); |
348 | } | 348 | } |
349 | 349 | ||
350 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 350 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
351 | { | 351 | { |
352 | QVBox::paletteChange( p ); | 352 | QVBox::paletteChange( p ); |
353 | QPalette pal = palette(); | 353 | QPalette pal = palette(); |
354 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 354 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
355 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 355 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
356 | categoryBar->setPalette( pal ); | 356 | categoryBar->setPalette( pal ); |
357 | categoryBar->update(); | 357 | categoryBar->update(); |
358 | } | 358 | } |
359 | 359 | ||
360 | void CategoryTabWidget::setBusy(bool on) | 360 | void CategoryTabWidget::setBusy(bool on) |
361 | { | 361 | { |
362 | if ( on ) | 362 | if ( on ) |
363 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 363 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
364 | else | 364 | else |
365 | for (int i=0; i<tabs; i++) | 365 | for (int i=0; i<tabs; i++) |
366 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 366 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
367 | } | 367 | } |
368 | 368 | ||
369 | LauncherView *CategoryTabWidget::view( const QString &id ) | 369 | LauncherView *CategoryTabWidget::view( const QString &id ) |
370 | { | 370 | { |
371 | int idx = ids.findIndex( id ); | 371 | int idx = ids.findIndex( id ); |
372 | return (LauncherView *)stack->widget(idx); | 372 | return (LauncherView *)stack->widget(idx); |
373 | } | 373 | } |
374 | 374 | ||
375 | void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) | 375 | void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) |
376 | { | 376 | { |
377 | for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) | 377 | for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) |
378 | view ( *it )-> setBusyIndicatorType ( type ); | 378 | view ( *it )-> setBusyIndicatorType ( type ); |
379 | } | 379 | } |
380 | 380 | ||
381 | //=========================================================================== | 381 | //=========================================================================== |
382 | 382 | ||
383 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 383 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
384 | : QTabBar( parent, name ) | 384 | : QTabBar( parent, name ) |
385 | { | 385 | { |
386 | setFocusPolicy( NoFocus ); | 386 | setFocusPolicy( NoFocus ); |
387 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 387 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
388 | } | 388 | } |
389 | 389 | ||
390 | CategoryTabBar::~CategoryTabBar() | 390 | CategoryTabBar::~CategoryTabBar() |
391 | { | 391 | { |
392 | } | 392 | } |
393 | 393 | ||
394 | void CategoryTabBar::layoutTabs() | 394 | void CategoryTabBar::layoutTabs() |
395 | { | 395 | { |
396 | if ( !count() ) | 396 | if ( !count() ) |
397 | return; | 397 | return; |
398 | 398 | ||
399 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 399 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
400 | int available = width()-1; | 400 | int available = width()-1; |
401 | QFontMetrics fm = fontMetrics(); | 401 | QFontMetrics fm = fontMetrics(); |
402 | int hiddenTabWidth = -7; | 402 | int hiddenTabWidth = -7; |
403 | int middleTab = currentTab(); | 403 | int middleTab = currentTab(); |
404 | int hframe, vframe, overlap; | 404 | int hframe, vframe, overlap; |
405 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 405 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
406 | int x = 0; | 406 | int x = 0; |
407 | QRect r; | 407 | QRect r; |
408 | QTab *t; | 408 | QTab *t; |
409 | int required = 0; | 409 | int required = 0; |
410 | int eventabwidth = (width()-1)/count(); | 410 | int eventabwidth = (width()-1)/count(); |
411 | enum Mode { HideBackText, Pack, Even } mode=Even; | 411 | enum Mode { HideBackText, Pack, Even } mode=Even; |
412 | for ( int i = 0; i < count(); i++ ) { | 412 | for ( int i = 0; i < count(); i++ ) { |
413 | t = tab(i); | 413 | t = tab(i); |
414 | int iw = fm.width( t->text() ) + hframe - overlap; | 414 | int iw = fm.width( t->text() ) + hframe - overlap; |
415 | if ( i != middleTab ) { | 415 | if ( i != middleTab ) { |
416 | available -= hiddenTabWidth + hframe - overlap; | 416 | available -= hiddenTabWidth + hframe - overlap; |
417 | if ( t->iconSet() != 0 ) | 417 | if ( t->iconSet() != 0 ) |
418 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 418 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
419 | } | 419 | } |
420 | if ( t->iconSet() != 0 ) | 420 | if ( t->iconSet() != 0 ) |
421 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 421 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
422 | required += iw; | 422 | required += iw; |
423 | // As space gets tight, packed looks better than even. "10" must be at least 0. | 423 | // As space gets tight, packed looks better than even. "10" must be at least 0. |
424 | if ( iw >= eventabwidth-10 ) | 424 | if ( iw >= eventabwidth-10 ) |
425 | mode = Pack; | 425 | mode = Pack; |
426 | } | 426 | } |
427 | if ( mode == Pack && required > width()-1 ) | 427 | if ( mode == Pack && required > width()-1 ) |
428 | mode = HideBackText; | 428 | mode = HideBackText; |
429 | for ( int i = 0; i < count(); i++ ) { | 429 | for ( int i = 0; i < count(); i++ ) { |
430 | t = tab(i); | 430 | t = tab(i); |
431 | if ( mode != HideBackText ) { | 431 | if ( mode != HideBackText ) { |
432 | int w = fm.width( t->text() ); | 432 | int w = fm.width( t->text() ); |
433 | int ih = 0; | 433 | int ih = 0; |
434 | if ( t->iconSet() != 0 ) { | 434 | if ( t->iconSet() != 0 ) { |
435 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 435 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
436 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 436 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
437 | } | 437 | } |
438 | int h = QMAX( fm.height(), ih ); | 438 | int h = QMAX( fm.height(), ih ); |
439 | h = QMAX( h, QApplication::globalStrut().height() ); | 439 | h = QMAX( h, QApplication::globalStrut().height() ); |
440 | 440 | ||
441 | h += vframe; | 441 | h += vframe; |
442 | w += hframe; | 442 | w += hframe; |
443 | 443 | ||
444 | QRect tr(x, 0, | 444 | QRect tr(x, 0, |
445 | mode == Even ? eventabwidth : w * (width()-1)/required, h); | 445 | mode == Even ? eventabwidth : w * (width()-1)/required, h); |
446 | t->setRect(tr); | 446 | t->setRect(tr); |
447 | x += tr.width() - overlap; | 447 | x += tr.width() - overlap; |
448 | r = r.unite(tr); | 448 | r = r.unite(tr); |
449 | } else if ( i != middleTab ) { | 449 | } else if ( i != middleTab ) { |
450 | int w = hiddenTabWidth; | 450 | int w = hiddenTabWidth; |
451 | int ih = 0; | 451 | int ih = 0; |
452 | if ( t->iconSet() != 0 ) { | 452 | if ( t->iconSet() != 0 ) { |
453 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 453 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
454 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 454 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
455 | } | 455 | } |
456 | int h = QMAX( fm.height(), ih ); | 456 | int h = QMAX( fm.height(), ih ); |
457 | h = QMAX( h, QApplication::globalStrut().height() ); | 457 | h = QMAX( h, QApplication::globalStrut().height() ); |
458 | 458 | ||
459 | h += vframe; | 459 | h += vframe; |
460 | w += hframe; | 460 | w += hframe; |
461 | 461 | ||
462 | t->setRect( QRect(x, 0, w, h) ); | 462 | t->setRect( QRect(x, 0, w, h) ); |
463 | x += t->rect().width() - overlap; | 463 | x += t->rect().width() - overlap; |
464 | r = r.unite( t->rect() ); | 464 | r = r.unite( t->rect() ); |
465 | } else { | 465 | } else { |
466 | int ih = 0; | 466 | int ih = 0; |
467 | if ( t->iconSet() != 0 ) { | 467 | if ( t->iconSet() != 0 ) { |
468 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 468 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
469 | } | 469 | } |
470 | int h = QMAX( fm.height(), ih ); | 470 | int h = QMAX( fm.height(), ih ); |
471 | h = QMAX( h, QApplication::globalStrut().height() ); | 471 | h = QMAX( h, QApplication::globalStrut().height() ); |
472 | 472 | ||
473 | h += vframe; | 473 | h += vframe; |
474 | 474 | ||
475 | t->setRect( QRect(x, 0, available, h) ); | 475 | t->setRect( QRect(x, 0, available, h) ); |
476 | x += t->rect().width() - overlap; | 476 | x += t->rect().width() - overlap; |
477 | r = r.unite( t->rect() ); | 477 | r = r.unite( t->rect() ); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | QRect rr = tab(count()-1)->rect(); | 481 | QRect rr = tab(count()-1)->rect(); |
482 | rr.setRight(width()-1); | 482 | rr.setRight(width()-1); |
483 | tab(count()-1)->setRect( rr ); | 483 | tab(count()-1)->setRect( rr ); |
484 | 484 | ||
485 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 485 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
486 | QRect tr = t->rect(); | 486 | QRect tr = t->rect(); |
487 | tr.setHeight( r.height() ); | 487 | tr.setHeight( r.height() ); |
488 | t->setRect( tr ); | 488 | t->setRect( tr ); |
489 | } | 489 | } |
490 | 490 | ||
491 | update(); | 491 | update(); |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 495 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
496 | { | 496 | { |
497 | CategoryTabBar *that = (CategoryTabBar *) this; | 497 | CategoryTabBar *that = (CategoryTabBar *) this; |
498 | CategoryTab *ct = (CategoryTab *)t; | 498 | CategoryTab *ct = (CategoryTab *)t; |
499 | QPalette pal = palette(); | 499 | QPalette pal = palette(); |
500 | bool setPal = FALSE; | 500 | bool setPal = FALSE; |
501 | if ( ct->bgColor.isValid() ) { | 501 | if ( ct->bgColor.isValid() ) { |
502 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); | 502 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); |
503 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); | 503 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); |
504 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); | 504 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); |
505 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); | 505 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); |
506 | that->setUpdatesEnabled( FALSE ); | 506 | that->setUpdatesEnabled( FALSE ); |
507 | that->setPalette( pal ); | 507 | that->setPalette( pal ); |
508 | setPal = TRUE; | 508 | setPal = TRUE; |
509 | } | 509 | } |
510 | #if QT_VERSION >= 300 | 510 | #if QT_VERSION >= 300 |
511 | QStyle::SFlags flags = QStyle::Style_Default; | 511 | QStyle::SFlags flags = QStyle::Style_Default; |
512 | if ( selected ) | 512 | if ( selected ) |
513 | flags |= QStyle::Style_Selected; | 513 | flags |= QStyle::Style_Selected; |
514 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 514 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
515 | colorGroup(), flags, QStyleOption(t) ); | 515 | colorGroup(), flags, QStyleOption(t) ); |
516 | #else | 516 | #else |
517 | style().drawTab( p, this, t, selected ); | 517 | style().drawTab( p, this, t, selected ); |
518 | #endif | 518 | #endif |
519 | 519 | ||
520 | QRect r( t->rect() ); | 520 | QRect r( t->rect() ); |
521 | QFont f( font() ); | 521 | QFont f( font() ); |
522 | if ( selected ) | 522 | if ( selected ) |
523 | f.setBold( TRUE ); | 523 | f.setBold( TRUE ); |
524 | p->setFont( f ); | 524 | p->setFont( f ); |
525 | 525 | ||
526 | if ( ct->fgColor.isValid() ) { | 526 | if ( ct->fgColor.isValid() ) { |
527 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); | 527 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); |
528 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); | 528 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); |
529 | that->setUpdatesEnabled( FALSE ); | 529 | that->setUpdatesEnabled( FALSE ); |
530 | that->setPalette( pal ); | 530 | that->setPalette( pal ); |
531 | setPal = TRUE; | 531 | setPal = TRUE; |
532 | } | 532 | } |
533 | int iw = 0; | 533 | int iw = 0; |
534 | int ih = 0; | 534 | int ih = 0; |
535 | if ( t->iconSet() != 0 ) { | 535 | if ( t->iconSet() != 0 ) { |
536 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 536 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
537 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 537 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
538 | } | 538 | } |
539 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 539 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
540 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 540 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
541 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 541 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
542 | r.top() + (r.height()-h)/2, w, h ), t, | 542 | r.top() + (r.height()-h)/2, w, h ), t, |
543 | #if QT_VERSION >= 300 | 543 | #if QT_VERSION >= 300 |
544 | t->identifier() == keyboardFocusTab() | 544 | t->identifier() == keyboardFocusTab() |
545 | #else | 545 | #else |
546 | t->identitifer() == keyboardFocusTab() | 546 | t->identitifer() == keyboardFocusTab() |
547 | #endif | 547 | #endif |
548 | ); | 548 | ); |
549 | if ( setPal ) { | 549 | if ( setPal ) { |
550 | that->unsetPalette(); | 550 | that->unsetPalette(); |
551 | that->setUpdatesEnabled( TRUE ); | 551 | that->setUpdatesEnabled( TRUE ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | 555 | ||
556 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 556 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
557 | QTab* t, bool has_focus ) const | 557 | QTab* t, bool has_focus ) const |
558 | { | 558 | { |
559 | QRect r = t->rect(); | 559 | QRect r = t->rect(); |
560 | // if ( t->id != currentTab() ) | 560 | // if ( t->id != currentTab() ) |
561 | //r.moveBy( 1, 1 ); | 561 | //r.moveBy( 1, 1 ); |
562 | // | 562 | // |
563 | if ( t->iconSet() ) { | 563 | if ( t->iconSet() ) { |
564 | // the tab has an iconset, draw it in the right mode | 564 | // the tab has an iconset, draw it in the right mode |
565 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 565 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
566 | if ( mode == QIconSet::Normal && has_focus ) | 566 | if ( mode == QIconSet::Normal && has_focus ) |
567 | mode = QIconSet::Active; | 567 | mode = QIconSet::Active; |
568 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 568 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
569 | int pixw = pixmap.width(); | 569 | int pixw = pixmap.width(); |
570 | int pixh = pixmap.height(); | 570 | int pixh = pixmap.height(); |
571 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 571 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
572 | r.setLeft( r.left() + pixw + 5 ); | 572 | r.setLeft( r.left() + pixw + 5 ); |
573 | } | 573 | } |
574 | 574 | ||
575 | QRect tr = r; | 575 | QRect tr = r; |
576 | 576 | ||
577 | if ( r.width() < 20 ) | 577 | if ( r.width() < 20 ) |
578 | return; | 578 | return; |
579 | 579 | ||
580 | if ( t->isEnabled() && isEnabled() ) { | 580 | if ( t->isEnabled() && isEnabled() ) { |
581 | #if defined(_WS_WIN32_) | 581 | #if defined(_WS_WIN32_) |
582 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 582 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
583 | p->setPen( colorGroup().buttonText() ); | 583 | p->setPen( colorGroup().buttonText() ); |
584 | else | 584 | else |
585 | p->setPen( colorGroup().foreground() ); | 585 | p->setPen( colorGroup().foreground() ); |
586 | #else | 586 | #else |
587 | p->setPen( colorGroup().foreground() ); | 587 | p->setPen( colorGroup().foreground() ); |
588 | #endif | 588 | #endif |
589 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 589 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
590 | } else { | 590 | } else { |
591 | p->setPen( palette().disabled().foreground() ); | 591 | p->setPen( palette().disabled().foreground() ); |
592 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 592 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
593 | } | 593 | } |
594 | } | 594 | } |
595 | 595 | ||
596 | //--------------------------------------------------------------------------- | 596 | //--------------------------------------------------------------------------- |
597 | 597 | ||
598 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 598 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
599 | : QMainWindow( parent, name, fl ) | 599 | : QMainWindow( parent, name, fl ) |
600 | { | 600 | { |
601 | setCaption( tr("Launcher") ); | 601 | setCaption( tr("Launcher") ); |
602 | 602 | ||
603 | syncDialog = 0; | 603 | syncDialog = 0; |
604 | 604 | ||
605 | // we have a pretty good idea how big we'll be | 605 | // we have a pretty good idea how big we'll be |
606 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 606 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
607 | 607 | ||
608 | tabs = 0; | 608 | tabs = 0; |
609 | rootFolder = 0; | 609 | rootFolder = 0; |
610 | docsFolder = 0; | 610 | docsFolder = 0; |
611 | 611 | ||
612 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know | 612 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
613 | //uidgen.store( stamp ); | 613 | //uidgen.store( stamp ); |
614 | m_timeStamp = QString::number( stamp ); | 614 | m_timeStamp = QString::number( stamp ); |
615 | 615 | ||
616 | tabs = new CategoryTabWidget( this ); | 616 | tabs = new CategoryTabWidget( this ); |
617 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 617 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
618 | setCentralWidget( tabs ); | 618 | setCentralWidget( tabs ); |
619 | 619 | ||
620 | connect( tabs, SIGNAL(selected(const QString&)), | 620 | connect( tabs, SIGNAL(selected(const QString&)), |
621 | this, SLOT(viewSelected(const QString&)) ); | 621 | this, SLOT(viewSelected(const QString&)) ); |
622 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 622 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
623 | this, SLOT(select(const AppLnk*))); | 623 | this, SLOT(select(const AppLnk*))); |
624 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 624 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
625 | this, SLOT(properties(AppLnk*))); | 625 | this, SLOT(properties(AppLnk*))); |
626 | 626 | ||
627 | #if !defined(QT_NO_COP) | 627 | #if !defined(QT_NO_COP) |
628 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 628 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
629 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 629 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
630 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 630 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
631 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 631 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
632 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 632 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
633 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); | 633 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); |
634 | #endif | 634 | #endif |
635 | 635 | ||
636 | storage = new StorageInfo( this ); | 636 | storage = new StorageInfo( this ); |
637 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 637 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
638 | 638 | ||
639 | updateTabs(); | 639 | updateTabs(); |
640 | 640 | ||
641 | preloadApps(); | 641 | preloadApps(); |
642 | 642 | ||
643 | in_lnk_props = FALSE; | 643 | in_lnk_props = FALSE; |
644 | got_lnk_change = FALSE; | 644 | got_lnk_change = FALSE; |
645 | } | 645 | } |
646 | 646 | ||
647 | Launcher::~Launcher() | 647 | Launcher::~Launcher() |
648 | { | 648 | { |
649 | delete rootFolder; | 649 | delete rootFolder; |
650 | delete docsFolder; | 650 | delete docsFolder; |
651 | } | 651 | } |
652 | 652 | ||
653 | static bool isVisibleWindow(int wid) | 653 | static bool isVisibleWindow(int wid) |
654 | { | 654 | { |
655 | #ifdef QWS | 655 | #ifdef QWS |
656 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 656 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
657 | QWSWindow* w; | 657 | QWSWindow* w; |
658 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 658 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
659 | if ( w->winId() == wid ) | 659 | if ( w->winId() == wid ) |
660 | return !w->isFullyObscured(); | 660 | return !w->isFullyObscured(); |
661 | } | 661 | } |
662 | #endif | 662 | #endif |
663 | return FALSE; | 663 | return FALSE; |
664 | } | 664 | } |
665 | 665 | ||
666 | void Launcher::showMaximized() | 666 | void Launcher::showMaximized() |
667 | { | 667 | { |
668 | if ( isVisibleWindow( winId() ) ) | 668 | if ( isVisibleWindow( winId() ) ) |
669 | doMaximize(); | 669 | doMaximize(); |
670 | else | 670 | else |
671 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 671 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
672 | } | 672 | } |
673 | 673 | ||
674 | void Launcher::doMaximize() | 674 | void Launcher::doMaximize() |
675 | { | 675 | { |
676 | QMainWindow::showMaximized(); | 676 | QMainWindow::showMaximized(); |
677 | } | 677 | } |
678 | 678 | ||
679 | void Launcher::updateMimeTypes() | 679 | void Launcher::updateMimeTypes() |
680 | { | 680 | { |
681 | MimeType::clear(); | 681 | MimeType::clear(); |
682 | updateMimeTypes(rootFolder); | 682 | updateMimeTypes(rootFolder); |
683 | } | 683 | } |
684 | 684 | ||
685 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 685 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
686 | { | 686 | { |
687 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 687 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
688 | AppLnk *app = it.current(); | 688 | AppLnk *app = it.current(); |
689 | if ( app->type() == "Folder" ) // No tr | 689 | if ( app->type() == "Folder" ) // No tr |
690 | updateMimeTypes((AppLnkSet *)app); | 690 | updateMimeTypes((AppLnkSet *)app); |
691 | else { | 691 | else { |
692 | MimeType::registerApp(*app); | 692 | MimeType::registerApp(*app); |
693 | } | 693 | } |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | /** This is a HACK.... | 697 | /** This is a HACK.... |
698 | * Reason: scanning huge mediums, microdirvers for examples | 698 | * Reason: scanning huge mediums, microdirvers for examples |
699 | * consomes time. To avoid that we invented the MediumMountCheck | 699 | * consomes time. To avoid that we invented the MediumMountCheck |
700 | * | 700 | * |
701 | * a) the user globally disabled medium checking. We can ignore | 701 | * a) the user globally disabled medium checking. We can ignore |
702 | * all removable medium | 702 | * all removable medium |
703 | * b) the user enabled medium checking globally and we need to use this mimefilter | 703 | * b) the user enabled medium checking globally and we need to use this mimefilter |
704 | * c) the user enabled medium checking on a per medium bases | 704 | * c) the user enabled medium checking on a per medium bases |
705 | * c1) we already checked and its not ask again turns | 705 | * c1) we already checked and its not ask again turns |
706 | * c2) we need to ask and then apply the mimefilter | 706 | * c2) we need to ask and then apply the mimefilter |
707 | */ | 707 | */ |
708 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 708 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
709 | { | 709 | { |
710 | delete docsFolder; | 710 | delete docsFolder; |
711 | docsFolder = new DocLnkSet; | 711 | docsFolder = new DocLnkSet; |
712 | 712 | ||
713 | DocLnkSet *tmp = 0; | 713 | DocLnkSet *tmp = 0; |
714 | QString home = QString(getenv("HOME")) + "/Documents"; | 714 | QString home = QString(getenv("HOME")) + "/Documents"; |
715 | tmp = new DocLnkSet( home , QString::null); | 715 | tmp = new DocLnkSet( home , QString::null); |
716 | docsFolder->appendFrom( *tmp ); | 716 | docsFolder->appendFrom( *tmp ); |
717 | delete tmp; | 717 | delete tmp; |
718 | 718 | ||
719 | // RAM documents | 719 | // RAM documents |
720 | StorageInfo storage; | 720 | StorageInfo storage; |
721 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 721 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
722 | QListIterator<FileSystem> it ( fileSystems ); | 722 | QListIterator<FileSystem> it ( fileSystems ); |
723 | 723 | ||
724 | for ( ; it.current(); ++it ) { | 724 | for ( ; it.current(); ++it ) { |
725 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 725 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
726 | tmp = new DocLnkSet( (*it)->path(), QString::null ); | 726 | tmp = new DocLnkSet( (*it)->path(), QString::null ); |
727 | docsFolder->appendFrom( *tmp ); | 727 | docsFolder->appendFrom( *tmp ); |
728 | delete tmp; | 728 | delete tmp; |
729 | } | 729 | } |
730 | } | 730 | } |
731 | 731 | ||
732 | Config mediumCfg( "medium"); | 732 | Config mediumCfg( "medium"); |
733 | mediumCfg.setGroup("main"); | 733 | mediumCfg.setGroup("main"); |
734 | // a) -zecke we don't want to check | 734 | // a) -zecke we don't want to check |
735 | if(!mediumCfg.readBoolEntry("use", true ) ) | 735 | if(!mediumCfg.readBoolEntry("use", true ) ) |
736 | return; | 736 | return; |
737 | 737 | ||
738 | // find out wich filesystems are new in this round | 738 | // find out wich filesystems are new in this round |
739 | // We will do this by having a timestamp inside each mountpoint | 739 | // We will do this by having a timestamp inside each mountpoint |
740 | // if the current timestamp doesn't match this is a new file system and | 740 | // if the current timestamp doesn't match this is a new file system and |
741 | // come up with our MediumMountGui :) let the hacking begin | 741 | // come up with our MediumMountGui :) let the hacking begin |
742 | int stamp = uidgen.generate(); | 742 | int stamp = uidgen.generate(); |
743 | 743 | ||
744 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 744 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
745 | 745 | ||
746 | // b) | 746 | // b) |
747 | if( mediumCfg.readBoolEntry("global", true ) ){ | 747 | if( mediumCfg.readBoolEntry("global", true ) ){ |
748 | QString mime = configToMime(&mediumCfg).join(";"); | 748 | QString mime = configToMime(&mediumCfg).join(";"); |
749 | for( it.toFirst(); it.current(); ++it ){ | 749 | for( it.toFirst(); it.current(); ++it ){ |
750 | if( (*it)->isRemovable() ){ | 750 | if( (*it)->isRemovable() ){ |
751 | tmp = new DocLnkSet( (*it)->path(), mime ); | 751 | tmp = new DocLnkSet( (*it)->path(), mime ); |
752 | docsFolder->appendFrom( *tmp ); | 752 | docsFolder->appendFrom( *tmp ); |
753 | delete tmp; | 753 | delete tmp; |
754 | } | 754 | } |
755 | } // done | 755 | } // done |
756 | return; // save the else | 756 | return; // save the else |
757 | } | 757 | } |
758 | // c) zecke | 758 | // c) zecke |
759 | for ( it.toFirst(); it.current(); ++it ) { | 759 | for ( it.toFirst(); it.current(); ++it ) { |
760 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 760 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
761 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); | 761 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); |
762 | cfg.setGroup("main"); | 762 | cfg.setGroup("main"); |
763 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 763 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
764 | /** This medium is uptodate | 764 | /** This medium is uptodate |
765 | */ | 765 | */ |
766 | if( stamp == m_timeStamp ){ // ok we know this card | 766 | if( stamp == m_timeStamp ){ // ok we know this card |
767 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp | 767 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
768 | // we need to scan the list now. Hopefully the cache will be there | 768 | // we need to scan the list now. Hopefully the cache will be there |
769 | // read the mimetypes from the config and search for documents | 769 | // read the mimetypes from the config and search for documents |
770 | QStringList mimetypes = configToMime( &cfg); | 770 | QStringList mimetypes = configToMime( &cfg); |
771 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | 771 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); |
772 | docsFolder->appendFrom( *tmp ); | 772 | docsFolder->appendFrom( *tmp ); |
773 | delete tmp; | 773 | delete tmp; |
774 | 774 | ||
775 | }else{ // come up with the gui cause this a new card | 775 | }else{ // come up with the gui cause this a new card |
776 | MediumMountGui medium(&cfg, (*it)->path() ); | 776 | MediumMountGui medium(&cfg, (*it)->path() ); |
777 | if( medium.check() ){ // we did not ask before or ask again is off | 777 | if( medium.check() ){ // we did not ask before or ask again is off |
778 | /** c2) */ | 778 | /** c2) */ |
779 | if( medium.exec() ){ // he clicked yes so search it | 779 | if( medium.exec() ){ // he clicked yes so search it |
780 | // speicher | 780 | // speicher |
781 | //cfg.read(); // cause of a race we need to reread - fixed | 781 | //cfg.read(); // cause of a race we need to reread - fixed |
782 | cfg.setGroup("main"); | 782 | cfg.setGroup("main"); |
783 | cfg.writeEntry("timestamp", newStamp ); | 783 | cfg.writeEntry("timestamp", newStamp ); |
784 | cfg.write(); | 784 | cfg.write(); |
785 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); | 785 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); |
786 | docsFolder->appendFrom( *tmp ); | 786 | docsFolder->appendFrom( *tmp ); |
787 | delete tmp; | 787 | delete tmp; |
788 | }// no else | 788 | }// no else |
789 | /** c1) */ | 789 | /** c1) */ |
790 | }else{ // we checked | 790 | }else{ // we checked |
791 | // do something different see what we need to do | 791 | // do something different see what we need to do |
792 | // let's see if we should check the device | 792 | // let's see if we should check the device |
793 | cfg.setGroup("main" ); | 793 | cfg.setGroup("main" ); |
794 | bool check = cfg.readBoolEntry("autocheck", true ); | 794 | bool check = cfg.readBoolEntry("autocheck", true ); |
795 | if( check ){ // find the documents | 795 | if( check ){ // find the documents |
796 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 796 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
797 | docsFolder->appendFrom( *tmp ); | 797 | docsFolder->appendFrom( *tmp ); |
798 | delete tmp; | 798 | delete tmp; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | } | 801 | } |
802 | } | 802 | } |
803 | } | 803 | } |
804 | m_timeStamp = newStamp; | 804 | m_timeStamp = newStamp; |
805 | } | 805 | } |
806 | 806 | ||
807 | void Launcher::updateTabs() | 807 | void Launcher::updateTabs() |
808 | { | 808 | { |
809 | MimeType::updateApplications(); // ### reads all applnks twice | 809 | MimeType::updateApplications(); // ### reads all applnks twice |
810 | 810 | ||
811 | delete rootFolder; | 811 | delete rootFolder; |
812 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 812 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
813 | 813 | ||
814 | loadDocs(); | 814 | loadDocs(); |
815 | 815 | ||
816 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 816 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
817 | } | 817 | } |
818 | 818 | ||
819 | void Launcher::updateDocs() | 819 | void Launcher::updateDocs() |
820 | { | 820 | { |
821 | loadDocs(); | 821 | loadDocs(); |
822 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 822 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
823 | } | 823 | } |
824 | 824 | ||
825 | void Launcher::viewSelected(const QString& s) | 825 | void Launcher::viewSelected(const QString& s) |
826 | { | 826 | { |
827 | setCaption( s + tr(" - Launcher") ); | 827 | setCaption( s + tr(" - Launcher") ); |
828 | } | 828 | } |
829 | 829 | ||
830 | void Launcher::nextView() | 830 | void Launcher::nextView() |
831 | { | 831 | { |
832 | tabs->nextTab(); | 832 | tabs->nextTab(); |
833 | } | 833 | } |
834 | 834 | ||
835 | 835 | ||
836 | void Launcher::select( const AppLnk *appLnk ) | 836 | void Launcher::select( const AppLnk *appLnk ) |
837 | { | 837 | { |
838 | if ( appLnk->type() == "Folder" ) { // No tr | 838 | if ( appLnk->type() == "Folder" ) { // No tr |
839 | // Not supported: flat is simpler for the user | 839 | // Not supported: flat is simpler for the user |
840 | } else { | 840 | } else { |
841 | if ( appLnk->exec().isNull() ) { | 841 | if ( appLnk->exec().isNull() ) { |
842 | QMessageBox::information(this,tr("No application"), | 842 | QMessageBox::information(this,tr("No application"), |
843 | tr("<p>No application is defined for this document." | 843 | tr("<p>No application is defined for this document." |
844 | "<p>Type is %1.").arg(appLnk->type())); | 844 | "<p>Type is %1.").arg(appLnk->type())); |
845 | return; | 845 | return; |
846 | } | 846 | } |
847 | tabs->setBusy(TRUE); | 847 | tabs->setBusy(TRUE); |
848 | emit executing( appLnk ); | 848 | emit executing( appLnk ); |
849 | appLnk->execute(); | 849 | appLnk->execute(); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
853 | void Launcher::externalSelected(const AppLnk *appLnk) | 853 | void Launcher::externalSelected(const AppLnk *appLnk) |
854 | { | 854 | { |
855 | tabs->setBusy(TRUE); | 855 | tabs->setBusy(TRUE); |
856 | emit executing( appLnk ); | 856 | emit executing( appLnk ); |
857 | } | 857 | } |
858 | 858 | ||
859 | void Launcher::properties( AppLnk *appLnk ) | 859 | void Launcher::properties( AppLnk *appLnk ) |
860 | { | 860 | { |
861 | if ( appLnk->type() == "Folder" ) { // No tr | 861 | if ( appLnk->type() == "Folder" ) { // No tr |
862 | // Not supported: flat is simpler for the user | 862 | // Not supported: flat is simpler for the user |
863 | } else { | 863 | } else { |
864 | in_lnk_props = TRUE; | 864 | in_lnk_props = TRUE; |
865 | got_lnk_change = FALSE; | 865 | got_lnk_change = FALSE; |
866 | LnkProperties prop(appLnk); | 866 | LnkProperties prop(appLnk); |
867 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 867 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
868 | prop.showMaximized(); | 868 | prop.showMaximized(); |
869 | prop.exec(); | 869 | prop.exec(); |
870 | in_lnk_props = FALSE; | 870 | in_lnk_props = FALSE; |
871 | if ( got_lnk_change ) { | 871 | if ( got_lnk_change ) { |
872 | updateLink(lnk_change); | 872 | updateLink(lnk_change); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void Launcher::updateLink(const QString& link) | 877 | void Launcher::updateLink(const QString& link) |
878 | { | 878 | { |
879 | if (link.isNull()) | 879 | if (link.isNull()) |
880 | updateTabs(); | 880 | updateTabs(); |
881 | else if (link.isEmpty()) | 881 | else if (link.isEmpty()) |
882 | updateDocs(); | 882 | updateDocs(); |
883 | else | 883 | else |
884 | tabs->updateLink(link); | 884 | tabs->updateLink(link); |
885 | } | 885 | } |
886 | 886 | ||
887 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 887 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
888 | { | 888 | { |
889 | QDataStream stream( data, IO_ReadOnly ); | 889 | QDataStream stream( data, IO_ReadOnly ); |
890 | if ( msg == "linkChanged(QString)" ) { | 890 | if ( msg == "linkChanged(QString)" ) { |
891 | QString link; | 891 | QString link; |
892 | stream >> link; | 892 | stream >> link; |
893 | if ( in_lnk_props ) { | 893 | if ( in_lnk_props ) { |
894 | got_lnk_change = TRUE; | 894 | got_lnk_change = TRUE; |
895 | lnk_change = link; | 895 | lnk_change = link; |
896 | } else { | 896 | } else { |
897 | updateLink(link); | 897 | updateLink(link); |
898 | } | 898 | } |
899 | } else if ( msg == "busy()" ) { | 899 | } else if ( msg == "busy()" ) { |
900 | emit busy(); | 900 | emit busy(); |
901 | } else if ( msg == "notBusy(QString)" ) { | 901 | } else if ( msg == "notBusy(QString)" ) { |
902 | QString app; | 902 | QString app; |
903 | stream >> app; | 903 | stream >> app; |
904 | tabs->setBusy(FALSE); | 904 | tabs->setBusy(FALSE); |
905 | emit notBusy(app); | 905 | emit notBusy(app); |
906 | } else if ( msg == "mkdir(QString)" ) { | 906 | } else if ( msg == "mkdir(QString)" ) { |
907 | QString dir; | 907 | QString dir; |
908 | stream >> dir; | 908 | stream >> dir; |
909 | if ( !dir.isEmpty() ) | 909 | if ( !dir.isEmpty() ) |
910 | mkdir( dir ); | 910 | mkdir( dir ); |
911 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 911 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
912 | QString baseFile, sigFile; | 912 | QString baseFile, sigFile; |
913 | stream >> baseFile >> sigFile; | 913 | stream >> baseFile >> sigFile; |
914 | QRsync::generateSignature( baseFile, sigFile ); | 914 | QRsync::generateSignature( baseFile, sigFile ); |
915 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 915 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
916 | QString baseFile, sigFile, deltaFile; | 916 | QString baseFile, sigFile, deltaFile; |
917 | stream >> baseFile >> sigFile >> deltaFile; | 917 | stream >> baseFile >> sigFile >> deltaFile; |
918 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 918 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
919 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 919 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
920 | QString baseFile, deltaFile; | 920 | QString baseFile, deltaFile; |
921 | stream >> baseFile >> deltaFile; | 921 | stream >> baseFile >> deltaFile; |
922 | if ( !QFile::exists( baseFile ) ) { | 922 | if ( !QFile::exists( baseFile ) ) { |
923 | QFile f( baseFile ); | 923 | QFile f( baseFile ); |
924 | f.open( IO_WriteOnly ); | 924 | f.open( IO_WriteOnly ); |
925 | f.close(); | 925 | f.close(); |
926 | } | 926 | } |
927 | QRsync::applyDiff( baseFile, deltaFile ); | 927 | QRsync::applyDiff( baseFile, deltaFile ); |
928 | #ifndef QT_NO_COP | 928 | #ifndef QT_NO_COP |
929 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 929 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
930 | e << baseFile; | 930 | e << baseFile; |
931 | #endif | 931 | #endif |
932 | } else if ( msg == "rdiffCleanup()" ) { | 932 | } else if ( msg == "rdiffCleanup()" ) { |
933 | mkdir( "/tmp/rdiff" ); | 933 | mkdir( "/tmp/rdiff" ); |
934 | QDir dir; | 934 | QDir dir; |
935 | dir.setPath( "/tmp/rdiff" ); | 935 | dir.setPath( "/tmp/rdiff" ); |
936 | QStringList entries = dir.entryList(); | 936 | QStringList entries = dir.entryList(); |
937 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 937 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
938 | dir.remove( *it ); | 938 | dir.remove( *it ); |
939 | } else if ( msg == "sendHandshakeInfo()" ) { | 939 | } else if ( msg == "sendHandshakeInfo()" ) { |
940 | QString home = getenv( "HOME" ); | 940 | QString home = getenv( "HOME" ); |
941 | #ifndef QT_NO_COP | 941 | #ifndef QT_NO_COP |
942 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 942 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
943 | e << home; | 943 | e << home; |
944 | int locked = (int) Desktop::screenLocked(); | 944 | int locked = (int) Desktop::screenLocked(); |
945 | e << locked; | 945 | e << locked; |
946 | #endif | 946 | #endif |
947 | } else if ( msg == "autoStart(QString)" ) { | 947 | } else if ( msg == "autoStart(QString)" ) { |
948 | QString appName; | 948 | QString appName; |
949 | stream >> appName; | 949 | stream >> appName; |
950 | Config cfg( "autostart" ); | 950 | Config cfg( "autostart" ); |
951 | cfg.setGroup( "AutoStart" ); | 951 | cfg.setGroup( "AutoStart" ); |
952 | if ( appName.compare("clear") == 0){ | 952 | if ( appName.compare("clear") == 0){ |
953 | cfg.writeEntry("Apps", ""); | 953 | cfg.writeEntry("Apps", ""); |
954 | } | 954 | } |
955 | } else if ( msg == "autoStart(QString,QString)" ) { | 955 | } else if ( msg == "autoStart(QString,QString)" ) { |
956 | QString modifier, appName; | 956 | QString modifier, appName; |
957 | stream >> modifier >> appName; | 957 | stream >> modifier >> appName; |
958 | Config cfg( "autostart" ); | 958 | Config cfg( "autostart" ); |
959 | cfg.setGroup( "AutoStart" ); | 959 | cfg.setGroup( "AutoStart" ); |
960 | if ( modifier.compare("add") == 0 ){ | 960 | if ( modifier.compare("add") == 0 ){ |
961 | // only add if appname is entered | 961 | // only add if appname is entered |
962 | if (!appName.isEmpty()) { | 962 | if (!appName.isEmpty()) { |
963 | cfg.writeEntry("Apps", appName); | 963 | cfg.writeEntry("Apps", appName); |
964 | } | 964 | } |
965 | } else if (modifier.compare("remove") == 0 ) { | 965 | } else if (modifier.compare("remove") == 0 ) { |
966 | // need to change for multiple entries | 966 | // need to change for multiple entries |
967 | // actually remove is right now simular to clear, but in future there | 967 | // actually remove is right now simular to clear, but in future there |
968 | // should be multiple apps in autostart possible. | 968 | // should be multiple apps in autostart possible. |
969 | QString checkName; | 969 | QString checkName; |
970 | checkName = cfg.readEntry("Apps", ""); | 970 | checkName = cfg.readEntry("Apps", ""); |
971 | if (checkName == appName) { | 971 | if (checkName == appName) { |
972 | cfg.writeEntry("Apps", ""); | 972 | cfg.writeEntry("Apps", ""); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | // case the autostart feature should be delayed | 975 | // case the autostart feature should be delayed |
976 | } else if ( msg == "autoStart(QString,QString,QString)") { | 976 | } else if ( msg == "autoStart(QString,QString,QString)") { |
977 | QString modifier, appName, delay; | 977 | QString modifier, appName, delay; |
978 | stream >> modifier >> appName >> delay; | 978 | stream >> modifier >> appName >> delay; |
979 | Config cfg( "autostart" ); | 979 | Config cfg( "autostart" ); |
980 | cfg.setGroup( "AutoStart" ); | 980 | cfg.setGroup( "AutoStart" ); |
981 | if ( modifier.compare("add") == 0 ){ | 981 | if ( modifier.compare("add") == 0 ){ |
982 | // only add it appname is entered | 982 | // only add it appname is entered |
983 | if (!appName.isEmpty()) { | 983 | if (!appName.isEmpty()) { |
984 | cfg.writeEntry("Apps", appName); | 984 | cfg.writeEntry("Apps", appName); |
985 | cfg.writeEntry("Delay", delay); | 985 | cfg.writeEntry("Delay", delay); |
986 | } | 986 | } |
987 | } else { | 987 | } else { |
988 | } | 988 | } |
989 | } | 989 | } |
990 | /* | 990 | /* |
991 | * QtopiaDesktop relies on the major number | 991 | * QtopiaDesktop relies on the major number |
992 | * to start with 1. We're at 0.9 | 992 | * to start with 1. We're at 0.9 |
993 | * so wee need to fake at least 1.4 to be able | 993 | * so wee need to fake at least 1.4 to be able |
994 | * to sync with QtopiaDesktop1.6 | 994 | * to sync with QtopiaDesktop1.6 |
995 | */ | 995 | */ |
996 | else if ( msg == "sendVersionInfo()" ) { | 996 | else if ( msg == "sendVersionInfo()" ) { |
997 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); | 997 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); |
998 | QString v2 = QString::fromLatin1("1.4"); | 998 | QString v2 = QString::fromLatin1("1.4"); |
999 | e << v2; | 999 | e << v2; |
1000 | //qDebug("version %s\n", line.latin1()); | 1000 | //qDebug("version %s\n", line.latin1()); |
1001 | } else if ( msg == "sendCardInfo()" ) { | 1001 | } else if ( msg == "sendCardInfo()" ) { |
1002 | #ifndef QT_NO_COP | 1002 | #ifndef QT_NO_COP |
1003 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 1003 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
1004 | #endif | 1004 | #endif |
1005 | const QList<FileSystem> &fs = storage->fileSystems(); | 1005 | const QList<FileSystem> &fs = storage->fileSystems(); |
1006 | QListIterator<FileSystem> it ( fs ); | 1006 | QListIterator<FileSystem> it ( fs ); |
1007 | QString s; | 1007 | QString s; |
1008 | QString homeDir = getenv("HOME"); | 1008 | QString homeDir = getenv("HOME"); |
1009 | QString hardDiskHome, hardDiskHomePath; | 1009 | QString hardDiskHome, hardDiskHomePath; |
1010 | for ( ; it.current(); ++it ) { | 1010 | for ( ; it.current(); ++it ) { |
1011 | int k4 = (*it)->blockSize()/256; | 1011 | int k4 = (*it)->blockSize()/256; |
1012 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { | 1012 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { |
1013 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 1013 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
1014 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1014 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1015 | + "K " + (*it)->options() + ";"; | 1015 | + "K " + (*it)->options() + ";"; |
1016 | } else if ( (*it)->disk() == "/dev/mtdblock1" || | 1016 | } else if ( (*it)->disk() == "/dev/mtdblock1" || |
1017 | (*it)->disk() == "/dev/mtdblock/1" ) { | 1017 | (*it)->disk() == "/dev/mtdblock/1" ) { |
1018 | s += (*it)->name() + "=" + homeDir + "/Documents " | 1018 | s += (*it)->name() + "=" + homeDir + "/Documents " |
1019 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1019 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1020 | + "K " + (*it)->options() + ";"; | 1020 | + "K " + (*it)->options() + ";"; |
1021 | } else if ( (*it)->name().contains( "Hard Disk") && | 1021 | } else if ( (*it)->name().contains( "Hard Disk") && |
1022 | homeDir.contains( (*it)->path() ) && | 1022 | homeDir.contains( (*it)->path() ) && |
1023 | (*it)->path().length() > hardDiskHomePath.length() ) { | 1023 | (*it)->path().length() > hardDiskHomePath.length() ) { |
1024 | hardDiskHomePath = (*it)->path(); | 1024 | hardDiskHomePath = (*it)->path(); |
1025 | hardDiskHome = | 1025 | hardDiskHome = |
1026 | (*it)->name() + "=" + homeDir + "/Documents " | 1026 | (*it)->name() + "=" + homeDir + "/Documents " |
1027 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1027 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1028 | + "K " + (*it)->options() + ";"; | 1028 | + "K " + (*it)->options() + ";"; |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | if ( !hardDiskHome.isEmpty() ) | 1031 | if ( !hardDiskHome.isEmpty() ) |
1032 | s += hardDiskHome; | 1032 | s += hardDiskHome; |
1033 | 1033 | ||
1034 | #ifndef QT_NO_COP | 1034 | #ifndef QT_NO_COP |
1035 | e << s; | 1035 | e << s; |
1036 | #endif | 1036 | #endif |
1037 | } else if ( msg == "sendSyncDate(QString)" ) { | 1037 | } else if ( msg == "sendSyncDate(QString)" ) { |
1038 | QString app; | 1038 | QString app; |
1039 | stream >> app; | 1039 | stream >> app; |
1040 | Config cfg( "qpe" ); | 1040 | Config cfg( "qpe" ); |
1041 | cfg.setGroup("SyncDate"); | 1041 | cfg.setGroup("SyncDate"); |
1042 | #ifndef QT_NO_COP | 1042 | #ifndef QT_NO_COP |
1043 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 1043 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
1044 | e << app << cfg.readEntry( app ); | 1044 | e << app << cfg.readEntry( app ); |
1045 | #endif | 1045 | #endif |
1046 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 1046 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
1047 | //cfg.readEntry( app ).latin1() ); | 1047 | //cfg.readEntry( app ).latin1() ); |
1048 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 1048 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
1049 | QString app, date; | 1049 | QString app, date; |
1050 | stream >> app >> date; | 1050 | stream >> app >> date; |
1051 | Config cfg( "qpe" ); | 1051 | Config cfg( "qpe" ); |
1052 | cfg.setGroup("SyncDate"); | 1052 | cfg.setGroup("SyncDate"); |
1053 | cfg.writeEntry( app, date ); | 1053 | cfg.writeEntry( app, date ); |
1054 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 1054 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
1055 | } else if ( msg == "startSync(QString)" ) { | 1055 | } else if ( msg == "startSync(QString)" ) { |
1056 | QString what; | 1056 | QString what; |
1057 | stream >> what; | 1057 | stream >> what; |
1058 | delete syncDialog; syncDialog = 0; | 1058 | delete syncDialog; syncDialog = 0; |
1059 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 1059 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
1060 | WStyle_Tool | WStyle_Customize | | 1060 | WStyle_Tool | WStyle_Customize | |
1061 | Qt::WStyle_StaysOnTop ); | 1061 | Qt::WStyle_StaysOnTop ); |
1062 | syncDialog->showMaximized(); | 1062 | syncDialog->showMaximized(); |
1063 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 1063 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
1064 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 1064 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
1065 | SLOT( cancelSync() ) ); | 1065 | SLOT( cancelSync() ) ); |
1066 | } else if ( msg == "stopSync()") { | 1066 | } else if ( msg == "stopSync()") { |
1067 | delete syncDialog; syncDialog = 0; | 1067 | delete syncDialog; syncDialog = 0; |
1068 | } else if ( msg == "getAllDocLinks()" ) { | 1068 | } else if ( msg == "getAllDocLinks()" ) { |
1069 | loadDocs(); | 1069 | loadDocs(); |
1070 | 1070 | ||
1071 | QString contents; | 1071 | QString contents; |
1072 | 1072 | ||
1073 | //Categories cats; | 1073 | //Categories cats; |
1074 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 1074 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
1075 | DocLnk *doc = it.current(); | 1075 | DocLnk *doc = it.current(); |
1076 | QFileInfo fi( doc->file() ); | 1076 | QFileInfo fi( doc->file() ); |
1077 | if ( !fi.exists() ) | 1077 | if ( !fi.exists() ) |
1078 | continue; | 1078 | continue; |
1079 | 1079 | ||
1080 | bool fake = !doc->linkFileKnown(); | 1080 | bool fake = !doc->linkFileKnown(); |
1081 | if ( !fake ) { | 1081 | if ( !fake ) { |
1082 | QFile f( doc->linkFile() ); | 1082 | QFile f( doc->linkFile() ); |
1083 | if ( f.open( IO_ReadOnly ) ) { | 1083 | if ( f.open( IO_ReadOnly ) ) { |
1084 | QTextStream ts( &f ); | 1084 | QTextStream ts( &f ); |
1085 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 1085 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
1086 | contents += ts.read(); | 1086 | contents += ts.read(); |
1087 | f.close(); | 1087 | f.close(); |
1088 | } else | 1088 | } else |
1089 | fake = TRUE; | 1089 | fake = TRUE; |
1090 | } | 1090 | } |
1091 | if (fake) { | 1091 | if (fake) { |
1092 | contents += "[Desktop Entry]\n"; | 1092 | contents += "[Desktop Entry]\n"; |
1093 | contents += "Categories = " + // No tr | 1093 | contents += "Categories = " + // No tr |
1094 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 1094 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
1095 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 1095 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
1096 | contents += "Name = "+doc->name()+"\n"; // No tr | 1096 | contents += "Name = "+doc->name()+"\n"; // No tr |
1097 | contents += "Type = "+doc->type()+"\n"; // No tr | 1097 | contents += "Type = "+doc->type()+"\n"; // No tr |
1098 | } | 1098 | } |
1099 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 1099 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
1100 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 1100 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | //qDebug( "sending length %d", contents.length() ); | 1103 | //qDebug( "sending length %d", contents.length() ); |
1104 | #ifndef QT_NO_COP | 1104 | #ifndef QT_NO_COP |
1105 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 1105 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
1106 | e << contents; | 1106 | e << contents; |
1107 | #endif | 1107 | #endif |
1108 | 1108 | ||
1109 | //qDebug( "================ \n\n%s\n\n===============", | 1109 | //qDebug( "================ \n\n%s\n\n===============", |
1110 | //contents.latin1() ); | 1110 | //contents.latin1() ); |
1111 | 1111 | ||
1112 | delete docsFolder; | 1112 | delete docsFolder; |
1113 | docsFolder = 0; | 1113 | docsFolder = 0; |
1114 | #ifdef QWS | 1114 | #ifdef QWS |
1115 | } else if ( msg == "setMouseProto(QString)" ) { | 1115 | } else if ( msg == "setMouseProto(QString)" ) { |
1116 | QString mice; | 1116 | QString mice; |
1117 | stream >> mice; | 1117 | stream >> mice; |
1118 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 1118 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
1119 | qwsServer->openMouse(); | 1119 | qwsServer->openMouse(); |
1120 | } else if ( msg == "setKeyboard(QString)" ) { | 1120 | } else if ( msg == "setKeyboard(QString)" ) { |
1121 | QString kb; | 1121 | QString kb; |
1122 | stream >> kb; | 1122 | stream >> kb; |
1123 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 1123 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
1124 | qwsServer->openKeyboard(); | 1124 | qwsServer->openKeyboard(); |
1125 | #endif | 1125 | #endif |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | void Launcher::cancelSync() | 1129 | void Launcher::cancelSync() |
1130 | { | 1130 | { |
1131 | #ifndef QT_NO_COP | 1131 | #ifndef QT_NO_COP |
1132 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 1132 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
1133 | #endif | 1133 | #endif |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) | 1136 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) |
1137 | { | 1137 | { |
1138 | QDataStream stream( data, IO_ReadOnly ); | 1138 | QDataStream stream( data, IO_ReadOnly ); |
1139 | if ( msg == "setTabView(QString,int)" ) { | 1139 | if ( msg == "setTabView(QString,int)" ) { |
1140 | QString id; | 1140 | QString id; |
1141 | stream >> id; | 1141 | stream >> id; |
1142 | int mode; | 1142 | int mode; |
1143 | stream >> mode; | 1143 | stream >> mode; |
1144 | if ( tabs->view(id) ) | 1144 | if ( tabs->view(id) ) |
1145 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 1145 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
1146 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 1146 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
1147 | QString id; | 1147 | QString id; |
1148 | stream >> id; | 1148 | stream >> id; |
1149 | int mode; | 1149 | int mode; |
1150 | stream >> mode; | 1150 | stream >> mode; |
1151 | QString pixmapOrColor; | 1151 | QString pixmapOrColor; |
1152 | stream >> pixmapOrColor; | 1152 | stream >> pixmapOrColor; |
1153 | if ( tabs->view(id) ) | 1153 | if ( tabs->view(id) ) |
1154 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 1154 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
1155 | } else if ( msg == "setTextColor(QString,QString)" ) { | 1155 | } else if ( msg == "setTextColor(QString,QString)" ) { |
1156 | QString id; | 1156 | QString id; |
1157 | stream >> id; | 1157 | stream >> id; |
1158 | QString color; | 1158 | QString color; |
1159 | stream >> color; | 1159 | stream >> color; |
1160 | if ( tabs->view(id) ) | 1160 | if ( tabs->view(id) ) |
1161 | tabs->view(id)->setTextColor( QColor(color) ); | 1161 | tabs->view(id)->setTextColor( QColor(color) ); |
1162 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 1162 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
1163 | QString id; | 1163 | QString id; |
1164 | stream >> id; | 1164 | stream >> id; |
1165 | QString fam; | 1165 | QString fam; |
1166 | stream >> fam; | 1166 | stream >> fam; |
1167 | int size; | 1167 | int size; |
1168 | stream >> size; | 1168 | stream >> size; |
1169 | int weight; | 1169 | int weight; |
1170 | stream >> weight; | 1170 | stream >> weight; |
1171 | int italic; | 1171 | int italic; |
1172 | stream >> italic; | 1172 | stream >> italic; |
1173 | if ( tabs->view(id) ) | 1173 | if ( tabs->view(id) ) |
1174 | if ( !fam. isEmpty ( )) | 1174 | if ( !fam. isEmpty ( )) |
1175 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 1175 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
1176 | else | 1176 | else |
1177 | tabs->view(id)->unsetViewFont(); | 1177 | tabs->view(id)->unsetViewFont(); |
1178 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 1178 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
1179 | } | 1179 | } |
1180 | else if ( msg == "setBusyIndicatorType(QString)" ) { | 1180 | else if ( msg == "setBusyIndicatorType(QString)" ) { |
1181 | QString type; | 1181 | QString type; |
1182 | stream >> type; | 1182 | stream >> type; |
1183 | tabs->setBusyIndicatorType(type); | 1183 | tabs->setBusyIndicatorType(type); |
1184 | } | 1184 | } |
1185 | else if ( msg == "home()" ) { | ||
1186 | if ( isVisibleWindow( winId ( ))) | ||
1187 | nextView ( ); | ||
1188 | else | ||
1189 | raise ( ); | ||
1190 | |||
1191 | } | ||
1185 | } | 1192 | } |
1186 | 1193 | ||
1187 | void Launcher::storageChanged() | 1194 | void Launcher::storageChanged() |
1188 | { | 1195 | { |
1189 | if ( in_lnk_props ) { | 1196 | if ( in_lnk_props ) { |
1190 | got_lnk_change = TRUE; | 1197 | got_lnk_change = TRUE; |
1191 | lnk_change = QString::null; | 1198 | lnk_change = QString::null; |
1192 | } else { | 1199 | } else { |
1193 | updateLink( QString::null ); | 1200 | updateLink( QString::null ); |
1194 | } | 1201 | } |
1195 | } | 1202 | } |
1196 | 1203 | ||
1197 | 1204 | ||
1198 | bool Launcher::mkdir(const QString &localPath) | 1205 | bool Launcher::mkdir(const QString &localPath) |
1199 | { | 1206 | { |
1200 | QDir fullDir(localPath); | 1207 | QDir fullDir(localPath); |
1201 | if (fullDir.exists()) | 1208 | if (fullDir.exists()) |
1202 | return true; | 1209 | return true; |
1203 | 1210 | ||
1204 | // at this point the directory doesn't exist | 1211 | // at this point the directory doesn't exist |
1205 | // go through the directory tree and start creating the direcotories | 1212 | // go through the directory tree and start creating the direcotories |
1206 | // that don't exist; if we can't create the directories, return false | 1213 | // that don't exist; if we can't create the directories, return false |
1207 | 1214 | ||
1208 | QString dirSeps = "/"; | 1215 | QString dirSeps = "/"; |
1209 | int dirIndex = localPath.find(dirSeps); | 1216 | int dirIndex = localPath.find(dirSeps); |
1210 | QString checkedPath; | 1217 | QString checkedPath; |
1211 | 1218 | ||
1212 | // didn't find any seps; weird, use the cur dir instead | 1219 | // didn't find any seps; weird, use the cur dir instead |
1213 | if (dirIndex == -1) { | 1220 | if (dirIndex == -1) { |
1214 | //qDebug("No seperators found in path %s", localPath.latin1()); | 1221 | //qDebug("No seperators found in path %s", localPath.latin1()); |
1215 | checkedPath = QDir::currentDirPath(); | 1222 | checkedPath = QDir::currentDirPath(); |
1216 | } | 1223 | } |
1217 | 1224 | ||
1218 | while (checkedPath != localPath) { | 1225 | while (checkedPath != localPath) { |
1219 | // no more seperators found, use the local path | 1226 | // no more seperators found, use the local path |
1220 | if (dirIndex == -1) | 1227 | if (dirIndex == -1) |
1221 | checkedPath = localPath; | 1228 | checkedPath = localPath; |
1222 | else { | 1229 | else { |
1223 | // the next directory to check | 1230 | // the next directory to check |
1224 | checkedPath = localPath.left(dirIndex) + "/"; | 1231 | checkedPath = localPath.left(dirIndex) + "/"; |
1225 | // advance the iterator; the next dir seperator | 1232 | // advance the iterator; the next dir seperator |
1226 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 1233 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
1227 | } | 1234 | } |
1228 | 1235 | ||
1229 | QDir checkDir(checkedPath); | 1236 | QDir checkDir(checkedPath); |
1230 | if (!checkDir.exists()) { | 1237 | if (!checkDir.exists()) { |
1231 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 1238 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
1232 | 1239 | ||
1233 | if (!checkDir.mkdir(checkedPath)) { | 1240 | if (!checkDir.mkdir(checkedPath)) { |
1234 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 1241 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
1235 | return FALSE; | 1242 | return FALSE; |
1236 | } | 1243 | } |
1237 | } | 1244 | } |
1238 | 1245 | ||
1239 | } | 1246 | } |
1240 | return TRUE; | 1247 | return TRUE; |
1241 | } | 1248 | } |
1242 | 1249 | ||
1243 | void Launcher::preloadApps() | 1250 | void Launcher::preloadApps() |
1244 | { | 1251 | { |
1245 | Config cfg("Launcher"); | 1252 | Config cfg("Launcher"); |
1246 | cfg.setGroup("Preload"); | 1253 | cfg.setGroup("Preload"); |
1247 | QStringList apps = cfg.readListEntry("Apps",','); | 1254 | QStringList apps = cfg.readListEntry("Apps",','); |
1248 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1255 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1249 | #ifndef QT_NO_COP | 1256 | #ifndef QT_NO_COP |
1250 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1257 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
1251 | #endif | 1258 | #endif |
1252 | } | 1259 | } |
1253 | } | 1260 | } |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 8b91f5d..49b41d6 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,182 +1,177 @@ | |||
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 "taskbar.h" | 22 | #include "taskbar.h" |
23 | #include "stabmon.h" | 23 | #include "stabmon.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/network.h> | 26 | #include <qpe/network.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) | 28 | #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) |
29 | #include <qpe/custom.h> | 29 | #include <qpe/custom.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <opie/odevice.h> | 32 | #include <opie/odevice.h> |
33 | 33 | ||
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/alarmserver.h> | 39 | #include <qpe/alarmserver.h> |
40 | 40 | ||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <stdio.h> | 42 | #include <stdio.h> |
43 | #include <signal.h> | 43 | #include <signal.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | 45 | ||
46 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 46 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
47 | #include "../calibrate/calibrate.h" | 47 | #include "../calibrate/calibrate.h" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | using namespace Opie; | 50 | using namespace Opie; |
51 | 51 | ||
52 | void initEnvironment() | 52 | void initEnvironment() |
53 | { | 53 | { |
54 | Config config("locale"); | 54 | Config config("locale"); |
55 | config.setGroup( "Location" ); | 55 | config.setGroup( "Location" ); |
56 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 56 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
57 | 57 | ||
58 | // if not timezone set, pick New York | 58 | // if not timezone set, pick New York |
59 | if (tz.isNull()) | 59 | if (tz.isNull()) |
60 | tz = "America/New_York"; | 60 | tz = "America/New_York"; |
61 | 61 | ||
62 | setenv( "TZ", tz, 1 ); | 62 | setenv( "TZ", tz, 1 ); |
63 | config.writeEntry( "Timezone", tz); | 63 | config.writeEntry( "Timezone", tz); |
64 | 64 | ||
65 | config.setGroup( "Language" ); | 65 | config.setGroup( "Language" ); |
66 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 66 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
67 | if ( !lang.isNull() ) | 67 | if ( !lang.isNull() ) |
68 | setenv( "LANG", lang, 1 ); | 68 | setenv( "LANG", lang, 1 ); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | int initApplication( int argc, char ** argv ) | 72 | int initApplication( int argc, char ** argv ) |
73 | { | 73 | { |
74 | initEnvironment(); | 74 | initEnvironment(); |
75 | 75 | ||
76 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) | 76 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) |
77 | setenv( "QWS_SIZE", "240x320", 0 ); | 77 | setenv( "QWS_SIZE", "240x320", 0 ); |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | //Don't flicker at startup: | 80 | //Don't flicker at startup: |
81 | QWSServer::setDesktopBackground( QImage() ); | 81 | QWSServer::setDesktopBackground( QImage() ); |
82 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 82 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
83 | 83 | ||
84 | ODevice::inst ( )-> setSoftSuspend ( true ); | 84 | ODevice::inst ( )-> setSoftSuspend ( true ); |
85 | 85 | ||
86 | { // init backlight | 86 | { // init backlight |
87 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 87 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
88 | e << -3; // Forced on | 88 | e << -3; // Forced on |
89 | } | 89 | } |
90 | 90 | ||
91 | AlarmServer::initialize(); | 91 | AlarmServer::initialize(); |
92 | 92 | ||
93 | Desktop *d = new Desktop(); | 93 | Desktop *d = new Desktop(); |
94 | 94 | ||
95 | QObject::connect( &a, SIGNAL(menu()), d, SLOT(raiseMenu()) ); | ||
96 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); | ||
97 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); | ||
98 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); | ||
99 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); | ||
100 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 95 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
101 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 96 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
102 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 97 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
103 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); | 98 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); |
104 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); | 99 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); |
105 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); | 100 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); |
106 | 101 | ||
107 | (void)new SysFileMonitor(d); | 102 | (void)new SysFileMonitor(d); |
108 | Network::createServer(d); | 103 | Network::createServer(d); |
109 | 104 | ||
110 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 105 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
111 | if ( !QFile::exists( "/etc/pointercal" ) ) { | 106 | if ( !QFile::exists( "/etc/pointercal" ) ) { |
112 | // Make sure calibration widget starts on top. | 107 | // Make sure calibration widget starts on top. |
113 | Calibrate *cal = new Calibrate; | 108 | Calibrate *cal = new Calibrate; |
114 | cal->exec(); | 109 | cal->exec(); |
115 | delete cal; | 110 | delete cal; |
116 | } | 111 | } |
117 | #endif | 112 | #endif |
118 | 113 | ||
119 | d->show(); | 114 | d->show(); |
120 | 115 | ||
121 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 116 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { |
122 | if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 117 | if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { |
123 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | 118 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); |
124 | e << QString ( ); | 119 | e << QString ( ); |
125 | } | 120 | } |
126 | } | 121 | } |
127 | 122 | ||
128 | int rv = a.exec(); | 123 | int rv = a.exec(); |
129 | 124 | ||
130 | delete d; | 125 | delete d; |
131 | 126 | ||
132 | ODevice::inst ( )-> setSoftSuspend ( false ); | 127 | ODevice::inst ( )-> setSoftSuspend ( false ); |
133 | 128 | ||
134 | return rv; | 129 | return rv; |
135 | } | 130 | } |
136 | 131 | ||
137 | static const char *pidfile_path = "/var/run/opie.pid"; | 132 | static const char *pidfile_path = "/var/run/opie.pid"; |
138 | 133 | ||
139 | void create_pidfile ( ) | 134 | void create_pidfile ( ) |
140 | { | 135 | { |
141 | FILE *f; | 136 | FILE *f; |
142 | 137 | ||
143 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 138 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
144 | ::fprintf ( f, "%d", getpid ( )); | 139 | ::fprintf ( f, "%d", getpid ( )); |
145 | ::fclose ( f ); | 140 | ::fclose ( f ); |
146 | } | 141 | } |
147 | } | 142 | } |
148 | 143 | ||
149 | void remove_pidfile ( ) | 144 | void remove_pidfile ( ) |
150 | { | 145 | { |
151 | ::unlink ( pidfile_path ); | 146 | ::unlink ( pidfile_path ); |
152 | } | 147 | } |
153 | 148 | ||
154 | void handle_sigterm ( int /* sig */ ) | 149 | void handle_sigterm ( int /* sig */ ) |
155 | { | 150 | { |
156 | if ( qApp ) | 151 | if ( qApp ) |
157 | qApp-> quit ( ); | 152 | qApp-> quit ( ); |
158 | } | 153 | } |
159 | 154 | ||
160 | int main( int argc, char ** argv ) | 155 | int main( int argc, char ** argv ) |
161 | { | 156 | { |
162 | ::signal ( SIGCHLD, SIG_IGN ); | 157 | ::signal ( SIGCHLD, SIG_IGN ); |
163 | 158 | ||
164 | ::signal ( SIGTERM, handle_sigterm ); | 159 | ::signal ( SIGTERM, handle_sigterm ); |
165 | ::signal ( SIGINT, handle_sigterm ); | 160 | ::signal ( SIGINT, handle_sigterm ); |
166 | 161 | ||
167 | ::setsid ( ); | 162 | ::setsid ( ); |
168 | ::setpgid ( 0, 0 ); | 163 | ::setpgid ( 0, 0 ); |
169 | 164 | ||
170 | ::atexit ( remove_pidfile ); | 165 | ::atexit ( remove_pidfile ); |
171 | create_pidfile ( ); | 166 | create_pidfile ( ); |
172 | 167 | ||
173 | int retVal = initApplication ( argc, argv ); | 168 | int retVal = initApplication ( argc, argv ); |
174 | 169 | ||
175 | // Kill them. Kill them all. | 170 | // Kill them. Kill them all. |
176 | ::kill ( 0, SIGTERM ); | 171 | ::kill ( 0, SIGTERM ); |
177 | ::sleep ( 1 ); | 172 | ::sleep ( 1 ); |
178 | ::kill ( 0, SIGKILL ); | 173 | ::kill ( 0, SIGKILL ); |
179 | 174 | ||
180 | return retVal; | 175 | return retVal; |
181 | } | 176 | } |
182 | 177 | ||
diff --git a/core/launcher/opie-taskbar.control b/core/launcher/opie-taskbar.control index 13e5715..8bf2113 100644 --- a/core/launcher/opie-taskbar.control +++ b/core/launcher/opie-taskbar.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: bin/qpe apps/Settings/Calibrate.desktop pics/launcher plugins/applets/libsuspendapplet.so* plugins/applets/libhomeapplet.so* plugins/applets/liblogoutapplet.so* | 1 | Files: bin/qpe apps/Settings/Calibrate.desktop pics/launcher pics/devicebuttons/*.png plugins/applets/libsuspendapplet.so* plugins/applets/libhomeapplet.so* plugins/applets/liblogoutapplet.so* |
2 | Priority: required | 2 | Priority: required |
3 | Section: opie/system | 3 | Section: opie/system |
4 | Maintainer: Project Opie <opie@handhelds.org> | 4 | Maintainer: Project Opie <opie@handhelds.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | 6 | Version: $QPE_VERSION-$SUB_VERSION.1 |
7 | Depends: qt-embedded (>=$QTE_VERSION) | 7 | Depends: qt-embedded (>=$QTE_VERSION) |
8 | Description: Launcher for Opie | 8 | Description: Launcher for Opie |
9 | The "finder" or "explorer", or whatever you want to call it. | 9 | The "finder" or "explorer", or whatever you want to call it. |
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp index 3ac66f2..356200b 100644 --- a/core/launcher/runningappbar.cpp +++ b/core/launcher/runningappbar.cpp | |||
@@ -1,322 +1,313 @@ | |||
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 | 21 | ||
22 | #define QTOPIA_INTERNAL_PRELOADACCESS | 22 | #define QTOPIA_INTERNAL_PRELOADACCESS |
23 | 23 | ||
24 | // For "kill" | 24 | // For "kill" |
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | #include <signal.h> | 26 | #include <signal.h> |
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | 29 | ||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpainter.h> | 34 | #include <qpainter.h> |
35 | #include <opie/oprocess.h> | 35 | #include <opie/oprocess.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
40 | #include <qwindowsystem_qws.h> | 40 | #include <qwindowsystem_qws.h> |
41 | #include "runningappbar.h" | 41 | #include "runningappbar.h" |
42 | 42 | ||
43 | RunningAppBar::RunningAppBar(QWidget* parent) | 43 | RunningAppBar::RunningAppBar(QWidget* parent) |
44 | : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex( -1) | 44 | : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex( -1) |
45 | { | 45 | { |
46 | setBackgroundMode( PaletteBackground ); | 46 | setBackgroundMode( PaletteBackground ); |
47 | 47 | ||
48 | m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); | 48 | m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); |
49 | 49 | ||
50 | #ifdef QWS | 50 | #ifdef QWS |
51 | 51 | ||
52 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); | 52 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); |
53 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); | 53 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 56 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
57 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 57 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
58 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 58 | this, SLOT(received(const QCString&, const QByteArray&)) ); |
59 | 59 | ||
60 | spacing = AppLnk::smallIconSize() + 3; | 60 | spacing = AppLnk::smallIconSize() + 3; |
61 | } | 61 | } |
62 | 62 | ||
63 | RunningAppBar::~RunningAppBar() | 63 | RunningAppBar::~RunningAppBar() |
64 | {} | 64 | {} |
65 | 65 | ||
66 | void RunningAppBar::newQcopChannel(const QString& channelName) | 66 | void RunningAppBar::newQcopChannel(const QString& channelName) |
67 | { | 67 | { |
68 | QString prefix("QPE/Application/"); | 68 | QString prefix("QPE/Application/"); |
69 | if (channelName.startsWith(prefix)) { | 69 | if (channelName.startsWith(prefix)) { |
70 | QString appName = channelName.mid(prefix.length()); | 70 | QString appName = channelName.mid(prefix.length()); |
71 | // qDebug("App %s just connected!", appName.latin1()); | 71 | // qDebug("App %s just connected!", appName.latin1()); |
72 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); | 72 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); |
73 | if (newGuy && !newGuy->isPreloaded()) { | 73 | if (newGuy && !newGuy->isPreloaded()) { |
74 | addTask(*newGuy); | 74 | addTask(*newGuy); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | void RunningAppBar::removedQcopChannel(const QString& channelName) | 79 | void RunningAppBar::removedQcopChannel(const QString& channelName) |
80 | { | 80 | { |
81 | QString prefix("QPE/Application/"); | 81 | QString prefix("QPE/Application/"); |
82 | if (channelName.startsWith(prefix)) { | 82 | if (channelName.startsWith(prefix)) { |
83 | QString appName = channelName.mid(prefix.length()); | 83 | QString appName = channelName.mid(prefix.length()); |
84 | qDebug("App %s just disconnected!", appName.latin1()); | 84 | qDebug("App %s just disconnected!", appName.latin1()); |
85 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); | 85 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); |
86 | if (newGuy) { | 86 | if (newGuy) { |
87 | removeTask(*newGuy); | 87 | removeTask(*newGuy); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) | 92 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) |
93 | { | 93 | { |
94 | // Since fast apps appear and disappear without disconnecting from their | 94 | // Since fast apps appear and disappear without disconnecting from their |
95 | // channel we need to watch for the showing/hiding events and update according. | 95 | // channel we need to watch for the showing/hiding events and update according. |
96 | QDataStream stream( data, IO_ReadOnly ); | 96 | QDataStream stream( data, IO_ReadOnly ); |
97 | if ( msg == "fastAppShowing(QString)") { | 97 | if ( msg == "fastAppShowing(QString)") { |
98 | QString appName; | 98 | QString appName; |
99 | stream >> appName; | 99 | stream >> appName; |
100 | addTask(*m_AppLnkSet->findExec(appName)); | 100 | addTask(*m_AppLnkSet->findExec(appName)); |
101 | } | 101 | } |
102 | else if ( msg == "fastAppHiding(QString)") { | 102 | else if ( msg == "fastAppHiding(QString)") { |
103 | QString appName; | 103 | QString appName; |
104 | stream >> appName; | 104 | stream >> appName; |
105 | removeTask(*m_AppLnkSet->findExec(appName)); | 105 | removeTask(*m_AppLnkSet->findExec(appName)); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | void RunningAppBar::addTask(const AppLnk& appLnk) | 109 | void RunningAppBar::addTask(const AppLnk& appLnk) |
110 | { | 110 | { |
111 | // qDebug("Added %s to app list.", appLnk.name().latin1()); | 111 | // qDebug("Added %s to app list.", appLnk.name().latin1()); |
112 | AppLnk* newApp = new AppLnk(appLnk); | 112 | AppLnk* newApp = new AppLnk(appLnk); |
113 | newApp->setExec(appLnk.exec()); | 113 | newApp->setExec(appLnk.exec()); |
114 | m_AppList.prepend(newApp); | 114 | m_AppList.prepend(newApp); |
115 | update(); | 115 | update(); |
116 | } | 116 | } |
117 | 117 | ||
118 | void RunningAppBar::removeTask(const AppLnk& appLnk) | 118 | void RunningAppBar::removeTask(const AppLnk& appLnk) |
119 | { | 119 | { |
120 | unsigned int i = 0; | 120 | unsigned int i = 0; |
121 | for (; i < m_AppList.count() ; i++) { | 121 | for (; i < m_AppList.count() ; i++) { |
122 | AppLnk* target = m_AppList.at(i); | 122 | AppLnk* target = m_AppList.at(i); |
123 | if (target->exec() == appLnk.exec()) { | 123 | if (target->exec() == appLnk.exec()) { |
124 | qDebug("Removing %s from app list.", appLnk.name().latin1()); | 124 | qDebug("Removing %s from app list.", appLnk.name().latin1()); |
125 | m_AppList.remove(); | 125 | m_AppList.remove(); |
126 | 126 | ||
127 | // grab the keyboard back, in case the app crashed/forgot | ||
128 | |||
129 | QPEApplication *qpeapp = (QPEApplication *) qApp; | ||
130 | |||
131 | if ( appLnk.exec() == qpeapp-> keyboardGrabbedBy ( )) { | ||
132 | qDebug ( "grabbing keyboard back from %s", appLnk.name().latin1()); | ||
133 | qpeapp-> grabKeyboard ( ); | ||
134 | } | ||
135 | |||
136 | delete target; | 127 | delete target; |
137 | } | 128 | } |
138 | } | 129 | } |
139 | update(); | 130 | update(); |
140 | } | 131 | } |
141 | 132 | ||
142 | void RunningAppBar::mousePressEvent(QMouseEvent *e) | 133 | void RunningAppBar::mousePressEvent(QMouseEvent *e) |
143 | { | 134 | { |
144 | // Find out if the user is clicking on an app icon... | 135 | // Find out if the user is clicking on an app icon... |
145 | // If so, snag the index so when we repaint we show it | 136 | // If so, snag the index so when we repaint we show it |
146 | // as highlighed. | 137 | // as highlighed. |
147 | m_SelectedAppIndex = 0; | 138 | m_SelectedAppIndex = 0; |
148 | int x = 0; | 139 | int x = 0; |
149 | QListIterator<AppLnk> it( m_AppList ); | 140 | QListIterator<AppLnk> it( m_AppList ); |
150 | for ( ; it.current(); ++it, ++m_SelectedAppIndex, x += spacing ) { | 141 | for ( ; it.current(); ++it, ++m_SelectedAppIndex, x += spacing ) { |
151 | if ( x + spacing <= width() ) { | 142 | if ( x + spacing <= width() ) { |
152 | if ( e->x() >= x && e->x() < x + spacing ) { | 143 | if ( e->x() >= x && e->x() < x + spacing ) { |
153 | if ( m_SelectedAppIndex < (int)m_AppList.count() ) { | 144 | if ( m_SelectedAppIndex < (int)m_AppList.count() ) { |
154 | repaint(FALSE); | 145 | repaint(FALSE); |
155 | return ; | 146 | return ; |
156 | } | 147 | } |
157 | } | 148 | } |
158 | } | 149 | } |
159 | else { | 150 | else { |
160 | break; | 151 | break; |
161 | } | 152 | } |
162 | } | 153 | } |
163 | m_SelectedAppIndex = -1; | 154 | m_SelectedAppIndex = -1; |
164 | repaint( FALSE ); | 155 | repaint( FALSE ); |
165 | } | 156 | } |
166 | 157 | ||
167 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) | 158 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) |
168 | { | 159 | { |
169 | if (e->button() == QMouseEvent::RightButton) { | 160 | if (e->button() == QMouseEvent::RightButton) { |
170 | return ; | 161 | return ; |
171 | } | 162 | } |
172 | if ( m_SelectedAppIndex >= 0 ) { | 163 | if ( m_SelectedAppIndex >= 0 ) { |
173 | QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec(); | 164 | QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec(); |
174 | if (QCopChannel::isRegistered(channel.latin1())) { | 165 | if (QCopChannel::isRegistered(channel.latin1())) { |
175 | // qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1()); | 166 | // qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1()); |
176 | QCopEnvelope e(channel.latin1(), "raise()"); | 167 | QCopEnvelope e(channel.latin1(), "raise()"); |
177 | // This class will delete itself after hearing from the app or the timer expiring | 168 | // This class will delete itself after hearing from the app or the timer expiring |
178 | (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this); | 169 | (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this); |
179 | } | 170 | } |
180 | else { | 171 | else { |
181 | removeTask(*m_AppList.at(m_SelectedAppIndex)); | 172 | removeTask(*m_AppList.at(m_SelectedAppIndex)); |
182 | } | 173 | } |
183 | 174 | ||
184 | m_SelectedAppIndex = -1; | 175 | m_SelectedAppIndex = -1; |
185 | update(); | 176 | update(); |
186 | } | 177 | } |
187 | } | 178 | } |
188 | 179 | ||
189 | void RunningAppBar::paintEvent( QPaintEvent * ) | 180 | void RunningAppBar::paintEvent( QPaintEvent * ) |
190 | { | 181 | { |
191 | QPainter p( this ); | 182 | QPainter p( this ); |
192 | AppLnk *curApp; | 183 | AppLnk *curApp; |
193 | int x = 0; | 184 | int x = 0; |
194 | int y = (height() - AppLnk::smallIconSize()) / 2; | 185 | int y = (height() - AppLnk::smallIconSize()) / 2; |
195 | int i = 0; | 186 | int i = 0; |
196 | 187 | ||
197 | //p.fillRect( 0, 0, width(), height(), colorGroup().background() ); | 188 | //p.fillRect( 0, 0, width(), height(), colorGroup().background() ); |
198 | 189 | ||
199 | QListIterator<AppLnk> it(m_AppList); | 190 | QListIterator<AppLnk> it(m_AppList); |
200 | 191 | ||
201 | for (; it.current(); i++, ++it ) { | 192 | for (; it.current(); i++, ++it ) { |
202 | if ( x + spacing <= width() ) { | 193 | if ( x + spacing <= width() ) { |
203 | curApp = it.current(); | 194 | curApp = it.current(); |
204 | if ( (int)i == m_SelectedAppIndex ) | 195 | if ( (int)i == m_SelectedAppIndex ) |
205 | p.fillRect( x, y, spacing, curApp->pixmap().height() + 1, colorGroup().highlight() ); | 196 | p.fillRect( x, y, spacing, curApp->pixmap().height() + 1, colorGroup().highlight() ); |
206 | else | 197 | else |
207 | // p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); | 198 | // p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); |
208 | p.drawPixmap( x, y, curApp->pixmap() ); | 199 | p.drawPixmap( x, y, curApp->pixmap() ); |
209 | x += spacing; | 200 | x += spacing; |
210 | } | 201 | } |
211 | } | 202 | } |
212 | } | 203 | } |
213 | 204 | ||
214 | QSize RunningAppBar::sizeHint() const | 205 | QSize RunningAppBar::sizeHint() const |
215 | { | 206 | { |
216 | return QSize( frameWidth(), AppLnk::smallIconSize() + frameWidth()*2 + 3 ); | 207 | return QSize( frameWidth(), AppLnk::smallIconSize() + frameWidth()*2 + 3 ); |
217 | } | 208 | } |
218 | 209 | ||
219 | const int AppMonitor::RAISE_TIMEOUT_MS = 500; | 210 | const int AppMonitor::RAISE_TIMEOUT_MS = 500; |
220 | 211 | ||
221 | AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner) | 212 | AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner) |
222 | : QObject(0L), m_Owner(owner), m_App(app), m_AppKillerBox(0L) | 213 | : QObject(0L), m_Owner(owner), m_App(app), m_AppKillerBox(0L) |
223 | { | 214 | { |
224 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 215 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
225 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 216 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
226 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 217 | this, SLOT(received(const QCString&, const QByteArray&)) ); |
227 | connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired())); | 218 | connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired())); |
228 | m_Timer.start(RAISE_TIMEOUT_MS, TRUE); | 219 | m_Timer.start(RAISE_TIMEOUT_MS, TRUE); |
229 | } | 220 | } |
230 | 221 | ||
231 | AppMonitor::~AppMonitor() | 222 | AppMonitor::~AppMonitor() |
232 | { | 223 | { |
233 | if (m_AppKillerBox) { | 224 | if (m_AppKillerBox) { |
234 | delete m_AppKillerBox; | 225 | delete m_AppKillerBox; |
235 | m_AppKillerBox = 0L; | 226 | m_AppKillerBox = 0L; |
236 | } | 227 | } |
237 | } | 228 | } |
238 | 229 | ||
239 | void AppMonitor::received(const QCString& msg, const QByteArray& data) | 230 | void AppMonitor::received(const QCString& msg, const QByteArray& data) |
240 | { | 231 | { |
241 | QDataStream stream( data, IO_ReadOnly ); | 232 | QDataStream stream( data, IO_ReadOnly ); |
242 | 233 | ||
243 | if (msg == "appRaised(QString)") { | 234 | if (msg == "appRaised(QString)") { |
244 | QString appName; | 235 | QString appName; |
245 | stream >> appName; | 236 | stream >> appName; |
246 | if (appName == m_App.exec()) { | 237 | if (appName == m_App.exec()) { |
247 | // qDebug("Got a heartbeat from %s", appName.latin1()); | 238 | // qDebug("Got a heartbeat from %s", appName.latin1()); |
248 | m_Timer.stop(); | 239 | m_Timer.stop(); |
249 | // Check to make sure we're not waiting on user input... | 240 | // Check to make sure we're not waiting on user input... |
250 | if (m_AppKillerBox) { | 241 | if (m_AppKillerBox) { |
251 | // If we are, we kill the dialog box, and the code waiting on the result | 242 | // If we are, we kill the dialog box, and the code waiting on the result |
252 | // will clean us up (basically the user said "no"). | 243 | // will clean us up (basically the user said "no"). |
253 | delete m_AppKillerBox; | 244 | delete m_AppKillerBox; |
254 | m_AppKillerBox = 0L; | 245 | m_AppKillerBox = 0L; |
255 | } | 246 | } |
256 | else { | 247 | else { |
257 | // Ok, we're not waiting on user input, so clean us up now. | 248 | // Ok, we're not waiting on user input, so clean us up now. |
258 | // WE DELETE OURSELVES HERE! Don't do anything else!! | 249 | // WE DELETE OURSELVES HERE! Don't do anything else!! |
259 | delete this; | 250 | delete this; |
260 | } | 251 | } |
261 | } | 252 | } |
262 | } | 253 | } |
263 | } | 254 | } |
264 | 255 | ||
265 | void AppMonitor::timerExpired() | 256 | void AppMonitor::timerExpired() |
266 | { | 257 | { |
267 | // We store this incase the application responds while we're | 258 | // We store this incase the application responds while we're |
268 | // waiting for user input so we know not to delete ourselves. This | 259 | // waiting for user input so we know not to delete ourselves. This |
269 | // will be cleaned up in the destructor. | 260 | // will be cleaned up in the destructor. |
270 | m_AppKillerBox = new QMessageBox(tr("Application Problem"), | 261 | m_AppKillerBox = new QMessageBox(tr("Application Problem"), |
271 | tr("<p>%1 is not responding.</p>").arg(m_App.name()) + | 262 | tr("<p>%1 is not responding.</p>").arg(m_App.name()) + |
272 | tr("<p>Would you like to force the application to exit?</p>"), | 263 | tr("<p>Would you like to force the application to exit?</p>"), |
273 | QMessageBox::Warning, QMessageBox::Yes, | 264 | QMessageBox::Warning, QMessageBox::Yes, |
274 | QMessageBox::No | QMessageBox::Default, | 265 | QMessageBox::No | QMessageBox::Default, |
275 | QMessageBox::NoButton); | 266 | QMessageBox::NoButton); |
276 | if ( m_AppKillerBox-> exec ( ) == QMessageBox::Yes ) { | 267 | if ( m_AppKillerBox-> exec ( ) == QMessageBox::Yes ) { |
277 | QDir proc ( "/proc/", "[0-9]*", QDir::Name | QDir::Reversed, QDir::Dirs ); | 268 | QDir proc ( "/proc/", "[0-9]*", QDir::Name | QDir::Reversed, QDir::Dirs ); |
278 | QStringList allprocs = proc. entryList ( ); | 269 | QStringList allprocs = proc. entryList ( ); |
279 | 270 | ||
280 | pid_t mypid = ::getpid ( ); | 271 | pid_t mypid = ::getpid ( ); |
281 | 272 | ||
282 | for ( QStringList::Iterator it = allprocs. begin ( ); it != allprocs. end ( ); ++it ) { | 273 | for ( QStringList::Iterator it = allprocs. begin ( ); it != allprocs. end ( ); ++it ) { |
283 | if (( *it ). toInt ( ) <= mypid ) // only interested in children | 274 | if (( *it ). toInt ( ) <= mypid ) // only interested in children |
284 | continue; | 275 | continue; |
285 | 276 | ||
286 | QCString s = QString ( "/proc/" + *it + "/stat" ). local8Bit ( ); | 277 | QCString s = QString ( "/proc/" + *it + "/stat" ). local8Bit ( ); |
287 | 278 | ||
288 | FILE *fp = ::fopen ( s. data ( ), "r" ); | 279 | FILE *fp = ::fopen ( s. data ( ), "r" ); |
289 | if ( fp ) { | 280 | if ( fp ) { |
290 | pid_t pid, ppid; | 281 | pid_t pid, ppid; |
291 | char *execptr, *exec = 0; | 282 | char *execptr, *exec = 0; |
292 | 283 | ||
293 | if ( ::fscanf ( fp, "%d %as %*c %d ", &pid, &execptr, &ppid ) == 3 ) { | 284 | if ( ::fscanf ( fp, "%d %as %*c %d ", &pid, &execptr, &ppid ) == 3 ) { |
294 | exec = execptr [0] ? execptr + 1 : execptr; | 285 | exec = execptr [0] ? execptr + 1 : execptr; |
295 | if ( exec [0] ) | 286 | if ( exec [0] ) |
296 | exec [::strlen ( exec ) - 1] = 0; | 287 | exec [::strlen ( exec ) - 1] = 0; |
297 | 288 | ||
298 | if (( ppid == ::getpid ( )) && ( m_App. exec ( ). local8Bit ( ) == exec )) { | 289 | if (( ppid == ::getpid ( )) && ( m_App. exec ( ). local8Bit ( ) == exec )) { |
299 | bool success = false; | 290 | bool success = false; |
300 | 291 | ||
301 | qDebug ( "trying to kill pid=%d, exec=%s, ppid=%d", pid, exec, ppid ); | 292 | qDebug ( "trying to kill pid=%d, exec=%s, ppid=%d", pid, exec, ppid ); |
302 | 293 | ||
303 | 294 | ||
304 | success |= ( ::kill ( pid, SIGTERM ) == 0 ); | 295 | success |= ( ::kill ( pid, SIGTERM ) == 0 ); |
305 | ::usleep ( 1000 * 500 ); | 296 | ::usleep ( 1000 * 500 ); |
306 | success |= ( ::kill ( pid, SIGKILL ) == 0 ); | 297 | success |= ( ::kill ( pid, SIGKILL ) == 0 ); |
307 | 298 | ||
308 | if ( success ) | 299 | if ( success ) |
309 | m_Owner. removeTask ( m_App ); | 300 | m_Owner. removeTask ( m_App ); |
310 | 301 | ||
311 | ::free ( execptr ); | 302 | ::free ( execptr ); |
312 | break; | 303 | break; |
313 | } | 304 | } |
314 | ::free ( execptr ); | 305 | ::free ( execptr ); |
315 | } | 306 | } |
316 | ::fclose ( fp ); | 307 | ::fclose ( fp ); |
317 | } | 308 | } |
318 | } | 309 | } |
319 | } | 310 | } |
320 | delete this; | 311 | delete this; |
321 | } | 312 | } |
322 | 313 | ||
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index 88c6219..39e07c8 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp | |||
@@ -1,391 +1,392 @@ | |||
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 | } | ||
250 | else { | 251 | else { |
251 | QWidget *active = qApp->activeWindow(); | 252 | QWidget *active = qApp-> activeWindow ( ); |
252 | if ( active && active->isPopup() ) | 253 | if ( active && active-> isPopup ( )) |
253 | active->close(); | 254 | active-> close ( ); |
254 | 255 | ||
255 | launchMenu->popup( QPoint( 1, y ) ); | 256 | launchMenu-> popup ( QPoint ( 1, y )); |
256 | } | 257 | } |
257 | } | 258 | } |
258 | 259 | ||
259 | const AppLnk* StartMenu::execToLink(const QString& appname) | 260 | const AppLnk* StartMenu::execToLink(const QString& appname) |
260 | { | 261 | { |
261 | const AppLnk* a = apps->findExec( appname ); | 262 | const AppLnk* a = apps->findExec( appname ); |
262 | return a; | 263 | return a; |
263 | } | 264 | } |
264 | 265 | ||
265 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) | 266 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) |
266 | { | 267 | { |
267 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { | 268 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { |
268 | // "OK" button, little hacky | 269 | // "OK" button, little hacky |
269 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); | 270 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); |
270 | QPopupMenu::keyPressEvent( &ke ); | 271 | QPopupMenu::keyPressEvent( &ke ); |
271 | } else { | 272 | } else { |
272 | QPopupMenu::keyPressEvent( e ); | 273 | QPopupMenu::keyPressEvent( e ); |
273 | } | 274 | } |
274 | } | 275 | } |
275 | 276 | ||
276 | static int compareAppletPositions(const void *a, const void *b) | 277 | static int compareAppletPositions(const void *a, const void *b) |
277 | { | 278 | { |
278 | const MenuApplet* aa = *(const MenuApplet**)a; | 279 | const MenuApplet* aa = *(const MenuApplet**)a; |
279 | const MenuApplet* ab = *(const MenuApplet**)b; | 280 | const MenuApplet* ab = *(const MenuApplet**)b; |
280 | int d = aa->iface->position() - ab->iface->position(); | 281 | int d = aa->iface->position() - ab->iface->position(); |
281 | if ( d ) return d; | 282 | if ( d ) return d; |
282 | return QString::compare(aa->library->library(),ab->library->library()); | 283 | return QString::compare(aa->library->library(),ab->library->library()); |
283 | } | 284 | } |
284 | 285 | ||
285 | void StartMenu::clearApplets() | 286 | void StartMenu::clearApplets() |
286 | { | 287 | { |
287 | launchMenu-> hide(); | 288 | launchMenu-> hide(); |
288 | 289 | ||
289 | for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { | 290 | for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { |
290 | MenuApplet *applet = it. current ( ); | 291 | MenuApplet *applet = it. current ( ); |
291 | if ( launchMenu ) { | 292 | if ( launchMenu ) { |
292 | launchMenu-> removeItem ( applet-> id ); | 293 | launchMenu-> removeItem ( applet-> id ); |
293 | delete applet-> popup; | 294 | delete applet-> popup; |
294 | } | 295 | } |
295 | 296 | ||
296 | applet-> iface-> release(); | 297 | applet-> iface-> release(); |
297 | applet-> library-> unload(); | 298 | applet-> library-> unload(); |
298 | delete applet-> library; | 299 | delete applet-> library; |
299 | } | 300 | } |
300 | applets.clear(); | 301 | applets.clear(); |
301 | } | 302 | } |
302 | 303 | ||
303 | 304 | ||
304 | 305 | ||
305 | void StartMenu::loadApplets() | 306 | void StartMenu::loadApplets() |
306 | { | 307 | { |
307 | Config cfg( "StartMenu" ); | 308 | Config cfg( "StartMenu" ); |
308 | cfg.setGroup( "Applets" ); | 309 | cfg.setGroup( "Applets" ); |
309 | 310 | ||
310 | // SafeMode causes too much problems, so we disable it for now -- | 311 | // SafeMode causes too much problems, so we disable it for now -- |
311 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 | 312 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 |
312 | 313 | ||
313 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); | 314 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); |
314 | if ( safe && !safety_tid ) | 315 | if ( safe && !safety_tid ) |
315 | return; | 316 | return; |
316 | cfg.writeEntry("SafeMode",TRUE); | 317 | cfg.writeEntry("SafeMode",TRUE); |
317 | cfg.write(); | 318 | cfg.write(); |
318 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 319 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
319 | 320 | ||
320 | QString lang = getenv( "LANG" ); | 321 | QString lang = getenv( "LANG" ); |
321 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 322 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
322 | QDir dir( path, "lib*.so" ); | 323 | QDir dir( path, "lib*.so" ); |
323 | QStringList list = dir.entryList(); | 324 | QStringList list = dir.entryList(); |
324 | QStringList::Iterator it; | 325 | QStringList::Iterator it; |
325 | int napplets=0; | 326 | int napplets=0; |
326 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; | 327 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; |
327 | for ( it = list.begin(); it != list.end(); ++it ) { | 328 | for ( it = list.begin(); it != list.end(); ++it ) { |
328 | if ( exclude.find( *it ) != exclude.end() ) | 329 | if ( exclude.find( *it ) != exclude.end() ) |
329 | continue; | 330 | continue; |
330 | MenuAppletInterface *iface = 0; | 331 | MenuAppletInterface *iface = 0; |
331 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 332 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
332 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 333 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
333 | MenuApplet *applet = new MenuApplet; | 334 | MenuApplet *applet = new MenuApplet; |
334 | xapplets[napplets++] = applet; | 335 | xapplets[napplets++] = applet; |
335 | applet->library = lib; | 336 | applet->library = lib; |
336 | applet->iface = iface; | 337 | applet->iface = iface; |
337 | 338 | ||
338 | QTranslator *trans = new QTranslator(qApp); | 339 | QTranslator *trans = new QTranslator(qApp); |
339 | QString type = (*it).left( (*it).find(".") ); | 340 | QString type = (*it).left( (*it).find(".") ); |
340 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 341 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
341 | if ( trans->load( tfn )) | 342 | if ( trans->load( tfn )) |
342 | qApp->installTranslator( trans ); | 343 | qApp->installTranslator( trans ); |
343 | else | 344 | else |
344 | delete trans; | 345 | delete trans; |
345 | } else { | 346 | } else { |
346 | exclude += *it; | 347 | exclude += *it; |
347 | delete lib; | 348 | delete lib; |
348 | } | 349 | } |
349 | } | 350 | } |
350 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 351 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
351 | qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); | 352 | qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); |
352 | 353 | ||
353 | if ( sepId ) | 354 | if ( sepId ) |
354 | launchMenu-> removeItem ( sepId ); | 355 | launchMenu-> removeItem ( sepId ); |
355 | sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; | 356 | sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; |
356 | 357 | ||
357 | while (napplets--) { | 358 | while (napplets--) { |
358 | MenuApplet *applet = xapplets[napplets]; | 359 | MenuApplet *applet = xapplets[napplets]; |
359 | 360 | ||
360 | applet-> popup = applet-> iface-> popup ( this ); | 361 | applet-> popup = applet-> iface-> popup ( this ); |
361 | 362 | ||
362 | if ( applet-> popup ) | 363 | if ( applet-> popup ) |
363 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); | 364 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); |
364 | else | 365 | else |
365 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); | 366 | applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); |
366 | applets.insert ( applet-> id, new MenuApplet(*applet)); | 367 | applets.insert ( applet-> id, new MenuApplet(*applet)); |
367 | } | 368 | } |
368 | delete [] xapplets; | 369 | delete [] xapplets; |
369 | 370 | ||
370 | if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets | 371 | if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets |
371 | launchMenu-> removeItem ( sepId ); | 372 | launchMenu-> removeItem ( sepId ); |
372 | sepId = 0; | 373 | sepId = 0; |
373 | } | 374 | } |
374 | if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later | 375 | if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later |
375 | sepId = launchMenu-> insertSeparator ( ); | 376 | sepId = launchMenu-> insertSeparator ( ); |
376 | 377 | ||
377 | if ( !safety_tid ) | 378 | if ( !safety_tid ) |
378 | safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) | 379 | safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) |
379 | } | 380 | } |
380 | 381 | ||
381 | void StartMenu::timerEvent(QTimerEvent* e) | 382 | void StartMenu::timerEvent(QTimerEvent* e) |
382 | { | 383 | { |
383 | if ( e->timerId() == safety_tid ) { | 384 | if ( e->timerId() == safety_tid ) { |
384 | Config cfg( "StartMenu" ); | 385 | Config cfg( "StartMenu" ); |
385 | cfg.setGroup( "Applets" ); | 386 | cfg.setGroup( "Applets" ); |
386 | cfg.writeEntry( "SafeMode", FALSE ); | 387 | cfg.writeEntry( "SafeMode", FALSE ); |
387 | killTimer(safety_tid); | 388 | killTimer(safety_tid); |
388 | safety_tid = 0; | 389 | safety_tid = 0; |
389 | } | 390 | } |
390 | } | 391 | } |
391 | 392 | ||
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index b4b7df6..77035a3 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp | |||
@@ -1,334 +1,344 @@ | |||
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 "startmenu.h" | 21 | #include "startmenu.h" |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | #include "runningappbar.h" | 23 | #include "runningappbar.h" |
24 | #include "systray.h" | 24 | #include "systray.h" |
25 | #include "calibrate.h" | 25 | #include "calibrate.h" |
26 | #include "wait.h" | 26 | #include "wait.h" |
27 | #include "appicons.h" | 27 | #include "appicons.h" |
28 | 28 | ||
29 | #include "taskbar.h" | 29 | #include "taskbar.h" |
30 | #include "desktop.h" | 30 | #include "desktop.h" |
31 | 31 | ||
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
35 | 35 | ||
36 | #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) | 36 | #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) |
37 | #include <qpe/custom.h> | 37 | #include <qpe/custom.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #include <opie/odevice.h> | 40 | #include <opie/odevice.h> |
41 | 41 | ||
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qwindowsystem_qws.h> | 45 | #include <qwindowsystem_qws.h> |
46 | #include <qwidgetstack.h> | 46 | #include <qwidgetstack.h> |
47 | 47 | ||
48 | #if defined( Q_WS_QWS ) | 48 | #if defined( Q_WS_QWS ) |
49 | #include <qwsdisplay_qws.h> | 49 | #include <qwsdisplay_qws.h> |
50 | #include <qgfx_qws.h> | 50 | #include <qgfx_qws.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | 53 | ||
54 | using namespace Opie; | 54 | using namespace Opie; |
55 | 55 | ||
56 | #define FACTORY(T) \ | 56 | #define FACTORY(T) \ |
57 | static QWidget *new##T( bool maximized ) { \ | 57 | static QWidget *new##T( bool maximized ) { \ |
58 | QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 58 | QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
59 | if ( maximized ) { \ | 59 | if ( maximized ) { \ |
60 | if ( qApp->desktop()->width() <= 350 ) { \ | 60 | if ( qApp->desktop()->width() <= 350 ) { \ |
61 | w->showMaximized(); \ | 61 | w->showMaximized(); \ |
62 | } else { \ | 62 | } else { \ |
63 | w->resize( QSize( 300, 300 ) ); \ | 63 | w->resize( QSize( 300, 300 ) ); \ |
64 | } \ | 64 | } \ |
65 | } \ | 65 | } \ |
66 | w->show(); \ | 66 | w->show(); \ |
67 | return w; \ | 67 | return w; \ |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | #ifdef SINGLE_APP | 71 | #ifdef SINGLE_APP |
72 | #define APP(a,b,c,d) FACTORY(b) | 72 | #define APP(a,b,c,d) FACTORY(b) |
73 | #include "../launcher/apps.h" | 73 | #include "../launcher/apps.h" |
74 | #undef APP | 74 | #undef APP |
75 | #endif // SINGLE_APP | 75 | #endif // SINGLE_APP |
76 | 76 | ||
77 | static Global::Command builtins[] = { | 77 | static Global::Command builtins[] = { |
78 | 78 | ||
79 | #ifdef SINGLE_APP | 79 | #ifdef SINGLE_APP |
80 | #define APP(a,b,c,d) { a, new##b, c }, | 80 | #define APP(a,b,c,d) { a, new##b, c }, |
81 | #include "../launcher/apps.h" | 81 | #include "../launcher/apps.h" |
82 | #undef APP | 82 | #undef APP |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SHARP) | 85 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SHARP) |
86 | { "calibrate", TaskBar::calibrate, 1, 0 }, | 86 | { "calibrate", TaskBar::calibrate, 1, 0 }, |
87 | #endif | 87 | #endif |
88 | #if !defined(QT_QWS_CASSIOPEIA) | 88 | #if !defined(QT_QWS_CASSIOPEIA) |
89 | { "shutdown", Global::shutdown, 1, 0 }, | 89 | { "shutdown", Global::shutdown, 1, 0 }, |
90 | // { "run", run, 1, 0 }, | 90 | // { "run", run, 1, 0 }, |
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | { 0, TaskBar::calibrate, 0, 0 }, | 93 | { 0, TaskBar::calibrate, 0, 0 }, |
94 | }; | 94 | }; |
95 | 95 | ||
96 | static bool initNumLock() | 96 | static bool initNumLock() |
97 | { | 97 | { |
98 | #ifdef QPE_INITIAL_NUMLOCK_STATE | 98 | #ifdef QPE_INITIAL_NUMLOCK_STATE |
99 | QPE_INITIAL_NUMLOCK_STATE | 99 | QPE_INITIAL_NUMLOCK_STATE |
100 | #endif | 100 | #endif |
101 | return FALSE; | 101 | return FALSE; |
102 | } | 102 | } |
103 | 103 | ||
104 | class LockKeyState : public QWidget | 104 | class LockKeyState : public QWidget |
105 | { | 105 | { |
106 | public: | 106 | public: |
107 | LockKeyState( QWidget *parent ) : | 107 | LockKeyState( QWidget *parent ) : |
108 | QWidget(parent), | 108 | QWidget(parent), |
109 | nl(initNumLock()), cl(FALSE) | 109 | nl(initNumLock()), cl(FALSE) |
110 | { | 110 | { |
111 | nl_pm = Resource::loadPixmap("numlock"); | 111 | nl_pm = Resource::loadPixmap("numlock"); |
112 | cl_pm = Resource::loadPixmap("capslock"); | 112 | cl_pm = Resource::loadPixmap("capslock"); |
113 | } | 113 | } |
114 | QSize sizeHint() const | 114 | QSize sizeHint() const |
115 | { | 115 | { |
116 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); | 116 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); |
117 | } | 117 | } |
118 | void toggleNumLockState() | 118 | void toggleNumLockState() |
119 | { | 119 | { |
120 | nl = !nl; repaint(); | 120 | nl = !nl; repaint(); |
121 | } | 121 | } |
122 | void toggleCapsLockState() | 122 | void toggleCapsLockState() |
123 | { | 123 | { |
124 | cl = !cl; repaint(); | 124 | cl = !cl; repaint(); |
125 | } | 125 | } |
126 | void paintEvent( QPaintEvent * ) | 126 | void paintEvent( QPaintEvent * ) |
127 | { | 127 | { |
128 | int y = (height()-sizeHint().height())/2; | 128 | int y = (height()-sizeHint().height())/2; |
129 | QPainter p(this); | 129 | QPainter p(this); |
130 | if ( nl ) | 130 | if ( nl ) |
131 | p.drawPixmap(1,y,nl_pm); | 131 | p.drawPixmap(1,y,nl_pm); |
132 | if ( cl ) | 132 | if ( cl ) |
133 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); | 133 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); |
134 | } | 134 | } |
135 | private: | 135 | private: |
136 | QPixmap nl_pm, cl_pm; | 136 | QPixmap nl_pm, cl_pm; |
137 | bool nl, cl; | 137 | bool nl, cl; |
138 | }; | 138 | }; |
139 | 139 | ||
140 | TaskBar::~TaskBar() | 140 | TaskBar::~TaskBar() |
141 | { | 141 | { |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) | 145 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) |
146 | { | 146 | { |
147 | Global::setBuiltinCommands(builtins); | 147 | Global::setBuiltinCommands(builtins); |
148 | 148 | ||
149 | sm = new StartMenu( this ); | 149 | sm = new StartMenu( this ); |
150 | 150 | ||
151 | inputMethods = new InputMethods( this ); | 151 | inputMethods = new InputMethods( this ); |
152 | connect( inputMethods, SIGNAL(inputToggled(bool)), | 152 | connect( inputMethods, SIGNAL(inputToggled(bool)), |
153 | this, SLOT(calcMaxWindowRect()) ); | 153 | this, SLOT(calcMaxWindowRect()) ); |
154 | //new QuickLauncher( this ); | 154 | //new QuickLauncher( this ); |
155 | 155 | ||
156 | stack = new QWidgetStack( this ); | 156 | stack = new QWidgetStack( this ); |
157 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 157 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
158 | label = new QLabel(stack); | 158 | label = new QLabel(stack); |
159 | 159 | ||
160 | //mru = new MRUList( stack ); | 160 | //mru = new MRUList( stack ); |
161 | //stack->raiseWidget( mru ); | 161 | //stack->raiseWidget( mru ); |
162 | 162 | ||
163 | runningAppBar = new RunningAppBar(stack); | 163 | runningAppBar = new RunningAppBar(stack); |
164 | stack->raiseWidget(runningAppBar); | 164 | stack->raiseWidget(runningAppBar); |
165 | 165 | ||
166 | waitIcon = new Wait( this ); | 166 | waitIcon = new Wait( this ); |
167 | (void) new AppIcons( this ); | 167 | (void) new AppIcons( this ); |
168 | 168 | ||
169 | sysTray = new SysTray( this ); | 169 | sysTray = new SysTray( this ); |
170 | 170 | ||
171 | // ## make customizable in some way? | 171 | // ## make customizable in some way? |
172 | lockState = new LockKeyState( this ); | 172 | lockState = new LockKeyState( this ); |
173 | 173 | ||
174 | #if defined(Q_WS_QWS) | 174 | #if defined(Q_WS_QWS) |
175 | #if !defined(QT_NO_COP) | 175 | #if !defined(QT_NO_COP) |
176 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); | 176 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); |
177 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 177 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
178 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 178 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
179 | #endif | 179 | #endif |
180 | #endif | 180 | #endif |
181 | waitTimer = new QTimer( this ); | 181 | waitTimer = new QTimer( this ); |
182 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); | 182 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); |
183 | clearer = new QTimer( this ); | 183 | clearer = new QTimer( this ); |
184 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); | 184 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); |
185 | QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); | 185 | QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); |
186 | } | 186 | } |
187 | 187 | ||
188 | void TaskBar::setStatusMessage( const QString &text ) | 188 | void TaskBar::setStatusMessage( const QString &text ) |
189 | { | 189 | { |
190 | if ( !text.isEmpty() ) { | 190 | if ( !text.isEmpty() ) { |
191 | label->setText( text ); | 191 | label->setText( text ); |
192 | stack->raiseWidget( label ); | 192 | stack->raiseWidget( label ); |
193 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) | 193 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) |
194 | sysTray->hide(); | 194 | sysTray->hide(); |
195 | clearer->start( 3000, TRUE ); | 195 | clearer->start( 3000, TRUE ); |
196 | } else { | 196 | } else { |
197 | clearStatusBar(); | 197 | clearStatusBar(); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void TaskBar::clearStatusBar() | 201 | void TaskBar::clearStatusBar() |
202 | { | 202 | { |
203 | label->clear(); | 203 | label->clear(); |
204 | stack->raiseWidget(runningAppBar); | 204 | stack->raiseWidget(runningAppBar); |
205 | // stack->raiseWidget( mru ); | 205 | // stack->raiseWidget( mru ); |
206 | } | 206 | } |
207 | 207 | ||
208 | void TaskBar::startWait() | 208 | void TaskBar::startWait() |
209 | { | 209 | { |
210 | waitIcon->setWaiting( true ); | 210 | waitIcon->setWaiting( true ); |
211 | // a catchall stop after 10 seconds... | 211 | // a catchall stop after 10 seconds... |
212 | waitTimer->start( 10 * 1000, true ); | 212 | waitTimer->start( 10 * 1000, true ); |
213 | } | 213 | } |
214 | 214 | ||
215 | void TaskBar::stopWait(const QString& /*app*/) | 215 | void TaskBar::stopWait(const QString& /*app*/) |
216 | { | 216 | { |
217 | waitTimer->stop(); | 217 | waitTimer->stop(); |
218 | //mru->addTask(sm->execToLink(app)); | 218 | //mru->addTask(sm->execToLink(app)); |
219 | waitIcon->setWaiting( false ); | 219 | waitIcon->setWaiting( false ); |
220 | } | 220 | } |
221 | 221 | ||
222 | void TaskBar::stopWait() | 222 | void TaskBar::stopWait() |
223 | { | 223 | { |
224 | waitTimer->stop(); | 224 | waitTimer->stop(); |
225 | 225 | ||
226 | waitIcon->setWaiting( false ); | 226 | waitIcon->setWaiting( false ); |
227 | } | 227 | } |
228 | 228 | ||
229 | void TaskBar::resizeEvent( QResizeEvent *e ) | 229 | void TaskBar::resizeEvent( QResizeEvent *e ) |
230 | { | 230 | { |
231 | QHBox::resizeEvent( e ); | 231 | QHBox::resizeEvent( e ); |
232 | calcMaxWindowRect(); | 232 | calcMaxWindowRect(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void TaskBar::styleChange( QStyle &s ) | 235 | void TaskBar::styleChange( QStyle &s ) |
236 | { | 236 | { |
237 | QHBox::styleChange( s ); | 237 | QHBox::styleChange( s ); |
238 | calcMaxWindowRect(); | 238 | calcMaxWindowRect(); |
239 | } | 239 | } |
240 | 240 | ||
241 | void TaskBar::calcMaxWindowRect() | 241 | void TaskBar::calcMaxWindowRect() |
242 | { | 242 | { |
243 | #ifdef Q_WS_QWS | 243 | #ifdef Q_WS_QWS |
244 | QRect wr; | 244 | QRect wr; |
245 | int displayWidth = qApp->desktop()->width(); | 245 | int displayWidth = qApp->desktop()->width(); |
246 | QRect ir = inputMethods->inputRect(); | 246 | QRect ir = inputMethods->inputRect(); |
247 | if ( ir.isValid() ) { | 247 | if ( ir.isValid() ) { |
248 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 248 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
249 | } else { | 249 | } else { |
250 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); | 250 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); |
251 | } | 251 | } |
252 | 252 | ||
253 | #if QT_VERSION < 300 | 253 | #if QT_VERSION < 300 |
254 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, | 254 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, |
255 | QSize(qt_screen->width(),qt_screen->height())) | 255 | QSize(qt_screen->width(),qt_screen->height())) |
256 | ); | 256 | ); |
257 | #else | 257 | #else |
258 | QWSServer::setMaxWindowRect( wr ); | 258 | QWSServer::setMaxWindowRect( wr ); |
259 | #endif | 259 | #endif |
260 | #endif | 260 | #endif |
261 | } | 261 | } |
262 | 262 | ||
263 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) | 263 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) |
264 | { | 264 | { |
265 | QDataStream stream( data, IO_ReadOnly ); | 265 | QDataStream stream( data, IO_ReadOnly ); |
266 | if ( msg == "message(QString)" ) { | 266 | if ( msg == "message(QString)" ) { |
267 | QString text; | 267 | QString text; |
268 | stream >> text; | 268 | stream >> text; |
269 | setStatusMessage( text ); | 269 | setStatusMessage( text ); |
270 | } else if ( msg == "hideInputMethod()" ) { | 270 | } else if ( msg == "hideInputMethod()" ) { |
271 | inputMethods->hideInputMethod(); | 271 | inputMethods->hideInputMethod(); |
272 | } else if ( msg == "showInputMethod()" ) { | 272 | } else if ( msg == "showInputMethod()" ) { |
273 | inputMethods->showInputMethod(); | 273 | inputMethods->showInputMethod(); |
274 | } else if ( msg == "reloadInputMethods()" ) { | 274 | } else if ( msg == "reloadInputMethods()" ) { |
275 | inputMethods->loadInputMethods(); | 275 | inputMethods->loadInputMethods(); |
276 | } else if ( msg == "reloadApps()" ) { | 276 | } else if ( msg == "reloadApps()" ) { |
277 | sm->reloadApps(); | 277 | sm->reloadApps(); |
278 | } else if ( msg == "reloadApplets()" ) { | 278 | } else if ( msg == "reloadApplets()" ) { |
279 | sysTray->clearApplets(); | 279 | sysTray->clearApplets(); |
280 | sysTray->addApplets(); | 280 | sysTray->addApplets(); |
281 | sm->reloadApplets(); | 281 | sm->reloadApplets(); |
282 | } else if ( msg == "soundAlarm()" ) { | 282 | } else if ( msg == "soundAlarm()" ) { |
283 | Desktop::soundAlarm(); | 283 | DesktopApplication::soundAlarm ( ); |
284 | } | 284 | } |
285 | else if ( msg == "setLed(int,bool)" ) { | 285 | else if ( msg == "setLed(int,bool)" ) { |
286 | int led, status; | 286 | int led, status; |
287 | stream >> led >> status; | 287 | stream >> led >> status; |
288 | 288 | ||
289 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | 289 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
290 | if ( ll. count ( )){ | 290 | if ( ll. count ( )){ |
291 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | 291 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; |
292 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | 292 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); |
293 | 293 | ||
294 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | 294 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); |
295 | } | 295 | } |
296 | } | 296 | } |
297 | else if ( msg == "toggleMenu()" ) { | ||
298 | if ( sm-> launchMenu-> isVisible ( )) | ||
299 | sm-> launch ( ); | ||
300 | else { | ||
301 | QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" ); | ||
302 | } | ||
303 | } | ||
304 | else if ( msg == "toggleStartMenu()" ) { | ||
305 | sm-> launch ( ); | ||
306 | } | ||
297 | } | 307 | } |
298 | 308 | ||
299 | QWidget *TaskBar::calibrate(bool) | 309 | QWidget *TaskBar::calibrate(bool) |
300 | { | 310 | { |
301 | #ifdef Q_WS_QWS | 311 | #ifdef Q_WS_QWS |
302 | Calibrate *c = new Calibrate; | 312 | Calibrate *c = new Calibrate; |
303 | c->show(); | 313 | c->show(); |
304 | return c; | 314 | return c; |
305 | #else | 315 | #else |
306 | return 0; | 316 | return 0; |
307 | #endif | 317 | #endif |
308 | } | 318 | } |
309 | 319 | ||
310 | void TaskBar::toggleNumLockState() | 320 | void TaskBar::toggleNumLockState() |
311 | { | 321 | { |
312 | if ( lockState ) lockState->toggleNumLockState(); | 322 | if ( lockState ) lockState->toggleNumLockState(); |
313 | } | 323 | } |
314 | 324 | ||
315 | void TaskBar::toggleCapsLockState() | 325 | void TaskBar::toggleCapsLockState() |
316 | { | 326 | { |
317 | if ( lockState ) lockState->toggleCapsLockState(); | 327 | if ( lockState ) lockState->toggleCapsLockState(); |
318 | } | 328 | } |
319 | 329 | ||
320 | void TaskBar::toggleSymbolInput() | 330 | void TaskBar::toggleSymbolInput() |
321 | { | 331 | { |
322 | if ( inputMethods->currentShown() == "Unicode" ) { | 332 | if ( inputMethods->currentShown() == "Unicode" ) { |
323 | inputMethods->hideInputMethod(); | 333 | inputMethods->hideInputMethod(); |
324 | } else { | 334 | } else { |
325 | inputMethods->showInputMethod("Unicode"); | 335 | inputMethods->showInputMethod("Unicode"); |
326 | } | 336 | } |
327 | } | 337 | } |
328 | 338 | ||
329 | bool TaskBar::recoverMemory() | 339 | bool TaskBar::recoverMemory() |
330 | { | 340 | { |
331 | //eturn mru->quitOldApps(); | 341 | //eturn mru->quitOldApps(); |
332 | return true; | 342 | return true; |
333 | } | 343 | } |
334 | 344 | ||