-rw-r--r-- | core/launcher/desktop.cpp | 132 | ||||
-rw-r--r-- | core/launcher/desktop.h | 4 | ||||
-rw-r--r-- | core/launcher/opie-taskbar.control | 4 |
3 files changed, 100 insertions, 40 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index d39af25..ce99bad 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -1,315 +1,371 @@ /********************************************************************** ** 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 "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/qcopenvelope_qws.h> #include <qpe/global.h> #ifdef QT_QWS_CUSTOM #include "qpe/custom.h" #endif #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; 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; } DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) : QPEApplication( argc, argv, t ) { QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); t->start( 10000 ); ps = new PowerStatus; pa = new DesktopPowerAlerter( 0 ); + + channel = new QCopChannel( "QPE/Desktop", this ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT(receive(const QCString&, const QByteArray&)) ); } DesktopApplication::~DesktopApplication() { delete ps; delete pa; } +void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) +{ + QDataStream stream( data, IO_ReadOnly ); + if (msg == "keyRegister(int key, QString channel, QString message)") + { + int k; + QString c, m; + + stream >> k; + stream >> c; + stream >> m; + + qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); + keyRegisterList.append(QCopKeyRegister(k,c,m)); + } +} enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; #ifdef Q_WS_QWS bool DesktopApplication::qwsEventFilter( QWSEvent *e ) { qpedesktop->checkMemory(); if ( e->type == QWSEvent::Key ) { - QWSKeyEvent *ke = (QWSKeyEvent *)e; - if ( !loggedin && ke->simpleData.keycode != Key_F34 ) + QWSKeyEvent *ke = (QWSKeyEvent *)e; + if ( !loggedin && ke->simpleData.keycode != Key_F34 ) return TRUE; - bool press = ke->simpleData.is_press; - if ( !keyboardGrabbed() ) { + bool press = ke->simpleData.is_press; + + KeyRegisterList::Iterator it; + for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) + { + if ((*it).getKeyCode() == ke->simpleData.keycode) + QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); + } + + if ( !keyboardGrabbed() ) { if ( ke->simpleData.keycode == Key_F9 ) { - if ( press ) emit datebook(); - return TRUE; + if ( press ) emit datebook(); + return TRUE; } if ( ke->simpleData.keycode == Key_F10 ) { if ( !press && cardSendTimer ) { emit contacts(); delete cardSendTimer; - } else if ( press ) { + } else if ( press ) { cardSendTimer = new QTimer(); cardSendTimer->start( 2000, TRUE ); connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); - } - return TRUE; + } + return TRUE; } /* menu key now opens application menu/toolbar - if ( ke->simpleData.keycode == Key_F11 ) { - if ( press ) emit menu(); - return TRUE; - } + if ( ke->simpleData.keycode == Key_F11 ) { + if ( press ) emit menu(); + return TRUE; + } */ if ( ke->simpleData.keycode == Key_F12 ) { - while( activePopupWidget() ) + while( activePopupWidget() ) activePopupWidget()->close(); - if ( press ) emit launch(); - return TRUE; + if ( press ) emit launch(); + return TRUE; } if ( ke->simpleData.keycode == Key_F13 ) { - if ( press ) emit email(); - return TRUE; + if ( press ) emit email(); + return TRUE; } - } - if ( ke->simpleData.keycode == Key_F34 ) { + } + /* + if ( ke->simpleData.keycode == 4096 ) { + QCopEnvelope e("QPE/VMemo", "toggleRecord()"); + return TRUE; + } + */ + if ( ke->simpleData.keycode == Key_F34 ) { if ( press ) emit power(); return TRUE; - } - if ( ke->simpleData.keycode == Key_F35 ) { + } + if ( ke->simpleData.keycode == Key_F35 ) { if ( press ) emit backlight(); return TRUE; - } - if ( ke->simpleData.keycode == Key_F32 ) { + } + 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 ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { if ( press ) emit symbol(); return TRUE; - } - if ( ke->simpleData.keycode == Key_NumLock ) { + } + if ( ke->simpleData.keycode == Key_NumLock ) { if ( press ) emit numLockStateToggle(); - } - if ( ke->simpleData.keycode == Key_CapsLock ) { + } + if ( ke->simpleData.keycode == Key_CapsLock ) { if ( press ) emit capsLockStateToggle(); - } - if ( press ) + } + if ( press ) qpedesktop->keyClick(); } else { - if ( e->type == QWSEvent::Mouse ) { + if ( e->type == QWSEvent::Mouse ) { QWSMouseEvent *me = (QWSMouseEvent *)e; static bool up = TRUE; if ( me->simpleData.state&LeftButton ) { - if ( up ) { + if ( up ) { up = FALSE; qpedesktop->screenClick(); - } + } } else { - up = TRUE; + 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 ); connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); qApp->installEventFilter( this ); } diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index dfdbeab..f0a7cba 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h @@ -1,129 +1,133 @@ /********************************************************************** ** 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> class Background; class Launcher; class TaskBar; class PowerStatus; class QCopBridge; class TransferServer; class DesktopPowerAlerter; class PackageSlave; class DesktopApplication : public QPEApplication { Q_OBJECT public: DesktopApplication( int& argc, char **argv, Type t ); ~DesktopApplication(); signals: 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: + void receive( const QCString &msg, const QByteArray &data ); + protected slots: void shutdown(ShutdownImpl::Type); void psTimeout(); void sendCard(); private: DesktopPowerAlerter *pa; PowerStatus *ps; QTimer *cardSendTimer; + QCopChannel *channel; }; 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 togglePower(); void toggleLight(); void toggleNumLockState(); void toggleCapsLockState(); void toggleSymbolInput(); void terminateServers(); void rereadVolumes(); protected: void executeOrModify(const QString& appLnkFile); void styleChange( QStyle & ); void timerEvent( QTimerEvent *e ); bool eventFilter( QObject *, QEvent * ); QWidget *bg; Launcher *launcher; TaskBar *tb; private: void startTransferServer(); bool recoverMemory(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageSlave *packageSlave; bool keyclick,touchclick; }; #endif // __DESKTOP_H__ diff --git a/core/launcher/opie-taskbar.control b/core/launcher/opie-taskbar.control index 53daa82..3db0480 100644 --- a/core/launcher/opie-taskbar.control +++ b/core/launcher/opie-taskbar.control @@ -1,9 +1,9 @@ Files: bin/qpe apps/Settings/Calibrate.desktop Priority: required Section: opie/system Maintainer: Warwick Allison <warwick@trolltech.com> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION-$SUB_VERSION.1 Depends: qt-embedded (>=$QTE_VERSION) Description: Launcher for Opie - The "finder" or "explorer", or whatever you want to call it. + The "finder" or "explorer", or whatever you want to call it.
\ No newline at end of file |