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(0x00, 0x00, 0xff); // blue
27 s << QColor(0xff, 0x00, 0x00); // red
28 s << QColor(0x00, 0xff, 0x00); // green
29 s << QColor(0xff, 0xff, 0x00); // yellow
30 s << QColor(0xff, 0x00, 0xff); // magenta
31 s << QColor(0x80, 0x00, 0x80); // purple
32 schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Default"), s);
35 s << QBrush(QColor(0x00, 0x00, 0x00), Qt::SolidPattern);
36 s << QBrush(QColor(0x33, 0x33, 0x33), Qt::Dense3Pattern);
37 s << QBrush(QColor(0x66, 0x66, 0x66), Qt::Dense1Pattern);
38 s << QBrush(QColor(0x99, 0x99, 0x99), Qt::SolidPattern);
39 s << QBrush(QColor(0xcc, 0xcc, 0xcc), Qt::CrossPattern);
40 s << QBrush(QColor(0xff, 0xff, 0xff), Qt::SolidPattern);
41 schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Black-and-white"), s);
44 currentScheme = settings.value("colorScheme", 0).toInt();
46 if (currentScheme < 0 || currentScheme > s.size())
50 ColorScheme::~ColorScheme ()
53 settings.setValue("colorScheme", currentScheme);
56 int ColorScheme::getNumSchemes ()
58 return schemes.size();
61 QString ColorScheme::getSchemeName (int scheme)
63 Q_ASSERT(scheme > 0 && scheme < getNumSchemes());
64 return schemes.at(scheme).first;
67 const QVector<QBrush> &ColorScheme::getScheme (int scheme)
69 Q_ASSERT(scheme > 0 && scheme < getNumSchemes());
70 return schemes.at(scheme).second;
73 QString ColorScheme::getSchemeName ()
75 return schemes.at(currentScheme).first;
78 const QVector<QBrush> &ColorScheme::getScheme ()
80 return schemes.at(currentScheme).second;
83 void ColorScheme::setScheme (int scheme)
85 Q_ASSERT(scheme >= 0 && scheme < getNumSchemes());
86 currentScheme = scheme;