diff --git a/src-vpn/frontend/single-pages/singlepage.cpp b/src-vpn/frontend/single-pages/singlepage.cpp index 52fc568d..43a29603 100644 --- a/src-vpn/frontend/single-pages/singlepage.cpp +++ b/src-vpn/frontend/single-pages/singlepage.cpp @@ -58,7 +58,7 @@ void SinglePage::initUI() m_titleLayout->addWidget(m_titleLabel); m_titleLayout->addStretch(); - m_netDivider = new Divider(this); + m_netDivider = new Divider(true, this); m_listFrame = new QFrame(this); m_listLayout = new QVBoxLayout(m_listFrame); @@ -68,7 +68,7 @@ void SinglePage::initUI() m_listLayout->addWidget(m_listWidget); m_listWidget->setProperty("needTranslucent", true); - m_setDivider = new Divider(this); + m_setDivider = new Divider(true, this); m_settingsFrame = new QFrame(this); m_settingsFrame->setFixedHeight(TITLE_FRAME_HEIGHT); diff --git a/src-vpn/frontend/vpndetails/vpndetail.cpp b/src-vpn/frontend/vpndetails/vpndetail.cpp index 9be9fb42..cda56da2 100644 --- a/src-vpn/frontend/vpndetails/vpndetail.cpp +++ b/src-vpn/frontend/vpndetails/vpndetail.cpp @@ -102,7 +102,7 @@ void VpnDetail::initUI() m_topWidget = new QWidget(this); m_centerWidget = new QWidget(this); m_bottomWidget = new QWidget(this); - m_divider = new Divider(this); + m_divider = new Divider(false, this); m_vpnTabBar = new VpnTabBar(this); m_autoConnectBox = new QCheckBox(this); m_autoConnectLabel = new QLabel(this); diff --git a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp index e78891f7..556b665a 100644 --- a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp +++ b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp @@ -139,7 +139,7 @@ void EnterpriseWlanDialog::initUI() m_enterWlanScrollArea->setWidgetResizable(true); m_enterWlanScrollArea->setBackgroundRole(QPalette::Base); - m_bottomDivider = new Divider(this); + m_bottomDivider = new Divider(false, this); QWidget *bottomWidget = new QWidget(this); QHBoxLayout *btnLayout = new QHBoxLayout(bottomWidget); diff --git a/src/frontend/netdetails/dnssettingwidget.cpp b/src/frontend/netdetails/dnssettingwidget.cpp index 557138a2..da15c15c 100644 --- a/src/frontend/netdetails/dnssettingwidget.cpp +++ b/src/frontend/netdetails/dnssettingwidget.cpp @@ -60,7 +60,7 @@ void DnsSettingWidget::initUi() } m_retryComboBox->setCurrentIndex(m_retryComboBox->findData(m_retry.toInt())); - m_bottomDivider = new Divider(true, this); + m_bottomDivider = new Divider(false, this); m_closeBtn = new QPushButton(this); m_closeBtn->setFixedSize(32,32); diff --git a/src/frontend/netdetails/ipv4page.cpp b/src/frontend/netdetails/ipv4page.cpp index 185219d4..17e3bffe 100644 --- a/src/frontend/netdetails/ipv4page.cpp +++ b/src/frontend/netdetails/ipv4page.cpp @@ -96,7 +96,7 @@ void Ipv4Page::initUI() { // IP的正则格式限制 QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); - Divider* divider = new Divider(true, this); + Divider* divider = new Divider(false, this); m_dnsWidget = new MultipleDnsWidget(rx, true, this); m_detailLayout = new QFormLayout(this); diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp index 95cb54a9..9aa6c324 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.cpp +++ b/src/frontend/netdetails/joinhiddenwifipage.cpp @@ -77,7 +77,7 @@ void JoinHiddenWiFiPage::initUI() m_nameLabel->setFixedWidth(LABEL_MIN_WIDTH); m_nameEdit =new LineEdit(this); - m_bottomDivider = new Divider(this); + m_bottomDivider = new Divider(false, this); m_showListBtn = new KBorderlessButton(this); m_cancelBtn =new QPushButton(this); m_joinBtn =new QPushButton(this); diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 697c17ac..a1d454d4 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -400,7 +400,7 @@ void NetDetail::initUI() centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0,为安全页滚动区域留出空间 centerlayout->addWidget(stackWidget); - Divider *divider = new Divider(true, this); + Divider *divider = new Divider(false, this); QHBoxLayout *bottomLayout = new QHBoxLayout(bottomWidget); bottomLayout->setContentsMargins(BOTTOM_LAYOUT_MARGINS); diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index ccebd419..71f0a4c7 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -60,7 +60,7 @@ void TabPage::initUI() m_titleLayout->addWidget(m_titleLabel); m_titleLayout->addStretch(); m_titleLayout->addWidget(m_netSwitch); - m_titleDivider = new Divider(this); + m_titleDivider = new Divider(true, this); //临时增加的下拉框选择网卡区域 m_deviceFrame = new QFrame(this); @@ -92,7 +92,7 @@ void TabPage::initUI() m_activatedNetLabel->setContentsMargins(TEXT_MARGINS); m_activatedNetLabel->setFixedHeight(TEXT_HEIGHT); m_activatedNetLayout->addWidget(m_activatedNetLabel); - m_activatedNetDivider = new Divider(this); + m_activatedNetDivider = new Divider(true, this); m_inactivatedNetFrame = new QFrame(this); m_inactivatedNetFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT); @@ -120,7 +120,7 @@ void TabPage::initUI() m_inactivatedNetLayout->addWidget(m_inactivatedNetLabel); m_inactivatedNetLayout->addWidget(m_inactivatedNetListArea); - m_inactivatedNetDivider = new Divider(this); + m_inactivatedNetDivider = new Divider(true, this); m_settingsFrame = new QFrame(this); m_settingsFrame->setFixedHeight(TITLE_FRAME_HEIGHT); diff --git a/src/frontend/tools/divider.cpp b/src/frontend/tools/divider.cpp index ed4c0423..94fd5565 100644 --- a/src/frontend/tools/divider.cpp +++ b/src/frontend/tools/divider.cpp @@ -27,34 +27,28 @@ #define THEME_SCHAME "org.ukui.style" #define COLOR_THEME "styleName" -Divider::Divider(bool useLightPal, QWidget * parent) - :m_useLightPal(useLightPal), +Divider::Divider(bool useDarkPal, QWidget * parent) + :m_useDarkPal(useDarkPal), QFrame(parent) { this->setFixedHeight(1); - initPalette(); connect(qApp, &QApplication::paletteChanged, this ,&Divider::onPaletteChanged); onPaletteChanged(); } -void Divider::initPalette() +void Divider::onPaletteChanged() { QPalette pal = qApp->palette(); QGSettings * styleGsettings = nullptr; const QByteArray styleId(THEME_SCHAME); - if (QGSettings::isSchemaInstalled(styleId)) { + if (QGSettings::isSchemaInstalled(styleId) && m_useDarkPal) { 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(); m_color = pal.color(QPalette::BrightText); m_color.setAlphaF(0.08); } diff --git a/src/frontend/tools/divider.h b/src/frontend/tools/divider.h index bd87a2a8..7c57278f 100644 --- a/src/frontend/tools/divider.h +++ b/src/frontend/tools/divider.h @@ -24,12 +24,11 @@ class Divider : public QFrame { public: - Divider(bool useLightPal = false, QWidget * parent = nullptr); + Divider(bool useDarkPal = false, QWidget * parent = nullptr); ~Divider() = default; private: - bool m_useLightPal; + bool m_useDarkPal; QColor m_color; - void initPalette(); private Q_SLOTS: void onPaletteChanged(); protected: