GH-903 force Dark theme to use Fusion Qt style
Themes now include Qt styles.
This commit is contained in:
		@@ -22,6 +22,7 @@
 | 
			
		||||
#include <QMessageBox>
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QStyleFactory>
 | 
			
		||||
 | 
			
		||||
#include "InstanceList.h"
 | 
			
		||||
#include <minecraft/auth/MojangAccountList.h>
 | 
			
		||||
@@ -982,9 +983,9 @@ void MultiMC::setApplicationTheme(const QString& name)
 | 
			
		||||
	if(themeIter != m_themes.end())
 | 
			
		||||
	{
 | 
			
		||||
		auto & theme = (*themeIter).second;
 | 
			
		||||
		setStyle(QStyleFactory::create(theme->qtTheme()));
 | 
			
		||||
		setPalette(theme->colorScheme());
 | 
			
		||||
		setStyleSheet(theme->appStyleSheet());
 | 
			
		||||
		//setStyle(QStyleFactory::create("Fusion"));
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,11 @@ QString DarkTheme::name()
 | 
			
		||||
	return QObject::tr("Dark");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DarkTheme::qtTheme()
 | 
			
		||||
{
 | 
			
		||||
	return "Fusion";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QPalette DarkTheme::colorScheme()
 | 
			
		||||
{
 | 
			
		||||
	QPalette darkPalette;
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ class DarkTheme: public ITheme
 | 
			
		||||
public:
 | 
			
		||||
	virtual ~DarkTheme() {}
 | 
			
		||||
 | 
			
		||||
	QString qtTheme() override;
 | 
			
		||||
	QString id() override;
 | 
			
		||||
	QString name() override;
 | 
			
		||||
	QString appStyleSheet() override;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,5 +9,6 @@ public:
 | 
			
		||||
	virtual QString id() = 0;
 | 
			
		||||
	virtual QString name() = 0;
 | 
			
		||||
	virtual QString appStyleSheet() = 0;
 | 
			
		||||
	virtual QString qtTheme() = 0;
 | 
			
		||||
	virtual QPalette colorScheme() = 0;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,26 @@
 | 
			
		||||
#include "SystemTheme.h"
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
#include <QStyle>
 | 
			
		||||
#include <QStyleFactory>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
SystemTheme::SystemTheme()
 | 
			
		||||
{
 | 
			
		||||
	systemPalette = QApplication::style()->standardPalette();
 | 
			
		||||
	const auto & style = QApplication::style();
 | 
			
		||||
	systemPalette = style->standardPalette();
 | 
			
		||||
	QString lowerThemeName = style->objectName();
 | 
			
		||||
	qWarning() << 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";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString SystemTheme::id()
 | 
			
		||||
@@ -17,6 +33,11 @@ QString SystemTheme::name()
 | 
			
		||||
	return QObject::tr("System");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString SystemTheme::qtTheme()
 | 
			
		||||
{
 | 
			
		||||
	return systemTheme;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QPalette SystemTheme::colorScheme()
 | 
			
		||||
{
 | 
			
		||||
	return systemPalette;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ public:
 | 
			
		||||
 | 
			
		||||
	QString id() override;
 | 
			
		||||
	QString name() override;
 | 
			
		||||
	QString qtTheme() override;
 | 
			
		||||
	QString appStyleSheet() override;
 | 
			
		||||
	QPalette colorScheme() override;
 | 
			
		||||
private:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user