Remove not necessary forward declaration
[rsibreak.git] / plasma / rsibreak.cpp
blob0f2a845ccffb32e0af9f35696d2068c4fb6d1c09
1 /*
2 Copyright (C) 2007 Tom Albers <tomalbers@kde.nl>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "rsibreak.h"
20 #include <QPainter>
21 #include <QTimer>
22 #include <QFontMetrics>
23 #include <QDBusInterface>
24 #include <QDBusReply>
26 RSIBreak::RSIBreak(QObject *parent, const QStringList &args)
27 : Plasma::Applet(parent, args)
29 setDrawStandardBackground(true);
31 QDBusInterface rsibreak("org.rsibreak.rsibreak","/rsibreak",
32 "org.rsibreak.rsiwidget");
34 QTimer* m_timer = new QTimer(this);
35 connect( m_timer, SIGNAL(timeout()), this, SLOT(slotUpdate()));
36 m_timer->start(1000);
39 RSIBreak::~RSIBreak()
41 if (failedToLaunch()) {
42 // Do some cleanup here
43 } else {
44 // Save settings
48 void RSIBreak::slotUpdate()
50 update();
53 QSizeF RSIBreak::contentSize() const
55 return QSizeF( 140, 140 );
58 void RSIBreak::paintInterface( QPainter *painter,
59 const QStyleOptionGraphicsItem *option,
60 const QRect &contentsRect)
62 QString text;
63 QDBusInterface rsibreak("org.rsibreak.rsibreak","/rsibreak",
64 "org.rsibreak.rsiwidget");
66 if (!rsibreak.isValid())
68 text.append(i18n("Please\nlaunch\nRSIBreak"));
69 } else {
70 QDBusReply<int> idle = rsibreak.call("idleTime");
71 QDBusReply<int> active1 = rsibreak.call("tinyLeft");
72 QDBusReply<int> active2 = rsibreak.call("bigLeft");
74 text.append(i18np("Currently Idle:\none second\n",
75 "Currently Idle:\n%1 seconds\n", idle.value()));
76 text.append(i18np("Next short break:\none second\n",
77 "Next short break:\n%1 seconds\n", active1.value()));
78 text.append(i18np("Next big break:\n%1 seconds\n",
79 "Next big break:\n%1 seconds\n", active2.value()));
82 painter->save();
83 painter->setPen(Qt::white);
84 painter->drawText(QRect(10,10,130,130),
85 Qt::AlignBottom+Qt::AlignHCenter,
86 text);
87 painter->drawText(boundingRect(),
88 Qt::AlignBottom+Qt::AlignHCenter,
89 "RSIBreak Info");
90 painter->restore();
93 #include "rsibreak.moc"