author | mickeyl <mickeyl> | 2004-03-01 21:10:13 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-01 21:10:13 (UTC) |
commit | 77af6f58d59011e123309c82b684695508a46787 (patch) (side-by-side diff) | |
tree | 1eeb3b323bc14581af7da9fe5b58c4c611b00575 | |
parent | 7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc (diff) | |
download | opie-77af6f58d59011e123309c82b684695508a46787.zip opie-77af6f58d59011e123309c82b684695508a46787.tar.gz opie-77af6f58d59011e123309c82b684695508a46787.tar.bz2 |
remove boiler plate code in favour of a template
21 files changed, 67 insertions, 354 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 @@ -11,12 +11,13 @@ *************************************************************************/ #include "autorotate.h" /* OPIE */ #include <opie2/odevice.h> +#include <opie2/otaskbarapplet.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/resource.h> /* QT */ #include <qpainter.h> @@ -40,12 +41,17 @@ AutoRotate::~AutoRotate() { if (popupMenu) { delete popupMenu; } } +int AutoRotate::position() +{ + return 7; +} + void AutoRotate::mousePressEvent(QMouseEvent *) { QPopupMenu *menu = new QPopupMenu(this); menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); QPoint p = mapToGlobal(QPoint(0, 0)); @@ -85,6 +91,11 @@ bool AutoRotate::isRotateEnabled() qDebug("Enabled"); else qDebug("Disabled"); return res; } +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( OTaskbarAppletWrapper<AutoRotate> ); +} + 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 @@ -19,14 +19,13 @@ class AutoRotate : public QWidget { Q_OBJECT public: AutoRotate( QWidget *parent = 0 ); ~AutoRotate(); - -private slots: + static int position(); protected: void paintEvent( QPaintEvent* ); void mousePressEvent( QMouseEvent * ); private: bool isRotateEnabled(); 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 @@ -TEMPLATE = lib +TEMPLATE = lib CONFIG += qt plugin warn_on release -HEADERS = autorotate.h autorotateimpl.h -SOURCES = autorotate.cpp autorotateimpl.cpp +HEADERS = autorotate.h +SOURCES = autorotate.cpp TARGET = autorotateapplet -DESTDIR = $(OPIEDIR)/plugins/applets -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include ../launcher -LIBS += -lqpe -lopiecore2 -VERSION = 1.0.0 +DESTDIR = $(OPIEDIR)/plugins/applets +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include ../launcher +LIBS += -lqpe -lopiecore2 +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 deleted file mode 100644 index 305ac50..0000000 --- a/noncore/applets/autorotateapplet/autorotateimpl.cpp +++ b/dev/null @@ -1,42 +0,0 @@ -#include "autorotate.h" -#include "autorotateimpl.h" - - -AutoRotateImpl::AutoRotateImpl() - : autoRotate(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; - } else - return QS_FALSE; - - 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 deleted file mode 100644 index fde23a9..0000000 --- a/noncore/applets/autorotateapplet/autorotateimpl.h +++ b/dev/null @@ -1,18 +0,0 @@ -#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; -}; diff --git a/noncore/applets/memoryapplet/memoryapplet.pro b/noncore/applets/memoryapplet/memoryapplet.pro index 6031386..3cd7839 100644 --- a/noncore/applets/memoryapplet/memoryapplet.pro +++ b/noncore/applets/memoryapplet/memoryapplet.pro @@ -1,24 +1,22 @@ TEMPLATE = lib CONFIG += qt plugin warn_on release HEADERS = ../../settings/sysinfo/graph.h \ ../../settings/sysinfo/load.h \ ../../settings/sysinfo/memory.h \ - memoryappletimpl.h \ memorymeter.h \ memorystatus.h \ swapfile.h SOURCES = ../../settings/sysinfo/graph.cpp \ ../../settings/sysinfo/load.cpp \ ../../settings/sysinfo/memory.cpp \ - memoryappletimpl.cpp \ memorymeter.cpp \ memorystatus.cpp \ swapfile.cpp TARGET = memoryapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include VERSION = 1.0.0 -LIBS += -lqpe -lopieui2 +LIBS += -lqpe -lopiecore2 -lopieui2 include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/applets/memoryapplet/memoryappletimpl.cpp b/noncore/applets/memoryapplet/memoryappletimpl.cpp deleted file mode 100644 index a117e7f..0000000 --- a/noncore/applets/memoryapplet/memoryappletimpl.cpp +++ b/dev/null @@ -1,65 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the 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. -** -**********************************************************************/ -#include "memorymeter.h" -#include "memoryappletimpl.h" - -MemoryAppletImpl::MemoryAppletImpl() - : memory(0) -{ -} - -MemoryAppletImpl::~MemoryAppletImpl() -{ - delete memory; -} - -QWidget *MemoryAppletImpl::applet( QWidget *parent ) -{ - if ( !memory ) - memory = new MemoryMeter( parent ); - - return memory; -} - -int MemoryAppletImpl::position() const -{ - return 8; -} - -QRESULT MemoryAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) -{ - *iface = 0; - if ( uuid == IID_QUnknown ) - *iface = this; - else if ( uuid == IID_TaskbarApplet ) - *iface = this; - else - return QS_FALSE; - - (*iface)->addRef(); - - return QS_OK; -} - -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( MemoryAppletImpl ) -} - diff --git a/noncore/applets/memoryapplet/memoryappletimpl.h b/noncore/applets/memoryapplet/memoryappletimpl.h deleted file mode 100644 index 2db7dbe..0000000 --- a/noncore/applets/memoryapplet/memoryappletimpl.h +++ b/dev/null @@ -1,43 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the 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 MEMORYAPPLETIMPL_H -#define MEMORYAPPLETIMPL_H - -#include <qtopia/taskbarappletinterface.h> - -class MemoryMeter; - -class /*QTOPIA_PLUGIN_EXPORT*/ MemoryAppletImpl : public TaskbarAppletInterface -{ -public: - MemoryAppletImpl(); - virtual ~MemoryAppletImpl(); - - QRESULT queryInterface( const QUuid&, QUnknownInterface** ); - Q_REFCOUNT - - virtual QWidget *applet( QWidget *parent ); - virtual int position() const; - -private: - MemoryMeter *memory; -}; - -#endif diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp index 54b5c52..9299f49 100644 --- a/noncore/applets/memoryapplet/memorymeter.cpp +++ b/noncore/applets/memoryapplet/memorymeter.cpp @@ -17,18 +17,16 @@ ** not clear to you. ** **********************************************************************/ #include "memorymeter.h" #include "memorystatus.h" +#include <opie2/otaskbarapplet.h> #include <qtopia/power.h> #include <qtopia/config.h> - -#if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include <qtopia/qcopenvelope_qws.h> -#endif #include <qpainter.h> #include <qtimer.h> #include <qapplication.h> #include <qtopia/applnk.h> @@ -63,12 +61,17 @@ MemoryMeter::MemoryMeter( QWidget *parent ) MemoryMeter::~MemoryMeter() { delete (QWidget *) memoryView; } +int MemoryMeter::position() +{ + return 7; +} + QSize MemoryMeter::sizeHint() const { return QSize(10, AppLnk::smallIconSize()); } bool MemoryMeter::updateMemoryViewGeometry() @@ -234,6 +237,11 @@ void MemoryMeter::paintEvent( QPaintEvent* ) p.setBrush(darkc); p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height); } } +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> ); +} + diff --git a/noncore/applets/memoryapplet/memorymeter.h b/noncore/applets/memoryapplet/memorymeter.h index 0f3cb0b..ed541f0 100644 --- a/noncore/applets/memoryapplet/memorymeter.h +++ b/noncore/applets/memoryapplet/memorymeter.h @@ -28,12 +28,13 @@ class QTimer; class MemoryMeter : public QWidget { Q_OBJECT public: MemoryMeter( QWidget *parent = 0 ); ~MemoryMeter(); + static int position(); QSize sizeHint() const; MemoryStatus* memoryView; protected: void timerEvent( QTimerEvent * ); diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 7b8bdd9..1142028 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp @@ -16,12 +16,13 @@ #include "notes.h" #include <qapplication.h> #include <stdlib.h> #include <qstringlist.h> +#include <opie2/otaskbarapplet.h> #include <qpe/filemanager.h> #include <qpe/qpeapplication.h> #include <qpe/timestring.h> #include <qpe/applnk.h> #include <qpe/ir.h> #include <qpe/config.h> @@ -463,12 +464,17 @@ NotesApplet::NotesApplet( QWidget *parent, const char *name ) } NotesApplet::~NotesApplet() { delete vc; } +int NotesApplet::position() +{ + return 6; +} + void NotesApplet::mousePressEvent( QMouseEvent *) { if( !vc->isHidden()) { vc->doPopulate=false; vc->save(); vc->close(); } else { @@ -499,6 +505,10 @@ void NotesApplet::mousePressEvent( QMouseEvent *) { void NotesApplet::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1, ( const char** ) notes_xpm ); } +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NotesApplet> ); +} diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h index 08253cb..ed1f98c 100644 --- a/noncore/applets/notesapplet/notes.h +++ b/noncore/applets/notesapplet/notes.h @@ -73,12 +73,13 @@ private slots: class NotesApplet : public QWidget { Q_OBJECT public: NotesApplet( QWidget *parent = 0, const char *name=0 ); ~NotesApplet(); + static int position(); NotesControl *vc; public slots: private: void mousePressEvent( QMouseEvent * ); void paintEvent( QPaintEvent* ); diff --git a/noncore/applets/notesapplet/notesapplet.pro b/noncore/applets/notesapplet/notesapplet.pro index 3075948..38ba184 100644 --- a/noncore/applets/notesapplet/notesapplet.pro +++ b/noncore/applets/notesapplet/notesapplet.pro @@ -1,16 +1,12 @@ TEMPLATE = lib CONFIG += qt plugin warn_on release -HEADERS = notes.h notesappletimpl.h -SOURCES = notes.cpp notesappletimpl.cpp +HEADERS = notes.h +SOURCES = notes.cpp TARGET = notesapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 -MOC_DIR=opieobj -OBJECTS_DIR=opieobj - - include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/applets/notesapplet/notesappletimpl.cpp b/noncore/applets/notesapplet/notesappletimpl.cpp deleted file mode 100644 index 8a9da7f..0000000 --- a/noncore/applets/notesapplet/notesappletimpl.cpp +++ b/dev/null @@ -1,53 +0,0 @@ -/********************************************************************** -** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org> -** -** -** 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. -** -** -**********************************************************************/ -#include "notes.h" -#include "notesappletimpl.h" - - -NotesAppletImpl::NotesAppletImpl() - : notes(0){ -} - -NotesAppletImpl::~NotesAppletImpl() { - // not needed though cause we should have a valid parent - delete notes; -} - -QWidget *NotesAppletImpl::applet( QWidget *parent ) { - if ( !notes ) - notes = new NotesApplet( parent ); - return notes; -} - -int NotesAppletImpl::position() const { - return 6; -} - -QRESULT NotesAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { - *iface = 0; - if ( uuid == IID_QUnknown ) - *iface = this; - else if ( uuid == IID_TaskbarApplet ) - *iface = this; - else - return QS_FALSE; - - if ( *iface ) - (*iface)->addRef(); - return QS_OK; -} - -Q_EXPORT_INTERFACE() { - Q_CREATE_INSTANCE( NotesAppletImpl ) -} - - diff --git a/noncore/applets/notesapplet/notesappletimpl.h b/noncore/applets/notesapplet/notesappletimpl.h deleted file mode 100644 index a87118c..0000000 --- a/noncore/applets/notesapplet/notesappletimpl.h +++ b/dev/null @@ -1,35 +0,0 @@ -/********************************************************************** -** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org> -** -** -** 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. -** -** -**********************************************************************/ -#ifndef NOTESAPPLETIMPL_H -#define NOTESAPPLETIMPL_H - -#include <qpe/taskbarappletinterface.h> - -class NotesApplet; - -class NotesAppletImpl : public TaskbarAppletInterface -{ -public: - NotesAppletImpl(); - virtual ~NotesAppletImpl(); - - QRESULT queryInterface( const QUuid&, QUnknownInterface** ); - Q_REFCOUNT - - virtual QWidget *applet( QWidget *parent ); - virtual int position() const; - -private: - NotesApplet *notes; -}; - -#endif diff --git a/noncore/applets/zkbapplet/.cvsignore b/noncore/applets/zkbapplet/.cvsignore new file mode 100644 index 0000000..0f79c04 --- a/dev/null +++ b/noncore/applets/zkbapplet/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +advancedconfigbase.cpp +advancedconfigbase.h +moc_* +.moc +.obj diff --git a/noncore/applets/zkbapplet/zkbapplet.cpp b/noncore/applets/zkbapplet/zkbapplet.cpp deleted file mode 100644 index 6c71568..0000000 --- a/noncore/applets/zkbapplet/zkbapplet.cpp +++ b/dev/null @@ -1,49 +0,0 @@ -#include <stdio.h> -#include <qlabel.h> -#include <qbutton.h> -#include <qwindowsystem_qws.h> -#include "zkbapplet.h" -#include "zkbwidget.h" - - -ZkbApplet::ZkbApplet() : app(0){ -} - -ZkbApplet::~ZkbApplet() -{ - if (app) delete app; -} - -QWidget* ZkbApplet::applet(QWidget* parent) { - if (app == 0) { - app = new ZkbWidget(parent); - } - - return app; -} - -int ZkbApplet::position() const { - return 8; -} - -QRESULT ZkbApplet::queryInterface(const QUuid& uuid, QUnknownInterface** iface) { - - *iface = 0; - if (uuid == IID_QUnknown) { - *iface = this; - } else if (uuid == IID_TaskbarApplet) { - *iface = this; - } else { - return QS_FALSE; - } - - if (*iface) { - (*iface)->addRef(); - } - - return QS_OK; -} - -Q_EXPORT_INTERFACE() { - Q_CREATE_INSTANCE(ZkbApplet) -} diff --git a/noncore/applets/zkbapplet/zkbapplet.h b/noncore/applets/zkbapplet/zkbapplet.h deleted file mode 100644 index fcf03b5..0000000 --- a/noncore/applets/zkbapplet/zkbapplet.h +++ b/dev/null @@ -1,23 +0,0 @@ -#include "qpe/taskbarappletinterface.h" - -#ifndef ZKBAPPLET_H -#define ZKBAPPLET_H - -class ZkbWidget; - -class ZkbApplet : public TaskbarAppletInterface { -public: - ZkbApplet(); - virtual ~ZkbApplet(); - - QRESULT queryInterface(const QUuid&, QUnknownInterface**); - Q_REFCOUNT - - virtual QWidget* applet(QWidget*); - virtual int position() const; - -protected: - ZkbWidget* app; -}; - -#endif diff --git a/noncore/applets/zkbapplet/zkbapplet.pro b/noncore/applets/zkbapplet/zkbapplet.pro index 22615d0..8cc1b58 100644 --- a/noncore/applets/zkbapplet/zkbapplet.pro +++ b/noncore/applets/zkbapplet/zkbapplet.pro @@ -1,16 +1,14 @@ TEMPLATE = lib CONFIG += qt plugin warn_on release -HEADERS = zkbapplet.h\ - zkbwidget.h \ +HEADERS = zkbwidget.h \ ../../apps/keyz-cfg/zkbcfg.h \ ../../apps/keyz-cfg/zkbnames.h \ ../../apps/keyz-cfg/zkbxml.h \ ../../apps/keyz-cfg/zkb.h -SOURCES = zkbapplet.cpp \ - zkbwidget.cpp \ +SOURCES = zkbwidget.cpp \ ../../apps/keyz-cfg/zkbcfg.cpp \ ../../apps/keyz-cfg/zkbnames.cpp \ ../../apps/keyz-cfg/zkbxml.cpp \ ../../apps/keyz-cfg/zkb.cpp TARGET = zkbapplet DESTDIR = $(OPIEDIR)/plugins/applets diff --git a/noncore/applets/zkbapplet/zkbwidget.cpp b/noncore/applets/zkbapplet/zkbwidget.cpp index 05a76e7..0b5ab78 100644 --- a/noncore/applets/zkbapplet/zkbwidget.cpp +++ b/noncore/applets/zkbapplet/zkbwidget.cpp @@ -1,6 +1,7 @@ +#include <opie2/otaskbarapplet.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/applnk.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <stdio.h> #include <unistd.h> @@ -23,12 +24,17 @@ ZkbWidget::ZkbWidget(QWidget* parent):QLabel(parent),keymap(0), setFixedHeight ( AppLnk::smallIconSize() ); } ZkbWidget::~ZkbWidget() { } +int ZkbWidget::position() +{ + return 8; +} + bool ZkbWidget::loadKeymap() { ZkbConfig c(QPEApplication::qpeDir()+"/share/zkb"); QFontMetrics fm(font()); if (keymap != 0) { delete keymap; @@ -145,6 +151,12 @@ void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { } void ZkbWidget::reload() { loadKeymap(); QCopEnvelope("QPE/System", "notBusy()"); } + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ZkbWidget> ); +} + diff --git a/noncore/applets/zkbapplet/zkbwidget.h b/noncore/applets/zkbapplet/zkbwidget.h index a943563..7c67794 100644 --- a/noncore/applets/zkbapplet/zkbwidget.h +++ b/noncore/applets/zkbapplet/zkbwidget.h @@ -12,12 +12,13 @@ class ZkbWidget : public QLabel { Q_OBJECT public: ZkbWidget(QWidget* parent); ~ZkbWidget(); + static int position(); QSize sizeHint() const; protected: QLabel* label; Keymap* keymap; |