author | harlekin <harlekin> | 2004-01-05 17:42:58 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-01-05 17:42:58 (UTC) |
commit | 3804209658d051d197526a28561bbd2e31b6f439 (patch) (unidiff) | |
tree | a584208303908ca31f6ab039ac00e9fe6fcd606a | |
parent | 642fd965cca78fe4398cbe12afcd15cd2f2257ad (diff) | |
download | opie-3804209658d051d197526a28561bbd2e31b6f439.zip opie-3804209658d051d197526a28561bbd2e31b6f439.tar.gz opie-3804209658d051d197526a28561bbd2e31b6f439.tar.bz2 |
inherit from qwidget instead of qbutton
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 71 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.h | 9 |
2 files changed, 41 insertions, 39 deletions
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp index 31d5bfe..5d98783 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.cpp +++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp | |||
@@ -1,7 +1,3 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qpainter.h> |
2 | #include <qpixmap.h> | ||
3 | #include <qlabel.h> | ||
4 | #include <qsound.h> | ||
5 | #include <qtimer.h> | 2 | #include <qtimer.h> |
6 | #include <qdir.h> | ||
7 | 3 | ||
@@ -10,5 +6,5 @@ | |||
10 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/applnk.h> | ||
11 | 8 | ||
12 | #include <opie/odevice.h> | 9 | #include <opie/odevice.h> |
13 | #include <qlist.h> | ||
14 | 10 | ||
@@ -20,4 +16,4 @@ using namespace Opie; | |||
20 | 16 | ||
21 | MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) | 17 | MailApplet::MailApplet( QWidget *parent ) |
22 | : QButton( parent, name, fl ) { | 18 | : QWidget( parent ) { |
23 | 19 | ||
@@ -26,10 +22,4 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) | |||
26 | 22 | ||
27 | QVBoxLayout *layout = new QVBoxLayout( this ); | 23 | setFixedWidth( AppLnk::smallIconSize() ); |
28 | layout->addItem( new QSpacerItem( 0,0 ) ); | 24 | setFixedHeight( AppLnk::smallIconSize() ); |
29 | |||
30 | QLabel *pixmap = new QLabel( this ); | ||
31 | pixmap->setPixmap( Resource::loadPixmap( "mail/mailchecker" ) ); | ||
32 | layout->addWidget( pixmap ); | ||
33 | |||
34 | layout->addItem( new QSpacerItem( 0,0 ) ); | ||
35 | 25 | ||
@@ -37,12 +27,6 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) | |||
37 | 27 | ||
38 | m_statusMail = 0; | 28 | m_newMails = 0; |
39 | 29 | m_statusMail = 0l; | |
40 | connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) ); | ||
41 | 30 | ||
42 | if ( !m_config->readBoolEntry( "Disabled", false ) ) { | 31 | if ( !m_config->readBoolEntry( "Disabled", false ) ) { |
43 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | ||
44 | m_intervalTimer = new QTimer(); | ||
45 | m_intervalTimer->start( m_intervalMs ); | ||
46 | connect( m_intervalTimer, SIGNAL(timeout() ), SLOT( slotCheck() ) ); | ||
47 | |||
48 | // delay 5 sec until the whole mail backend gets started .-) | 32 | // delay 5 sec until the whole mail backend gets started .-) |
@@ -50,10 +34,25 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) | |||
50 | } | 34 | } |
35 | repaint( true ); | ||
51 | } | 36 | } |
52 | 37 | ||
38 | |||
53 | MailApplet::~MailApplet() { | 39 | MailApplet::~MailApplet() { |
54 | if (m_statusMail) delete m_statusMail; | 40 | if (m_statusMail) delete m_statusMail; |
41 | if (m_config) delete m_config; | ||
55 | } | 42 | } |
56 | 43 | ||
57 | void MailApplet::drawButton(QPainter *) { } | 44 | void MailApplet::paintEvent( QPaintEvent* ) { |
58 | void MailApplet::drawButtonText(QPainter *) { } | 45 | QPainter p(this); |
46 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/mailchecker" ) ); | ||
47 | QFont f( "Fixed", AppLnk::smallIconSize() ); | ||
48 | QFontMetrics fm( f ); | ||
49 | p.setFont( f ); | ||
50 | p.drawText( AppLnk::smallIconSize()/2, AppLnk::smallIconSize()/2, QString::number( m_newMails ) ); | ||
51 | return; | ||
52 | |||
53 | } | ||
54 | |||
55 | void MailApplet::mouseReleaseEvent( QMouseEvent* e) { | ||
56 | slotClicked(); | ||
57 | } | ||
59 | 58 | ||
@@ -79,2 +78,8 @@ void MailApplet::startup() { | |||
79 | delete settings; | 78 | delete settings; |
79 | |||
80 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | ||
81 | m_intervalTimer = new QTimer(); | ||
82 | m_intervalTimer->start( m_intervalMs ); | ||
83 | connect( m_intervalTimer, SIGNAL(timeout() ), this, SLOT( slotCheck() ) ); | ||
84 | |||
80 | } | 85 | } |
@@ -92,5 +97,5 @@ void MailApplet::slotCheck() { | |||
92 | m_statusMail->check_current_stat( stat ); | 97 | m_statusMail->check_current_stat( stat ); |
93 | 98 | m_newMails = stat.message_unseen; | |
94 | qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); | 99 | qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); |
95 | if ( stat.message_unseen > 0 ) { | 100 | if ( m_newMails > 0 ) { |
96 | ODevice *device = ODevice::inst(); | 101 | ODevice *device = ODevice::inst(); |
@@ -106,9 +111,8 @@ void MailApplet::slotCheck() { | |||
106 | 111 | ||
107 | qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); | 112 | Config cfg( "mail" ); |
108 | |||
109 | Config cfg( "mail" ); | ||
110 | cfg.setGroup( "Status" ); | 113 | cfg.setGroup( "Status" ); |
111 | cfg.writeEntry( "NewMails", ( int )stat.message_unseen ); | 114 | cfg.writeEntry( "NewMails", m_newMails ); |
112 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); | 115 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); |
113 | env << stat.message_unseen; | 116 | env << stat.message_unseen; |
117 | repaint( true ); | ||
114 | 118 | ||
@@ -122,5 +126,2 @@ void MailApplet::slotCheck() { | |||
122 | } | 126 | } |
123 | |||
124 | // go trough accounts and check here | ||
125 | // also trigger qcop call and save status to config | ||
126 | } | 127 | } |
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.h b/noncore/net/mail/taskbarapplet/mailapplet.h index 8369176..25f0652 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.h +++ b/noncore/net/mail/taskbarapplet/mailapplet.h | |||
@@ -10,3 +10,3 @@ class QTimer; | |||
10 | 10 | ||
11 | class MailApplet : public QButton { | 11 | class MailApplet : public QWidget { |
12 | 12 | ||
@@ -15,3 +15,3 @@ class MailApplet : public QButton { | |||
15 | public: | 15 | public: |
16 | MailApplet( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); | 16 | MailApplet( QWidget *parent = 0 ); |
17 | ~MailApplet(); | 17 | ~MailApplet(); |
@@ -19,5 +19,5 @@ public: | |||
19 | protected: | 19 | protected: |
20 | void drawButton(QPainter *); | ||
21 | void drawButtonText(QPainter *); | ||
22 | void gotNewMail(); | 20 | void gotNewMail(); |
21 | void mouseReleaseEvent( QMouseEvent* ); | ||
22 | void paintEvent( QPaintEvent* ); | ||
23 | 23 | ||
@@ -32,2 +32,3 @@ private: | |||
32 | StatusMail* m_statusMail; | 32 | StatusMail* m_statusMail; |
33 | int m_newMails; | ||
33 | 34 | ||