SVN_SILENT made messages (.desktop file)
[rsibreak.git] / src / rsiglobals.h
blob2532113a3398616a118e12f1c5ceb6e537a5355d
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.
19 #ifndef RSIGLOBALS_H
20 #define RSIGLOBALS_H
22 #include <qbitarray.h>
23 #include <qmap.h>
24 #include <qobject.h>
25 #include <qstringlist.h>
27 #include <kpassivepopup.h>
29 class RSIStats;
31 enum RSIStat {
32 TOTAL_TIME,
33 ACTIVITY,
34 IDLENESS,
35 ACTIVITY_PERC,
36 ACTIVITY_PERC_MINUTE,
37 ACTIVITY_PERC_HOUR,
38 ACTIVITY_PERC_6HOUR,
39 MAX_IDLENESS,
40 CURRENT_IDLE_TIME,
41 IDLENESS_CAUSED_SKIP_TINY,
42 IDLENESS_CAUSED_SKIP_BIG,
43 TINY_BREAKS,
44 TINY_BREAKS_SKIPPED,
45 LAST_TINY_BREAK,
46 BIG_BREAKS,
47 BIG_BREAKS_SKIPPED,
48 LAST_BIG_BREAK,
49 PAUSE_SCORE
52 /**
53 * @class RSIGlobals
54 * This class consists of a few commonly used routines and values.
55 * @author Tom Albers <tomalbers@kde.nl>
57 class RSIGlobals : public QObject
59 Q_OBJECT
60 public:
61 /** Default constructor. */
62 explicit RSIGlobals( QObject *parent = 0 );
64 /** Default destructor. */
65 ~RSIGlobals();
67 /**
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
70 * instance.
72 static RSIGlobals *instance();
74 /**
75 * Returns the one and only statistics component.
77 * @see RSIStats
79 RSIStats *stats() {
80 return m_stats;
83 /**
84 * Converts @p seconds to a reasonable string.
85 * @param seconds the amount of seconds
86 * @returns a formatted string. Examples:
87 * - 3601: "One hour"
88 * - 3665: "One hour and one minute"
89 * - 60: "One minute"
90 * - 61: "One minute and one second"
91 * - 125: "2 minutes and 5 seconds"
92 * - 2: "2 seconds"
93 * - 0: "0 seconds"
95 QString formatSeconds( const int seconds );
97 /**
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
100 * long.
102 QMap<QString, int> &intervals() {
103 return m_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.
133 void resetUsage();
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 );
144 public slots:
146 * Reads the configuration.
148 void slotReadConfig();
150 private:
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