2016-10-21 12:37:26 +05:30
|
|
|
#include "SystemTheme.h"
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStyle>
|
2016-10-22 05:13:36 +05:30
|
|
|
#include <QStyleFactory>
|
|
|
|
#include <QDebug>
|
2016-10-21 12:37:26 +05:30
|
|
|
|
|
|
|
SystemTheme::SystemTheme()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
const auto & style = QApplication::style();
|
|
|
|
systemPalette = style->standardPalette();
|
|
|
|
QString lowerThemeName = style->objectName();
|
|
|
|
qDebug() << systemTheme;
|
|
|
|
QStringList styles = QStyleFactory::keys();
|
|
|
|
for(auto &st: styles)
|
|
|
|
{
|
|
|
|
if(st.toLower() == lowerThemeName)
|
|
|
|
{
|
|
|
|
systemTheme = st;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// fall back to fusion if we can't find the current theme.
|
|
|
|
systemTheme = "Fusion";
|
|
|
|
qDebug() << "System theme not found, defaulted to Fusion";
|
2016-10-21 12:37:26 +05:30
|
|
|
}
|
|
|
|
|
2017-01-18 07:15:04 +05:30
|
|
|
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);
|
2017-01-18 07:15:04 +05:30
|
|
|
}
|
|
|
|
|
2016-10-21 12:37:26 +05:30
|
|
|
QString SystemTheme::id()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return "system";
|
2016-10-21 12:37:26 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
QString SystemTheme::name()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return QObject::tr("System");
|
2016-10-21 12:37:26 +05:30
|
|
|
}
|
|
|
|
|
2016-10-22 05:13:36 +05:30
|
|
|
QString SystemTheme::qtTheme()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return systemTheme;
|
2016-10-22 05:13:36 +05:30
|
|
|
}
|
|
|
|
|
2016-10-21 12:37:26 +05:30
|
|
|
QPalette SystemTheme::colorScheme()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return systemPalette;
|
2016-10-21 12:37:26 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
QString SystemTheme::appStyleSheet()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return QString();
|
2016-10-21 12:37:26 +05:30
|
|
|
}
|
2016-11-06 08:59:12 +05:30
|
|
|
|
|
|
|
double SystemTheme::fadeAmount()
|
2017-01-18 07:15:04 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return 0.5;
|
2017-01-18 07:15:04 +05:30
|
|
|
}
|
2016-11-06 08:59:12 +05:30
|
|
|
|
|
|
|
QColor SystemTheme::fadeColor()
|
2017-01-18 07:15:04 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return QColor(128,128,128);
|
2017-01-18 07:15:04 +05:30
|
|
|
}
|
2017-01-16 03:26:03 +05:30
|
|
|
|
|
|
|
bool SystemTheme::hasStyleSheet()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return false;
|
2017-01-16 03:26:03 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemTheme::hasColorScheme()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return true;
|
2017-01-16 03:26:03 +05:30
|
|
|
}
|