summaryrefslogtreecommitdiff
path: root/noncore/applets/autorotateapplet
Unidiff
Diffstat (limited to 'noncore/applets/autorotateapplet') (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/autorotateapplet/autorotate.cpp11
-rw-r--r--noncore/applets/autorotateapplet/autorotate.h3
-rw-r--r--noncore/applets/autorotateapplet/autorotateapplet.pro4
-rw-r--r--noncore/applets/autorotateapplet/autorotateimpl.cpp42
-rw-r--r--noncore/applets/autorotateapplet/autorotateimpl.h18
5 files changed, 14 insertions, 64 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp
index 5152904..94be0ae 100644
--- a/noncore/applets/autorotateapplet/autorotate.cpp
+++ b/noncore/applets/autorotateapplet/autorotate.cpp
@@ -5,24 +5,25 @@
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 * * 10 * *
11 *************************************************************************/ 11 *************************************************************************/
12 12
13#include "autorotate.h" 13#include "autorotate.h"
14 14
15/* OPIE */ 15/* OPIE */
16#include <opie2/odevice.h> 16#include <opie2/odevice.h>
17#include <opie2/otaskbarapplet.h>
17#include <qpe/applnk.h> 18#include <qpe/applnk.h>
18#include <qpe/config.h> 19#include <qpe/config.h>
19#include <qpe/resource.h> 20#include <qpe/resource.h>
20 21
21/* QT */ 22/* QT */
22#include <qpainter.h> 23#include <qpainter.h>
23 24
24using namespace Opie; 25using namespace Opie;
25 26
26AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) 27AutoRotate::AutoRotate(QWidget * parent):QWidget(parent)
27{ 28{
28 setFixedWidth( AppLnk::smallIconSize() ); 29 setFixedWidth( AppLnk::smallIconSize() );
@@ -34,24 +35,29 @@ AutoRotate::AutoRotate(QWidget * parent):QWidget(parent)
34 repaint(true); 35 repaint(true);
35 popupMenu = 0; 36 popupMenu = 0;
36 show(); 37 show();
37} 38}
38 39
39AutoRotate::~AutoRotate() 40AutoRotate::~AutoRotate()
40{ 41{
41 if (popupMenu) { 42 if (popupMenu) {
42 delete popupMenu; 43 delete popupMenu;
43 } 44 }
44} 45}
45 46
47int AutoRotate::position()
48{
49 return 7;
50}
51
46void AutoRotate::mousePressEvent(QMouseEvent *) 52void AutoRotate::mousePressEvent(QMouseEvent *)
47{ 53{
48 QPopupMenu *menu = new QPopupMenu(this); 54 QPopupMenu *menu = new QPopupMenu(this);
49 menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); 55 menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 );
50 56
51 QPoint p = mapToGlobal(QPoint(0, 0)); 57 QPoint p = mapToGlobal(QPoint(0, 0));
52 QSize s = menu->sizeHint(); 58 QSize s = menu->sizeHint();
53 int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); 59 int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0);
54 60
55 if (opt==1) 61 if (opt==1)
56 { 62 {
57 setRotateEnabled( !isRotateEnabled() ); 63 setRotateEnabled( !isRotateEnabled() );
@@ -79,12 +85,17 @@ bool AutoRotate::isRotateEnabled()
79 Config cfg( "qpe" ); 85 Config cfg( "qpe" );
80 cfg.setGroup( "Appearance" ); 86 cfg.setGroup( "Appearance" );
81 87
82 bool res = cfg.readBoolEntry( "rotateEnabled" ); 88 bool res = cfg.readBoolEntry( "rotateEnabled" );
83 89
84 if (res ) 90 if (res )
85 qDebug("Enabled"); 91 qDebug("Enabled");
86 else 92 else
87 qDebug("Disabled"); 93 qDebug("Disabled");
88 return res; 94 return res;
89} 95}
90 96
97Q_EXPORT_INTERFACE()
98{
99 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<AutoRotate> );
100}
101
diff --git a/noncore/applets/autorotateapplet/autorotate.h b/noncore/applets/autorotateapplet/autorotate.h
index e05e7a0..ef322a6 100644
--- a/noncore/applets/autorotateapplet/autorotate.h
+++ b/noncore/applets/autorotateapplet/autorotate.h
@@ -13,26 +13,25 @@
13#ifndef AUTOROTATE_H 13#ifndef AUTOROTATE_H
14#define AUTOROTATE_H 14#define AUTOROTATE_H
15 15
16#include <qwidget.h> 16#include <qwidget.h>
17#include <qpixmap.h> 17#include <qpixmap.h>
18#include <qpopupmenu.h> 18#include <qpopupmenu.h>
19 19
20class AutoRotate : public QWidget { 20class AutoRotate : public QWidget {
21 Q_OBJECT 21 Q_OBJECT
22public: 22public:
23 AutoRotate( QWidget *parent = 0 ); 23 AutoRotate( QWidget *parent = 0 );
24 ~AutoRotate(); 24 ~AutoRotate();
25 25 static int position();
26private slots:
27 26
28protected: 27protected:
29 void paintEvent( QPaintEvent* ); 28 void paintEvent( QPaintEvent* );
30 void mousePressEvent( QMouseEvent * ); 29 void mousePressEvent( QMouseEvent * );
31private: 30private:
32 bool isRotateEnabled(); 31 bool isRotateEnabled();
33 void setRotateEnabled(bool); 32 void setRotateEnabled(bool);
34 QPixmap enabledPm; 33 QPixmap enabledPm;
35 QPixmap disabledPm; 34 QPixmap disabledPm;
36 void iconShow(); 35 void iconShow();
37 QPopupMenu *popupMenu; 36 QPopupMenu *popupMenu;
38 }; 37 };
diff --git a/noncore/applets/autorotateapplet/autorotateapplet.pro b/noncore/applets/autorotateapplet/autorotateapplet.pro
index 0ccbeba..465b165 100644
--- a/noncore/applets/autorotateapplet/autorotateapplet.pro
+++ b/noncore/applets/autorotateapplet/autorotateapplet.pro
@@ -1,13 +1,13 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt plugin warn_on release 2CONFIG += qt plugin warn_on release
3HEADERS = autorotate.h autorotateimpl.h 3HEADERS = autorotate.h
4SOURCES = autorotate.cpp autorotateimpl.cpp 4SOURCES = autorotate.cpp
5TARGET = autorotateapplet 5TARGET = autorotateapplet
6DESTDIR = $(OPIEDIR)/plugins/applets 6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include ../launcher 8DEPENDPATH += $(OPIEDIR)/include ../launcher
9LIBS += -lqpe -lopiecore2 9LIBS += -lqpe -lopiecore2
10VERSION = 1.0.0 10VERSION = 1.0.0
11 11
12include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )
13target.path = $$prefix/plugins/applets 13target.path = $$prefix/plugins/applets
diff --git a/noncore/applets/autorotateapplet/autorotateimpl.cpp b/noncore/applets/autorotateapplet/autorotateimpl.cpp
deleted file mode 100644
index 305ac50..0000000
--- a/noncore/applets/autorotateapplet/autorotateimpl.cpp
+++ b/dev/null
@@ -1,42 +0,0 @@
1#include "autorotate.h"
2#include "autorotateimpl.h"
3
4
5AutoRotateImpl::AutoRotateImpl()
6 : autoRotate(0){
7 qDebug ("here");
8}
9
10AutoRotateImpl::~AutoRotateImpl() {
11 delete autoRotate;
12}
13
14QWidget *AutoRotateImpl::applet( QWidget *parent ) {
15 if ( !autoRotate ) {
16 autoRotate = new AutoRotate( parent );
17 }
18 return autoRotate;
19}
20
21int AutoRotateImpl::position() const {
22 return 7;
23}
24
25QRESULT AutoRotateImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
26 *iface = 0;
27 if ( uuid == IID_QUnknown ) {
28 *iface = this;
29 } else if ( uuid == IID_TaskbarApplet ) {
30 *iface = this;
31 } else
32 return QS_FALSE;
33
34 if ( *iface ) {
35 (*iface)->addRef();
36 }
37 return QS_OK;
38}
39
40Q_EXPORT_INTERFACE() {
41 Q_CREATE_INSTANCE( AutoRotateImpl )
42}
diff --git a/noncore/applets/autorotateapplet/autorotateimpl.h b/noncore/applets/autorotateapplet/autorotateimpl.h
deleted file mode 100644
index fde23a9..0000000
--- a/noncore/applets/autorotateapplet/autorotateimpl.h
+++ b/dev/null
@@ -1,18 +0,0 @@
1#include <qpe/taskbarappletinterface.h>
2
3class AutoRotate;
4
5class AutoRotateImpl : public TaskbarAppletInterface {
6public:
7 AutoRotateImpl();
8 virtual ~AutoRotateImpl();
9
10 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
11 Q_REFCOUNT
12
13 virtual QWidget *applet( QWidget *parent );
14 virtual int position() const;
15
16private:
17 AutoRotate *autoRotate;
18};