summaryrefslogtreecommitdiffstats
path: root/application/themes/ITheme.cpp
blob: bfec87e7dba81ebb0c14da11542afdb947a823f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ITheme.h"
#include "rainbow.h"
#include <QStyleFactory>
#include <QDir>
#include "MultiMC.h"

void ITheme::apply(bool)
{
    QApplication::setStyle(QStyleFactory::create(qtTheme()));
    if(hasColorScheme())
    {
        QApplication::setPalette(colorScheme());
    }
    if(hasStyleSheet())
    {
        MMC->setStyleSheet(appStyleSheet());
    }
    else
    {
        MMC->setStyleSheet(QString());
    }
    QDir::setSearchPaths("theme", searchPaths());
}

QPalette ITheme::fadeInactive(QPalette in, qreal bias, QColor color)
{
    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;
}