05019649ba774180d944f48d23e07d3e3682fc80
[jspeed] / src / themescheduler.h
1 /*
2  * This file is part of jSpeed.
3  *
4  * jSpeed is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * jSpeed 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with jSpeed.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18
19 #ifndef THEMESCHEDULER_H
20 #define THEMESCHEDULER_H
21
22 #include <QtCore/QObject>
23 #include <QtCore/QList>
24 #include <QtCore/QTime>
25 #include <QtCore/QTimer>
26
27 class QString;
28
29 class ThemeScheduler : public QObject
30 {
31     Q_OBJECT
32
33 public:
34
35     struct SchedulerItem
36     {
37         QTime time;
38         QString theme;
39     };
40
41     ~ThemeScheduler();
42     static ThemeScheduler& instance();
43     static QString const& getDefaultTheme();
44     void addItem(QTime const& time, QString const& theme);
45     void removeItem(QTime const& time);
46     void setEnabled(bool enabled);
47     bool isEnabled() const;
48     QString currentTheme() const;
49     void clear();
50     void getItems(QList<SchedulerItem>& items);
51
52 public slots:
53     void store();
54
55 signals:
56     void themeChanged();
57
58 private slots:
59     void emitThemeChanged();
60
61 private:
62     struct ItemDetails
63     {
64         QTime time;
65         QString theme;
66         QTimer timer;
67     };
68
69     ThemeScheduler();
70     void loadConfig();
71     void sort();
72     bool enabled_;
73     QList<ItemDetails*> items_;
74
75
76 };
77
78 #endif