summaryrefslogtreecommitdiff
path: root/noncore/applets
authortreke <treke>2003-12-09 03:23:20 (UTC)
committer treke <treke>2003-12-09 03:23:20 (UTC)
commit1538a521b674d2eff02b926c0d82fa6184dd99db (patch) (side-by-side diff)
treec4e0c870e034275c31c901578f1e09527bc3361d /noncore/applets
parent0526dfbd3053dd89706f615e2549adfea8b87553 (diff)
downloadopie-1538a521b674d2eff02b926c0d82fa6184dd99db.zip
opie-1538a521b674d2eff02b926c0d82fa6184dd99db.tar.gz
opie-1538a521b674d2eff02b926c0d82fa6184dd99db.tar.bz2
Applet for turning on and off automatic rotation
Diffstat (limited to 'noncore/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/autorotateapplet/autorotate.cpp110
-rw-r--r--noncore/applets/autorotateapplet/autorotate.h41
-rw-r--r--noncore/applets/autorotateapplet/autorotateapplet.pro13
-rw-r--r--noncore/applets/autorotateapplet/autorotateimpl.cpp41
-rw-r--r--noncore/applets/autorotateapplet/autorotateimpl.h19
-rw-r--r--noncore/applets/autorotateapplet/config.in4
-rw-r--r--noncore/applets/autorotateapplet/opie-autorotate.control11
-rwxr-xr-xnoncore/applets/autorotateapplet/opie-autorotate.postinst6
-rwxr-xr-xnoncore/applets/autorotateapplet/opie-autorotate.postrm2
9 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 @@
+/*
+ * copyright : (c) 2003 by Greg Gilbert
+ * email : greg@treke.net
+ * based on the cardmon applet by Max Reiss
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************/
+
+
+#include "autorotate.h"
+
+#include <qpe/resource.h>
+
+#include <opie/odevice.h>
+
+#include <qpe/applnk.h>
+#include <qpe/config.h>
+
+#include <qcopchannel_qws.h>
+#include <qpainter.h>
+#include <qmessagebox.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qtimer.h>
+#include <qapplication.h>
+
+using namespace Opie;
+
+AutoRotate::AutoRotate(QWidget * parent):QWidget(parent),
+ enabledPm( Resource::loadPixmap("autorotate/rotate") ),
+ disabledPm( Resource::loadPixmap("autorotate/norotate") )
+{
+ setFixedWidth ( AppLnk::smallIconSize() );
+ setFixedHeight ( AppLnk::smallIconSize() );
+
+ repaint(true);
+ popupMenu = 0;
+ show();
+}
+
+AutoRotate::~AutoRotate()
+{
+ if (popupMenu) {
+ delete popupMenu;
+ }
+}
+
+void AutoRotate::mousePressEvent(QMouseEvent *)
+{
+ QPopupMenu *menu = new QPopupMenu(this);
+
+ if (isRotateEnabled())
+ menu->insertItem("Disable Rotation",1);
+ else
+ menu->insertItem("Enable Rotation",1);
+
+
+ QPoint p = mapToGlobal(QPoint(0, 0));
+ QSize s = menu->sizeHint();
+ int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2),
+ p.y() - s.height()), 0);
+
+ if (opt==1) {
+ if (isRotateEnabled())
+ setRotateEnabled(false);
+ else
+ setRotateEnabled(true);
+
+ repaint(true);
+ }
+
+ delete menu;
+}
+
+void AutoRotate::paintEvent(QPaintEvent *)
+{
+ QPainter p(this);
+
+ if ( isRotateEnabled() ) {
+ p.drawPixmap(0, 0, enabledPm );
+ } else {
+ p.drawPixmap(0, 0, disabledPm );
+ }
+}
+
+void AutoRotate::setRotateEnabled(bool status)
+{
+ Config cfg( "qpe" );
+ cfg.setGroup( "Appearance" );
+ cfg.writeEntry( "rotateEnabled",status );
+
+}
+bool AutoRotate::isRotateEnabled()
+{
+ Config cfg( "qpe" );
+ cfg.setGroup( "Appearance" );
+
+ bool res = cfg.readBoolEntry( "rotateEnabled" );
+
+ if (res )
+ qDebug("Enabled");
+ else
+ qDebug("Disabled");
+ return res;
+}
+
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 @@
+/*
+ * copyright : (c) 2003 by Greg Gilbert
+ * email : greg@treke.net
+ * based on the cardmon applet by Max Reiss
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************/
+
+#ifndef AUTOROTATE_H
+#define AUTOROTATE_H
+
+#include <qwidget.h>
+#include <qpixmap.h>
+#include <qpopupmenu.h>
+
+class AutoRotate : public QWidget {
+ Q_OBJECT
+public:
+ AutoRotate( QWidget *parent = 0 );
+ ~AutoRotate();
+
+private slots:
+
+protected:
+ void paintEvent( QPaintEvent* );
+ void mousePressEvent( QMouseEvent * );
+private:
+ bool isRotateEnabled();
+ void setRotateEnabled(bool);
+ QPixmap enabledPm;
+ QPixmap disabledPm;
+ void iconShow();
+ QPopupMenu *popupMenu;
+ };
+
+#endif
+
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 @@
+TEMPLATE = lib
+CONFIG += qt plugin warn_on release
+HEADERS = autorotate.h autorotateimpl.h
+SOURCES = autorotate.cpp autorotateimpl.cpp
+TARGET = autorotateapplet
+DESTDIR = $(OPIEDIR)/plugins/applets
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include ../launcher
+LIBS += -lqpe -lopie
+VERSION = 1.0.0
+
+include ( $(OPIEDIR)/include.pro )
+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 @@
+#include "autorotate.h"
+#include "autorotateimpl.h"
+
+
+AutoRotateImpl::AutoRotateImpl()
+ : autoRotate(0), ref(0) {
+ qDebug ("here");
+}
+
+AutoRotateImpl::~AutoRotateImpl() {
+ delete autoRotate;
+}
+
+QWidget *AutoRotateImpl::applet( QWidget *parent ) {
+ if ( !autoRotate ) {
+ autoRotate = new AutoRotate( parent );
+ }
+ return autoRotate;
+}
+
+int AutoRotateImpl::position() const {
+ return 7;
+}
+
+QRESULT AutoRotateImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
+ *iface = 0;
+ if ( uuid == IID_QUnknown ) {
+ *iface = this;
+ } else if ( uuid == IID_TaskbarApplet ) {
+ *iface = this;
+ }
+
+ if ( *iface ) {
+ (*iface)->addRef();
+ }
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE() {
+ Q_CREATE_INSTANCE( AutoRotateImpl )
+}
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 @@
+#include <qpe/taskbarappletinterface.h>
+
+class AutoRotate;
+
+class AutoRotateImpl : public TaskbarAppletInterface {
+public:
+ AutoRotateImpl();
+ virtual ~AutoRotateImpl();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+
+ virtual QWidget *applet( QWidget *parent );
+ virtual int position() const;
+
+private:
+ AutoRotate *autoRotate;
+ ulong ref;
+};
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 @@
+ config AUTOROTATEAPPLET
+ boolean "opie-autorotate applet ( disables screen rotation based on the orientation of the device)"
+ default "y"
+ 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 @@
+Package: opie-autorotate
+Files: plugins/applets/libautorotateapplet.so* pics/autorotate/*.png
+Priority: optional
+Section: opie/taskbar
+Maintainer: Greg Gilbert <greg@treke.net>
+Architecture: arm
+Depends: task-opie-minimal, libopie1
+Description: Automatic screen rotation applet
+ Taskbar applet for enabled and disabling the automatic rotation
+ of the screen based on your devices physical orientation/
+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 @@
+#!/bin/sh
+if pidof -s qpe >/dev/null; then
+ /opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()"
+else
+ exit 0
+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 @@
+#!/bin/sh
+/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()"