pollymc/application/themes/SystemTheme.cpp

84 lines
1.6 KiB
C++
Raw Normal View History

#include "SystemTheme.h"
#include <QApplication>
#include <QStyle>
#include <QStyleFactory>
#include <QDebug>
SystemTheme::SystemTheme()
{
qDebug() << "Determining System Theme...";
2018-07-15 18:21:05 +05:30
const auto & style = QApplication::style();
systemPalette = style->standardPalette();
QString lowerThemeName = style->objectName();
qDebug() << "System theme seems to be:" << lowerThemeName;
2018-07-15 18:21:05 +05:30
QStringList styles = QStyleFactory::keys();
for(auto &st: styles)
{
qDebug() << "Considering theme from theme factory:" << st.toLower();
2018-07-15 18:21:05 +05:30
if(st.toLower() == lowerThemeName)
{
systemTheme = st;
qDebug() << "System theme has been determined to be:" << systemTheme;
2018-07-15 18:21:05 +05:30
return;
}
}
// fall back to fusion if we can't find the current theme.
systemTheme = "Fusion";
qDebug() << "System theme not found, defaulted to Fusion";
}
void SystemTheme::apply(bool initial)
{
2018-07-15 18:21:05 +05:30
// if we are applying the system theme as the first theme, just don't touch anything. it's for the better...
if(initial)
{
return;
}
ITheme::apply(initial);
}
QString SystemTheme::id()
{
2018-07-15 18:21:05 +05:30
return "system";
}
QString SystemTheme::name()
{
2018-07-15 18:21:05 +05:30
return QObject::tr("System");
}
QString SystemTheme::qtTheme()
{
2018-07-15 18:21:05 +05:30
return systemTheme;
}
QPalette SystemTheme::colorScheme()
{
2018-07-15 18:21:05 +05:30
return systemPalette;
}
QString SystemTheme::appStyleSheet()
{
2018-07-15 18:21:05 +05:30
return QString();
}
double SystemTheme::fadeAmount()
{
2018-07-15 18:21:05 +05:30
return 0.5;
}
QColor SystemTheme::fadeColor()
{
2018-07-15 18:21:05 +05:30
return QColor(128,128,128);
}
bool SystemTheme::hasStyleSheet()
{
2018-07-15 18:21:05 +05:30
return false;
}
bool SystemTheme::hasColorScheme()
{
2018-07-15 18:21:05 +05:30
return true;
}