mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
使主题色依照DDE主题色改变
因为AUTOMOC不会在编译主程序的时候再对插件接口类进行MOC,所以需要在主程序内加一份一模一样的插件接口类定义。
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QJsonArray>
|
||||
#include "spkmsgbox.h"
|
||||
#include "spkmainwindow.h"
|
||||
#include "spklogging.h"
|
||||
#include "spkuimsg.h"
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
UiMetaObject SpkUiMetaObject;
|
||||
|
||||
SpkUiStyle CurrentStyle;
|
||||
QString StylesheetBase, CurrentStylesheet;
|
||||
QColor ColorLine, ColorBack;
|
||||
@@ -100,6 +102,13 @@ namespace SpkUi
|
||||
DtkPlugin = i;
|
||||
States::IsUsingDtkPlugin = true;
|
||||
}
|
||||
|
||||
i->Initialize();
|
||||
|
||||
SpkUiMetaObject.SetAccentColor(i->GetAccentColor()); // Match OS accent color
|
||||
|
||||
QObject::connect(i, &SpkDtkPlugin::AccentColorChanged,
|
||||
&SpkUiMetaObject, &UiMetaObject::SetAccentColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,10 +139,12 @@ namespace SpkUi
|
||||
{
|
||||
case Light:
|
||||
static auto LightColor = QList<QColor>{
|
||||
0x353535, 0x353535, 0xff0000, 0x0070ff, 0x2987ff,
|
||||
0x6b6b6b, 0x656565, 0x606060, 0x404040, 0x383838,
|
||||
ColorTextOnBackground(0x0070ff)
|
||||
};
|
||||
0x282828, 0x282828, 0xff0000, 0x0070ff, QColor(0x70ff).lighter(120),
|
||||
0x6b6b6b, 0x656565, 0x606060, 0x404040, 0x383838,
|
||||
ColorTextOnBackground(0x0070ff),
|
||||
ColorTextOnBackground(0x282828),
|
||||
ColorTextOnBackground(0x282828)
|
||||
};
|
||||
CurrentStylesheet = StylesheetFromColors(LightColor);
|
||||
qApp->setStyleSheet(CurrentStylesheet);
|
||||
// TODO
|
||||
@@ -141,10 +152,12 @@ namespace SpkUi
|
||||
break;
|
||||
case Dark:
|
||||
static auto DarkColor = QList<QColor>{
|
||||
0x353535, 0x353535, 0xff0000, 0x0070ff, 0x2987ff,
|
||||
0x6b6b6b, 0x656565, 0x606060, 0x404040, 0x383838,
|
||||
ColorTextOnBackground(0x0070ff)
|
||||
};
|
||||
0x282828, 0x282828, 0xff0000, 0x0070ff, QColor(0x70ff).lighter(120),
|
||||
0x6b6b6b, 0x656565, 0x606060, 0x404040, 0x383838,
|
||||
ColorTextOnBackground(0x0070ff),
|
||||
ColorTextOnBackground(0x282828),
|
||||
ColorTextOnBackground(0x282828)
|
||||
};
|
||||
CurrentStylesheet = StylesheetFromColors(DarkColor);
|
||||
CurrentColorSet = DarkColor;
|
||||
qApp->setStyleSheet(CurrentStylesheet);
|
||||
@@ -248,4 +261,12 @@ namespace SpkUi
|
||||
return gray > 0.5 ? Qt::black : Qt::white;
|
||||
}
|
||||
|
||||
void UiMetaObject::SetAccentColor(QColor aColor)
|
||||
{
|
||||
CurrentColorSet[3] = aColor.lighter(80);
|
||||
CurrentColorSet[4] = aColor;
|
||||
CurrentColorSet[10] = ColorTextOnBackground(aColor);
|
||||
qApp->setStyleSheet(StylesheetFromColors(CurrentColorSet));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user