分割线divider添加色板初始化

This commit is contained in:
zhangyuanyuan1 2023-07-26 14:31:24 +08:00
parent 3c0d0b28d3
commit 1875ebf085
2 changed files with 18 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include <QApplication>
#include "../netdetails/coninfo.h"
#include "themepalette.h"
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
@ -31,10 +32,26 @@ Divider::Divider(bool useLightPal, QWidget * parent)
QFrame(parent)
{
this->setFixedHeight(1);
initPalette();
connect(qApp, &QApplication::paletteChanged, this ,&Divider::onPaletteChanged);
onPaletteChanged();
}
void Divider::initPalette()
{
QPalette pal = qApp->palette();
QGSettings * styleGsettings = nullptr;
const QByteArray styleId(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(styleId)) {
styleGsettings = new QGSettings(styleId, QByteArray(), this);
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
if(currentTheme == "ukui-default"){
pal = themePalette(true, this);
}
}
this->setPalette(pal);
}
void Divider::onPaletteChanged()
{
QPalette pal = this->palette();

View File

@ -29,6 +29,7 @@ public:
private:
bool m_useLightPal;
QColor m_color;
void initPalette();
private Q_SLOTS:
void onPaletteChanged();
protected: