author | sandman <sandman> | 2002-06-18 12:49:05 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-18 12:49:05 (UTC) |
commit | c739f74f910b24884279d34836c1f78a97a7e7ae (patch) (side-by-side diff) | |
tree | 432c379c30469e2be9117b4895b345e4947e688a | |
parent | 61e2f9e5eb634b17ef480d79bdbcbc3a715990cb (diff) | |
download | opie-c739f74f910b24884279d34836c1f78a97a7e7ae.zip opie-c739f74f910b24884279d34836c1f78a97a7e7ae.tar.gz opie-c739f74f910b24884279d34836c1f78a97a7e7ae.tar.bz2 |
Replaced OHwInfo with ODevice and ported from custom-*.h #defines to
ODevice methods
-rw-r--r-- | core/launcher/desktop.cpp | 58 | ||||
-rw-r--r-- | core/launcher/main.cpp | 13 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 47 | ||||
-rw-r--r-- | core/launcher/taskbar.h | 4 |
4 files changed, 53 insertions, 69 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index ab4f14a..7662e48 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -14,64 +14,66 @@ ** 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 "mrulist.h" #include "qcopbridge.h" #include "shutdownimpl.h" #include "startmenu.h" #include "taskbar.h" #include "transferserver.h" #include "irserver.h" #include "packageslave.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/global.h> #if defined( QT_QWS_CUSTOM ) || 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> 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; @@ -238,140 +240,132 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) } } if ( ke->simpleData.keycode == Key_F34 ) { if ( press ) emit power(); return TRUE; } // This was used for the iPAQ PowerButton // See main.cpp for new KeyboardFilter // // if ( ke->simpleData.keycode == Key_SysReq ) { // if ( press ) emit power(); // return TRUE; // } if ( ke->simpleData.keycode == Key_F35 ) { if ( press ) emit backlight(); return TRUE; } if ( ke->simpleData.keycode == Key_F32 ) { if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); return TRUE; } if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { if ( press ) emit symbol(); return TRUE; } if ( ke->simpleData.keycode == Key_NumLock ) { if ( press ) emit numLockStateToggle(); } if ( ke->simpleData.keycode == Key_CapsLock ) { if ( press ) emit capsLockStateToggle(); } - if ( press ) + if (( press && !autoRepeat ) || ( !press && autoRepeat )) qpedesktop->keyClick(); } else { if ( e->type == QWSEvent::Mouse ) { QWSMouseEvent *me = (QWSMouseEvent *)e; static bool up = TRUE; if ( me->simpleData.state&LeftButton ) { if ( up ) { up = FALSE; qpedesktop->screenClick(); } } else { up = TRUE; } } } return QPEApplication::qwsEventFilter( e ); } #endif void DesktopApplication::psTimeout() { qpedesktop->checkMemory(); // in case no events are being generated *ps = PowerStatusManager::readStatus(); if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { pa->alert( tr( "Battery is running very low." ), 6 ); } if ( ps->batteryStatus() == PowerStatus::Critical ) { pa->alert( tr( "Battery level is critical!\n" "Keep power off until power restored!" ), 1 ); } if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); } } void DesktopApplication::sendCard() { delete cardSendTimer; cardSendTimer = 0; QString card = getenv("HOME"); card += "/Applications/addressbook/businesscard.vcf"; if ( QFile::exists( card ) ) { QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); QString mimetype = "text/x-vCard"; e << tr("business card") << card << mimetype; } } #if defined(QPE_HAVE_MEMALERTER) QPE_MEMALERTER_IMPL #endif -#if defined(CUSTOM_SOUND_IMPL) -CUSTOM_SOUND_IMPL -#endif - //=========================================================================== Desktop::Desktop() : QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), qcopBridge( 0 ), transferServer( 0 ), packageSlave( 0 ) { -#ifdef CUSTOM_SOUND_INIT - CUSTOM_SOUND_INIT; -#endif - qpedesktop = this; // bg = new Info( this ); tb = new TaskBar; launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); int displayw = qApp->desktop()->width(); int displayh = qApp->desktop()->height(); QSize sz = tb->sizeHint(); setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); tb->show(); launcher->showMaximized(); launcher->show(); launcher->raise(); #if defined(QPE_HAVE_MEMALERTER) initMemalerter(); #endif // start services startTransferServer(); (void) new IrServer( this ); rereadVolumes(); packageSlave = new PackageSlave( this ); @@ -727,70 +721,64 @@ void Desktop::startTransferServer() startTimer( 2000 ); } void Desktop::timerEvent( QTimerEvent *e ) { killTimer( e->timerId() ); startTransferServer(); } void Desktop::terminateServers() { delete transferServer; delete qcopBridge; transferServer = 0; qcopBridge = 0; } void Desktop::rereadVolumes() { Config cfg("qpe"); cfg.setGroup("Volume"); touchclick = cfg.readBoolEntry("TouchSound"); keyclick = cfg.readBoolEntry("KeySound"); alarmsound = cfg.readBoolEntry("AlarmSound"); // Config cfg("Sound"); // cfg.setGroup("System"); // touchclick = cfg.readBoolEntry("Touch"); // keyclick = cfg.readBoolEntry("Key"); } void Desktop::keyClick() { -#ifdef CUSTOM_SOUND_KEYCLICK - if ( keyclick ) - CUSTOM_SOUND_KEYCLICK; -#endif + if ( keyclick ) + ODevice::inst ( )-> keySound ( ); } void Desktop::screenClick() { -#ifdef CUSTOM_SOUND_TOUCH - if ( touchclick ) - CUSTOM_SOUND_TOUCH; -#endif + if ( touchclick ) + ODevice::inst ( )-> touchSound ( ); } void Desktop::soundAlarm() { -#ifdef CUSTOM_SOUND_ALARM - if (qpedesktop->alarmsound) - CUSTOM_SOUND_ALARM; -#endif + if ( qpedesktop-> alarmsound ) + ODevice::inst ( )-> alarmSound ( ); } -bool Desktop::eventFilter( QObject *w, QEvent *ev ) +bool Desktop::eventFilter( QObject *, QEvent *ev ) { - if ( ev->type() == QEvent::KeyPress ) { - QKeyEvent *ke = (QKeyEvent *)ev; - if ( ke->key() == Qt::Key_F11 ) { // menu key - QWidget *active = qApp->activeWindow(); - if ( active && active->isPopup() ) { - active->close(); - } - raiseMenu(); - return TRUE; - } - } - return FALSE; -} + if ( ev-> type ( ) == QEvent::KeyPress ) { + QKeyEvent *ke = (QKeyEvent *) ev; + if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key + QWidget *active = qApp-> activeWindow ( ); + + if ( active && active-> isPopup ( )) + active->close(); + raiseMenu ( ); + return true; + } + } + return false; +} diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 347eee9..b3c331b 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp @@ -1,70 +1,70 @@ /********************************************************************** ** 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 "taskbar.h" #include "stabmon.h" #include <qpe/qpeapplication.h> #include <qpe/network.h> #include <qpe/config.h> #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) #include <qpe/custom.h> #endif +#include <opie/odevice.h> + #include <qfile.h> #include <qwindowsystem_qws.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/alarmserver.h> -#include <opie/ohwinfo.h> - #include <stdlib.h> #include <stdio.h> #include <signal.h> #include <unistd.h> #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) #include "../calibrate/calibrate.h" #endif #ifdef QT_QWS_LOGIN #include "../login/qdmdialogimpl.h" #endif #ifdef QT_QWS_CASSIOPEIA static void ignoreMessage( QtMsgType, const char * ) { } #include <sys/mount.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include <fcntl.h> #include <qdatetime.h> void initCassiopeia() { // MIPSEL-specific init - make sure /proc exists for shm /* if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { perror("Remounting - / read/write"); } */ @@ -164,141 +164,140 @@ void initEnvironment() { Config config("locale"); config.setGroup( "Location" ); QString tz = config.readEntry( "Timezone", getenv("TZ") ); // if not timezone set, pick New York if (tz.isNull()) tz = "America/New_York"; setenv( "TZ", tz, 1 ); config.writeEntry( "Timezone", tz); config.setGroup( "Language" ); QString lang = config.readEntry( "Language", getenv("LANG") ); if ( !lang.isNull() ) setenv( "LANG", lang, 1 ); } static void initBacklight() { QCopEnvelope e("QPE/System", "setBacklight(int)" ); e << -3; // Forced on } class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter { public: ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) { bool doinst = false; - m_model = OHwInfo::inst ( )-> model ( ); + m_model = ODevice::inst ( )-> model ( ); m_power_timer = 0; switch ( m_model ) { case OMODEL_iPAQ_H31xx: case OMODEL_iPAQ_H36xx: case OMODEL_iPAQ_H37xx: case OMODEL_iPAQ_H38xx: doinst = true; break; default : break; } if ( doinst ) QWSServer::setKeyboardFilter ( this ); } - virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) + virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) { bool kill = false; // Rotate cursor keys 180° switch ( m_model ) { case OMODEL_iPAQ_H31xx: case OMODEL_iPAQ_H38xx: { int newkeycode = keycode; switch ( keycode ) { case Key_Left : newkeycode = Key_Right; break; case Key_Right: newkeycode = Key_Left; break; case Key_Up : newkeycode = Key_Down; break; case Key_Down : newkeycode = Key_Up; break; } if ( newkeycode != keycode ) { QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); kill = true; } break; } default: break; } // map Power Button short/long press to F34/F35 switch ( m_model ) { case OMODEL_iPAQ_H31xx: case OMODEL_iPAQ_H36xx: case OMODEL_iPAQ_H37xx: case OMODEL_iPAQ_H38xx: { if ( keycode == Key_SysReq ) { if ( isPress ) { m_power_timer = startTimer ( 500 ); } else if ( m_power_timer ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); } kill = true; } break; } default: break; } return kill; } virtual void timerEvent ( QTimerEvent * ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); } private: - OHwModel m_model; - bool m_power_press; - int m_power_timer; + OModel m_model; + int m_power_timer; }; int initApplication( int argc, char ** argv ) { #ifdef QT_QWS_CASSIOPEIA initCassiopeia(); #endif #ifdef QPE_OWNAPM initAPM(); #endif #ifdef QT_DEMO_SINGLE_FLOPPY initFloppy(); #endif initEnvironment(); #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) setenv( "QWS_SIZE", "240x320", 0 ); #endif //Don't flicker at startup: QWSServer::setDesktopBackground( QImage() ); DesktopApplication a( argc, argv, QApplication::GuiServer ); (void) new ModelKeyFilter ( ); initBacklight(); diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index 5e95c99..e38b9fe 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp @@ -8,64 +8,66 @@ ** 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 "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 @@ -224,87 +226,86 @@ void TaskBar::resizeEvent( QResizeEvent *e ) } 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(); - } else if ( msg == "soundAlarm()" ) { - Desktop::soundAlarm(); - } -#ifdef CUSTOM_LEDS - else if ( msg == "setLed(int,bool)" ) { - int led, status; - stream >> led >> status; - CUSTOM_LEDS( led, status ); - } -#endif + 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(); + } 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"); } } diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h index 78c4722..40983af 100644 --- a/core/launcher/taskbar.h +++ b/core/launcher/taskbar.h @@ -1,59 +1,55 @@ /********************************************************************** ** 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 __TASKBAR_H__ #define __TASKBAR_H__ -#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) -#include <qpe/custom.h> -#endif - #include <qhbox.h> class QLabel; class QTimer; class InputMethods; class Wait; class SysTray; class MRUList; class QWidgetStack; class QTimer; class QLabel; class StartMenu; class LockKeyState; class TaskBar : public QHBox { Q_OBJECT public: TaskBar(); ~TaskBar(); static QWidget *calibrate( bool ); bool recoverMemory(); StartMenu *startMenu() const { return sm; } public slots: void startWait(); void stopWait(const QString&); void stopWait(); void clearStatusBar(); void toggleNumLockState(); void toggleCapsLockState(); |