PrismLauncher/launcher/ui/themes/ITheme.cpp

43 lines
1.2 KiB
C++
Raw Normal View History

#include "ITheme.h"
#include "rainbow.h"
#include <QStyleFactory>
#include <QDir>
2021-11-20 15:22:22 +00:00
#include "Application.h"
void ITheme::apply(bool)
{
APPLICATION->setStyleSheet(QString());
2018-07-15 13:51:05 +01:00
QApplication::setStyle(QStyleFactory::create(qtTheme()));
if (hasColorScheme()) {
2018-07-15 13:51:05 +01:00
QApplication::setPalette(colorScheme());
}
if (hasStyleSheet())
2021-11-20 15:22:22 +00:00
APPLICATION->setStyleSheet(appStyleSheet());
2018-07-15 13:51:05 +01:00
QDir::setSearchPaths("theme", searchPaths());
}
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;
}