summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp2
-rw-r--r--core/launcher/desktop.h2
-rw-r--r--core/launcher/startmenu.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 34b52d2..6c67056 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,224 +1,224 @@
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
61using namespace Opie; 61using namespace Opie;
62 62
63class QCopKeyRegister 63class QCopKeyRegister
64{ 64{
65public: 65public:
66 QCopKeyRegister() : keyCode( 0 ) 66 QCopKeyRegister() : keyCode( 0 )
67 { } 67 { }
68 QCopKeyRegister( int k, const QString &c, const QString &m ) 68 QCopKeyRegister( int k, const QString &c, const QString &m )
69 : keyCode( k ), channel( c ), message( m ) 69 : keyCode( k ), channel( c ), message( m )
70 { } 70 { }
71 71
72 int getKeyCode() const 72 int getKeyCode() const
73 { 73 {
74 return keyCode; 74 return keyCode;
75 } 75 }
76 QString getChannel() const 76 QString getChannel() const
77 { 77 {
78 return channel; 78 return channel;
79 } 79 }
80 QString getMessage() const 80 QString getMessage() const
81 { 81 {
82 return message; 82 return message;
83 } 83 }
84 84
85private: 85private:
86 int keyCode; 86 int keyCode;
87 QString channel, message; 87 QString channel, message;
88}; 88};
89 89
90typedef QValueList<QCopKeyRegister> KeyRegisterList; 90typedef QValueList<QCopKeyRegister> KeyRegisterList;
91KeyRegisterList keyRegisterList; 91KeyRegisterList keyRegisterList;
92 92
93static Desktop* qpedesktop = 0; 93static Desktop* qpedesktop = 0;
94static int loggedin = 0; 94static int loggedin = 0;
95static void login( bool at_poweron ) 95static void login( bool at_poweron )
96{ 96{
97 if ( !loggedin ) { 97 if ( !loggedin ) {
98 Global::terminateBuiltin( "calibrate" ); 98 Global::terminateBuiltin( "calibrate" );
99 Password::authenticate( at_poweron ); 99 Password::authenticate( at_poweron );
100 loggedin = 1; 100 loggedin = 1;
101 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 101 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
102 } 102 }
103} 103}
104 104
105bool Desktop::screenLocked() 105bool Desktop::screenLocked()
106{ 106{
107 return loggedin == 0; 107 return loggedin == 0;
108} 108}
109 109
110/* 110/*
111 Priority is number of alerts that are needed to pop up 111 Priority is number of alerts that are needed to pop up
112 alert. 112 alert.
113 */ 113 */
114class DesktopPowerAlerter : public QMessageBox 114class DesktopPowerAlerter : public QMessageBox
115{ 115{
116public: 116public:
117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
118 : QMessageBox( tr( "Battery Status" ), "Low Battery", 118 : QMessageBox( tr( "Battery Status" ), "Low Battery",
119 QMessageBox::Critical, 119 QMessageBox::Critical,
120 QMessageBox::Ok | QMessageBox::Default, 120 QMessageBox::Ok | QMessageBox::Default,
121 QMessageBox::NoButton, QMessageBox::NoButton, 121 QMessageBox::NoButton, QMessageBox::NoButton,
122 parent, name, FALSE ) 122 parent, name, FALSE )
123 { 123 {
124 currentPriority = INT_MAX; 124 currentPriority = INT_MAX;
125 alertCount = 0; 125 alertCount = 0;
126 } 126 }
127 127
128 void alert( const QString &text, int priority ); 128 void alert( const QString &text, int priority );
129 void hideEvent( QHideEvent * ); 129 void hideEvent( QHideEvent * );
130private: 130private:
131 int currentPriority; 131 int currentPriority;
132 int alertCount; 132 int alertCount;
133}; 133};
134 134
135void DesktopPowerAlerter::alert( const QString &text, int priority ) 135void DesktopPowerAlerter::alert( const QString &text, int priority )
136{ 136{
137 alertCount++; 137 alertCount++;
138 if ( alertCount < priority ) 138 if ( alertCount < priority )
139 return ; 139 return ;
140 if ( priority > currentPriority ) 140 if ( priority > currentPriority )
141 return ; 141 return ;
142 currentPriority = priority; 142 currentPriority = priority;
143 setText( text ); 143 setText( text );
144 show(); 144 show();
145} 145}
146 146
147 147
148void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 148void DesktopPowerAlerter::hideEvent( QHideEvent *e )
149{ 149{
150 QMessageBox::hideEvent( e ); 150 QMessageBox::hideEvent( e );
151 alertCount = 0; 151 alertCount = 0;
152 currentPriority = INT_MAX; 152 currentPriority = INT_MAX;
153} 153}
154 154
155 155
156void DesktopApplication::switchLCD ( bool on ) 156void DesktopApplication::switchLCD ( bool on )
157{ 157{
158 if ( qApp ) { 158 if ( qApp ) {
159 DesktopApplication *dapp = (DesktopApplication *) qApp; 159 DesktopApplication *dapp = (DesktopApplication *) qApp;
160 160
161 if ( dapp-> m_screensaver ) { 161 if ( dapp-> m_screensaver ) {
162 if ( on ) { 162 if ( on ) {
163 dapp-> m_screensaver-> setDisplayState ( true ); 163 dapp-> m_screensaver-> setDisplayState ( true );
164 dapp-> m_screensaver-> setBacklight ( -3 ); 164 dapp-> m_screensaver-> setBacklight ( -3 );
165 } 165 }
166 else { 166 else {
167 dapp-> m_screensaver-> setDisplayState ( false ); 167 dapp-> m_screensaver-> setDisplayState ( false );
168 } 168 }
169 } 169 }
170 } 170 }
171} 171}
172 172
173 173
174DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 174DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
175 : QPEApplication( argc, argv, appType ) 175 : QPEApplication( argc, argv, appType )
176{ 176{
177 177
178 Config cfg( "apm" ); 178 Config cfg( "apm" );
179 cfg.setGroup( "Warnings" ); 179 cfg.setGroup( "Warnings" );
180 //cfg.readNumEntry( "checkinterval", 10000 ) 180 //cfg.readNumEntry( "checkinterval", 10000 )
181 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); 181 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
182 m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); 182 m_powerCritical = cfg.readNumEntry( "powercritical", 5 );
183 183
184 m_ps = new PowerStatus; 184 m_ps = new PowerStatus;
185 m_ps_last = new PowerStatus; 185 m_ps_last = new PowerStatus;
186 pa = new DesktopPowerAlerter( 0 ); 186 pa = new DesktopPowerAlerter( 0 );
187 187
188 m_timer = new QTimer( this ); 188 m_timer = new QTimer( this );
189 connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); 189 connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) );
190 m_timer->start( 5000 ); 190 m_timer->start( 5000 );
191 191
192 channel = new QCopChannel( "QPE/Desktop", this ); 192 channel = new QCopChannel( "QPE/Desktop", this );
193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
194 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 194 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
195 195
196 channel = new QCopChannel( "QPE/System", this ); 196 channel = new QCopChannel( "QPE/System", this );
197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
198 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 198 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
199 199
200 m_screensaver = new OpieScreenSaver ( ); 200 m_screensaver = new OpieScreenSaver ( );
201 m_screensaver-> setInterval ( -1 ); 201 m_screensaver-> setInterval ( -1 );
202 QWSServer::setScreenSaver( m_screensaver ); 202 QWSServer::setScreenSaver( m_screensaver );
203 203
204 apmTimeout ( ); 204 apmTimeout ( );
205} 205}
206 206
207 207
208DesktopApplication::~DesktopApplication() 208DesktopApplication::~DesktopApplication()
209{ 209{
210 delete m_ps; 210 delete m_ps;
211 delete m_ps_last; 211 delete m_ps_last;
212 delete pa; 212 delete pa;
213} 213}
214 214
215void DesktopApplication::apmTimeout() 215void DesktopApplication::apmTimeout()
216{ 216{
217 qpedesktop->checkMemory(); // in case no events are being generated 217 qpedesktop->checkMemory(); // in case no events are being generated
218 218
219 *m_ps_last = *m_ps; 219 *m_ps_last = *m_ps;
220 *m_ps = PowerStatusManager::readStatus(); 220 *m_ps = PowerStatusManager::readStatus();
221 221
222 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) 222 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( ))
223 m_screensaver-> powerStatusChanged ( *m_ps ); 223 m_screensaver-> powerStatusChanged ( *m_ps );
224 224
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index 13f28b3..1f8daa0 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -1,152 +1,152 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __DESKTOP_H__ 21#ifndef __DESKTOP_H__
22#define __DESKTOP_H__ 22#define __DESKTOP_H__
23 23
24 24
25#include "shutdownimpl.h" 25#include "shutdownimpl.h"
26 26
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32class Background; 32class Background;
33class Launcher; 33class Launcher;
34class TaskBar; 34class TaskBar;
35class PowerStatus; 35class PowerStatus;
36class QCopBridge; 36class QCopBridge;
37class TransferServer; 37class TransferServer;
38class DesktopPowerAlerter; 38class DesktopPowerAlerter;
39class PackageSlave; 39class PackageSlave;
40class OpieScreenSaver; 40class OpieScreenSaver;
41 41
42class DesktopApplication : public QPEApplication 42class DesktopApplication : public QPEApplication
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 DesktopApplication( int& argc, char **argv, Type t ); 46 DesktopApplication( int& argc, char **argv, Type t );
47 ~DesktopApplication(); 47 ~DesktopApplication();
48 48
49 static void switchLCD ( bool on ); // only for togglePower in Desktop 49 static void switchLCD ( bool on ); // only for togglePower in Desktop
50 50
51signals: 51signals:
52 void menu(); 52 void menu();
53 void home(); 53 void home();
54 void datebook(); 54 void datebook();
55 void contacts(); 55 void contacts();
56 void launch(); 56 void launch();
57 void email(); 57 void email();
58 void backlight(); 58 void backlight();
59 void power(); 59 void power();
60 void symbol(); 60 void symbol();
61 void numLockStateToggle(); 61 void numLockStateToggle();
62 void capsLockStateToggle(); 62 void capsLockStateToggle();
63 void prepareForRestart(); 63 void prepareForRestart();
64 64
65protected: 65protected:
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
74public slots: 74public slots:
75 virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); 75 virtual void desktopMessage ( const QCString &msg, const QByteArray &data );
76 virtual void systemMessage ( const QCString &msg, const QByteArray &data ); 76 virtual void systemMessage ( const QCString &msg, const QByteArray &data );
77 77
78protected slots: 78protected slots:
79 void shutdown( ShutdownImpl::Type ); 79 void shutdown( ShutdownImpl::Type );
80 void apmTimeout(); 80 void apmTimeout();
81 void sendCard(); 81 void sendCard();
82private: 82private:
83 void reloadPowerWarnSettings(); 83 void reloadPowerWarnSettings();
84 DesktopPowerAlerter *pa; 84 DesktopPowerAlerter *pa;
85 PowerStatus *m_ps, *m_ps_last; 85 PowerStatus *m_ps, *m_ps_last;
86 QTimer *cardSendTimer; 86 QTimer *cardSendTimer;
87 QCopChannel *channel; 87 QCopChannel *channel;
88 OpieScreenSaver *m_screensaver; 88 OpieScreenSaver *m_screensaver;
89 QTimer * m_timer; 89 QTimer * m_timer;
90 int m_powerVeryLow; 90 int m_powerVeryLow;
91 int m_powerCritical; 91 int m_powerCritical;
92 int m_currentPowerLevel; 92 int m_currentPowerLevel;
93}; 93};
94 94
95 95
96class Desktop : public QWidget 96class Desktop : public QWidget
97{ 97{
98 Q_OBJECT 98 Q_OBJECT
99public: 99public:
100 Desktop(); 100 Desktop();
101 ~Desktop(); 101 ~Desktop();
102 102
103 static bool screenLocked(); 103 static bool screenLocked();
104 104
105 void show(); 105 void show();
106 void checkMemory(); 106 void checkMemory();
107 107
108 void keyClick(); 108 void keyClick();
109 void screenClick(); 109 void screenClick();
110 static void soundAlarm(); 110 static void soundAlarm();
111 111
112public slots: 112public slots:
113 void raiseDatebook(); 113 void raiseDatebook();
114 void raiseContacts(); 114 void raiseContacts();
115 void raiseMenu(); 115 void raiseMenu();
116 void raiseLauncher(); 116 void raiseLauncher();
117 void raiseEmail(); 117 void raiseEmail();
118 void execAutoStart(); 118 void execAutoStart();
119 void togglePower(); 119 void togglePower();
120 void toggleLight(); 120 void toggleLight();
121 void toggleNumLockState(); 121 void toggleNumLockState();
122 void toggleCapsLockState(); 122 void toggleCapsLockState();
123 void toggleSymbolInput(); 123 void toggleSymbolInput();
124 void terminateServers(); 124 void terminateServers();
125 void rereadVolumes(); 125 void rereadVolumes();
126 126
127 void home ( ); 127 void home ( );
128 128
129protected: 129protected:
130 void executeOrModify( const QString& appLnkFile ); 130 void executeOrModify( const QString& appLnkFile );
131 void styleChange( QStyle & ); 131 void styleChange( QStyle & );
132 void timerEvent( QTimerEvent *e ); 132 void timerEvent( QTimerEvent *e );
133 133
134 QWidget *bg; 134 QWidget *bg;
135 Launcher *launcher; 135 Launcher *launcher;
136 TaskBar *tb; 136 TaskBar *tb;
137 137
138private: 138private:
139 void startTransferServer(); 139 void startTransferServer();
140 bool recoverMemory(); 140 bool recoverMemory();
141 141
142 QCopBridge *qcopBridge; 142 QCopBridge *qcopBridge;
143 TransferServer *transferServer; 143 TransferServer *transferServer;
144 PackageSlave *packageSlave; 144 PackageSlave *packageSlave;
145 145
146 QDateTime suspendTime; 146 QDateTime suspendTime;
147 bool keyclick, touchclick, alarmsound; 147 bool keyclick, touchclick, alarmsound;
148}; 148};
149 149
150 150
151#endif // __DESKTOP_H__ 151#endif // __DESKTOP_H__
152 152
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index e663072..88c6219 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,214 +1,214 @@
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
44StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 44StartMenu::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
65void StartMenu::mousePressEvent( QMouseEvent * ) 65void 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
73StartMenu::~StartMenu() 73StartMenu::~StartMenu()
74{ 74{
75 delete apps; 75 delete apps;
76} 76}
77 77
78 78
79void StartMenu::loadOptions() 79void 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
102void StartMenu::createMenu() 102void 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
116void StartMenu::reloadApps() 116void 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
144void StartMenu::reloadApplets() 144void 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
154void StartMenu::itemSelected( int id ) 154void 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
167bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) 167bool 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 ) {