-rw-r--r-- | core/launcher/desktop.cpp | 2 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/launcher/startmenu.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 34b52d2..6c67056 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -1,224 +1,224 @@ /********************************************************************** ** 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 "desktop.h" #include "info.h" #include "launcher.h" #include "qcopbridge.h" #include "shutdownimpl.h" #include "startmenu.h" #include "taskbar.h" #include "transferserver.h" #include "irserver.h" #include "packageslave.h" #include "screensaver.h" - + #include <qpe/applnk.h> #include <qpe/mimetype.h> #include <qpe/password.h> #include <qpe/config.h> #include <qpe/power.h> #include <qpe/timeconversion.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/network.h> #include <qpe/global.h> #if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) #include <qpe/custom.h> #endif #include <opie/odevice.h> #include <qgfx_qws.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qtimer.h> #include <qwindowsystem_qws.h> #include <qvaluelist.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> using namespace Opie; class QCopKeyRegister { public: QCopKeyRegister() : keyCode( 0 ) { } QCopKeyRegister( int k, const QString &c, const QString &m ) : keyCode( k ), channel( c ), message( m ) { } int getKeyCode() const { return keyCode; } QString getChannel() const { return channel; } QString getMessage() const { return message; } private: int keyCode; QString channel, message; }; typedef QValueList<QCopKeyRegister> KeyRegisterList; KeyRegisterList keyRegisterList; static Desktop* qpedesktop = 0; static int loggedin = 0; static void login( bool at_poweron ) { if ( !loggedin ) { Global::terminateBuiltin( "calibrate" ); Password::authenticate( at_poweron ); loggedin = 1; QCopEnvelope e( "QPE/Desktop", "unlocked()" ); } } bool Desktop::screenLocked() { return loggedin == 0; } /* Priority is number of alerts that are needed to pop up alert. */ class DesktopPowerAlerter : public QMessageBox { public: DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) : QMessageBox( tr( "Battery Status" ), "Low Battery", QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton, parent, name, FALSE ) { currentPriority = INT_MAX; alertCount = 0; } void alert( const QString &text, int priority ); void hideEvent( QHideEvent * ); private: int currentPriority; int alertCount; }; void DesktopPowerAlerter::alert( const QString &text, int priority ) { alertCount++; if ( alertCount < priority ) return ; if ( priority > currentPriority ) return ; currentPriority = priority; setText( text ); show(); } void DesktopPowerAlerter::hideEvent( QHideEvent *e ) { QMessageBox::hideEvent( e ); alertCount = 0; currentPriority = INT_MAX; } void DesktopApplication::switchLCD ( bool on ) { if ( qApp ) { DesktopApplication *dapp = (DesktopApplication *) qApp; if ( dapp-> m_screensaver ) { if ( on ) { dapp-> m_screensaver-> setDisplayState ( true ); dapp-> m_screensaver-> setBacklight ( -3 ); } else { dapp-> m_screensaver-> setDisplayState ( false ); } } } } DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) : QPEApplication( argc, argv, appType ) { Config cfg( "apm" ); cfg.setGroup( "Warnings" ); //cfg.readNumEntry( "checkinterval", 10000 ) m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); m_ps = new PowerStatus; m_ps_last = new PowerStatus; pa = new DesktopPowerAlerter( 0 ); m_timer = new QTimer( this ); connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); m_timer->start( 5000 ); channel = new QCopChannel( "QPE/Desktop", this ); connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); m_screensaver = new OpieScreenSaver ( ); m_screensaver-> setInterval ( -1 ); QWSServer::setScreenSaver( m_screensaver ); apmTimeout ( ); } DesktopApplication::~DesktopApplication() { delete m_ps; delete m_ps_last; delete pa; } void DesktopApplication::apmTimeout() { qpedesktop->checkMemory(); // in case no events are being generated *m_ps_last = *m_ps; *m_ps = PowerStatusManager::readStatus(); if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) m_screensaver-> powerStatusChanged ( *m_ps ); diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index 13f28b3..1f8daa0 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h @@ -1,152 +1,152 @@ /********************************************************************** ** 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. ** **********************************************************************/ #ifndef __DESKTOP_H__ #define __DESKTOP_H__ - + #include "shutdownimpl.h" #include <qpe/qpeapplication.h> #include <qwidget.h> #include <qdatetime.h> class Background; class Launcher; class TaskBar; class PowerStatus; class QCopBridge; class TransferServer; class DesktopPowerAlerter; class PackageSlave; class OpieScreenSaver; class DesktopApplication : public QPEApplication { Q_OBJECT public: DesktopApplication( int& argc, char **argv, Type t ); ~DesktopApplication(); static void switchLCD ( bool on ); // only for togglePower in Desktop signals: void menu(); void home(); void datebook(); void contacts(); void launch(); void email(); void backlight(); void power(); void symbol(); void numLockStateToggle(); void capsLockStateToggle(); void prepareForRestart(); protected: #ifdef Q_WS_QWS bool qwsEventFilter( QWSEvent * ); #endif void shutdown(); void restart(); public slots: virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); virtual void systemMessage ( const QCString &msg, const QByteArray &data ); protected slots: void shutdown( ShutdownImpl::Type ); void apmTimeout(); void sendCard(); private: void reloadPowerWarnSettings(); DesktopPowerAlerter *pa; PowerStatus *m_ps, *m_ps_last; QTimer *cardSendTimer; QCopChannel *channel; OpieScreenSaver *m_screensaver; QTimer * m_timer; int m_powerVeryLow; int m_powerCritical; int m_currentPowerLevel; }; class Desktop : public QWidget { Q_OBJECT public: Desktop(); ~Desktop(); static bool screenLocked(); void show(); void checkMemory(); void keyClick(); void screenClick(); static void soundAlarm(); public slots: void raiseDatebook(); void raiseContacts(); void raiseMenu(); void raiseLauncher(); void raiseEmail(); void execAutoStart(); void togglePower(); void toggleLight(); void toggleNumLockState(); void toggleCapsLockState(); void toggleSymbolInput(); void terminateServers(); void rereadVolumes(); void home ( ); protected: void executeOrModify( const QString& appLnkFile ); void styleChange( QStyle & ); void timerEvent( QTimerEvent *e ); QWidget *bg; Launcher *launcher; TaskBar *tb; private: void startTransferServer(); bool recoverMemory(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageSlave *packageSlave; QDateTime suspendTime; bool keyclick, touchclick, alarmsound; }; #endif // __DESKTOP_H__ diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index e663072..88c6219 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp @@ -1,214 +1,214 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** 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. ** **********************************************************************/ #define INCLUDE_MENUITEM_DEF - + #include "startmenu.h" #include "sidething.h" //#include "mrulist.h" #include "info.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/applnk.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qpe/qlibrary.h> #include <qintdict.h> #include <qdir.h> #include <stdlib.h> // #define USE_CONFIG_FILE StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) { loadOptions(); int sz = AppLnk::smallIconSize()+3; QPixmap pm; pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz)); setPixmap(pm); setFocusPolicy( NoFocus ); //setFlat( startButtonIsFlat ); apps = 0; launchMenu = 0; applets. setAutoDelete ( true ); sepId = 0; reloadApps ( ); reloadApplets ( ); } void StartMenu::mousePressEvent( QMouseEvent * ) { launch(); if (desktopInfo) desktopInfo->menuClicked(); } StartMenu::~StartMenu() { delete apps; } void StartMenu::loadOptions() { #ifdef USE_CONFIG_FILE // Read configuration file Config config("StartMenu"); config.setGroup( "StartMenu" ); QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); startButtonPixmap = config.readEntry( "StartButtonPixmap", "launcher/start_button" ); #else // Basically just #include the .qpe_menu.conf file settings useWidePopupMenu = FALSE; popupMenuSidePixmap = "launcher/sidebar"; startButtonIsFlat = TRUE; startButtonPixmap = "launcher/start_button"; // No tr #endif } void StartMenu::createMenu() { delete launchMenu; if ( useWidePopupMenu ) launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); else launchMenu = new StartPopupMenu( this ); loadMenu ( apps, launchMenu ); loadApplets ( ); connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); } void StartMenu::reloadApps() { Config cfg("StartMenu"); cfg.setGroup("Menu"); bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); bool lot = cfg.readBoolEntry("LauncherOther",TRUE); bool lt = ltabs || lot; if ( launchMenu && apps && !lt ) return; // nothing to do if ( lt ) { delete apps; apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); } if ( launchMenu ) { launchMenu-> hide ( ); for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { launchMenu-> removeItem ( it. currentKey ( )); delete it.current ( ); } tabdict. clear ( ); loadMenu(apps,launchMenu); } else { createMenu(); } } void StartMenu::reloadApplets() { if ( launchMenu ) { clearApplets ( ); loadApplets ( ); } else createMenu ( ); } void StartMenu::itemSelected( int id ) { const AppLnk *app = apps->find( id ); if ( app ) app->execute(); else { MenuApplet *applet = applets. find ( id ); if ( applet ) applet-> iface-> activated ( ); } } bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) { bool result = FALSE; Config cfg("StartMenu"); cfg.setGroup("Menu"); bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); bool lot = cfg.readBoolEntry("LauncherOther",TRUE); tabdict. clear ( ); if ( sepId ) menu-> removeItem ( sepId ); sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; if ( ltabs || lot ) { QDict<QPopupMenu> typpop; QStringList typs = folder->types(); for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { if ( !(*tit).isEmpty() ) { QPopupMenu *new_menu; if ( ltabs ) { new_menu = new StartPopupMenu( menu ); connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); tabdict. insert ( id, new_menu ); } else { new_menu = (QPopupMenu*)1; } typpop.insert(*tit, new_menu); } if ( tit == typs. begin ( )) break; } QListIterator<AppLnk> it( folder->children() ); bool f=TRUE; for ( ; it.current(); ++it ) { AppLnk *app = it.current(); if ( app->type() == "Separator" ) { // No tr if ( lot ) { menu->insertSeparator(); } } else { f = FALSE; QString t = app->type(); QPopupMenu* pmenu = typpop.find(t); if ( ltabs ) { |