2 Copyright 2010 Serge Ziryukin <ftrvxmtrx@gmail.com>
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 2 of the License.
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.
15 #include "colorscheme.hpp"
17 static int currentScheme = 0;
18 static QVector<QPair<QString, QVector<QBrush> > > schemes;
20 ColorScheme::ColorScheme ()
26 s << QColor(0x60, 0x60, 0xa8);
27 s << QColor(0xf6, 0xf6, 0x1d);
28 s << QColor(0x46, 0xb0, 0xe0);
29 s << QColor(0x7e, 0xa0, 0x20);
30 s << QColor(0xf0, 0x70, 0xa0);
31 s << QColor(0xdc, 0x4a, 0x20);
32 /*: default color scheme name */
33 schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Default scheme"), s);
36 s << QBrush(QColor(0x00, 0x00, 0x00), Qt::SolidPattern);
37 s << QBrush(QColor(0x20, 0x20, 0x20), Qt::Dense3Pattern);
38 s << QBrush(QColor(0x66, 0x66, 0x66), Qt::Dense1Pattern);
39 s << QBrush(QColor(0x99, 0x99, 0x99), Qt::SolidPattern);
40 s << QBrush(QColor(0xcc, 0xcc, 0xcc), Qt::CrossPattern);
41 s << QBrush(QColor(0xff, 0xff, 0xff), Qt::SolidPattern);
42 /*: black-and-white color scheme name */
43 schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Black-and-white scheme"), s);
46 currentScheme = settings.value("colorScheme", 0).toInt();
48 if (currentScheme < 0 || currentScheme > s.size())
52 ColorScheme::~ColorScheme ()
55 settings.setValue("colorScheme", currentScheme);
58 int ColorScheme::getNumSchemes ()
60 return schemes.size();
63 int ColorScheme::getNextColorScheme ()
65 return (currentScheme + 1) % schemes.size();
68 QString ColorScheme::getSchemeName (int scheme)
70 Q_ASSERT(scheme >= 0 && scheme < getNumSchemes());
71 return schemes.at(scheme).first;
74 const QVector<QBrush> &ColorScheme::getScheme (int scheme)
76 Q_ASSERT(scheme > 0 && scheme < getNumSchemes());
77 return schemes.at(scheme).second;
80 QString ColorScheme::getSchemeName ()
82 return schemes.at(currentScheme).first;
85 const QVector<QBrush> &ColorScheme::getScheme ()
87 return schemes.at(currentScheme).second;
90 void ColorScheme::setScheme (int scheme)
92 Q_ASSERT(scheme >= 0 && scheme < getNumSchemes());
93 currentScheme = scheme;