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.
22 #include <QFontMetrics>
23 #include <QDBusInterface>
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()));
41 if (failedToLaunch()) {
42 // Do some cleanup here
48 void RSIBreak::slotUpdate()
53 QSizeF
RSIBreak::contentSize() const
55 return QSizeF( 140, 140 );
58 void RSIBreak::paintInterface( QPainter
*painter
,
59 const QStyleOptionGraphicsItem
*option
,
60 const QRect
&contentsRect
)
63 QDBusInterface
rsibreak("org.rsibreak.rsibreak","/rsibreak",
64 "org.rsibreak.rsiwidget");
66 if (!rsibreak
.isValid())
68 text
.append(i18n("Please\nlaunch\nRSIBreak"));
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()));
83 painter
->setPen(Qt::white
);
84 painter
->drawText(QRect(10,10,130,130),
85 Qt::AlignBottom
+Qt::AlignHCenter
,
87 painter
->drawText(boundingRect(),
88 Qt::AlignBottom
+Qt::AlignHCenter
,
93 #include "rsibreak.moc"