Merge branch '2309bug1' into 'yhkylin/v101'

fix bug 180162 【VPN】深色模式下托盘VPN弹窗存在未反白现象

See merge request kylinos-src/kylin-nm!203
This commit is contained in:
赵世旭 2023-07-07 01:31:41 +00:00
commit bc403b5554
2 changed files with 30 additions and 0 deletions

View File

@ -26,11 +26,15 @@
#include <QPainterPath>
#include <KWindowEffects>
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
SinglePage::SinglePage(QWidget *parent) : QWidget(parent)
{
initUI();
initWindowProperties();
initTransparency();
initWindowTheme();
}
SinglePage::~SinglePage()
@ -104,6 +108,20 @@ void SinglePage::initWindowProperties()
}
}
/**
* @brief SinglePage::initWindowTheme
*/
void SinglePage::initWindowTheme()
{
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
m_styleGsettings = new QGSettings(style_id, QByteArray(), this);
connect(m_styleGsettings, &QGSettings::changed, this, &SinglePage::onThemeChanged);
} else {
qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__;
}
}
void SinglePage::showDesktopNotify(const QString &message, QString soundName)
{
QDBusInterface iface("org.freedesktop.Notifications",
@ -165,6 +183,14 @@ void SinglePage::onTransChanged()
paintWithTrans();
}
void SinglePage::onThemeChanged(const QString &key)
{
if (key == COLOR_THEME) {
paintWithTrans();
Q_EMIT qApp->paletteChanged(qApp->palette());
}
}
void SinglePage::paintWithTrans()
{
QPalette pal = this->palette();

View File

@ -71,6 +71,7 @@ Q_SIGNALS:
private Q_SLOTS:
void onTransChanged();
void onThemeChanged(const QString &key);
protected:
void paintEvent(QPaintEvent *event);
@ -84,6 +85,7 @@ protected:
private:
void initWindowProperties();
void initWindowTheme();
protected:
QVBoxLayout * m_mainLayout = nullptr;
@ -106,6 +108,8 @@ protected:
QGSettings * m_transGsettings = nullptr;
double m_transparency = 1.0; //透明度
//监听主题的Gsettings
QGSettings * m_styleGsettings = nullptr;
};