summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/taskbar.cpp215
1 files changed, 137 insertions, 78 deletions
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index e8a81c3..37fdb30 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of 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
@@ -16,33 +16,31 @@
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"
26#include "wait.h" 25#include "wait.h"
27#include "appicons.h" 26#include "appicons.h"
28 27
29#include "taskbar.h" 28#include "taskbar.h"
30#include "desktop.h" 29#include "server.h"
31 30
32#include <qpe/qpeapplication.h> 31#include <qtopia/qpeapplication.h>
33#include <qpe/qcopenvelope_qws.h> 32#ifdef QWS
34#include <qpe/global.h> 33#include <qtopia/qcopenvelope_qws.h>
35
36#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ ) || defined( QT_QWS_RAMSES)
37#include <qpe/custom.h>
38#endif 34#endif
39 35#include <qtopia/global.h>
40#include <opie/odevice.h> 36#include <qtopia/custom.h>
41 37
42#include <qlabel.h> 38#include <qlabel.h>
43#include <qlayout.h> 39#include <qlayout.h>
44#include <qtimer.h> 40#include <qtimer.h>
41#ifdef QWS
45#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
43#endif
46#include <qwidgetstack.h> 44#include <qwidgetstack.h>
47 45
48#if defined( Q_WS_QWS ) 46#if defined( Q_WS_QWS )
@@ -51,21 +49,6 @@
51#endif 49#endif
52 50
53 51
54using namespace Opie;
55
56static Global::Command builtins[] = {
57
58#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES)
59 { "calibrate", TaskBar::calibrate, 1, 0 },
60#endif
61#if !defined(QT_QWS_CASSIOPEIA)
62 { "shutdown", Global::shutdown, 1, 0 },
63// { "run", run, 1, 0 },
64#endif
65
66 { 0, TaskBar::calibrate, 0, 0 },
67};
68
69static bool initNumLock() 52static bool initNumLock()
70{ 53{
71#ifdef QPE_INITIAL_NUMLOCK_STATE 54#ifdef QPE_INITIAL_NUMLOCK_STATE
@@ -74,6 +57,76 @@ static bool initNumLock()
74 return FALSE; 57 return FALSE;
75} 58}
76 59
60//---------------------------------------------------------------------------
61
62class SafeMode : public QWidget
63{
64 Q_OBJECT
65public:
66 SafeMode( QWidget *parent ) : QWidget( parent ), menu(0)
67 {
68 message = tr("Safe Mode");
69 QFont f( font() );
70 f.setWeight( QFont::Bold );
71 setFont( f );
72 }
73
74 void mousePressEvent( QMouseEvent *);
75 QSize sizeHint() const;
76 void paintEvent( QPaintEvent* );
77
78private slots:
79 void action(int i);
80
81private:
82 QString message;
83 QPopupMenu *menu;
84};
85
86void SafeMode::mousePressEvent( QMouseEvent *)
87{
88 if ( !menu ) {
89 menu = new QPopupMenu(this);
90 menu->insertItem( tr("Plugin Manager..."), 0 );
91 menu->insertItem( tr("Restart Qtopia"), 1 );
92 menu->insertItem( tr("Help..."), 2 );
93 connect(menu, SIGNAL(activated(int)), this, SLOT(action(int)));
94 }
95 QPoint curPos = mapToGlobal( QPoint(0,0) );
96 QSize sh = menu->sizeHint();
97 menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) );
98}
99
100void SafeMode::action(int i)
101{
102 switch (i) {
103 case 0:
104 Global::execute( "pluginmanager" );
105 break;
106 case 1:
107 Global::restart();
108 break;
109 case 2:
110 Global::execute( "helpbrowser", "safemode.html" );
111 break;
112 }
113}
114
115QSize SafeMode::sizeHint() const
116{
117 QFontMetrics fm = fontMetrics();
118
119 return QSize( fm.width(message), fm.height() );
120}
121
122void SafeMode::paintEvent( QPaintEvent* )
123{
124 QPainter p(this);
125 p.drawText( rect(), AlignCenter, message );
126}
127
128//---------------------------------------------------------------------------
129
77class LockKeyState : public QWidget 130class LockKeyState : public QWidget
78{ 131{
79public: 132public:
@@ -110,6 +163,8 @@ private:
110 bool nl, cl; 163 bool nl, cl;
111}; 164};
112 165
166//---------------------------------------------------------------------------
167
113TaskBar::~TaskBar() 168TaskBar::~TaskBar()
114{ 169{
115} 170}
@@ -117,9 +172,9 @@ TaskBar::~TaskBar()
117 172
118TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 173TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
119{ 174{
120 Global::setBuiltinCommands(builtins);
121
122 sm = new StartMenu( this ); 175 sm = new StartMenu( this );
176 connect( sm, SIGNAL(tabSelected(const QString&)), this,
177 SIGNAL(tabSelected(const QString&)) );
123 178
124 inputMethods = new InputMethods( this ); 179 inputMethods = new InputMethods( this );
125 connect( inputMethods, SIGNAL(inputToggled(bool)), 180 connect( inputMethods, SIGNAL(inputToggled(bool)),
@@ -137,8 +192,18 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
137 192
138 sysTray = new SysTray( this ); 193 sysTray = new SysTray( this );
139 194
195 /* ### FIXME plugin loader and safe mode */
196#if 0
197 if (PluginLoader::inSafeMode())
198 (void)new SafeMode( this );
199#endif
200
140 // ## make customizable in some way? 201 // ## make customizable in some way?
202#ifdef QT_QWS_CUSTOM
141 lockState = new LockKeyState( this ); 203 lockState = new LockKeyState( this );
204#else
205 lockState = 0;
206#endif
142 207
143#if defined(Q_WS_QWS) 208#if defined(Q_WS_QWS)
144#if !defined(QT_NO_COP) 209#if !defined(QT_NO_COP)
@@ -151,7 +216,10 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
151 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 216 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
152 clearer = new QTimer( this ); 217 clearer = new QTimer( this );
153 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 218 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
154 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); 219
220 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
221 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
222 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
155} 223}
156 224
157void TaskBar::setStatusMessage( const QString &text ) 225void TaskBar::setStatusMessage( const QString &text )
@@ -171,6 +239,8 @@ void TaskBar::clearStatusBar()
171{ 239{
172 label->clear(); 240 label->clear();
173 stack->raiseWidget(runningAppBar); 241 stack->raiseWidget(runningAppBar);
242 if ( sysTray )
243 sysTray->show();
174 // stack->raiseWidget( mru ); 244 // stack->raiseWidget( mru );
175} 245}
176 246
@@ -181,24 +251,36 @@ void TaskBar::startWait()
181 waitTimer->start( 10 * 1000, true ); 251 waitTimer->start( 10 * 1000, true );
182} 252}
183 253
184void TaskBar::stopWait(const QString& /*app*/) 254void TaskBar::stopWait(const QString&)
185{ 255{
186 waitTimer->stop(); 256 waitTimer->stop();
187 //mru->addTask(sm->execToLink(app));
188 waitIcon->setWaiting( false ); 257 waitIcon->setWaiting( false );
189} 258}
190 259
191void TaskBar::stopWait() 260void TaskBar::stopWait()
192{ 261{
193 waitTimer->stop(); 262 waitTimer->stop();
194
195 waitIcon->setWaiting( false ); 263 waitIcon->setWaiting( false );
196} 264}
197 265
266/*
267 * This resizeEvent will be captured by
268 * the ServerInterface and it'll layout
269 * and calc rect. Now if we go from bigger
270 * to smaller screen the SysTray is out of
271 * bounds and repaint() won't trigger an Event
272 */
198void TaskBar::resizeEvent( QResizeEvent *e ) 273void TaskBar::resizeEvent( QResizeEvent *e )
199{ 274{
275 if ( sysTray )
276 sysTray->hide();
277
200 QHBox::resizeEvent( e ); 278 QHBox::resizeEvent( e );
201 calcMaxWindowRect(); 279
280 if ( sysTray )
281 sysTray->show();
282
283 qWarning("TaskBar::resize event");
202} 284}
203 285
204void TaskBar::styleChange( QStyle &s ) 286void TaskBar::styleChange( QStyle &s )
@@ -209,6 +291,7 @@ void TaskBar::styleChange( QStyle &s )
209 291
210void TaskBar::calcMaxWindowRect() 292void TaskBar::calcMaxWindowRect()
211{ 293{
294 /*
212#ifdef Q_WS_QWS 295#ifdef Q_WS_QWS
213 QRect wr; 296 QRect wr;
214 int displayWidth = qApp->desktop()->width(); 297 int displayWidth = qApp->desktop()->width();
@@ -219,7 +302,7 @@ void TaskBar::calcMaxWindowRect()
219 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 302 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
220 } 303 }
221 304
222#if QT_VERSION < 300 305#if QT_VERSION < 0x030000
223 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 306 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
224 QSize(qt_screen->width(),qt_screen->height())) 307 QSize(qt_screen->width(),qt_screen->height()))
225 ); 308 );
@@ -227,6 +310,7 @@ void TaskBar::calcMaxWindowRect()
227 QWSServer::setMaxWindowRect( wr ); 310 QWSServer::setMaxWindowRect( wr );
228#endif 311#endif
229#endif 312#endif
313 */
230} 314}
231 315
232void TaskBar::receive( const QCString &msg, const QByteArray &data ) 316void TaskBar::receive( const QCString &msg, const QByteArray &data )
@@ -240,52 +324,31 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data )
240 inputMethods->hideInputMethod(); 324 inputMethods->hideInputMethod();
241 } else if ( msg == "showInputMethod()" ) { 325 } else if ( msg == "showInputMethod()" ) {
242 inputMethods->showInputMethod(); 326 inputMethods->showInputMethod();
327 } else if ( msg == "showInputMethod(QString)" ) {
328 QString name;
329 stream >> name;
330 inputMethods->showInputMethod(name);
243 } else if ( msg == "reloadInputMethods()" ) { 331 } else if ( msg == "reloadInputMethods()" ) {
244 inputMethods->loadInputMethods(); 332 inputMethods->loadInputMethods();
245 } else if ( msg == "toggleInputMethod()" ) {
246 inputMethods->shown() ? inputMethods->hideInputMethod() : inputMethods->showInputMethod();
247 } else if ( msg == "reloadApps()" ) {
248 sm->reloadApps();
249 } else if ( msg == "reloadApplets()" ) { 333 } else if ( msg == "reloadApplets()" ) {
250 sysTray->clearApplets(); 334 sysTray->clearApplets();
335 sm->createMenu();
251 sysTray->addApplets(); 336 sysTray->addApplets();
252 sm->reloadApplets(); 337 }else if ( msg == "toggleMenu()" ) {
253 } else if ( msg == "soundAlarm()" ) {
254 DesktopApplication::soundAlarm ( );
255 }
256 else if ( msg == "setLed(int,bool)" ) {
257 int led, status;
258 stream >> led >> status;
259
260 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
261 if ( ll. count ( )){
262 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
263 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
264
265 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
266 }
267 }
268 else if ( msg == "toggleMenu()" ) {
269 if ( sm-> launchMenu-> isVisible ( )) 338 if ( sm-> launchMenu-> isVisible ( ))
270 sm-> launch ( ); 339 sm-> launch ( );
271 else { 340 else
272 QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" ); 341 QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" );
273 } 342 }else if ( msg == "toggleStartMenu()" )
274 }
275 else if ( msg == "toggleStartMenu()" ) {
276 sm-> launch ( ); 343 sm-> launch ( );
277 } 344 }
278}
279 345
280QWidget *TaskBar::calibrate(bool) 346void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state )
281{ 347{
282#ifdef Q_WS_QWS 348 if ( state == ServerInterface::Launching )
283 Calibrate *c = new Calibrate; 349 runningAppBar->applicationLaunched( name );
284 c->show(); 350 else if ( state == ServerInterface::Terminated )
285 return c; 351 runningAppBar->applicationTerminated( name );
286#else
287 return 0;
288#endif
289} 352}
290 353
291void TaskBar::toggleNumLockState() 354void TaskBar::toggleNumLockState()
@@ -300,16 +363,12 @@ void TaskBar::toggleCapsLockState()
300 363
301void TaskBar::toggleSymbolInput() 364void TaskBar::toggleSymbolInput()
302{ 365{
303 if ( inputMethods->currentShown() == "Unicode" ) { 366 QString unicodeInput = qApp->translate( "InputMethods", "Unicode" );
367 if ( inputMethods->currentShown() == unicodeInput ) {
304 inputMethods->hideInputMethod(); 368 inputMethods->hideInputMethod();
305 } else { 369 } else {
306 inputMethods->showInputMethod("Unicode"); 370 inputMethods->showInputMethod( unicodeInput );
307 }
308} 371}
309
310bool TaskBar::recoverMemory()
311{
312 //mru->quitOldApps() is no longer supported
313 return true;
314} 372}
315 373
374#include "taskbar.moc"