summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-02-03 22:25:41 (UTC)
committer harlekin <harlekin>2004-02-03 22:25:41 (UTC)
commit8a796b594669c54a34b2e416ff0d931aaa3cc76d (patch) (unidiff)
tree9e8465a881932a2c3da9ca9018bb2fcbc346b163
parentca3580f98de6e68cc595234859691df997b60a98 (diff)
downloadopie-8a796b594669c54a34b2e416ff0d931aaa3cc76d.zip
opie-8a796b594669c54a34b2e416ff0d931aaa3cc76d.tar.gz
opie-8a796b594669c54a34b2e416ff0d931aaa3cc76d.tar.bz2
today example plugin
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--examples/todayplugin/config.in5
-rw-r--r--examples/todayplugin/example.pro19
-rw-r--r--examples/todayplugin/exampleplugin.cpp76
-rw-r--r--examples/todayplugin/exampleplugin.h51
-rw-r--r--examples/todayplugin/examplepluginimpl.cpp48
-rw-r--r--examples/todayplugin/examplepluginimpl.h40
-rw-r--r--examples/todayplugin/examplepluginwidget.cpp71
-rw-r--r--examples/todayplugin/examplepluginwidget.h44
-rw-r--r--examples/todayplugin/opie-today-exampleplugin.control9
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 @@
1 config TODAY_EXAMPLE
2 boolean "example"
3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
5 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 @@
1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt release
4
5# Input
6HEADERS = exampleplugin.h examplepluginimpl.h examplepluginwidget.h
7SOURCES = exampleplugin.cpp examplepluginimpl.cpp examplepluginwidget.cpp
8
9INCLUDEPATH += $(OPIEDIR)/include \
10 ../ ../library
11DEPENDPATH += $(OPIEDIR)/include \
12 ../ ../library
13
14LIBS+= -lqpe -lopie
15
16DESTDIR = $(OPIEDIR)/plugins/today
17TARGET = todayexampleplugin
18
19include ( $(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 @@
1/*
2 * exampleplugin.cpp
3 *
4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#include "exampleplugin.h"
19
20ExamplePlugin::ExamplePlugin() {
21 m_widget = 0l;
22}
23
24ExamplePlugin::~ExamplePlugin() {
25 delete (ExamplePluginWidget*)m_widget;
26}
27
28QString ExamplePlugin::pluginName() const {
29 return QObject::tr( "Example plugin" );
30}
31
32double ExamplePlugin::versionNumber() const {
33 return 0.1;
34}
35
36// this sets the image that will be shown on the left side of the plugin
37QString ExamplePlugin::pixmapNameWidget() const {
38 return "Tux";
39}
40
41QWidget* ExamplePlugin::widget( QWidget * wid ) {
42 if(!m_widget) {
43 m_widget = new ExamplePluginWidget( wid, "Example" );
44 }
45 return m_widget;
46}
47
48
49// that would be the icon of the config widget in todays config view
50QString ExamplePlugin::pixmapNameConfig() const {
51 return 0l;
52}
53
54// No config widget yet, look at the datebook plugin for an example of that
55TodayConfigWidget* ExamplePlugin::configWidget( QWidget* ) {
56 return 0l;
57}
58
59// add the binary name of the app to launch here
60QString ExamplePlugin::appName() const {
61 return "";
62}
63
64// if the plugin should be excluded form the refresh cycles that can be set in the today app
65bool ExamplePlugin::excludeFromRefresh() const {
66 return false;
67}
68
69void ExamplePlugin::refresh() {
70 if ( m_widget ) {
71 m_widget->refresh();
72 }
73}
74
75void ExamplePlugin::reinitialize() {
76}
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 @@
1/*
2 * exampleplugin.h
3 *
4 * copyright : (c) 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#ifndef EXAMPLE_PLUGIN_H
19#define EXAMPLE_PLUGIN_H
20
21#include <qwidget.h>
22#include <qguardedptr.h>
23
24#include <opie/todayplugininterface.h>
25#include <opie/todayconfigwidget.h>
26
27#include "examplepluginwidget.h"
28
29// implementation of the today plugin interface
30class ExamplePlugin : public TodayPluginObject {
31
32public:
33 ExamplePlugin();
34 ~ExamplePlugin();
35
36 QString pluginName() const;
37 double versionNumber() const;
38 QString pixmapNameWidget() const;
39 QWidget* widget(QWidget *);
40 QString pixmapNameConfig() const;
41 TodayConfigWidget* configWidget(QWidget *);
42 QString appName() const;
43 bool excludeFromRefresh() const;
44 void refresh();
45 void reinitialize();
46
47 private:
48 QGuardedPtr<ExamplePluginWidget> m_widget;
49};
50
51#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 @@
1/*
2 * examplepluginimpl.cpp
3 *
4 * copyright : (c) 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18
19#include "exampleplugin.h"
20#include "examplepluginimpl.h"
21
22ExamplePluginImpl::ExamplePluginImpl() {
23 examplePlugin = new ExamplePlugin();
24}
25
26ExamplePluginImpl::~ExamplePluginImpl() {
27 delete examplePlugin;
28}
29
30
31TodayPluginObject* ExamplePluginImpl::guiPart() {
32 return examplePlugin;
33}
34
35QRESULT ExamplePluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
36 *iface = 0;
37 if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) {
38 *iface = this, (*iface)->addRef();
39 }else
40 return QS_FALSE;
41
42 return QS_OK;
43
44}
45
46Q_EXPORT_INTERFACE() {
47 Q_CREATE_INSTANCE( ExamplePluginImpl );
48}
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 @@
1/*
2 * examplepluginimpl.h
3 *
4 * copyright : (c) 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef EXAMPLE_PLUGIN_IMPL_H
18#define EXAMPLE_PLUGIN_IMPL_H
19
20#include <opie/todayplugininterface.h>
21
22class ExamplePlugin;
23
24class ExamplePluginImpl : public TodayPluginInterface{
25
26public:
27 ExamplePluginImpl();
28 virtual ~ExamplePluginImpl();
29
30 QRESULT queryInterface( const QUuid &, QUnknownInterface** );
31 Q_REFCOUNT
32
33 virtual TodayPluginObject *guiPart();
34
35private:
36 ExamplePlugin *examplePlugin;
37 ulong ref;
38};
39
40#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 @@
1/*
2 * examplepluginwidget.cpp
3 *
4 * copyright : (c) 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#include <qpe/config.h>
18#include <qpe/qcopenvelope_qws.h>
19
20#include "examplepluginwidget.h"
21
22ExamplePluginWidget::ExamplePluginWidget( QWidget *parent, const char* name)
23 : QWidget(parent, name ) {
24
25 m_exampleLabel = 0l;
26 m_layout = 0l;
27
28 if ( m_exampleLabel ) {
29 delete m_exampleLabel;
30 }
31
32 // since here a OClickableLabel is used, the plugin part will be clickable, and the actions
33 // that should be triggered when clicked are defined in slotClicked()
34 // of course also normal widgets can be used.
35 m_exampleLabel = new OClickableLabel( this );
36 connect( m_exampleLabel, SIGNAL( clicked() ), this, SLOT( slotClicked() ) );
37
38 if ( m_layout ) {
39 delete m_layout;
40 }
41 m_layout = new QHBoxLayout( this );
42 m_layout->setAutoAdd( true );
43
44 readConfig();
45 getInfo();
46}
47
48
49ExamplePluginWidget::~ExamplePluginWidget() {
50 delete m_exampleLabel;
51 delete m_layout;
52}
53
54
55void ExamplePluginWidget::readConfig() {
56// we dont have any config entries in this plugin
57// normally this method is used after today config was used
58}
59
60
61void ExamplePluginWidget::refresh() {
62
63}
64
65void ExamplePluginWidget::getInfo() {
66 m_exampleLabel->setText( "Example text" );
67}
68
69void ExamplePluginWidget::slotClicked() {
70 getInfo();
71}
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 @@
1/*
2 * examplepluginwidget.h
3 *
4 * copyright : (c) 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef EXAMPLE_PLUGIN_WIDGET_H
18#define EXAMPLE_PLUGIN_WIDGET_H
19
20#include <qlayout.h>
21
22#include <opie/oclickablelabel.h>
23
24class ExamplePluginWidget : public QWidget {
25
26 Q_OBJECT
27
28public:
29 ExamplePluginWidget( QWidget *parent, const char *name );
30 ~ExamplePluginWidget();
31
32 void refresh();
33
34private slots:
35 void slotClicked();
36
37private:
38 OClickableLabel* m_exampleLabel;
39 QHBoxLayout* m_layout;
40 void readConfig();
41 void getInfo();
42};
43
44#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 @@
1Package: opie-today-exampleplugin
2Files: plugins/today/libtodayexampleplugin.so*
3Priority: optional
4Section: opie/applications
5Maintainer: Maximilian Reiss <harlekin@handhelds.org>
6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: libqte2, opie-today
9Description: an example plugin for today