-rw-r--r-- | core/pim/today/plugins/mail/mailplugin.cpp | 17 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailplugin.h | 6 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailpluginwidget.cpp | 33 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailpluginwidget.h | 6 |
4 files changed, 48 insertions, 14 deletions
diff --git a/core/pim/today/plugins/mail/mailplugin.cpp b/core/pim/today/plugins/mail/mailplugin.cpp index d497970..a37d506 100644 --- a/core/pim/today/plugins/mail/mailplugin.cpp +++ b/core/pim/today/plugins/mail/mailplugin.cpp | |||
@@ -7,54 +7,63 @@ | |||
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | 17 | ||
18 | #include "mailplugin.h" | 18 | #include "mailplugin.h" |
19 | #include "mailpluginwidget.h" | ||
20 | |||
21 | 19 | ||
22 | MailPlugin::MailPlugin() { | 20 | MailPlugin::MailPlugin() { |
21 | m_widget = 0l; | ||
23 | } | 22 | } |
24 | 23 | ||
25 | MailPlugin::~MailPlugin() { | 24 | MailPlugin::~MailPlugin() { |
25 | delete m_widget; | ||
26 | } | 26 | } |
27 | 27 | ||
28 | QString MailPlugin::pluginName() const { | 28 | QString MailPlugin::pluginName() const { |
29 | return QObject::tr( "Mail plugin" ); | 29 | return QObject::tr( "Mail plugin" ); |
30 | } | 30 | } |
31 | 31 | ||
32 | double MailPlugin::versionNumber() const { | 32 | double MailPlugin::versionNumber() const { |
33 | return 0.6; | 33 | return 0.6; |
34 | } | 34 | } |
35 | 35 | ||
36 | QString MailPlugin::pixmapNameWidget() const { | 36 | QString MailPlugin::pixmapNameWidget() const { |
37 | return "mail/desktopicon"; | 37 | return "mail/desktopicon"; |
38 | } | 38 | } |
39 | 39 | ||
40 | QWidget* MailPlugin::widget( QWidget * wid ) { | 40 | QWidget* MailPlugin::widget( QWidget * wid ) { |
41 | return new MailPluginWidget( wid, "Mail" ); | 41 | if(!m_widget) { |
42 | m_widget = new MailPluginWidget( wid, "Datebook" ); | ||
43 | } | ||
44 | return m_widget; | ||
42 | } | 45 | } |
43 | 46 | ||
47 | |||
44 | QString MailPlugin::pixmapNameConfig() const { | 48 | QString MailPlugin::pixmapNameConfig() const { |
45 | return 0l; | 49 | return 0l; |
46 | } | 50 | } |
47 | 51 | ||
48 | TodayConfigWidget* MailPlugin::configWidget( QWidget* wid ) { | 52 | TodayConfigWidget* MailPlugin::configWidget( QWidget* ) { |
49 | return 0l; | 53 | return 0l; |
50 | } | 54 | } |
51 | 55 | ||
52 | QString MailPlugin::appName() const { | 56 | QString MailPlugin::appName() const { |
53 | return "mail"; | 57 | return "mail"; |
54 | } | 58 | } |
55 | 59 | ||
56 | 60 | ||
57 | bool MailPlugin::excludeFromRefresh() const { | 61 | bool MailPlugin::excludeFromRefresh() const { |
58 | return false; | 62 | return false; |
59 | } | 63 | } |
60 | 64 | ||
65 | void MailPlugin::refresh() { | ||
66 | if ( m_widget ) { | ||
67 | m_widget->refresh(); | ||
68 | } | ||
69 | } | ||
diff --git a/core/pim/today/plugins/mail/mailplugin.h b/core/pim/today/plugins/mail/mailplugin.h index c937b9e..67fac0c 100644 --- a/core/pim/today/plugins/mail/mailplugin.h +++ b/core/pim/today/plugins/mail/mailplugin.h | |||
@@ -18,29 +18,35 @@ | |||
18 | #ifndef MAIL_PLUGIN_H | 18 | #ifndef MAIL_PLUGIN_H |
19 | #define MAIL_PLUGIN_H | 19 | #define MAIL_PLUGIN_H |
20 | 20 | ||
21 | #include <qstring.h> | 21 | #include <qstring.h> |
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | 23 | ||
24 | #include <opie/tododb.h> | 24 | #include <opie/tododb.h> |
25 | #include <opie/oclickablelabel.h> | 25 | #include <opie/oclickablelabel.h> |
26 | 26 | ||
27 | #include <opie/todayplugininterface.h> | 27 | #include <opie/todayplugininterface.h> |
28 | #include <opie/todayconfigwidget.h> | 28 | #include <opie/todayconfigwidget.h> |
29 | 29 | ||
30 | #include "mailpluginwidget.h" | ||
31 | |||
30 | class MailPlugin : public TodayPluginObject { | 32 | class MailPlugin : public TodayPluginObject { |
31 | 33 | ||
32 | public: | 34 | public: |
33 | MailPlugin(); | 35 | MailPlugin(); |
34 | ~MailPlugin(); | 36 | ~MailPlugin(); |
35 | 37 | ||
36 | QString pluginName() const; | 38 | QString pluginName() const; |
37 | double versionNumber() const; | 39 | double versionNumber() const; |
38 | QString pixmapNameWidget() const; | 40 | QString pixmapNameWidget() const; |
39 | QWidget* widget(QWidget *); | 41 | QWidget* widget(QWidget *); |
40 | QString pixmapNameConfig() const; | 42 | QString pixmapNameConfig() const; |
41 | TodayConfigWidget* configWidget(QWidget *); | 43 | TodayConfigWidget* configWidget(QWidget *); |
42 | QString appName() const; | 44 | QString appName() const; |
43 | bool excludeFromRefresh() const; | 45 | bool excludeFromRefresh() const; |
46 | void refresh(); | ||
47 | |||
48 | private: | ||
49 | MailPluginWidget *m_widget; | ||
44 | }; | 50 | }; |
45 | 51 | ||
46 | #endif | 52 | #endif |
diff --git a/core/pim/today/plugins/mail/mailpluginwidget.cpp b/core/pim/today/plugins/mail/mailpluginwidget.cpp index a6f3562..aad1d07 100644 --- a/core/pim/today/plugins/mail/mailpluginwidget.cpp +++ b/core/pim/today/plugins/mail/mailpluginwidget.cpp | |||
@@ -21,53 +21,68 @@ | |||
21 | #include <qobject.h> | 21 | #include <qobject.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | 23 | ||
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | 27 | ||
28 | #include "mailpluginwidget.h" | 28 | #include "mailpluginwidget.h" |
29 | 29 | ||
30 | MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name) | 30 | MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name) |
31 | : QWidget(parent, name ) { | 31 | : QWidget(parent, name ) { |
32 | 32 | ||
33 | m_mailLabel = 0l; | ||
34 | m_layout = 0l; | ||
35 | |||
36 | if ( m_mailLabel ) { | ||
37 | delete m_mailLabel; | ||
38 | } | ||
39 | m_mailLabel = new OClickableLabel( this ); | ||
40 | m_mailLabel->setMaximumHeight( 15 ); | ||
41 | connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); | ||
42 | |||
43 | if ( m_layout ) { | ||
44 | delete m_layout; | ||
45 | } | ||
46 | m_layout = new QHBoxLayout( this ); | ||
47 | m_layout->setAutoAdd( true ); | ||
48 | |||
33 | readConfig(); | 49 | readConfig(); |
34 | getInfo(); | 50 | getInfo(); |
35 | } | 51 | } |
36 | 52 | ||
37 | MailPluginWidget::~MailPluginWidget() { | 53 | MailPluginWidget::~MailPluginWidget() { |
54 | delete m_mailLabel; | ||
55 | delete m_layout; | ||
38 | } | 56 | } |
39 | 57 | ||
40 | 58 | ||
41 | void MailPluginWidget::readConfig() { | 59 | void MailPluginWidget::readConfig() { |
42 | Config cfg( "todaymailplugin" ); | 60 | Config cfg( "todaymailplugin" ); |
43 | cfg.setGroup( "config" ); | 61 | cfg.setGroup( "config" ); |
44 | } | 62 | } |
45 | 63 | ||
46 | 64 | ||
47 | void MailPluginWidget::getInfo() { | 65 | void MailPluginWidget::refresh() { |
48 | 66 | getInfo(); | |
49 | QHBoxLayout* layout = new QHBoxLayout( this ); | 67 | } |
50 | 68 | ||
51 | mailLabel = new OClickableLabel( this ); | 69 | void MailPluginWidget::getInfo() { |
52 | mailLabel->setMaximumHeight( 15 ); | ||
53 | connect( mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); | ||
54 | 70 | ||
55 | Config cfg( "opiemail" ); | 71 | Config cfg( "opiemail" ); |
56 | cfg.setGroup( "today" ); | 72 | cfg.setGroup( "today" ); |
57 | 73 | ||
58 | int NEW_MAILS = cfg.readNumEntry( "newmails", 0 ); | 74 | int NEW_MAILS = cfg.readNumEntry( "newmails", 0 ); |
59 | int OUTGOING = cfg.readNumEntry( "outgoing", 0 ); | 75 | int OUTGOING = cfg.readNumEntry( "outgoing", 0 ); |
60 | 76 | ||
61 | QString output = QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( NEW_MAILS ).arg( OUTGOING ); | 77 | //QString output = QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( NEW_MAILS ).arg( OUTGOING ); |
62 | 78 | ||
63 | mailLabel->setText( output ); | 79 | m_mailLabel->setText( QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( NEW_MAILS ).arg( OUTGOING ) ); |
64 | layout->addWidget( mailLabel ); | ||
65 | } | 80 | } |
66 | 81 | ||
67 | /** | 82 | /** |
68 | * launches datebook | 83 | * launches datebook |
69 | */ | 84 | */ |
70 | void MailPluginWidget::startMail() { | 85 | void MailPluginWidget::startMail() { |
71 | QCopEnvelope e("QPE/System", "execute(QString)"); | 86 | QCopEnvelope e("QPE/System", "execute(QString)"); |
72 | e << QString( "mail" ); | 87 | e << QString( "mail" ); |
73 | } | 88 | } |
diff --git a/core/pim/today/plugins/mail/mailpluginwidget.h b/core/pim/today/plugins/mail/mailpluginwidget.h index 2feef80..c678833 100644 --- a/core/pim/today/plugins/mail/mailpluginwidget.h +++ b/core/pim/today/plugins/mail/mailpluginwidget.h | |||
@@ -11,35 +11,39 @@ | |||
11 | * it under the terms of the GNU General Public License as published by * | 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 * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | 17 | ||
18 | #ifndef MAIL_PLUGIN_WIDGET_H | 18 | #ifndef MAIL_PLUGIN_WIDGET_H |
19 | #define MAIL_PLUGIN_WIDGET_H | 19 | #define MAIL_PLUGIN_WIDGET_H |
20 | 20 | ||
21 | #include <qstring.h> | 21 | #include <qstring.h> |
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qlayout.h> | ||
23 | 24 | ||
24 | #include <opie/tododb.h> | 25 | #include <opie/tododb.h> |
25 | #include <opie/oclickablelabel.h> | 26 | #include <opie/oclickablelabel.h> |
26 | 27 | ||
27 | class MailPluginWidget : public QWidget { | 28 | class MailPluginWidget : public QWidget { |
28 | 29 | ||
29 | Q_OBJECT | 30 | Q_OBJECT |
30 | 31 | ||
31 | 32 | ||
32 | public: | 33 | public: |
33 | MailPluginWidget( QWidget *parent, const char *name ); | 34 | MailPluginWidget( QWidget *parent, const char *name ); |
34 | ~MailPluginWidget(); | 35 | ~MailPluginWidget(); |
35 | 36 | ||
37 | void refresh(); | ||
38 | |||
36 | protected slots: | 39 | protected slots: |
37 | void startMail(); | 40 | void startMail(); |
38 | 41 | ||
39 | private: | 42 | private: |
40 | OClickableLabel *mailLabel; | 43 | OClickableLabel* m_mailLabel; |
44 | QHBoxLayout* m_layout; | ||
41 | void readConfig(); | 45 | void readConfig(); |
42 | void getInfo(); | 46 | void getInfo(); |
43 | }; | 47 | }; |
44 | 48 | ||
45 | #endif | 49 | #endif |