matrixion/src/ui/Theme.cc

74 lines
1.4 KiB
C++
Raw Normal View History

2017-04-06 02:06:42 +03:00
#include <QDebug>
#include "Theme.h"
Theme::Theme(QObject *parent)
: QObject(parent)
{
setColor("Black", ui::Color::Black);
setColor("BrightWhite", ui::Color::BrightWhite);
setColor("FadedWhite", ui::Color::FadedWhite);
setColor("MediumWhite", ui::Color::MediumWhite);
setColor("BrightGreen", ui::Color::BrightGreen);
setColor("DarkGreen", ui::Color::DarkGreen);
setColor("LightGreen", ui::Color::LightGreen);
setColor("Gray", ui::Color::Gray);
setColor("Red", ui::Color::Red);
setColor("Blue", ui::Color::Blue);
setColor("Transparent", ui::Color::Transparent);
}
Theme::~Theme()
{
}
QColor Theme::rgba(int r, int g, int b, qreal a) const
{
QColor color(r, g, b);
color.setAlphaF(a);
return color;
}
QColor Theme::getColor(const QString &key) const
{
if (!colors_.contains(key)) {
qWarning() << "Color with key" << key << "could not be found";
return QColor();
}
return colors_.value(key);
}
void Theme::setColor(const QString &key, const QColor &color)
{
colors_.insert(key, color);
}
2017-05-08 00:51:03 +03:00
void Theme::setColor(const QString &key, ui::Color color)
2017-04-06 02:06:42 +03:00
{
static const QColor palette[] = {
QColor("#171919"),
QColor("#EBEBEB"),
QColor("#C9C9C9"),
QColor("#929292"),
QColor("#1C3133"),
QColor("#577275"),
QColor("#46A451"),
QColor("#5D6565"),
QColor("#E22826"),
QColor("#81B3A9"),
rgba(0, 0, 0, 0),
};
2017-05-08 00:51:03 +03:00
colors_.insert(key, palette[static_cast<int>(color)]);
2017-04-06 02:06:42 +03:00
}