Minor fix for another change in Google's movie pages and a fix in
[movie-schedule] / src / ui / styleutils.cpp
1 // Copyright 2010 Jochen Becher
2 //
3 // This file is part of MovieSchedule.
4 //
5 // MovieSchedule is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // MovieSchedule is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with MovieSchedule.  If not, see <http://www.gnu.org/licenses/>.
17
18 #include "styleutils.h"
19
20 #ifdef Q_WS_MAEMO_5
21 #include <QMaemo5Style>
22 #endif
23
24 #include <QPalette>
25
26 StyleUtils::StyleUtils()
27 {
28 }
29
30 QColor StyleUtils::GetColor(const QPalette &palette, StandardColor standard_color)
31 {
32 #ifdef Q_WS_MAEMO_5
33     Q_UNUSED(palette);
34     switch (standard_color)
35     {
36     case DefaultBackgroundColor:
37         return QMaemo5Style::standardColor("DefaultBackgroundColor");
38     case DefaultTextColor:
39         return QMaemo5Style::standardColor("DefaultTextColor");
40     case SecondaryTextColor:
41         return QMaemo5Style::standardColor("ActiveTextColor");
42     default:
43         return QColor();
44     }
45 #else
46     QColor color;
47     switch (standard_color)
48     {
49     case DefaultBackgroundColor:
50         return palette.color(QPalette::Window);
51     case DefaultTextColor:
52         return palette.color(QPalette::WindowText);
53     case SecondaryTextColor:
54          color = palette.color(QPalette::WindowText);
55          color.setAlpha(160);
56          return color;
57     default:
58         return palette.color(QPalette::WindowText);
59     }
60 #endif
61 }
62
63 QColor StyleUtils::GetScheduleTimeColor(const QPalette &palette, QTime time)
64 {
65     Q_UNUSED(time);
66 #ifdef Q_WS_MAEMO_5
67     Q_UNUSED(palette);
68     return QMaemo5Style::standardColor("DefaultTextColor");
69 #else
70     QColor color = palette.color(QPalette::WindowText);
71     return color;
72 #endif
73 }
74
75 QColor StyleUtils::GetDayTextColor(const QPalette &palette, const QDate &date)
76 {
77     Q_UNUSED(date);
78 #ifdef Q_WS_MAEMO_5
79     Q_UNUSED(palette);
80     QColor color = QMaemo5Style::standardColor("DefaultTextColor");
81     color.setAlpha(160);
82     return color;
83 #else
84     QColor color = palette.color(QPalette::WindowText);
85     color.setAlpha(160);
86     return color;
87 #endif
88 }
89
90 QColor StyleUtils::GetDayBackgroundColor(const QPalette &palette, const QDate &date)
91 {
92     Q_UNUSED(date);
93 #ifdef Q_WS_MAEMO_5
94     Q_UNUSED(palette);
95     QColor color = QMaemo5Style::standardColor("DefaultTextColor");
96     color.setAlpha(48);
97     return color;
98 #else
99     QColor color = palette.color(QPalette::WindowText);
100     color.setAlpha(48);
101     return color;
102 #endif
103 }
104
105 StyleUtils *StyleUtils::_instance = 0;
106
107 StyleUtilsSingleton::StyleUtilsSingleton()
108 {
109     StyleUtils::_instance = &_instance;
110 }