on 19bfe13 help sign in
132 lines 2.7 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program 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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
19#include "ColorTheme.h"
21#include <QtCore/QDir>
22#include <QtCore/QString>
23#include <QtGui/QIcon>
24#include <QMultiMap>
26using namespace UserMetricsOutput;
28namespace UserMetricsOutput
31class ColorThemePrivate: QObject
33 Q_OBJECT
35public:
36 explicit ColorThemePrivate(ColorTheme *parent = 0);
38 ColorThemePrivate(const QColor &start, const QColor &main,
39 const QColor &end, ColorTheme *parent = 0);
41 ~ColorThemePrivate();
43 ColorTheme * const q_ptr;
45 QColor m_start;
47 QColor m_main;
49 QColor m_end;
51protected:
52 int calculateLength();
54private:
55 Q_DECLARE_PUBLIC(ColorTheme)
56};
60ColorThemePrivate::ColorThemePrivate(
61 ColorTheme *parent) :
62 q_ptr(parent)
66ColorThemePrivate::ColorThemePrivate(const QColor &start,
67 const QColor &main, const QColor &end, ColorTheme *parent) :
68 q_ptr(parent), m_start(start), m_main(main), m_end(end)
72ColorThemePrivate::~ColorThemePrivate()
76ColorTheme::ColorTheme(QObject *parent) :
77 QObject(parent), d_ptr(new ColorThemePrivate(this))
81ColorTheme::ColorTheme(QColor &first, QColor &main,
82 QColor &end, QObject *parent) :
83 QObject(parent), d_ptr(
84 new ColorThemePrivate(first, main, end, this))
89ColorTheme & ColorTheme::operator=(
90 const ColorTheme & other)
92 if (d_ptr->m_start != other.d_ptr->m_start)
93 {
94 d_ptr->m_start = other.d_ptr->m_start;
95 startChanged(d_ptr->m_start);
96 }
97 if (d_ptr->m_main != other.d_ptr->m_main)
98 {
99 d_ptr->m_main = other.d_ptr->m_main;
100 mainChanged(d_ptr->m_main);
101 }
103 if (d_ptr->m_end != other.d_ptr->m_end)
104 {
105 d_ptr->m_end = other.d_ptr->m_end;
106 endChanged(d_ptr->m_end);
107 }
109 return *this;
112ColorTheme::~ColorTheme()
114 delete d_ptr;
117QColor ColorTheme::start() const
119 return d_ptr->m_start;
122QColor ColorTheme::main() const
124 return d_ptr->m_main;
127QColor ColorTheme::end() const
129 return d_ptr->m_end;
132#include "ColorTheme.moc"