-rw-r--r-- | core/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/launcher/main.cpp | 2 | ||||
-rw-r--r-- | core/launcher/systray.cpp | 103 | ||||
-rw-r--r-- | core/launcher/systray.h | 13 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 4 |
5 files changed, 83 insertions, 41 deletions
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro index 0e557aa..dbe3820 100644 --- a/core/launcher/launcher.pro +++ b/core/launcher/launcher.pro @@ -1,118 +1,116 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = ../../bin HEADERS = background.h \ desktop.h \ qprocess.h \ mediummountgui.h \ info.h \ appicons.h \ taskbar.h \ sidething.h \ - mrulist.h \ runningappbar.h \ stabmon.h \ inputmethods.h \ systray.h \ wait.h \ shutdownimpl.h \ launcher.h \ launcherview.h \ ../../core/apps/calibrate/calibrate.h \ startmenu.h \ transferserver.h \ qcopbridge.h \ packageslave.h \ irserver.h \ ../../rsync/buf.h \ ../../rsync/checksum.h \ ../../rsync/command.h \ ../../rsync/emit.h \ ../../rsync/job.h \ ../../rsync/netint.h \ ../../rsync/protocol.h \ ../../rsync/prototab.h \ ../../rsync/rsync.h \ ../../rsync/search.h \ ../../rsync/stream.h \ ../../rsync/sumset.h \ ../../rsync/trace.h \ ../../rsync/types.h \ ../../rsync/util.h \ ../../rsync/whole.h \ ../../rsync/config_rsync.h \ ../../rsync/qrsync.h # quicklauncher.h \ SOURCES = background.cpp \ desktop.cpp \ mediummountgui.cpp \ qprocess.cpp qprocess_unix.cpp \ info.cpp \ appicons.cpp \ taskbar.cpp \ sidething.cpp \ - mrulist.cpp \ runningappbar.cpp \ stabmon.cpp \ inputmethods.cpp \ systray.cpp \ wait.cpp \ shutdownimpl.cpp \ launcher.cpp \ launcherview.cpp \ ../../core/apps/calibrate/calibrate.cpp \ transferserver.cpp \ packageslave.cpp \ irserver.cpp \ qcopbridge.cpp \ startmenu.cpp \ main.cpp \ ../../rsync/base64.c \ ../../rsync/buf.c \ ../../rsync/checksum.c \ ../../rsync/command.c \ ../../rsync/delta.c \ ../../rsync/emit.c \ ../../rsync/hex.c \ ../../rsync/job.c \ ../../rsync/mdfour.c \ ../../rsync/mksum.c \ ../../rsync/msg.c \ ../../rsync/netint.c \ ../../rsync/patch.c \ ../../rsync/prototab.c \ ../../rsync/readsums.c \ ../../rsync/scoop.c \ ../../rsync/search.c \ ../../rsync/stats.c \ ../../rsync/stream.c \ ../../rsync/sumset.c \ ../../rsync/trace.c \ ../../rsync/tube.c \ ../../rsync/util.c \ ../../rsync/version.c \ ../../rsync/whole.c \ ../../rsync/qrsync.cpp INTERFACES = syncdialog.ui INCLUDEPATH += ../../include DEPENDPATH += ../../include . INCLUDEPATH += ../../core/apps/calibrate DEPENDPATH += ../../core/apps/calibrate INCLUDEPATH += ../../rsync DEPENDPATH += ../../rsync TARGET = qpe LIBS += -lqpe -lcrypt -lopie TRANSLATIONS = ../../i18n/de/qpe.ts \ ../../i18n/en/qpe.ts \ ../../i18n/es/qpe.ts \ ../../i18n/fr/qpe.ts \ ../../i18n/hu/qpe.ts \ ../../i18n/ja/qpe.ts \ ../../i18n/ko/qpe.ts \ ../../i18n/no/qpe.ts \ ../../i18n/pl/qpe.ts \ ../../i18n/pt/qpe.ts \ ../../i18n/pt_BR/qpe.ts \ ../../i18n/sl/qpe.ts \ ../../i18n/zh_CN/qpe.ts \ diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index ca0bbe4..490af39 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp @@ -181,85 +181,85 @@ int initApplication( int argc, char ** argv ) AlarmServer::initialize(); Desktop *d = new Desktop(); QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); (void)new SysFileMonitor(d); Network::createServer(d); #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) if ( !QFile::exists( "/etc/pointercal" ) ) { // Make sure calibration widget starts on top. Calibrate *cal = new Calibrate; cal->exec(); delete cal; } #endif d->show(); int rv = a.exec(); delete d; ODevice::inst ( )-> setPowerButtonHandler ( ODevice::KERNEL ); return rv; } static const char *pidfile_path = "/var/run/opie.pid"; void create_pidfile ( ) { FILE *f; if (( f = ::fopen ( pidfile_path, "w" ))) { ::fprintf ( f, "%d", getpid ( )); ::fclose ( f ); } } void remove_pidfile ( ) { ::unlink ( pidfile_path ); } void handle_sigterm ( int /* sig */ ) { if ( qApp ) qApp-> quit ( ); } int main( int argc, char ** argv ) { - ::signal( SIGCHLD, SIG_IGN ); + ::signal ( SIGCHLD, SIG_IGN ); ::signal ( SIGTERM, handle_sigterm ); ::signal ( SIGINT, handle_sigterm ); ::setsid ( ); ::setpgid ( 0, 0 ); ::atexit ( remove_pidfile ); create_pidfile ( ); int retVal = initApplication ( argc, argv ); // Kill them. Kill them all. ::kill ( 0, SIGTERM ); ::sleep ( 1 ); ::kill ( 0, SIGKILL ); return retVal; } diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index ad1553f..4767150 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp @@ -1,107 +1,148 @@ /********************************************************************** -** 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 ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/config.h> #include <qlayout.h> #include <qdir.h> #include <qtranslator.h> #include "quicklauncher.h" #include "systray.h" #include <stdlib.h> #ifdef SINGLE_APP #include "clockappletimpl.h" #endif SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) { + safety_tid = 0; //setFrameStyle( QFrame::Panel | QFrame::Sunken ); loadApplets(); } +static int compareAppletPositions(const void *a, const void *b) +{ + const TaskbarApplet* aa = *(const TaskbarApplet**)a; + const TaskbarApplet* ab = *(const TaskbarApplet**)b; + int d = ab->iface->position() - aa->iface->position(); + if ( d ) return d; + return QString::compare(ab->library->library(),aa->library->library()); +} + void SysTray::loadApplets() { + clearApplets(); + addApplets(); +} + +void SysTray::clearApplets() +{ + hide(); #ifndef SINGLE_APP QValueList<TaskbarApplet>::Iterator mit; for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { (*mit).iface->release(); (*mit).library->unload(); delete (*mit).library; } +#endif appletList.clear(); if ( layout ) delete layout; - layout = new QHBoxLayout( this ); + layout = new QHBoxLayout( this, 0, 1 ); + layout->setAutoAdd(TRUE); +} + +void SysTray::addApplets() +{ +#ifndef SINGLE_APP + Config cfg( "Taskbar" ); + cfg.setGroup( "Applets" ); + bool safe = cfg.readBoolEntry("SafeMode",FALSE); + if ( safe && !safety_tid ) + return; + cfg.writeEntry("SafeMode",TRUE); + cfg.write(); + QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); QString path = QPEApplication::qpeDir() + "/plugins/applets"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; + int napplets=0; + TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; for ( it = list.begin(); it != list.end(); ++it ) { + if ( exclude.find( *it ) != exclude.end() ) + continue; TaskbarAppletInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) { - TaskbarApplet applet; - applet.library = lib; - applet.iface = iface; - applet.applet = applet.iface->applet( this ); - positionApplet( applet ); - QString lang = getenv( "LANG" ); - QTranslator * trans = new QTranslator(qApp); - QString type = (*it).left( (*it).find(".") ); - QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; - qDebug("tr fpr sysapplet: %s", tfn.latin1() ); - if ( trans->load( tfn )) - qApp->installTranslator( trans ); - else - delete trans; + TaskbarApplet *applet = new TaskbarApplet; + applets[napplets++] = applet; + applet->library = lib; + applet->iface = iface; } else { + exclude += *it; delete lib; } } + cfg.writeEntry( "ExcludeApplets", exclude, ',' ); + qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); + while (napplets--) { + TaskbarApplet *applet = applets[napplets]; + applet->applet = applet->iface->applet( this ); + appletList.append(*applet); + QString lang = getenv( "LANG" ); + QTranslator * trans = new QTranslator(qApp); + QString type = (*it).left( (*it).find(".") ); + QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; + if ( trans->load( tfn )) + qApp->installTranslator( trans ); + else + delete trans; + } + delete applets; #else - layout = new QHBoxLayout( this ); TaskbarApplet applet; applet.iface = new ClockAppletImpl(); applet.applet = applet.iface->applet( this ); - positionApplet( applet ); + appletList.append( a ); #endif + show(); + + if ( !safety_tid ) + safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) } -void SysTray::positionApplet( const TaskbarApplet &a ) +void SysTray::timerEvent(QTimerEvent* e) { - int p = 0; - QValueList<TaskbarApplet>::Iterator it; - for ( it = appletList.begin(); it != appletList.end(); ++it ) { - if ( (*it).iface->position() > a.iface->position() ) - break; - p += 2; + if ( e->timerId() == safety_tid ) { + Config cfg( "Taskbar" ); + cfg.setGroup( "Applets" ); + cfg.writeEntry( "SafeMode", FALSE ); + killTimer(safety_tid); + safety_tid = 0; } - - appletList.insert( it, a ); - layout->insertWidget( p, a.applet ); - layout->insertSpacing( p, 1 ); } - diff --git a/core/launcher/systray.h b/core/launcher/systray.h index 0aed348..5a6849a 100644 --- a/core/launcher/systray.h +++ b/core/launcher/systray.h @@ -1,58 +1,61 @@ /********************************************************************** -** 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 ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __SYSTRAY_H__ #define __SYSTRAY_H__ #include <qpe/taskbarappletinterface.h> #include <qframe.h> #include <qvaluelist.h> class QHBoxLayout; class QLibrary; struct TaskbarApplet { #ifndef QT_NO_COMPONENT QLibrary *library; #endif TaskbarAppletInterface *iface; QWidget *applet; }; class SysTray : public QFrame { Q_OBJECT public: SysTray( QWidget *parent ); - void loadApplets(); + void clearApplets(); + void addApplets(); -private: - void positionApplet( const TaskbarApplet &a ); +protected: + void timerEvent(QTimerEvent* e); private: + void loadApplets(); + int safety_tid; QHBoxLayout *layout; QValueList<TaskbarApplet> appletList; }; #endif // __SYSTRAY_H__ diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index 988d072..1feae4a 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp @@ -1,87 +1,86 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** *********************************************************************/ #include "startmenu.h" #include "inputmethods.h" -#include "mrulist.h" #include "runningappbar.h" #include "systray.h" #include "calibrate.h" #include "wait.h" #include "appicons.h" #include "taskbar.h" #include "desktop.h" #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/global.h> #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) #include <qpe/custom.h> #endif #include <opie/odevice.h> #include <qlabel.h> #include <qlayout.h> #include <qtimer.h> #include <qwindowsystem_qws.h> #include <qwidgetstack.h> #if defined( Q_WS_QWS ) #include <qwsdisplay_qws.h> #include <qgfx_qws.h> #endif #define FACTORY(T) \ static QWidget *new##T( bool maximized ) { \ QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ if ( maximized ) { \ if ( qApp->desktop()->width() <= 350 ) { \ w->showMaximized(); \ } else { \ w->resize( QSize( 300, 300 ) ); \ } \ } \ w->show(); \ return w; \ } #ifdef SINGLE_APP #define APP(a,b,c,d) FACTORY(b) #include "../launcher/apps.h" #undef APP #endif // SINGLE_APP static Global::Command builtins[] = { #ifdef SINGLE_APP #define APP(a,b,c,d) { a, new##b, c }, #include "../launcher/apps.h" #undef APP #endif #if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) { "calibrate", TaskBar::calibrate, 1, 0 }, #endif #if !defined(QT_QWS_CASSIOPEIA) @@ -212,112 +211,113 @@ void TaskBar::startWait() } void TaskBar::stopWait(const QString& app) { waitTimer->stop(); //mru->addTask(sm->execToLink(app)); waitIcon->setWaiting( false ); } void TaskBar::stopWait() { waitTimer->stop(); waitIcon->setWaiting( false ); } void TaskBar::resizeEvent( QResizeEvent *e ) { QHBox::resizeEvent( e ); calcMaxWindowRect(); } void TaskBar::styleChange( QStyle &s ) { QHBox::styleChange( s ); calcMaxWindowRect(); } void TaskBar::calcMaxWindowRect() { #ifdef Q_WS_QWS QRect wr; int displayWidth = qApp->desktop()->width(); QRect ir = inputMethods->inputRect(); if ( ir.isValid() ) { wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); } else { wr.setCoords( 0, 0, displayWidth-1, y()-1 ); } #if QT_VERSION < 300 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, QSize(qt_screen->width(),qt_screen->height())) ); #else QWSServer::setMaxWindowRect( wr ); #endif #endif } void TaskBar::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString text; stream >> text; setStatusMessage( text ); } else if ( msg == "hideInputMethod()" ) { inputMethods->hideInputMethod(); } else if ( msg == "showInputMethod()" ) { inputMethods->showInputMethod(); } else if ( msg == "reloadInputMethods()" ) { inputMethods->loadInputMethods(); } else if ( msg == "reloadApplets()" ) { - sysTray->loadApplets(); + sysTray->clearApplets(); + sysTray->addApplets(); } else if ( msg == "soundAlarm()" ) { Desktop::soundAlarm(); } else if ( msg == "setLed(int,bool)" ) { int led, status; stream >> led >> status; ODevice::inst ( )-> setLed ( led, status ? OLED_BlinkSlow : OLED_Off ); } } QWidget *TaskBar::calibrate(bool) { #ifdef Q_WS_QWS Calibrate *c = new Calibrate; c->show(); return c; #else return 0; #endif } void TaskBar::toggleNumLockState() { if ( lockState ) lockState->toggleNumLockState(); } void TaskBar::toggleCapsLockState() { if ( lockState ) lockState->toggleCapsLockState(); } void TaskBar::toggleSymbolInput() { if ( inputMethods->currentShown() == "Unicode" ) { inputMethods->hideInputMethod(); } else { inputMethods->showInputMethod("Unicode"); } } bool TaskBar::recoverMemory() { //eturn mru->quitOldApps(); return true; } |