-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.cpp | 110 | ||||
-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.h | 41 | ||||
-rw-r--r-- | noncore/applets/autorotateapplet/autorotateapplet.pro | 13 | ||||
-rw-r--r-- | noncore/applets/autorotateapplet/autorotateimpl.cpp | 41 | ||||
-rw-r--r-- | noncore/applets/autorotateapplet/autorotateimpl.h | 19 | ||||
-rw-r--r-- | noncore/applets/autorotateapplet/config.in | 4 | ||||
-rw-r--r-- | noncore/applets/autorotateapplet/opie-autorotate.control | 11 | ||||
-rwxr-xr-x | noncore/applets/autorotateapplet/opie-autorotate.postinst | 6 | ||||
-rwxr-xr-x | noncore/applets/autorotateapplet/opie-autorotate.postrm | 2 | ||||
-rw-r--r-- | pics/autorotate/norotate.png | bin | 0 -> 720 bytes | |||
-rw-r--r-- | pics/autorotate/rotate.png | bin | 0 -> 485 bytes |
11 files changed, 247 insertions, 0 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp new file mode 100644 index 0000000..4733860 --- a/dev/null +++ b/noncore/applets/autorotateapplet/autorotate.cpp | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * copyright : (c) 2003 by Greg Gilbert | ||
3 | * email : greg@treke.net | ||
4 | * based on the cardmon applet by Max Reiss | ||
5 | * * | ||
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 * | ||
8 | * the Free Software Foundation; either version 2 of the License, or * | ||
9 | * (at your option) any later version. * | ||
10 | * * | ||
11 | *************************************************************************/ | ||
12 | |||
13 | |||
14 | #include "autorotate.h" | ||
15 | |||
16 | #include <qpe/resource.h> | ||
17 | |||
18 | #include <opie/odevice.h> | ||
19 | |||
20 | #include <qpe/applnk.h> | ||
21 | #include <qpe/config.h> | ||
22 | |||
23 | #include <qcopchannel_qws.h> | ||
24 | #include <qpainter.h> | ||
25 | #include <qmessagebox.h> | ||
26 | #include <qfile.h> | ||
27 | #include <qtextstream.h> | ||
28 | #include <qtimer.h> | ||
29 | #include <qapplication.h> | ||
30 | |||
31 | using namespace Opie; | ||
32 | |||
33 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent), | ||
34 | enabledPm( Resource::loadPixmap("autorotate/rotate") ), | ||
35 | disabledPm( Resource::loadPixmap("autorotate/norotate") ) | ||
36 | { | ||
37 | setFixedWidth ( AppLnk::smallIconSize() ); | ||
38 | setFixedHeight ( AppLnk::smallIconSize() ); | ||
39 | |||
40 | repaint(true); | ||
41 | popupMenu = 0; | ||
42 | show(); | ||
43 | } | ||
44 | |||
45 | AutoRotate::~AutoRotate() | ||
46 | { | ||
47 | if (popupMenu) { | ||
48 | delete popupMenu; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | void AutoRotate::mousePressEvent(QMouseEvent *) | ||
53 | { | ||
54 | QPopupMenu *menu = new QPopupMenu(this); | ||
55 | |||
56 | if (isRotateEnabled()) | ||
57 | menu->insertItem("Disable Rotation",1); | ||
58 | else | ||
59 | menu->insertItem("Enable Rotation",1); | ||
60 | |||
61 | |||
62 | QPoint p = mapToGlobal(QPoint(0, 0)); | ||
63 | QSize s = menu->sizeHint(); | ||
64 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | ||
65 | p.y() - s.height()), 0); | ||
66 | |||
67 | if (opt==1) { | ||
68 | if (isRotateEnabled()) | ||
69 | setRotateEnabled(false); | ||
70 | else | ||
71 | setRotateEnabled(true); | ||
72 | |||
73 | repaint(true); | ||
74 | } | ||
75 | |||
76 | delete menu; | ||
77 | } | ||
78 | |||
79 | void AutoRotate::paintEvent(QPaintEvent *) | ||
80 | { | ||
81 | QPainter p(this); | ||
82 | |||
83 | if ( isRotateEnabled() ) { | ||
84 | p.drawPixmap(0, 0, enabledPm ); | ||
85 | } else { | ||
86 | p.drawPixmap(0, 0, disabledPm ); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void AutoRotate::setRotateEnabled(bool status) | ||
91 | { | ||
92 | Config cfg( "qpe" ); | ||
93 | cfg.setGroup( "Appearance" ); | ||
94 | cfg.writeEntry( "rotateEnabled",status ); | ||
95 | |||
96 | } | ||
97 | bool AutoRotate::isRotateEnabled() | ||
98 | { | ||
99 | Config cfg( "qpe" ); | ||
100 | cfg.setGroup( "Appearance" ); | ||
101 | |||
102 | bool res = cfg.readBoolEntry( "rotateEnabled" ); | ||
103 | |||
104 | if (res ) | ||
105 | qDebug("Enabled"); | ||
106 | else | ||
107 | qDebug("Disabled"); | ||
108 | return res; | ||
109 | } | ||
110 | |||
diff --git a/noncore/applets/autorotateapplet/autorotate.h b/noncore/applets/autorotateapplet/autorotate.h new file mode 100644 index 0000000..e05e7a0 --- a/dev/null +++ b/noncore/applets/autorotateapplet/autorotate.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * copyright : (c) 2003 by Greg Gilbert | ||
3 | * email : greg@treke.net | ||
4 | * based on the cardmon applet by Max Reiss | ||
5 | * * | ||
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 * | ||
8 | * the Free Software Foundation; either version 2 of the License, or * | ||
9 | * (at your option) any later version. * | ||
10 | * * | ||
11 | *************************************************************************/ | ||
12 | |||
13 | #ifndef AUTOROTATE_H | ||
14 | #define AUTOROTATE_H | ||
15 | |||
16 | #include <qwidget.h> | ||
17 | #include <qpixmap.h> | ||
18 | #include <qpopupmenu.h> | ||
19 | |||
20 | class AutoRotate : public QWidget { | ||
21 | Q_OBJECT | ||
22 | public: | ||
23 | AutoRotate( QWidget *parent = 0 ); | ||
24 | ~AutoRotate(); | ||
25 | |||
26 | private slots: | ||
27 | |||
28 | protected: | ||
29 | void paintEvent( QPaintEvent* ); | ||
30 | void mousePressEvent( QMouseEvent * ); | ||
31 | private: | ||
32 | bool isRotateEnabled(); | ||
33 | void setRotateEnabled(bool); | ||
34 | QPixmap enabledPm; | ||
35 | QPixmap disabledPm; | ||
36 | void iconShow(); | ||
37 | QPopupMenu *popupMenu; | ||
38 | }; | ||
39 | |||
40 | #endif | ||
41 | |||
diff --git a/noncore/applets/autorotateapplet/autorotateapplet.pro b/noncore/applets/autorotateapplet/autorotateapplet.pro new file mode 100644 index 0000000..0b966b0 --- a/dev/null +++ b/noncore/applets/autorotateapplet/autorotateapplet.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt plugin warn_on release | ||
3 | HEADERS =autorotate.h autorotateimpl.h | ||
4 | SOURCES =autorotate.cpp autorotateimpl.cpp | ||
5 | TARGET = autorotateapplet | ||
6 | DESTDIR = $(OPIEDIR)/plugins/applets | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | ||
8 | DEPENDPATH += $(OPIEDIR)/include ../launcher | ||
9 | LIBS += -lqpe -lopie | ||
10 | VERSION = 1.0.0 | ||
11 | |||
12 | include ( $(OPIEDIR)/include.pro ) | ||
13 | target.path = $$prefix/plugins/applets | ||
diff --git a/noncore/applets/autorotateapplet/autorotateimpl.cpp b/noncore/applets/autorotateapplet/autorotateimpl.cpp new file mode 100644 index 0000000..01d8a01 --- a/dev/null +++ b/noncore/applets/autorotateapplet/autorotateimpl.cpp | |||
@@ -0,0 +1,41 @@ | |||
1 | #include "autorotate.h" | ||
2 | #include "autorotateimpl.h" | ||
3 | |||
4 | |||
5 | AutoRotateImpl::AutoRotateImpl() | ||
6 | : autoRotate(0), ref(0) { | ||
7 | qDebug ("here"); | ||
8 | } | ||
9 | |||
10 | AutoRotateImpl::~AutoRotateImpl() { | ||
11 | delete autoRotate; | ||
12 | } | ||
13 | |||
14 | QWidget *AutoRotateImpl::applet( QWidget *parent ) { | ||
15 | if ( !autoRotate ) { | ||
16 | autoRotate = new AutoRotate( parent ); | ||
17 | } | ||
18 | return autoRotate; | ||
19 | } | ||
20 | |||
21 | int AutoRotateImpl::position() const { | ||
22 | return 7; | ||
23 | } | ||
24 | |||
25 | QRESULT 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 | } | ||
32 | |||
33 | if ( *iface ) { | ||
34 | (*iface)->addRef(); | ||
35 | } | ||
36 | return QS_OK; | ||
37 | } | ||
38 | |||
39 | Q_EXPORT_INTERFACE() { | ||
40 | Q_CREATE_INSTANCE( AutoRotateImpl ) | ||
41 | } | ||
diff --git a/noncore/applets/autorotateapplet/autorotateimpl.h b/noncore/applets/autorotateapplet/autorotateimpl.h new file mode 100644 index 0000000..87b0731 --- a/dev/null +++ b/noncore/applets/autorotateapplet/autorotateimpl.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #include <qpe/taskbarappletinterface.h> | ||
2 | |||
3 | class AutoRotate; | ||
4 | |||
5 | class AutoRotateImpl : public TaskbarAppletInterface { | ||
6 | public: | ||
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 | |||
16 | private: | ||
17 | AutoRotate *autoRotate; | ||
18 | ulong ref; | ||
19 | }; | ||
diff --git a/noncore/applets/autorotateapplet/config.in b/noncore/applets/autorotateapplet/config.in new file mode 100644 index 0000000..0ddbd59 --- a/dev/null +++ b/noncore/applets/autorotateapplet/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config AUTOROTATEAPPLET | ||
2 | boolean "opie-autorotate applet ( disables screen rotation based on the orientation of the device)" | ||
3 | default "y" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | ||
diff --git a/noncore/applets/autorotateapplet/opie-autorotate.control b/noncore/applets/autorotateapplet/opie-autorotate.control new file mode 100644 index 0000000..4ab141c --- a/dev/null +++ b/noncore/applets/autorotateapplet/opie-autorotate.control | |||
@@ -0,0 +1,11 @@ | |||
1 | Package: opie-autorotate | ||
2 | Files: plugins/applets/libautorotateapplet.so* pics/autorotate/*.png | ||
3 | Priority: optional | ||
4 | Section: opie/taskbar | ||
5 | Maintainer: Greg Gilbert <greg@treke.net> | ||
6 | Architecture: arm | ||
7 | Depends: task-opie-minimal, libopie1 | ||
8 | Description: Automatic screen rotation applet | ||
9 | Taskbar applet for enabled and disabling the automatic rotation | ||
10 | of the screen based on your devices physical orientation/ | ||
11 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/applets/autorotateapplet/opie-autorotate.postinst b/noncore/applets/autorotateapplet/opie-autorotate.postinst new file mode 100755 index 0000000..a549c30 --- a/dev/null +++ b/noncore/applets/autorotateapplet/opie-autorotate.postinst | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/bin/sh | ||
2 | if pidof -s qpe >/dev/null; then | ||
3 | /opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" | ||
4 | else | ||
5 | exit 0 | ||
6 | fi | ||
diff --git a/noncore/applets/autorotateapplet/opie-autorotate.postrm b/noncore/applets/autorotateapplet/opie-autorotate.postrm new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/noncore/applets/autorotateapplet/opie-autorotate.postrm | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/sh | ||
2 | /opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" | ||
diff --git a/pics/autorotate/norotate.png b/pics/autorotate/norotate.png new file mode 100644 index 0000000..e19e80c --- a/dev/null +++ b/pics/autorotate/norotate.png | |||
Binary files differ | |||
diff --git a/pics/autorotate/rotate.png b/pics/autorotate/rotate.png new file mode 100644 index 0000000..ae1a6d7 --- a/dev/null +++ b/pics/autorotate/rotate.png | |||
Binary files differ | |||