summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp
index 6078013..f242bda 100644
--- a/noncore/net/mail/taskbarapplet/mailapplet.cpp
+++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp
@@ -1,139 +1,141 @@
1#include <qpainter.h> 1#include <qpainter.h>
2#include <qtimer.h> 2#include <qtimer.h>
3 3
4#include <qpe/qcopenvelope_qws.h> 4#include <qpe/qcopenvelope_qws.h>
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qpe/applnk.h> 7#include <qpe/applnk.h>
8 8
9#include <opie/odevice.h> 9#include <opie/odevice.h>
10 10
11#include <libmailwrapper/settings.h> 11#include <libmailwrapper/settings.h>
12 12
13#include "mailapplet.h" 13#include "mailapplet.h"
14 14
15using namespace Opie; 15using namespace Opie;
16 16
17MailApplet::MailApplet( QWidget *parent ) 17MailApplet::MailApplet( QWidget *parent )
18: QWidget( parent ) { 18: QWidget( parent ) {
19 19
20 m_config = new Config( "mail" ); 20 m_config = new Config( "mail" );
21 m_config->setGroup( "Applet" ); 21 m_config->setGroup( "Applet" );
22 22
23 setFixedWidth( AppLnk::smallIconSize() ); 23 setFixedWidth( AppLnk::smallIconSize() );
24 setFixedHeight( AppLnk::smallIconSize() ); 24 setFixedHeight( AppLnk::smallIconSize() );
25 25
26 hide(); 26 hide();
27 27
28 m_newMails = 0; 28 m_newMails = 0;
29 m_statusMail = 0l; 29 m_statusMail = 0l;
30 30
31 if ( !m_config->readBoolEntry( "Disabled", false ) ) { 31 if ( !m_config->readBoolEntry( "Disabled", false ) ) {
32 // delay 5 sec until the whole mail backend gets started .-) 32 // delay 5 sec until the whole mail backend gets started .-)
33 QTimer::singleShot( 5000, this, SLOT( startup() ) ); 33 QTimer::singleShot( 5000, this, SLOT( startup() ) );
34 } 34 }
35 repaint( true ); 35 repaint( true );
36} 36}
37 37
38 38
39MailApplet::~MailApplet() { 39MailApplet::~MailApplet() {
40 if ( m_statusMail ) 40 if ( m_statusMail )
41 delete m_statusMail; 41 delete m_statusMail;
42 if ( m_config ) 42 if ( m_config )
43 delete m_config; 43 delete m_config;
44} 44}
45 45
46void MailApplet::paintEvent( QPaintEvent* ) { 46void MailApplet::paintEvent( QPaintEvent* ) {
47 QPainter p( this ); 47 QPainter p( this );
48 p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); 48 p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) );
49 QFont f( "vera", AppLnk::smallIconSize() ); 49 QFont f( "vera", AppLnk::smallIconSize() );
50 QFontMetrics fm( f ); 50 QFontMetrics fm( f );
51 p.setFont( f ); 51 p.setFont( f );
52 p.setPen( Qt::blue ); 52 p.setPen( Qt::blue );
53 p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); 53 p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) );
54 return; 54 return;
55 55
56} 56}
57 57
58void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { 58void MailApplet::mouseReleaseEvent( QMouseEvent* e ) {
59 slotClicked(); 59 slotClicked();
60} 60}
61 61
62void MailApplet::slotClicked() { 62void MailApplet::slotClicked() {
63 QCopEnvelope e( "QPE/System", "execute(QString)" ); 63 QCopEnvelope e( "QPE/System", "execute(QString)" );
64 e << QString( "opiemail" ); 64 e << QString( "opiemail" );
65 65
66 ODevice *device = ODevice::inst(); 66 ODevice *device = ODevice::inst();
67 if ( !device-> ledList().isEmpty() ) { 67 if ( !device-> ledList().isEmpty() ) {
68 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 68 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
69 69
70 device->setLedState( led, Led_Off ); 70 device->setLedState( led, Led_Off );
71 } 71 }
72 72
73 if (m_statusMail) m_statusMail->reset_status(); 73 if (m_statusMail) m_statusMail->reset_status();
74
75 hide();
74} 76}
75 77
76void MailApplet::startup() { 78void MailApplet::startup() {
77 Settings *settings = new Settings(); 79 Settings *settings = new Settings();
78 QList<Account> ma = settings->getAccounts(); 80 QList<Account> ma = settings->getAccounts();
79 m_statusMail = new StatusMail( ma ); 81 m_statusMail = new StatusMail( ma );
80 delete settings; 82 delete settings;
81 83
82 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 84 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
83 m_intervalTimer = new QTimer(); 85 m_intervalTimer = new QTimer();
84 m_intervalTimer->start( m_intervalMs ); 86 m_intervalTimer->start( m_intervalMs );
85 connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); 87 connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) );
86} 88}
87 89
88void MailApplet::slotCheck() { 90void MailApplet::slotCheck() {
89 // Check wether the check interval has been changed. 91 // Check wether the check interval has been changed.
90 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 92 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
91 if ( newIntervalMs != m_intervalMs ) { 93 if ( newIntervalMs != m_intervalMs ) {
92 m_intervalTimer->changeInterval( newIntervalMs ); 94 m_intervalTimer->changeInterval( newIntervalMs );
93 m_intervalMs = newIntervalMs; 95 m_intervalMs = newIntervalMs;
94 } 96 }
95 97
96 if (m_statusMail == 0) { 98 if (m_statusMail == 0) {
97 return; 99 return;
98 } 100 }
99 101
100 folderStat stat; 102 folderStat stat;
101 m_statusMail->check_current_stat( stat ); 103 m_statusMail->check_current_stat( stat );
102 m_newMails = stat.message_unseen; 104 m_newMails = stat.message_unseen;
103 qDebug( QString( "test %1" ).arg( m_newMails ) ); 105 qDebug( QString( "test %1" ).arg( m_newMails ) );
104 if ( m_newMails > 0 ) { 106 if ( m_newMails > 0 ) {
105 ODevice *device = ODevice::inst(); 107 ODevice *device = ODevice::inst();
106 if ( isHidden() ) 108 if ( isHidden() )
107 show(); 109 show();
108 if ( m_config->readBoolEntry( "BlinkLed", true ) ) { 110 if ( m_config->readBoolEntry( "BlinkLed", true ) ) {
109 if ( !device->ledList().isEmpty() ) { 111 if ( !device->ledList().isEmpty() ) {
110 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 112 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
111 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); 113 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On );
112 } 114 }
113 } 115 }
114 if ( m_config->readBoolEntry( "PlaySound", false ) ) 116 if ( m_config->readBoolEntry( "PlaySound", false ) )
115 device->alarmSound(); 117 device->alarmSound();
116 118
117 Config cfg( "mail" ); 119 Config cfg( "mail" );
118 cfg.setGroup( "Status" ); 120 cfg.setGroup( "Status" );
119 cfg.writeEntry( "newMails", m_newMails ); 121 cfg.writeEntry( "newMails", m_newMails );
120 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 122 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
121 env << m_newMails; 123 env << m_newMails;
122 repaint( true ); 124 repaint( true );
123 125
124 } else { 126 } else {
125 ODevice *device = ODevice::inst(); 127 ODevice *device = ODevice::inst();
126 if ( !isHidden() ) 128 if ( !isHidden() )
127 hide(); 129 hide();
128 if ( !device->ledList().isEmpty() ) { 130 if ( !device->ledList().isEmpty() ) {
129 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 131 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
130 device->setLedState( led, Led_Off ); 132 device->setLedState( led, Led_Off );
131 } 133 }
132 134
133 Config cfg( "mail" ); 135 Config cfg( "mail" );
134 cfg.setGroup( "Status" ); 136 cfg.setGroup( "Status" );
135 cfg.writeEntry( "newMails", m_newMails ); 137 cfg.writeEntry( "newMails", m_newMails );
136 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 138 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
137 env << m_newMails; 139 env << m_newMails;
138 } 140 }
139} 141}