summaryrefslogtreecommitdiff
authorzecke <zecke>2003-08-28 14:49:24 (UTC)
committer zecke <zecke>2003-08-28 14:49:24 (UTC)
commit704de5567caccd769c693676a55a4af45c85e044 (patch) (side-by-side diff)
tree36ba1b370136a89d9b41a596e72db9a6bfbe6730
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 (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 @@
/**********************************************************************
-** 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.
**
@@ -18,3 +18,3 @@
**
-*********************************************************************/
+**********************************************************************/
@@ -24,3 +24,2 @@
#include "systray.h"
-#include "calibrate.h"
#include "wait.h"
@@ -29,13 +28,10 @@
#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>
@@ -44,3 +40,5 @@
#include <qtimer.h>
+#ifdef QWS
#include <qwindowsystem_qws.h>
+#endif
#include <qwidgetstack.h>
@@ -53,17 +51,2 @@
-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()
@@ -76,2 +59,72 @@ static bool initNumLock()
+//---------------------------------------------------------------------------
+
+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
@@ -80,7 +133,7 @@ public:
LockKeyState( QWidget *parent ) :
- QWidget(parent),
- nl(initNumLock()), cl(FALSE)
+ QWidget(parent),
+ nl(initNumLock()), cl(FALSE)
{
- nl_pm = Resource::loadPixmap("numlock");
- cl_pm = Resource::loadPixmap("capslock");
+ nl_pm = Resource::loadPixmap("numlock");
+ cl_pm = Resource::loadPixmap("capslock");
}
@@ -88,3 +141,3 @@ public:
{
- return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
+ return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
}
@@ -92,3 +145,3 @@ public:
{
- nl = !nl; repaint();
+ nl = !nl; repaint();
}
@@ -96,3 +149,3 @@ public:
{
- cl = !cl; repaint();
+ cl = !cl; repaint();
}
@@ -100,8 +153,8 @@ public:
{
- int y = (height()-sizeHint().height())/2;
- QPainter p(this);
- if ( nl )
- p.drawPixmap(1,y,nl_pm);
- if ( cl )
- p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
+ int y = (height()-sizeHint().height())/2;
+ QPainter p(this);
+ if ( nl )
+ p.drawPixmap(1,y,nl_pm);
+ if ( cl )
+ p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
}
@@ -112,2 +165,4 @@ private:
+//---------------------------------------------------------------------------
+
TaskBar::~TaskBar()
@@ -119,5 +174,5 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
{
- Global::setBuiltinCommands(builtins);
-
sm = new StartMenu( this );
+ connect( sm, SIGNAL(tabSelected(const QString&)), this,
+ SIGNAL(tabSelected(const QString&)) );
@@ -125,3 +180,3 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
connect( inputMethods, SIGNAL(inputToggled(bool)),
- this, SLOT(calcMaxWindowRect()) );
+ this, SLOT(calcMaxWindowRect()) );
@@ -139,4 +194,14 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
- // ## make customizable in some way?
+ /* ### 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
@@ -146,3 +211,3 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(receive(const QCString&, const QByteArray&)) );
+ this, SLOT(receive(const QCString&, const QByteArray&)) );
#endif
@@ -153,3 +218,6 @@ TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOn
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()) );
}
@@ -173,3 +241,5 @@ void TaskBar::clearStatusBar()
stack->raiseWidget(runningAppBar);
- // stack->raiseWidget( mru );
+ if ( sysTray )
+ sysTray->show();
+ // stack->raiseWidget( mru );
}
@@ -183,6 +253,5 @@ void TaskBar::startWait()
-void TaskBar::stopWait(const QString& /*app*/)
+void TaskBar::stopWait(const QString&)
{
waitTimer->stop();
- //mru->addTask(sm->execToLink(app));
waitIcon->setWaiting( false );
@@ -193,3 +262,2 @@ void TaskBar::stopWait()
waitTimer->stop();
-
waitIcon->setWaiting( false );
@@ -197,6 +265,20 @@ void TaskBar::stopWait()
+/*
+ * 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");
}
@@ -211,2 +293,3 @@ void TaskBar::calcMaxWindowRect()
{
+ /*
#ifdef Q_WS_QWS
@@ -216,11 +299,11 @@ void TaskBar::calcMaxWindowRect()
if ( ir.isValid() ) {
- wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
+ wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
} else {
- wr.setCoords( 0, 0, displayWidth-1, y()-1 );
+ 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()))
- );
+ QSize(qt_screen->width(),qt_screen->height()))
+ );
#else
@@ -229,2 +312,3 @@ void TaskBar::calcMaxWindowRect()
#endif
+ */
}
@@ -239,51 +323,30 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data )
} else if ( msg == "hideInputMethod()" ) {
- inputMethods->hideInputMethod();
+ inputMethods->hideInputMethod();
} else if ( msg == "showInputMethod()" ) {
- inputMethods->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();
+ inputMethods->loadInputMethods();
} else if ( msg == "reloadApplets()" ) {
- sysTray->clearApplets();
- 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()" ) {
- if ( sm-> launchMenu-> isVisible ( ))
- sm-> launch ( );
- else {
- QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" );
- }
- }
- else if ( msg == "toggleStartMenu()" ) {
- sm-> launch ( );
- }
+ sysTray->clearApplets();
+ sm->createMenu();
+ sysTray->addApplets();
+ }else if ( msg == "toggleMenu()" ) {
+ if ( sm-> launchMenu-> isVisible() )
+ sm-> launch();
+ else
+ QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" );
+ }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 );
}
@@ -302,6 +365,7 @@ void TaskBar::toggleSymbolInput()
{
- if ( inputMethods->currentShown() == "Unicode" ) {
- inputMethods->hideInputMethod();
+ QString unicodeInput = qApp->translate( "InputMethods", "Unicode" );
+ if ( inputMethods->currentShown() == unicodeInput ) {
+ inputMethods->hideInputMethod();
} else {
- inputMethods->showInputMethod("Unicode");
+ inputMethods->showInputMethod( unicodeInput );
}
@@ -309,7 +373,2 @@ void TaskBar::toggleSymbolInput()
-bool TaskBar::recoverMemory()
-{
- //mru->quitOldApps() is no longer supported
- return true;
-}
-
+#include "taskbar.moc"