-rw-r--r-- | core/launcher/taskbar.cpp | 215 |
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 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software @@ -16,33 +16,31 @@ ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** -*********************************************************************/ +**********************************************************************/ #include "startmenu.h" #include "inputmethods.h" #include "runningappbar.h" #include "systray.h" -#include "calibrate.h" #include "wait.h" #include "appicons.h" #include "taskbar.h" -#include "desktop.h" +#include "server.h" -#include <qpe/qpeapplication.h> -#include <qpe/qcopenvelope_qws.h> -#include <qpe/global.h> - -#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ ) || defined( QT_QWS_RAMSES) -#include <qpe/custom.h> +#include <qtopia/qpeapplication.h> +#ifdef QWS +#include <qtopia/qcopenvelope_qws.h> #endif - -#include <opie/odevice.h> +#include <qtopia/global.h> +#include <qtopia/custom.h> #include <qlabel.h> #include <qlayout.h> #include <qtimer.h> +#ifdef QWS #include <qwindowsystem_qws.h> +#endif #include <qwidgetstack.h> #if defined( Q_WS_QWS ) @@ -51,21 +49,6 @@ #endif -using namespace Opie; - -static Global::Command builtins[] = { - -#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) - { "calibrate", TaskBar::calibrate, 1, 0 }, -#endif -#if !defined(QT_QWS_CASSIOPEIA) - { "shutdown", Global::shutdown, 1, 0 }, -// { "run", run, 1, 0 }, -#endif - - { 0, TaskBar::calibrate, 0, 0 }, -}; - static bool initNumLock() { #ifdef QPE_INITIAL_NUMLOCK_STATE @@ -74,6 +57,76 @@ static bool initNumLock() return FALSE; } +//--------------------------------------------------------------------------- + +class SafeMode : public QWidget +{ + Q_OBJECT +public: + SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) + { + message = tr("Safe Mode"); + QFont f( font() ); + f.setWeight( QFont::Bold ); + setFont( f ); + } + + void mousePressEvent( QMouseEvent *); + QSize sizeHint() const; + void paintEvent( QPaintEvent* ); + +private slots: + void action(int i); + +private: + QString message; + QPopupMenu *menu; +}; + +void SafeMode::mousePressEvent( QMouseEvent *) +{ + if ( !menu ) { + menu = new QPopupMenu(this); + menu->insertItem( tr("Plugin Manager..."), 0 ); + menu->insertItem( tr("Restart Qtopia"), 1 ); + menu->insertItem( tr("Help..."), 2 ); + connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); + } + QPoint curPos = mapToGlobal( QPoint(0,0) ); + QSize sh = menu->sizeHint(); + menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); +} + +void SafeMode::action(int i) +{ + switch (i) { + case 0: + Global::execute( "pluginmanager" ); + break; + case 1: + Global::restart(); + break; + case 2: + Global::execute( "helpbrowser", "safemode.html" ); + break; + } +} + +QSize SafeMode::sizeHint() const +{ + QFontMetrics fm = fontMetrics(); + + return QSize( fm.width(message), fm.height() ); +} + +void SafeMode::paintEvent( QPaintEvent* ) +{ + QPainter p(this); + p.drawText( rect(), AlignCenter, message ); +} + +//--------------------------------------------------------------------------- + class LockKeyState : public QWidget { public: @@ -110,6 +163,8 @@ private: bool nl, cl; }; +//--------------------------------------------------------------------------- + TaskBar::~TaskBar() { } @@ -117,9 +172,9 @@ TaskBar::~TaskBar() TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) { - Global::setBuiltinCommands(builtins); - sm = new StartMenu( this ); + connect( sm, SIGNAL(tabSelected(const QString&)), this, + SIGNAL(tabSelected(const QString&)) ); inputMethods = new InputMethods( this ); connect( inputMethods, SIGNAL(inputToggled(bool)), @@ -137,8 +192,18 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn sysTray = new SysTray( this ); + /* ### FIXME plugin loader and safe mode */ +#if 0 + if (PluginLoader::inSafeMode()) + (void)new SafeMode( this ); +#endif + // ## make customizable in some way? +#ifdef QT_QWS_CUSTOM lockState = new LockKeyState( this ); +#else + lockState = 0; +#endif #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) @@ -151,7 +216,10 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); clearer = new QTimer( this ); QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); - QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); + + connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); + connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); + connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); } void TaskBar::setStatusMessage( const QString &text ) @@ -171,6 +239,8 @@ void TaskBar::clearStatusBar() { label->clear(); stack->raiseWidget(runningAppBar); + if ( sysTray ) + sysTray->show(); // stack->raiseWidget( mru ); } @@ -181,24 +251,36 @@ void TaskBar::startWait() waitTimer->start( 10 * 1000, true ); } -void TaskBar::stopWait(const QString& /*app*/) +void TaskBar::stopWait(const QString&) { waitTimer->stop(); - //mru->addTask(sm->execToLink(app)); waitIcon->setWaiting( false ); } void TaskBar::stopWait() { waitTimer->stop(); - waitIcon->setWaiting( false ); } +/* + * This resizeEvent will be captured by + * the ServerInterface and it'll layout + * and calc rect. Now if we go from bigger + * to smaller screen the SysTray is out of + * bounds and repaint() won't trigger an Event + */ void TaskBar::resizeEvent( QResizeEvent *e ) { + if ( sysTray ) + sysTray->hide(); + QHBox::resizeEvent( e ); - calcMaxWindowRect(); + + if ( sysTray ) + sysTray->show(); + + qWarning("TaskBar::resize event"); } void TaskBar::styleChange( QStyle &s ) @@ -209,6 +291,7 @@ void TaskBar::styleChange( QStyle &s ) void TaskBar::calcMaxWindowRect() { + /* #ifdef Q_WS_QWS QRect wr; int displayWidth = qApp->desktop()->width(); @@ -219,7 +302,7 @@ void TaskBar::calcMaxWindowRect() wr.setCoords( 0, 0, displayWidth-1, y()-1 ); } -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, QSize(qt_screen->width(),qt_screen->height())) ); @@ -227,6 +310,7 @@ void TaskBar::calcMaxWindowRect() QWSServer::setMaxWindowRect( wr ); #endif #endif + */ } void TaskBar::receive( const QCString &msg, const QByteArray &data ) @@ -240,52 +324,31 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data ) inputMethods->hideInputMethod(); } else if ( msg == "showInputMethod()" ) { inputMethods->showInputMethod(); + } else if ( msg == "showInputMethod(QString)" ) { + QString name; + stream >> name; + inputMethods->showInputMethod(name); } else if ( msg == "reloadInputMethods()" ) { inputMethods->loadInputMethods(); - } else if ( msg == "toggleInputMethod()" ) { - inputMethods->shown() ? inputMethods->hideInputMethod() : inputMethods->showInputMethod(); - } else if ( msg == "reloadApps()" ) { - sm->reloadApps(); } else if ( msg == "reloadApplets()" ) { sysTray->clearApplets(); + sm->createMenu(); sysTray->addApplets(); - sm->reloadApplets(); - } else if ( msg == "soundAlarm()" ) { - DesktopApplication::soundAlarm ( ); - } - else if ( msg == "setLed(int,bool)" ) { - int led, status; - stream >> led >> status; - - QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); - if ( ll. count ( )) { - OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; - bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); - - ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); - } - } - else if ( msg == "toggleMenu()" ) { + }else if ( msg == "toggleMenu()" ) { if ( sm-> launchMenu-> isVisible ( )) sm-> launch ( ); - else { + else QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" ); - } - } - else if ( msg == "toggleStartMenu()" ) { + }else if ( msg == "toggleStartMenu()" ) sm-> launch ( ); } -} -QWidget *TaskBar::calibrate(bool) +void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) { -#ifdef Q_WS_QWS - Calibrate *c = new Calibrate; - c->show(); - return c; -#else - return 0; -#endif + if ( state == ServerInterface::Launching ) + runningAppBar->applicationLaunched( name ); + else if ( state == ServerInterface::Terminated ) + runningAppBar->applicationTerminated( name ); } void TaskBar::toggleNumLockState() @@ -300,16 +363,12 @@ void TaskBar::toggleCapsLockState() void TaskBar::toggleSymbolInput() { - if ( inputMethods->currentShown() == "Unicode" ) { + QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); + if ( inputMethods->currentShown() == unicodeInput ) { inputMethods->hideInputMethod(); } else { - inputMethods->showInputMethod("Unicode"); - } + inputMethods->showInputMethod( unicodeInput ); } - -bool TaskBar::recoverMemory() -{ - //mru->quitOldApps() is no longer supported - return true; } +#include "taskbar.moc" |