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