fix themes leak
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com> (cherry picked from commit 5b12d3cfff9092c0364e455c211fc189d87039cd)
This commit is contained in:
parent
1a56396e2e
commit
fcc1e80237
@ -42,16 +42,18 @@
|
|||||||
|
|
||||||
SystemTheme::SystemTheme(const QString& styleName, bool isDefaultTheme)
|
SystemTheme::SystemTheme(const QString& styleName, bool isDefaultTheme)
|
||||||
{
|
{
|
||||||
themeName = isDefaultTheme ? "system" : styleName;
|
m_themeName = isDefaultTheme ? "system" : styleName;
|
||||||
widgetTheme = styleName;
|
m_widgetTheme = styleName;
|
||||||
colorPalette = QStyleFactory::create(styleName)->standardPalette();
|
auto style = QStyleFactory::create(styleName);
|
||||||
|
m_colorPalette = style->standardPalette();
|
||||||
|
delete style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTheme::apply(bool initial)
|
void SystemTheme::apply(bool initial)
|
||||||
{
|
{
|
||||||
// See https://github.com/MultiMC/Launcher/issues/1790
|
// See https://github.com/MultiMC/Launcher/issues/1790
|
||||||
// or https://github.com/PrismLauncher/PrismLauncher/issues/490
|
// or https://github.com/PrismLauncher/PrismLauncher/issues/490
|
||||||
if (initial && themeName == "system") {
|
if (initial && m_themeName == "system") {
|
||||||
QApplication::setStyle(new HintOverrideProxyStyle(QStyleFactory::create(qtTheme())));
|
QApplication::setStyle(new HintOverrideProxyStyle(QStyleFactory::create(qtTheme())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,35 +63,35 @@ void SystemTheme::apply(bool initial)
|
|||||||
|
|
||||||
QString SystemTheme::id()
|
QString SystemTheme::id()
|
||||||
{
|
{
|
||||||
return themeName;
|
return m_themeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SystemTheme::name()
|
QString SystemTheme::name()
|
||||||
{
|
{
|
||||||
if (themeName.toLower() == "windowsvista") {
|
if (m_themeName.toLower() == "windowsvista") {
|
||||||
return QObject::tr("Windows Vista");
|
return QObject::tr("Windows Vista");
|
||||||
} else if (themeName.toLower() == "windows") {
|
} else if (m_themeName.toLower() == "windows") {
|
||||||
return QObject::tr("Windows 9x");
|
return QObject::tr("Windows 9x");
|
||||||
} else if (themeName.toLower() == "windows11") {
|
} else if (m_themeName.toLower() == "windows11") {
|
||||||
return QObject::tr("Windows 11");
|
return QObject::tr("Windows 11");
|
||||||
} else if (themeName.toLower() == "system") {
|
} else if (m_themeName.toLower() == "system") {
|
||||||
return QObject::tr("System");
|
return QObject::tr("System");
|
||||||
} else {
|
} else {
|
||||||
return themeName;
|
return m_themeName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SystemTheme::tooltip()
|
QString SystemTheme::tooltip()
|
||||||
{
|
{
|
||||||
if (themeName.toLower() == "windowsvista") {
|
if (m_themeName.toLower() == "windowsvista") {
|
||||||
return QObject::tr("Widget style trying to look like your win32 theme");
|
return QObject::tr("Widget style trying to look like your win32 theme");
|
||||||
} else if (themeName.toLower() == "windows") {
|
} else if (m_themeName.toLower() == "windows") {
|
||||||
return QObject::tr("Windows 9x inspired widget style");
|
return QObject::tr("Windows 9x inspired widget style");
|
||||||
} else if (themeName.toLower() == "windows11") {
|
} else if (m_themeName.toLower() == "windows11") {
|
||||||
return QObject::tr("WinUI 3 inspired Qt widget style");
|
return QObject::tr("WinUI 3 inspired Qt widget style");
|
||||||
} else if (themeName.toLower() == "fusion") {
|
} else if (m_themeName.toLower() == "fusion") {
|
||||||
return QObject::tr("The default Qt widget style");
|
return QObject::tr("The default Qt widget style");
|
||||||
} else if (themeName.toLower() == "system") {
|
} else if (m_themeName.toLower() == "system") {
|
||||||
return QObject::tr("Your current system theme");
|
return QObject::tr("Your current system theme");
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
@ -98,12 +100,12 @@ QString SystemTheme::tooltip()
|
|||||||
|
|
||||||
QString SystemTheme::qtTheme()
|
QString SystemTheme::qtTheme()
|
||||||
{
|
{
|
||||||
return widgetTheme;
|
return m_widgetTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPalette SystemTheme::colorScheme()
|
QPalette SystemTheme::colorScheme()
|
||||||
{
|
{
|
||||||
return colorPalette;
|
return m_colorPalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SystemTheme::appStyleSheet()
|
QString SystemTheme::appStyleSheet()
|
||||||
|
@ -53,7 +53,7 @@ class SystemTheme : public ITheme {
|
|||||||
QColor fadeColor() override;
|
QColor fadeColor() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPalette colorPalette;
|
QPalette m_colorPalette;
|
||||||
QString widgetTheme;
|
QString m_widgetTheme;
|
||||||
QString themeName;
|
QString m_themeName;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user