From 6e6dd3265921098e78674ab34758df3b66556e97 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Fri, 21 Oct 2022 18:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=BC=BA=E8=B0=83=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/netdetails/netdetail.cpp | 2 ++ src/frontend/tools/radioitembutton.cpp | 12 ++++++++++++ src/frontend/tools/radioitembutton.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 9d37e939..53df88a1 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -495,6 +495,8 @@ void NetDetail::initComponent() connect(fontSetting, &QGSettings::changed,[=](QString key) { if ("systemFont" == key || "systemFontSize" ==key) { setNetTabToolTip(); + } else if ("themeColor" == key) { + onPaletteChanged(); } }); } diff --git a/src/frontend/tools/radioitembutton.cpp b/src/frontend/tools/radioitembutton.cpp index bea5c933..8603d1ab 100644 --- a/src/frontend/tools/radioitembutton.cpp +++ b/src/frontend/tools/radioitembutton.cpp @@ -36,6 +36,7 @@ #define FOREGROUND_COLOR_PRESS_ACTIVE QColor(36,109,212,255) #define COLOR_BRIGHT_TEXT qApp->palette().brightText().color() #define COLOR_HIGH_LIGHT qApp->palette().highlight().color() +#define THEME_SCHAME "org.ukui.style" QColor mixColor(const QColor &c1, const QColor &c2, qreal bias); @@ -49,6 +50,17 @@ RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent) m_iconLabel->setAlignment(Qt::AlignCenter); setActive(false); + + const QByteArray id(THEME_SCHAME); + if (QGSettings::isSchemaInstalled(id)) { + m_styleGSettings = new QGSettings(id); + connect(m_styleGSettings, &QGSettings::changed, this, [=](QString key){ + if ("themeColor" == key) { + onPaletteChanged(); + } + }); + } + //JXJ_TODO loading动画 connect(this, &RadioItemButton::requestStartLoading, this, &RadioItemButton::onLoadingStarted); connect(this , &RadioItemButton::requestStopLoading, this, &RadioItemButton::onLoadingStopped); diff --git a/src/frontend/tools/radioitembutton.h b/src/frontend/tools/radioitembutton.h index ed59a034..1904f7da 100644 --- a/src/frontend/tools/radioitembutton.h +++ b/src/frontend/tools/radioitembutton.h @@ -24,6 +24,7 @@ #include #include #include +#include #define MIDDLE_COLOR 178 @@ -66,6 +67,7 @@ private: QVariantAnimation * m_animation = nullptr; QPixmap m_pixmap; + QGSettings *m_styleGSettings = nullptr; void refreshButtonIcon();