on 2492425 help sign in
128 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
33public:
34 explicit ColorThemePrivate(ColorTheme *parent = 0);
36 ColorThemePrivate(const QColor &start, const QColor &main,
37 const QColor &end, ColorTheme *parent = 0);
39 ~ColorThemePrivate();
41 ColorTheme * const q_ptr;
43 QColor m_start;
45 QColor m_main;
47 QColor m_end;
49protected:
50 int calculateLength();
52private:
53 Q_DECLARE_PUBLIC(ColorTheme)
54};
58ColorThemePrivate::ColorThemePrivate(
59 ColorTheme *parent) :
60 q_ptr(parent)
64ColorThemePrivate::ColorThemePrivate(const QColor &start,
65 const QColor &main, const QColor &end, ColorTheme *parent) :
66 q_ptr(parent), m_start(start), m_main(main), m_end(end)
70ColorThemePrivate::~ColorThemePrivate()
74ColorTheme::ColorTheme(QObject *parent) :
75 QObject(parent), d_ptr(new ColorThemePrivate(this))
79ColorTheme::ColorTheme(QColor &first, QColor &main,
80 QColor &end, QObject *parent) :
81 QObject(parent), d_ptr(
82 new ColorThemePrivate(first, main, end, this))
87ColorTheme & ColorTheme::operator=(
88 const ColorTheme & other)
90 if (d_ptr->m_start != other.d_ptr->m_start)
91 {
92 d_ptr->m_start = other.d_ptr->m_start;
93 startChanged(d_ptr->m_start);
94 }
95 if (d_ptr->m_main != other.d_ptr->m_main)
96 {
97 d_ptr->m_main = other.d_ptr->m_main;
98 mainChanged(d_ptr->m_main);
99 }
101 if (d_ptr->m_end != other.d_ptr->m_end)
102 {
103 d_ptr->m_end = other.d_ptr->m_end;
104 endChanged(d_ptr->m_end);
105 }
107 return *this;
110ColorTheme::~ColorTheme()
112 delete d_ptr;
115QColor ColorTheme::start() const
117 return d_ptr->m_start;
120QColor ColorTheme::main() const
122 return d_ptr->m_main;
125QColor ColorTheme::end() const
127 return d_ptr->m_end;