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