summaryrefslogtreecommitdiff
path: root/core/launcher
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
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') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/taskbar.cpp277
1 files changed, 168 insertions, 109 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
@@ -80,7 +133,7 @@ public:
80 LockKeyState( QWidget *parent ) : 133 LockKeyState( QWidget *parent ) :
81 QWidget(parent), 134 QWidget(parent),
82 nl(initNumLock()), cl(FALSE) 135 nl(initNumLock()), cl(FALSE)
83 { 136 {
84 nl_pm = Resource::loadPixmap("numlock"); 137 nl_pm = Resource::loadPixmap("numlock");
85 cl_pm = Resource::loadPixmap("capslock"); 138 cl_pm = Resource::loadPixmap("capslock");
86 } 139 }
@@ -88,3 +141,3 @@ public:
88 { 141 {
89 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 142 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
90 } 143 }
@@ -92,3 +145,3 @@ public:
92 { 145 {
93 nl = !nl; repaint(); 146 nl = !nl; repaint();
94 } 147 }
@@ -96,3 +149,3 @@ public:
96 { 149 {
97 cl = !cl; repaint(); 150 cl = !cl; repaint();
98 } 151 }
@@ -100,8 +153,8 @@ public:
100 { 153 {
101 int y = (height()-sizeHint().height())/2; 154 int y = (height()-sizeHint().height())/2;
102 QPainter p(this); 155 QPainter p(this);
103 if ( nl ) 156 if ( nl )
104 p.drawPixmap(1,y,nl_pm); 157 p.drawPixmap(1,y,nl_pm);
105 if ( cl ) 158 if ( cl )
106 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 159 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
107 } 160 }
@@ -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
@@ -125,3 +180,3 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
125 connect( inputMethods, SIGNAL(inputToggled(bool)), 180 connect( inputMethods, SIGNAL(inputToggled(bool)),
126 this, SLOT(calcMaxWindowRect()) ); 181 this, SLOT(calcMaxWindowRect()) );
127 182
@@ -139,4 +194,14 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
139 194
140 // ## make customizable in some way? 195 /* ### FIXME plugin loader and safe mode */
196#if 0
197 if (PluginLoader::inSafeMode())
198 (void)new SafeMode( this );
199#endif
200
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
@@ -146,3 +211,3 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
146 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 211 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
147 this, SLOT(receive(const QCString&, const QByteArray&)) ); 212 this, SLOT(receive(const QCString&, const QByteArray&)) );
148#endif 213#endif
@@ -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,3 +241,5 @@ void TaskBar::clearStatusBar()
173 stack->raiseWidget(runningAppBar); 241 stack->raiseWidget(runningAppBar);
174 // stack->raiseWidget( mru ); 242 if ( sysTray )
243 sysTray->show();
244 // stack->raiseWidget( mru );
175} 245}
@@ -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
@@ -216,11 +299,11 @@ void TaskBar::calcMaxWindowRect()
216 if ( ir.isValid() ) { 299 if ( ir.isValid() ) {
217 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 300 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
218 } else { 301 } else {
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 );
226#else 309#else
@@ -229,2 +312,3 @@ void TaskBar::calcMaxWindowRect()
229#endif 312#endif
313 */
230} 314}
@@ -239,51 +323,30 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data )
239 } else if ( msg == "hideInputMethod()" ) { 323 } else if ( msg == "hideInputMethod()" ) {
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();
251 sysTray->addApplets(); 335 sm->createMenu();
252 sm->reloadApplets(); 336 sysTray->addApplets();
253 } else if ( msg == "soundAlarm()" ) { 337 }else if ( msg == "toggleMenu()" ) {
254 DesktopApplication::soundAlarm ( ); 338 if ( sm-> launchMenu-> isVisible() )
255 } 339 sm-> launch();
256 else if ( msg == "setLed(int,bool)" ) { 340 else
257 int led, status; 341 QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" );
258 stream >> led >> status; 342 }else if ( msg == "toggleStartMenu()" )
259 343 sm->launch();
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 ( ))
270 sm-> launch ( );
271 else {
272 QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" );
273 }
274 }
275 else if ( msg == "toggleStartMenu()" ) {
276 sm-> launch ( );
277 }
278} 344}
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,6 +365,7 @@ void TaskBar::toggleSymbolInput()
302{ 365{
303 if ( inputMethods->currentShown() == "Unicode" ) { 366 QString unicodeInput = qApp->translate( "InputMethods", "Unicode" );
304 inputMethods->hideInputMethod(); 367 if ( inputMethods->currentShown() == unicodeInput ) {
368 inputMethods->hideInputMethod();
305 } else { 369 } else {
306 inputMethods->showInputMethod("Unicode"); 370 inputMethods->showInputMethod( unicodeInput );
307 } 371 }
@@ -309,7 +373,2 @@ void TaskBar::toggleSymbolInput()
309 373
310bool TaskBar::recoverMemory() 374#include "taskbar.moc"
311{
312 //mru->quitOldApps() is no longer supported
313 return true;
314}
315