author | harlekin <harlekin> | 2004-02-03 22:25:41 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-02-03 22:25:41 (UTC) |
commit | 8a796b594669c54a34b2e416ff0d931aaa3cc76d (patch) (side-by-side diff) | |
tree | 9e8465a881932a2c3da9ca9018bb2fcbc346b163 /examples | |
parent | ca3580f98de6e68cc595234859691df997b60a98 (diff) | |
download | opie-8a796b594669c54a34b2e416ff0d931aaa3cc76d.zip opie-8a796b594669c54a34b2e416ff0d931aaa3cc76d.tar.gz opie-8a796b594669c54a34b2e416ff0d931aaa3cc76d.tar.bz2 |
today example plugin
-rw-r--r-- | examples/todayplugin/config.in | 5 | ||||
-rw-r--r-- | examples/todayplugin/example.pro | 19 | ||||
-rw-r--r-- | examples/todayplugin/exampleplugin.cpp | 76 | ||||
-rw-r--r-- | examples/todayplugin/exampleplugin.h | 51 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginimpl.cpp | 48 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginimpl.h | 40 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginwidget.cpp | 71 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginwidget.h | 44 | ||||
-rw-r--r-- | examples/todayplugin/opie-today-exampleplugin.control | 9 |
9 files changed, 363 insertions, 0 deletions
diff --git a/examples/todayplugin/config.in b/examples/todayplugin/config.in new file mode 100644 index 0000000..1f1efd9 --- a/dev/null +++ b/examples/todayplugin/config.in @@ -0,0 +1,5 @@ + config TODAY_EXAMPLE + boolean "example" + default "n" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + comment "opie today example plugin" diff --git a/examples/todayplugin/example.pro b/examples/todayplugin/example.pro new file mode 100644 index 0000000..931e056 --- a/dev/null +++ b/examples/todayplugin/example.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +CONFIG -= moc +CONFIG += qt release + +# Input +HEADERS = exampleplugin.h examplepluginimpl.h examplepluginwidget.h +SOURCES = exampleplugin.cpp examplepluginimpl.cpp examplepluginwidget.cpp + +INCLUDEPATH += $(OPIEDIR)/include \ + ../ ../library +DEPENDPATH += $(OPIEDIR)/include \ + ../ ../library + +LIBS+= -lqpe -lopie + +DESTDIR = $(OPIEDIR)/plugins/today +TARGET = todayexampleplugin + +include ( $(OPIEDIR)/include.pro ) diff --git a/examples/todayplugin/exampleplugin.cpp b/examples/todayplugin/exampleplugin.cpp new file mode 100644 index 0000000..e5d75df --- a/dev/null +++ b/examples/todayplugin/exampleplugin.cpp @@ -0,0 +1,76 @@ +/* + * exampleplugin.cpp + * + * copyright : (c) 2002,2003,2004 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * 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 "exampleplugin.h" + +ExamplePlugin::ExamplePlugin() { + m_widget = 0l; +} + +ExamplePlugin::~ExamplePlugin() { + delete (ExamplePluginWidget*)m_widget; +} + +QString ExamplePlugin::pluginName() const { + return QObject::tr( "Example plugin" ); +} + +double ExamplePlugin::versionNumber() const { + return 0.1; +} + +// this sets the image that will be shown on the left side of the plugin +QString ExamplePlugin::pixmapNameWidget() const { + return "Tux"; +} + +QWidget* ExamplePlugin::widget( QWidget * wid ) { + if(!m_widget) { + m_widget = new ExamplePluginWidget( wid, "Example" ); + } + return m_widget; +} + + +// that would be the icon of the config widget in todays config view +QString ExamplePlugin::pixmapNameConfig() const { + return 0l; +} + +// No config widget yet, look at the datebook plugin for an example of that +TodayConfigWidget* ExamplePlugin::configWidget( QWidget* ) { + return 0l; +} + +// add the binary name of the app to launch here +QString ExamplePlugin::appName() const { + return ""; +} + +// if the plugin should be excluded form the refresh cycles that can be set in the today app +bool ExamplePlugin::excludeFromRefresh() const { + return false; +} + +void ExamplePlugin::refresh() { + if ( m_widget ) { + m_widget->refresh(); + } +} + +void ExamplePlugin::reinitialize() { +} diff --git a/examples/todayplugin/exampleplugin.h b/examples/todayplugin/exampleplugin.h new file mode 100644 index 0000000..0d9f11d --- a/dev/null +++ b/examples/todayplugin/exampleplugin.h @@ -0,0 +1,51 @@ +/* + * exampleplugin.h + * + * copyright : (c) 2004 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * 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 EXAMPLE_PLUGIN_H +#define EXAMPLE_PLUGIN_H + +#include <qwidget.h> +#include <qguardedptr.h> + +#include <opie/todayplugininterface.h> +#include <opie/todayconfigwidget.h> + +#include "examplepluginwidget.h" + +// implementation of the today plugin interface +class ExamplePlugin : public TodayPluginObject { + +public: + ExamplePlugin(); + ~ExamplePlugin(); + + QString pluginName() const; + double versionNumber() const; + QString pixmapNameWidget() const; + QWidget* widget(QWidget *); + QString pixmapNameConfig() const; + TodayConfigWidget* configWidget(QWidget *); + QString appName() const; + bool excludeFromRefresh() const; + void refresh(); + void reinitialize(); + + private: + QGuardedPtr<ExamplePluginWidget> m_widget; +}; + +#endif diff --git a/examples/todayplugin/examplepluginimpl.cpp b/examples/todayplugin/examplepluginimpl.cpp new file mode 100644 index 0000000..9ab6164 --- a/dev/null +++ b/examples/todayplugin/examplepluginimpl.cpp @@ -0,0 +1,48 @@ +/* + * examplepluginimpl.cpp + * + * copyright : (c) 2004 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * 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 "exampleplugin.h" +#include "examplepluginimpl.h" + +ExamplePluginImpl::ExamplePluginImpl() { + examplePlugin = new ExamplePlugin(); +} + +ExamplePluginImpl::~ExamplePluginImpl() { + delete examplePlugin; +} + + +TodayPluginObject* ExamplePluginImpl::guiPart() { + return examplePlugin; +} + +QRESULT ExamplePluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) { + *iface = 0; + if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) { + *iface = this, (*iface)->addRef(); + }else + return QS_FALSE; + + return QS_OK; + +} + +Q_EXPORT_INTERFACE() { + Q_CREATE_INSTANCE( ExamplePluginImpl ); +} diff --git a/examples/todayplugin/examplepluginimpl.h b/examples/todayplugin/examplepluginimpl.h new file mode 100644 index 0000000..2c10583 --- a/dev/null +++ b/examples/todayplugin/examplepluginimpl.h @@ -0,0 +1,40 @@ +/* + * examplepluginimpl.h + * + * copyright : (c) 2004 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * 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 EXAMPLE_PLUGIN_IMPL_H +#define EXAMPLE_PLUGIN_IMPL_H + +#include <opie/todayplugininterface.h> + +class ExamplePlugin; + +class ExamplePluginImpl : public TodayPluginInterface{ + +public: + ExamplePluginImpl(); + virtual ~ExamplePluginImpl(); + + QRESULT queryInterface( const QUuid &, QUnknownInterface** ); + Q_REFCOUNT + + virtual TodayPluginObject *guiPart(); + +private: + ExamplePlugin *examplePlugin; + ulong ref; +}; + +#endif diff --git a/examples/todayplugin/examplepluginwidget.cpp b/examples/todayplugin/examplepluginwidget.cpp new file mode 100644 index 0000000..14f1020 --- a/dev/null +++ b/examples/todayplugin/examplepluginwidget.cpp @@ -0,0 +1,71 @@ +/* + * examplepluginwidget.cpp + * + * copyright : (c) 2004 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * 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 <qpe/config.h> +#include <qpe/qcopenvelope_qws.h> + +#include "examplepluginwidget.h" + +ExamplePluginWidget::ExamplePluginWidget( QWidget *parent, const char* name) + : QWidget(parent, name ) { + + m_exampleLabel = 0l; + m_layout = 0l; + + if ( m_exampleLabel ) { + delete m_exampleLabel; + } + + // since here a OClickableLabel is used, the plugin part will be clickable, and the actions + // that should be triggered when clicked are defined in slotClicked() + // of course also normal widgets can be used. + m_exampleLabel = new OClickableLabel( this ); + connect( m_exampleLabel, SIGNAL( clicked() ), this, SLOT( slotClicked() ) ); + + if ( m_layout ) { + delete m_layout; + } + m_layout = new QHBoxLayout( this ); + m_layout->setAutoAdd( true ); + + readConfig(); + getInfo(); +} + + +ExamplePluginWidget::~ExamplePluginWidget() { + delete m_exampleLabel; + delete m_layout; +} + + +void ExamplePluginWidget::readConfig() { +// we dont have any config entries in this plugin +// normally this method is used after today config was used +} + + +void ExamplePluginWidget::refresh() { + +} + +void ExamplePluginWidget::getInfo() { + m_exampleLabel->setText( "Example text" ); +} + +void ExamplePluginWidget::slotClicked() { + getInfo(); +} diff --git a/examples/todayplugin/examplepluginwidget.h b/examples/todayplugin/examplepluginwidget.h new file mode 100644 index 0000000..c94d2cf --- a/dev/null +++ b/examples/todayplugin/examplepluginwidget.h @@ -0,0 +1,44 @@ +/* + * examplepluginwidget.h + * + * copyright : (c) 2004 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * 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 EXAMPLE_PLUGIN_WIDGET_H +#define EXAMPLE_PLUGIN_WIDGET_H + +#include <qlayout.h> + +#include <opie/oclickablelabel.h> + +class ExamplePluginWidget : public QWidget { + + Q_OBJECT + +public: + ExamplePluginWidget( QWidget *parent, const char *name ); + ~ExamplePluginWidget(); + + void refresh(); + +private slots: + void slotClicked(); + +private: + OClickableLabel* m_exampleLabel; + QHBoxLayout* m_layout; + void readConfig(); + void getInfo(); +}; + +#endif diff --git a/examples/todayplugin/opie-today-exampleplugin.control b/examples/todayplugin/opie-today-exampleplugin.control new file mode 100644 index 0000000..b4e591f --- a/dev/null +++ b/examples/todayplugin/opie-today-exampleplugin.control @@ -0,0 +1,9 @@ +Package: opie-today-exampleplugin +Files: plugins/today/libtodayexampleplugin.so* +Priority: optional +Section: opie/applications +Maintainer: Maximilian Reiss <harlekin@handhelds.org> +Architecture: arm +Version: $QPE_VERSION-$SUB_VERSION +Depends: libqte2, opie-today +Description: an example plugin for today |