mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-22 22:23:49 +08:00
增加亮色模式支持,小幅修改QSS和UI元素大小
This commit is contained in:
@@ -115,8 +115,8 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
|
|||||||
StoreIcon = new QLabel(this);
|
StoreIcon = new QLabel(this);
|
||||||
StoreIcon->setObjectName("spk_mw_icon");
|
StoreIcon->setObjectName("spk_mw_icon");
|
||||||
StoreIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
StoreIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
StoreIcon->setMaximumSize({ 48, 48 });
|
StoreIcon->setMaximumSize({ 40, 40 });
|
||||||
StoreIcon->setMinimumSize({ 48, 48 });
|
StoreIcon->setMinimumSize({ 40, 40 });
|
||||||
StoreIcon->setPixmap(QIcon(":/icons/spark-store.svg").pixmap(StoreIcon->size()));
|
StoreIcon->setPixmap(QIcon(":/icons/spark-store.svg").pixmap(StoreIcon->size()));
|
||||||
|
|
||||||
SidebarMgr = new SpkSidebarSelector(this);
|
SidebarMgr = new SpkSidebarSelector(this);
|
||||||
@@ -126,9 +126,9 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
|
|||||||
BtnSettings->setObjectName("styPlainChkBtn");
|
BtnSettings->setObjectName("styPlainChkBtn");
|
||||||
BtnSettings->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
BtnSettings->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
BtnSettings->setCheckable(true);
|
BtnSettings->setCheckable(true);
|
||||||
BtnSettings->setMaximumSize({ 48, 48 });
|
BtnSettings->setMaximumSize({ 40, 40 });
|
||||||
BtnSettings->setMinimumSize({ 48, 48 });
|
BtnSettings->setMinimumSize({ 40, 40 });
|
||||||
BtnSettings->setIconSize(QSize(24, 24));
|
BtnSettings->setIconSize(QSize(20, 20));
|
||||||
BtnSettings->setIcon(SpkUi::GetThemedIcon("settings"));
|
BtnSettings->setIcon(SpkUi::GetThemedIcon("settings"));
|
||||||
BtnSettings->setProperty("spk_pageno", 0);
|
BtnSettings->setProperty("spk_pageno", 0);
|
||||||
SidebarMgr->BindPageSwitcherButton(BtnSettings);
|
SidebarMgr->BindPageSwitcherButton(BtnSettings);
|
||||||
|
|||||||
@@ -109,9 +109,12 @@ namespace SpkUi
|
|||||||
i->Initialize();
|
i->Initialize();
|
||||||
|
|
||||||
SpkUiMetaObject.SetAccentColor(i->GetAccentColor()); // Match OS accent color
|
SpkUiMetaObject.SetAccentColor(i->GetAccentColor()); // Match OS accent color
|
||||||
|
SpkUiMetaObject.SetDarkLightTheme(i->GetIsDarkTheme()); // Match OS dark theme type
|
||||||
|
|
||||||
QObject::connect(i, &SpkDtkPlugin::AccentColorChanged,
|
QObject::connect(i, &SpkDtkPlugin::AccentColorChanged,
|
||||||
&SpkUiMetaObject, &UiMetaObject::SetAccentColor);
|
&SpkUiMetaObject, &UiMetaObject::SetAccentColor);
|
||||||
|
QObject::connect(i, &SpkDtkPlugin::DarkLightThemeChanged,
|
||||||
|
&SpkUiMetaObject, &UiMetaObject::SetDarkLightTheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,4 +256,12 @@ namespace SpkUi
|
|||||||
qApp->setStyleSheet(StylesheetFromColors(CurrentColorSet));
|
qApp->setStyleSheet(StylesheetFromColors(CurrentColorSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UiMetaObject::SetDarkLightTheme(bool isDark)
|
||||||
|
{
|
||||||
|
if(isDark)
|
||||||
|
SetGlobalStyle(Dark);
|
||||||
|
else
|
||||||
|
SetGlobalStyle(Light);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ class SpkDtkPlugin : public QObject
|
|||||||
virtual void Initialize() = 0;
|
virtual void Initialize() = 0;
|
||||||
virtual void addWindow(QWidget* w, QObject* parent) = 0;
|
virtual void addWindow(QWidget* w, QObject* parent) = 0;
|
||||||
virtual QColor GetAccentColor() = 0;
|
virtual QColor GetAccentColor() = 0;
|
||||||
|
virtual bool GetIsDarkTheme() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void AccentColorChanged(QColor);
|
void AccentColorChanged(QColor);
|
||||||
|
void DarkLightThemeChanged(bool isDark);
|
||||||
};
|
};
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
Q_DECLARE_INTERFACE(SpkDtkPlugin, "org.spark-store.client.dtkplugin")
|
Q_DECLARE_INTERFACE(SpkDtkPlugin, "org.spark-store.client.dtkplugin")
|
||||||
|
|||||||
+16
-14
@@ -73,20 +73,22 @@ namespace SpkUi
|
|||||||
|
|
||||||
LightColorSet // TODO: Use real light color set
|
LightColorSet // TODO: Use real light color set
|
||||||
{
|
{
|
||||||
// { GlobalBgnd, 0x282828 },
|
{ GlobalBgnd, 0xf8f8f8 },
|
||||||
// { ControlsBgnd, 0x282828 },
|
{ ControlsBgnd, 0xf8f8f8 },
|
||||||
// { ControlsBgndHighlighted, 0xff0000 },
|
{ ControlsBgndHighlighted, 0xff0000 },
|
||||||
// { SelectionBgnd, 0x0070ff },
|
{ SelectionBgnd, 0x0070ff },
|
||||||
// { SelectionBgndHighlighted, QColor(0x0070ff).lighter(120) },
|
{ SelectionBgndHighlighted, QColor(0x0070ff).lighter(120) },
|
||||||
// { LightCtrlsGradLight, 0x6b6b6b },
|
{ LightCtrlsGradLight, 0xfbfbfb },
|
||||||
// { LightCtrlsGradDark, 0x656565 },
|
{ LightCtrlsGradDark, 0xf2f2f2 },
|
||||||
// { LightCtrlsGradDarker, 0x606060 },
|
{ LightCtrlsGradDarker, 0xebebeb },
|
||||||
// { DarkCtrlsGradLight, 0x404040 },
|
{ DarkCtrlsGradLight, 0xe4e4e4 },
|
||||||
// { DarkCtrlsGradDark, 0x383838 },
|
{ DarkCtrlsGradDark, 0xcecece },
|
||||||
// { TextOnSelection, ColorTextOnBackground(0x0070ff) },
|
{ TextOnSelection, ColorTextOnBackground(0x0070ff) },
|
||||||
// { TextOnGlobalBgnd, ColorTextOnBackground(0x282828) },
|
{ TextOnGlobalBgnd, ColorTextOnBackground(0xf8f8f8) },
|
||||||
// { TextOnControlsBgnd, ColorTextOnBackground(0x282828) },
|
{ TextOnControlsBgnd, ColorTextOnBackground(0xf8f8f8) },
|
||||||
// { TextLighter, 0xd5d5d5 }
|
{ TextLighter, 0x2a2a2a },
|
||||||
|
{ GlossyEdge, 0xc5c5c5 },
|
||||||
|
{ ShadesEdge, 0x9d9d9d }
|
||||||
};
|
};
|
||||||
|
|
||||||
using ColorSet = std::map<Qss::ColorSetIndex, QColor>;
|
using ColorSet = std::map<Qss::ColorSetIndex, QColor>;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace SpkUi
|
|||||||
UiMetaObject() {}
|
UiMetaObject() {}
|
||||||
public slots:
|
public slots:
|
||||||
void SetAccentColor(QColor);
|
void SetAccentColor(QColor);
|
||||||
|
void SetDarkLightTheme(bool isDark);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern UiMetaObject SpkUiMetaObject;
|
extern UiMetaObject SpkUiMetaObject;
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ void SpkDtkPluginImpl::Initialize()
|
|||||||
&DPlatformTheme::activeColorChanged,
|
&DPlatformTheme::activeColorChanged,
|
||||||
this,
|
this,
|
||||||
&SpkDtkPluginImpl::AccentColorChanged);
|
&SpkDtkPluginImpl::AccentColorChanged);
|
||||||
|
connect(DGuiApplicationHelper::instance(),
|
||||||
|
&DGuiApplicationHelper::themeTypeChanged,
|
||||||
|
this,
|
||||||
|
&SpkDtkPluginImpl::DarkLightThemeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpkDtkPluginImpl::addWindow(QWidget *w, QObject *parent)
|
void SpkDtkPluginImpl::addWindow(QWidget *w, QObject *parent)
|
||||||
@@ -23,3 +27,8 @@ QColor SpkDtkPluginImpl::GetAccentColor()
|
|||||||
{
|
{
|
||||||
return DGuiApplicationHelper::instance()->systemTheme()->activeColor();
|
return DGuiApplicationHelper::instance()->systemTheme()->activeColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpkDtkPluginImpl::GetIsDarkTheme()
|
||||||
|
{
|
||||||
|
return DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType;
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ class SpkDtkPlugin : public QObject
|
|||||||
virtual void Initialize() = 0;
|
virtual void Initialize() = 0;
|
||||||
virtual void addWindow(QWidget* w, QObject* parent) = 0;
|
virtual void addWindow(QWidget* w, QObject* parent) = 0;
|
||||||
virtual QColor GetAccentColor() = 0;
|
virtual QColor GetAccentColor() = 0;
|
||||||
|
virtual bool GetIsDarkTheme() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void AccentColorChanged(QColor);
|
void AccentColorChanged(QColor);
|
||||||
|
void DarkLightThemeChanged(bool isDark);
|
||||||
};
|
};
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
Q_DECLARE_INTERFACE(SpkDtkPlugin, "org.spark-store.client.dtkplugin")
|
Q_DECLARE_INTERFACE(SpkDtkPlugin, "org.spark-store.client.dtkplugin")
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ class SpkDtkPluginImpl : public SpkDtkPlugin
|
|||||||
void addWindow(QWidget* w, QObject* parent) override;
|
void addWindow(QWidget* w, QObject* parent) override;
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
QColor GetAccentColor() override;
|
QColor GetAccentColor() override;
|
||||||
|
bool GetIsDarkTheme() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
QWidget
|
QWidget
|
||||||
{
|
{
|
||||||
background-color: GBG_;
|
background-color: GBG_;
|
||||||
color: #ffffff;
|
color: TXGBG;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLabel
|
QLabel
|
||||||
@@ -35,16 +35,19 @@ QScrollArea
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineEdit
|
QLineEdit, QTextEdit
|
||||||
{
|
{
|
||||||
background:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 LCTL1, stop:1 LCTL2);
|
padding: 2px;
|
||||||
padding: 3px;
|
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
border: 1px solid SHD;
|
border: 1px solid SHD;
|
||||||
border-bottom: 1px solid GLS;
|
border-bottom: 1px solid GLS;
|
||||||
selection-color: TXACC;
|
selection-color: TXACC;
|
||||||
selection-background-color: ACC_;
|
selection-background-color: ACC_;
|
||||||
}
|
}
|
||||||
|
QLineEdit /*We can't apply gradient to TextEdit cuz it messes with scroll bar*/
|
||||||
|
{
|
||||||
|
background:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 CBG_, stop:1 GBG_);
|
||||||
|
}
|
||||||
|
|
||||||
QPushButton
|
QPushButton
|
||||||
{
|
{
|
||||||
@@ -152,7 +155,7 @@ SpkTitleBarDefaultButton
|
|||||||
margin: 0px;
|
margin: 0px;
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
background-color: CBG_;
|
background-color: GBG_;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpkTitleBarDefaultButton:hover
|
SpkTitleBarDefaultButton:hover
|
||||||
|
|||||||
Reference in New Issue
Block a user