mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 04:12:03 +08:00
对DDE下主题切换的修复
This commit is contained in:
@@ -54,7 +54,7 @@ namespace SpkUi
|
||||
StylesheetBase = ObtainStylesheet.readAll();
|
||||
ObtainStylesheet.close();
|
||||
|
||||
SetGlobalStyle(Dark);
|
||||
SetGlobalStyle(Light, false);
|
||||
|
||||
// Initalize crash handler
|
||||
signal(SIGSEGV, SpkUi::CrashSignalHandler);
|
||||
@@ -138,24 +138,31 @@ namespace SpkUi
|
||||
"with unwanted blue borders."));
|
||||
}
|
||||
|
||||
void SetGlobalStyle(const SpkUiStyle aStyle)
|
||||
void SetGlobalStyle(const SpkUiStyle aStyle, const bool aPreserveAccentColor)
|
||||
{
|
||||
if(aStyle == CurrentStyle) // Don't waste precious CPU time parsing new style sheet!
|
||||
return;
|
||||
CurrentStyle = aStyle;
|
||||
Qss::ColorSet tempset;
|
||||
switch(aStyle)
|
||||
{
|
||||
case Light:
|
||||
CurrentStylesheet = StylesheetFromColors(Qss::LightColorSet);
|
||||
CurrentColorSet = Qss::LightColorSet;
|
||||
qApp->setStyleSheet(CurrentStylesheet);
|
||||
tempset = Qss::LightColorSet;
|
||||
ColorLine = Qt::black;
|
||||
break;
|
||||
case Dark:
|
||||
CurrentStylesheet = StylesheetFromColors(Qss::DarkColorSet);
|
||||
CurrentColorSet = Qss::DarkColorSet;
|
||||
qApp->setStyleSheet(CurrentStylesheet);
|
||||
tempset = Qss::DarkColorSet;
|
||||
ColorLine = Qt::white;
|
||||
break;
|
||||
}
|
||||
if(aPreserveAccentColor)
|
||||
{
|
||||
for(auto i : Qss::AccentColorExceptions)
|
||||
tempset[i] = CurrentColorSet[i];
|
||||
}
|
||||
CurrentColorSet = tempset;
|
||||
CurrentStylesheet = StylesheetFromColors(CurrentColorSet);
|
||||
qApp->setStyleSheet(CurrentStylesheet);
|
||||
}
|
||||
|
||||
QString WriteStackTrace(const QString &aStackTrace)
|
||||
@@ -259,9 +266,9 @@ namespace SpkUi
|
||||
void UiMetaObject::SetDarkLightTheme(bool isDark)
|
||||
{
|
||||
if(isDark)
|
||||
SetGlobalStyle(Dark);
|
||||
SetGlobalStyle(Dark, true);
|
||||
else
|
||||
SetGlobalStyle(Light);
|
||||
SetGlobalStyle(Light, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <QColor>
|
||||
|
||||
namespace SpkUi
|
||||
@@ -30,6 +31,13 @@ namespace SpkUi
|
||||
ShadesEdge,
|
||||
};
|
||||
|
||||
const std::list<ColorSetIndex> AccentColorExceptions
|
||||
{
|
||||
AccentColor,
|
||||
AccentColorHighlighted,
|
||||
TextOnAccentColor,
|
||||
};
|
||||
|
||||
const std::map<ColorSetIndex, const char *> ColorSet2Token
|
||||
{
|
||||
{ GlobalBgnd, "GBG_" },
|
||||
@@ -87,8 +95,8 @@ namespace SpkUi
|
||||
{ TextOnGlobalBgnd, ColorTextOnBackground(0xf8f8f8) },
|
||||
{ TextOnControlsBgnd, ColorTextOnBackground(0xf8f8f8) },
|
||||
{ TextLighter, 0x2a2a2a },
|
||||
{ GlossyEdge, 0xc5c5c5 },
|
||||
{ ShadesEdge, 0x9d9d9d }
|
||||
{ GlossyEdge, 0x9d9d9d },
|
||||
{ ShadesEdge, 0xc5c5c5 }
|
||||
};
|
||||
|
||||
using ColorSet = std::map<Qss::ColorSetIndex, QColor>;
|
||||
|
||||
@@ -68,5 +68,5 @@ namespace SpkUi
|
||||
|
||||
void CrashSignalHandler(int);
|
||||
|
||||
void SetGlobalStyle(SpkUiStyle);
|
||||
void SetGlobalStyle(const SpkUiStyle, const bool aPreserveAccentColor);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user