NOISSUE add hack for system themes. Maybe it works?
This commit is contained in:
parent
71584fb8cc
commit
944ff256b2
@ -355,7 +355,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
connect(this, SIGNAL(aboutToQuit()), SLOT(onExit()));
|
connect(this, SIGNAL(aboutToQuit()), SLOT(onExit()));
|
||||||
|
|
||||||
setIconTheme(settings()->get("IconTheme").toString());
|
setIconTheme(settings()->get("IconTheme").toString());
|
||||||
//setApplicationTheme(settings()->get("ApplicationTheme").toString());
|
setApplicationTheme(settings()->get("ApplicationTheme").toString());
|
||||||
|
|
||||||
initAnalytics();
|
initAnalytics();
|
||||||
|
|
||||||
@ -876,11 +876,21 @@ void MultiMC::setApplicationTheme(const QString& name)
|
|||||||
{
|
{
|
||||||
auto & theme = (*themeIter).second;
|
auto & theme = (*themeIter).second;
|
||||||
setStyle(QStyleFactory::create(theme->qtTheme()));
|
setStyle(QStyleFactory::create(theme->qtTheme()));
|
||||||
|
if(theme->hasColorScheme())
|
||||||
|
{
|
||||||
setPalette(theme->colorScheme());
|
setPalette(theme->colorScheme());
|
||||||
QDir::setSearchPaths("theme", theme->searchPaths());
|
}
|
||||||
|
if(theme->hasStyleSheet())
|
||||||
|
{
|
||||||
setStyleSheet(theme->appStyleSheet());
|
setStyleSheet(theme->appStyleSheet());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
setStyleSheet(QString());
|
||||||
|
}
|
||||||
|
QDir::setSearchPaths("theme", theme->searchPaths());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
qWarning() << "Tried to set invalid theme:" << name;
|
qWarning() << "Tried to set invalid theme:" << name;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,11 @@ QString BrightTheme::name()
|
|||||||
return QObject::tr("Bright");
|
return QObject::tr("Bright");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BrightTheme::hasColorScheme()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QPalette BrightTheme::colorScheme()
|
QPalette BrightTheme::colorScheme()
|
||||||
{
|
{
|
||||||
QPalette brightPalette;
|
QPalette brightPalette;
|
||||||
@ -39,6 +44,11 @@ QColor BrightTheme::fadeColor()
|
|||||||
return QColor(239,240,241);
|
return QColor(239,240,241);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BrightTheme::hasStyleSheet()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString BrightTheme::appStyleSheet()
|
QString BrightTheme::appStyleSheet()
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
@ -9,7 +9,9 @@ public:
|
|||||||
|
|
||||||
QString id() override;
|
QString id() override;
|
||||||
QString name() override;
|
QString name() override;
|
||||||
|
bool hasStyleSheet() override;
|
||||||
QString appStyleSheet() override;
|
QString appStyleSheet() override;
|
||||||
|
bool hasColorScheme() override;
|
||||||
QPalette colorScheme() override;
|
QPalette colorScheme() override;
|
||||||
double fadeAmount() override;
|
double fadeAmount() override;
|
||||||
QColor fadeColor() override;
|
QColor fadeColor() override;
|
||||||
|
@ -208,11 +208,21 @@ QString CustomTheme::name()
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CustomTheme::hasColorScheme()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QPalette CustomTheme::colorScheme()
|
QPalette CustomTheme::colorScheme()
|
||||||
{
|
{
|
||||||
return m_palette;
|
return m_palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CustomTheme::hasStyleSheet()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QString CustomTheme::appStyleSheet()
|
QString CustomTheme::appStyleSheet()
|
||||||
{
|
{
|
||||||
return m_styleSheet;
|
return m_styleSheet;
|
||||||
|
@ -10,7 +10,9 @@ public:
|
|||||||
|
|
||||||
QString id() override;
|
QString id() override;
|
||||||
QString name() override;
|
QString name() override;
|
||||||
|
bool hasStyleSheet() override;
|
||||||
QString appStyleSheet() override;
|
QString appStyleSheet() override;
|
||||||
|
bool hasColorScheme() override;
|
||||||
QPalette colorScheme() override;
|
QPalette colorScheme() override;
|
||||||
double fadeAmount() override;
|
double fadeAmount() override;
|
||||||
QColor fadeColor() override;
|
QColor fadeColor() override;
|
||||||
|
@ -10,6 +10,11 @@ QString DarkTheme::name()
|
|||||||
return QObject::tr("Dark");
|
return QObject::tr("Dark");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DarkTheme::hasColorScheme()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QPalette DarkTheme::colorScheme()
|
QPalette DarkTheme::colorScheme()
|
||||||
{
|
{
|
||||||
QPalette darkPalette;
|
QPalette darkPalette;
|
||||||
@ -39,6 +44,11 @@ QColor DarkTheme::fadeColor()
|
|||||||
return QColor(49,54,59);
|
return QColor(49,54,59);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DarkTheme::hasStyleSheet()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QString DarkTheme::appStyleSheet()
|
QString DarkTheme::appStyleSheet()
|
||||||
{
|
{
|
||||||
return "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }";
|
return "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }";
|
||||||
|
@ -9,7 +9,9 @@ public:
|
|||||||
|
|
||||||
QString id() override;
|
QString id() override;
|
||||||
QString name() override;
|
QString name() override;
|
||||||
|
bool hasStyleSheet() override;
|
||||||
QString appStyleSheet() override;
|
QString appStyleSheet() override;
|
||||||
|
bool hasColorScheme() override;
|
||||||
QPalette colorScheme() override;
|
QPalette colorScheme() override;
|
||||||
double fadeAmount() override;
|
double fadeAmount() override;
|
||||||
QColor fadeColor() override;
|
QColor fadeColor() override;
|
||||||
|
@ -2,14 +2,18 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
|
class QStyle;
|
||||||
|
|
||||||
class ITheme
|
class ITheme
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ITheme() {}
|
virtual ~ITheme() {}
|
||||||
virtual QString id() = 0;
|
virtual QString id() = 0;
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
|
virtual bool hasStyleSheet() = 0;
|
||||||
virtual QString appStyleSheet() = 0;
|
virtual QString appStyleSheet() = 0;
|
||||||
virtual QString qtTheme() = 0;
|
virtual QString qtTheme() = 0;
|
||||||
|
virtual bool hasColorScheme() = 0;
|
||||||
virtual QPalette colorScheme() = 0;
|
virtual QPalette colorScheme() = 0;
|
||||||
virtual QColor fadeColor() = 0;
|
virtual QColor fadeColor() = 0;
|
||||||
virtual double fadeAmount() = 0;
|
virtual double fadeAmount() = 0;
|
||||||
|
@ -21,6 +21,7 @@ SystemTheme::SystemTheme()
|
|||||||
}
|
}
|
||||||
// fall back to fusion if we can't find the current theme.
|
// fall back to fusion if we can't find the current theme.
|
||||||
systemTheme = "Fusion";
|
systemTheme = "Fusion";
|
||||||
|
qWarning() << "System theme not found, defaulted to Fusion";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SystemTheme::id()
|
QString SystemTheme::id()
|
||||||
@ -57,3 +58,18 @@ QColor SystemTheme::fadeColor()
|
|||||||
{
|
{
|
||||||
return QColor(128,128,128);
|
return QColor(128,128,128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SystemTheme::hasStyleSheet()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SystemTheme::hasColorScheme()
|
||||||
|
{
|
||||||
|
// FIXME: horrible hack to work around Qt's sketchy theming APIs
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -11,7 +11,9 @@ public:
|
|||||||
QString id() override;
|
QString id() override;
|
||||||
QString name() override;
|
QString name() override;
|
||||||
QString qtTheme() override;
|
QString qtTheme() override;
|
||||||
|
bool hasStyleSheet() override;
|
||||||
QString appStyleSheet() override;
|
QString appStyleSheet() override;
|
||||||
|
bool hasColorScheme() override;
|
||||||
QPalette colorScheme() override;
|
QPalette colorScheme() override;
|
||||||
double fadeAmount() override;
|
double fadeAmount() override;
|
||||||
QColor fadeColor() override;
|
QColor fadeColor() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user