-rw-r--r-- | core/applets/homeapplet/home.cpp | 4 | ||||
-rw-r--r-- | core/applets/logoutapplet/logout.cpp | 115 | ||||
-rw-r--r-- | core/applets/logoutapplet/logout.h | 47 | ||||
-rw-r--r-- | core/applets/logoutapplet/logoutapplet.pro | 25 | ||||
-rw-r--r-- | core/applets/suspendapplet/suspend.cpp | 6 |
5 files changed, 192 insertions, 5 deletions
diff --git a/core/applets/homeapplet/home.cpp b/core/applets/homeapplet/home.cpp index 2b726ae..3670e6d 100644 --- a/core/applets/homeapplet/home.cpp +++ b/core/applets/homeapplet/home.cpp @@ -18,7 +18,7 @@ HomeApplet::~HomeApplet ( ) int HomeApplet::position ( ) const { - return 0; + return 4; } QString HomeApplet::name ( ) const @@ -37,7 +37,7 @@ QIconSet HomeApplet::icon ( ) const QImage img = Resource::loadImage ( "home" ); if ( !img. isNull ( )) - pix. convertFromImage ( img. smoothScale ( 16, 16 )); + pix. convertFromImage ( img. smoothScale ( 14, 14 )); return pix; } diff --git a/core/applets/logoutapplet/logout.cpp b/core/applets/logoutapplet/logout.cpp new file mode 100644 index 0000000..9470401 --- a/dev/null +++ b/core/applets/logoutapplet/logout.cpp @@ -0,0 +1,115 @@ +#include <qpe/resource.h> +#include <qpe/qcopenvelope_qws.h> + +#include <qapplication.h> +#include <qiconset.h> +#include <qpopupmenu.h> +#include <qmessagebox.h> + +#include <unistd.h> + +#include "logout.h" + + +LogoutApplet::LogoutApplet ( ) + : QObject ( 0, "LogoutApplet" ), ref ( 0 ) +{ +} + +LogoutApplet::~LogoutApplet ( ) +{ +} + +int LogoutApplet::position ( ) const +{ + return 0; +} + +QString LogoutApplet::name ( ) const +{ + return tr( "Logout shortcut" ); +} + +QString LogoutApplet::text ( ) const +{ + return tr( "Logout" ); +} + +QIconSet LogoutApplet::icon ( ) const +{ + QPixmap pix; + QImage img = Resource::loadImage ( "logout" ); + + if ( !img. isNull ( )) + pix. convertFromImage ( img. smoothScale ( 14, 14 )); + return pix; +} + +QPopupMenu *LogoutApplet::popup ( QWidget * ) const +{ + return 0; +} + +// This is a workaround for a Qt bug +// clipboard applet has to stop its poll timer, or Qt/E +// will hang on quit() right before it emits aboutToQuit() + +class HackApplication : public QApplication { +public: + HackApplication ( ) : QApplication ( dummy, 0 ) + { + } + + void emit_about_to_quit ( ) + { + emit aboutToQuit ( ); + } + + int dummy; +}; + + +void LogoutApplet::activated ( ) +{ + QMessageBox mb ( tr( "Logout" ), + tr( "Do you really want to\nend this session ?" ), + QMessageBox::NoIcon, + QMessageBox::Yes | QMessageBox::Default, + QMessageBox::No | QMessageBox::Escape, + QMessageBox::NoButton ); + + mb. setButtonText ( QMessageBox::Yes, "Yes" ); + mb. setButtonText ( QMessageBox::No, "No" ); + mb. setIconPixmap ( icon ( ). pixmap ( )); + + if ( mb. exec ( ) == QMessageBox::Yes ) { + { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); } + + qApp-> processEvents ( ); // ensure the message goes out. + sleep ( 1 ); // You have 1 second to comply. + + ((HackApplication *) qApp )-> emit_about_to_quit ( ); + qApp-> quit(); + } +} + + +QRESULT LogoutApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_MenuApplet ) + *iface = this; + + if ( *iface ) + (*iface)-> addRef ( ); + return QS_OK; +} + +Q_EXPORT_INTERFACE( ) +{ + Q_CREATE_INSTANCE( LogoutApplet ) +} + + diff --git a/core/applets/logoutapplet/logout.h b/core/applets/logoutapplet/logout.h new file mode 100644 index 0000000..e45f3ba --- a/dev/null +++ b/core/applets/logoutapplet/logout.h @@ -0,0 +1,47 @@ +/********************************************************************** +** 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 __OPIE_LOGOUT_APPLET_H__ +#define __OPIE_LOGOUT_APPLET_H__ + +#include <qpe/menuappletinterface.h> + +class LogoutApplet : public QObject, public MenuAppletInterface +{ +public: + LogoutApplet ( ); + virtual ~LogoutApplet ( ); + + QRESULT queryInterface( const QUuid&, QUnknownInterface** ); + Q_REFCOUNT + + virtual int position() const; + + virtual QString name ( ) const; + virtual QIconSet icon ( ) const; + virtual QString text ( ) const; + virtual QPopupMenu *popup ( QWidget *parent ) const; + + virtual void activated ( ); + +private: + ulong ref; +}; + +#endif diff --git a/core/applets/logoutapplet/logoutapplet.pro b/core/applets/logoutapplet/logoutapplet.pro new file mode 100644 index 0000000..9adfea5 --- a/dev/null +++ b/core/applets/logoutapplet/logoutapplet.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +HEADERS = logout.h +SOURCES = logout.cpp +TARGET = logoutapplet +DESTDIR = $(OPIEDIR)/plugins/applets +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe +VERSION = 1.0.0 + +TRANSLATIONS = ../../../i18n/de/liblogoutapplet.ts \ + ../../../i18n/en/liblogoutapplet.ts \ + ../../../i18n/es/liblogoutapplet.ts \ + ../../../i18n/fr/liblogoutapplet.ts \ + ../../../i18n/hu/liblogoutapplet.ts \ + ../../../i18n/ja/liblogoutapplet.ts \ + ../../../i18n/ko/liblogoutapplet.ts \ + ../../../i18n/no/liblogoutapplet.ts \ + ../../../i18n/pl/liblogoutapplet.ts \ + ../../../i18n/pt/liblogoutapplet.ts \ + ../../../i18n/pt_BR/liblogoutapplet.ts \ + ../../../i18n/sl/liblogoutapplet.ts \ + ../../../i18n/zh_CN/liblogoutapplet.ts \ + ../../../i18n/zh_TW/liblogoutapplet.ts diff --git a/core/applets/suspendapplet/suspend.cpp b/core/applets/suspendapplet/suspend.cpp index 5966a84..e9861e8 100644 --- a/core/applets/suspendapplet/suspend.cpp +++ b/core/applets/suspendapplet/suspend.cpp @@ -18,7 +18,7 @@ SuspendApplet::~SuspendApplet ( ) int SuspendApplet::position ( ) const { - return 0; + return 2; } QString SuspendApplet::name ( ) const @@ -34,10 +34,10 @@ QString SuspendApplet::text ( ) const QIconSet SuspendApplet::icon ( ) const { QPixmap pix; - QImage img = Resource::loadImage ( "Shutdown" ); + QImage img = Resource::loadImage ( "suspend" ); if ( !img. isNull ( )) - pix. convertFromImage ( img. smoothScale ( 16, 16 )); + pix. convertFromImage ( img. smoothScale ( 14, 14 )); return pix; } |