summaryrefslogtreecommitdiff
path: root/core/launcher/taskbar.cpp
authorzecke <zecke>2003-08-28 14:49:24 (UTC)
committer zecke <zecke>2003-08-28 14:49:24 (UTC)
commit704de5567caccd769c693676a55a4af45c85e044 (patch) (unidiff)
tree36ba1b370136a89d9b41a596e72db9a6bfbe6730 /core/launcher/taskbar.cpp
parent6ae5aaad2dec2470940f83f1e8629aec48f284a7 (diff)
downloadopie-704de5567caccd769c693676a55a4af45c85e044.zip
opie-704de5567caccd769c693676a55a4af45c85e044.tar.gz
opie-704de5567caccd769c693676a55a4af45c85e044.tar.bz2
-Implement new QCOP method for toggling the start menu
-almost kill resizeEvent ( todo )
Diffstat (limited to 'core/launcher/taskbar.cpp') (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,5 +1,5 @@
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**
@@ -18,3 +18,3 @@
18** 18**
19*********************************************************************/ 19**********************************************************************/
20 20
@@ -24,3 +24,2 @@
24#include "systray.h" 24#include "systray.h"
25#include "calibrate.h"
26#include "wait.h" 25#include "wait.h"
@@ -29,13 +28,10 @@
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
@@ -44,3 +40,5 @@
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>
@@ -53,17 +51,2 @@
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()
@@ -76,2 +59,72 @@ static bool initNumLock()
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
@@ -112,2 +165,4 @@ private:
112 165
166//---------------------------------------------------------------------------
167
113TaskBar::~TaskBar() 168TaskBar::~TaskBar()
@@ -119,5 +174,5 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
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
@@ -139,4 +194,14 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
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
@@ -153,3 +218,6 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
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}
@@ -173,2 +241,4 @@ void TaskBar::clearStatusBar()
173 stack->raiseWidget(runningAppBar); 241 stack->raiseWidget(runningAppBar);
242 if ( sysTray )
243 sysTray->show();
174 // stack->raiseWidget( mru ); 244 // stack->raiseWidget( mru );
@@ -183,6 +253,5 @@ void TaskBar::startWait()
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 );
@@ -193,3 +262,2 @@ void TaskBar::stopWait()
193 waitTimer->stop(); 262 waitTimer->stop();
194
195 waitIcon->setWaiting( false ); 263 waitIcon->setWaiting( false );
@@ -197,6 +265,20 @@ void TaskBar::stopWait()
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}
@@ -211,2 +293,3 @@ void TaskBar::calcMaxWindowRect()
211{ 293{
294 /*
212#ifdef Q_WS_QWS 295#ifdef Q_WS_QWS
@@ -221,3 +304,3 @@ void TaskBar::calcMaxWindowRect()
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,
@@ -229,2 +312,3 @@ void TaskBar::calcMaxWindowRect()
229#endif 312#endif
313 */
230} 314}
@@ -242,48 +326,27 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data )
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}
@@ -302,14 +365,10 @@ void 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"