1 /* This file is part of the KDE project
2 Copyright (C) 2006 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 <qbitarray.h>
25 #include <qstringlist.h>
27 #include <kpassivepopup.h>
41 IDLENESS_CAUSED_SKIP_TINY
,
42 IDLENESS_CAUSED_SKIP_BIG
,
54 * This class consists of a few commonly used routines and values.
55 * @author Tom Albers <tomalbers@kde.nl>
57 class RSIGlobals
: public QObject
61 /** Default constructor. */
62 explicit RSIGlobals( QObject
*parent
= 0 );
64 /** Default destructor. */
68 * Returns an instance of RSIGlobals. Never create your own instance
69 * of RSIGlobals, but use this method instead to get the one and only
72 static RSIGlobals
*instance();
75 * Returns the one and only statistics component.
84 * Converts @p seconds to a reasonable string.
85 * @param seconds the amount of seconds
86 * @returns a formatted string. Examples:
88 * - 3665: "One hour and one minute"
90 * - 61: "One minute and one second"
91 * - 125: "2 minutes and 5 seconds"
95 QString
formatSeconds( const int seconds
);
98 * Returns a reference to the mapping containing all intervals.
99 * These intervals define when a tiny or big break should occur and for how
102 QMap
<QString
, int> &intervals() {
107 * This function returns a color ranging from green to red.
108 * The more red, the more the user needs a tiny break.
110 QColor
getTinyBreakColor( int secsToBreak
) const;
113 * This function returns a color ranging from green to red.
114 * The more red, the more the user needs a tiny break.
116 QColor
getBigBreakColor( int secsToBreak
) const;
119 * Returns the array which keeps track per second for 24 hours when the
120 * user was active or idle. Activity = 1, idle = 0.
121 * The RSIStatBitArrayItem can read and write a certain interval of this
122 * array, for example to measure the activity in 60 seconds or 1 hour.
124 * @see RSIStatBitArrayItem
126 QBitArray
*usageArray() {
127 return &m_usageArray
;
131 * Resets the usage array, with all values to 0.
137 * Hook to KDE's Notifying system at start/end of a break.
138 * @param start when true the start commands are executed, false executes
139 * the ones at the end of a break.
140 * @param big true for big breaks, false for short ones.
142 void NotifyBreak( bool start
, bool big
);
146 * Reads the configuration.
148 void slotReadConfig();
151 static RSIGlobals
*m_instance
;
152 QMap
<QString
, int> m_intervals
;
153 static RSIStats
*m_stats
;
154 QBitArray m_usageArray
;
155 QStringList m_dcopstartbig
;
156 QStringList m_dcopendbig
;
157 QStringList m_dcopstarttiny
;
158 QStringList m_dcopendtiny
;
162 #endif // RSIGLOBALS_H