summaryrefslogtreecommitdiff
path: root/core/applets/logoutapplet
authorsandman <sandman>2002-10-06 22:22:17 (UTC)
committer sandman <sandman>2002-10-06 22:22:17 (UTC)
commit932cb3b350748549bfdb6fdc6f080061f4340f73 (patch) (side-by-side diff)
tree2998710324342eed2b4da3dc37f09fbf42daddda /core/applets/logoutapplet
parent685c08f1c48813f9d222446f0516b8e20635607e (diff)
downloadopie-932cb3b350748549bfdb6fdc6f080061f4340f73.zip
opie-932cb3b350748549bfdb6fdc6f080061f4340f73.tar.gz
opie-932cb3b350748549bfdb6fdc6f080061f4340f73.tar.bz2
- added a new logout menu-applet
- fixed the positions of all menu applets - changed the icons for logout/suspend
Diffstat (limited to 'core/applets/logoutapplet') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/logoutapplet/logout.cpp115
-rw-r--r--core/applets/logoutapplet/logout.h47
-rw-r--r--core/applets/logoutapplet/logoutapplet.pro25
3 files changed, 187 insertions, 0 deletions
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