2016-11-06 03:29:12 +00:00
|
|
|
#include "ITheme.h"
|
|
|
|
#include "rainbow.h"
|
2017-01-18 01:45:04 +00:00
|
|
|
#include <QStyleFactory>
|
|
|
|
#include <QDir>
|
2021-11-20 15:22:22 +00:00
|
|
|
#include "Application.h"
|
2017-01-18 01:45:04 +00:00
|
|
|
|
|
|
|
void ITheme::apply(bool)
|
|
|
|
{
|
2022-12-12 20:20:17 +00:00
|
|
|
APPLICATION->setStyleSheet(QString());
|
2018-07-15 13:51:05 +01:00
|
|
|
QApplication::setStyle(QStyleFactory::create(qtTheme()));
|
2022-12-12 20:20:17 +00:00
|
|
|
if (hasColorScheme()) {
|
2018-07-15 13:51:05 +01:00
|
|
|
QApplication::setPalette(colorScheme());
|
|
|
|
}
|
2022-12-12 20:20:17 +00:00
|
|
|
if (hasStyleSheet())
|
2021-11-20 15:22:22 +00:00
|
|
|
APPLICATION->setStyleSheet(appStyleSheet());
|
2022-12-12 20:20:17 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
QDir::setSearchPaths("theme", searchPaths());
|
2017-01-18 01:45:04 +00:00
|
|
|
}
|
2016-11-06 03:29:12 +00:00
|
|
|
|
|
|
|
QPalette ITheme::fadeInactive(QPalette in, qreal bias, QColor color)
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
auto blend = [&in, bias, color](QPalette::ColorRole role)
|
|
|
|
{
|
|
|
|
QColor from = in.color(QPalette::Active, role);
|
|
|
|
QColor blended = Rainbow::mix(from, color, bias);
|
|
|
|
in.setColor(QPalette::Disabled, role, blended);
|
|
|
|
};
|
|
|
|
blend(QPalette::Window);
|
|
|
|
blend(QPalette::WindowText);
|
|
|
|
blend(QPalette::Base);
|
|
|
|
blend(QPalette::AlternateBase);
|
|
|
|
blend(QPalette::ToolTipBase);
|
|
|
|
blend(QPalette::ToolTipText);
|
|
|
|
blend(QPalette::Text);
|
|
|
|
blend(QPalette::Button);
|
|
|
|
blend(QPalette::ButtonText);
|
|
|
|
blend(QPalette::BrightText);
|
|
|
|
blend(QPalette::Link);
|
|
|
|
blend(QPalette::Highlight);
|
|
|
|
blend(QPalette::HighlightedText);
|
|
|
|
return in;
|
2016-11-06 03:29:12 +00:00
|
|
|
}
|