From 12383fd53e7d669a9b06dabef3495a0e4135abb8 Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Tue, 22 Jun 2021 17:50:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E7=BA=BF?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E5=92=8C=E8=93=9D=E7=89=99=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 无线网络hover效果与分割线重叠问题,计算弹窗高度有问题,导致分割线与WirelessItem重叠 无线网络和蓝牙右侧margin按设计需求设置为10 Log: 优化无线网络和蓝牙显示效果 Bug: https://pms.uniontech.com/zentao/bug-view-81667.html Bug: https://pms.uniontech.com/zentao/bug-view-81641.html Change-Id: I4152b0eca000c74303e3f132cc000069e2114b21 --- .../bluetooth/componments/bluetoothapplet.cpp | 2 +- .../network/item/applet/devicecontrolwidget.cpp | 6 ++++-- plugins/network/networkitem.cpp | 17 +++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/plugins/bluetooth/componments/bluetoothapplet.cpp b/plugins/bluetooth/componments/bluetoothapplet.cpp index 60c4545b1..466f7a075 100644 --- a/plugins/bluetooth/componments/bluetoothapplet.cpp +++ b/plugins/bluetooth/componments/bluetoothapplet.cpp @@ -49,7 +49,7 @@ SettingLabel::SettingLabel(QString text, QWidget *parent) setContentsMargins(0, 0, 0, 0); m_layout->setMargin(0); m_layout->setSpacing(4); - m_layout->setContentsMargins(20, 0, 8, 0); + m_layout->setContentsMargins(20, 0, 6, 0); m_layout->addWidget(m_label, 0, Qt::AlignLeft | Qt::AlignHCenter); m_layout->addStretch(); diff --git a/plugins/network/item/applet/devicecontrolwidget.cpp b/plugins/network/item/applet/devicecontrolwidget.cpp index 15acf2e2d..702425c87 100644 --- a/plugins/network/item/applet/devicecontrolwidget.cpp +++ b/plugins/network/item/applet/devicecontrolwidget.cpp @@ -61,13 +61,15 @@ DeviceControlWidget::DeviceControlWidget(QWidget *parent) QHBoxLayout *infoLayout = new QHBoxLayout; infoLayout->setMargin(0); infoLayout->setSpacing(0); - infoLayout->setContentsMargins(0, 0, 0, 0); + infoLayout->setContentsMargins(20, 0, 0, 0); infoLayout->addWidget(m_deviceName); infoLayout->addStretch(); infoLayout->addWidget(m_loadingIndicator); infoLayout->addSpacing(4); infoLayout->addWidget(m_switchBtn); - infoLayout->addSpacing(8); + // DSwitchButton 按照设计要求: 在保持现有控件的尺寸下,这里需要预留绘制focusRect的区域,borderWidth为2,间隙宽度为2 + // 所以此处按设计的要求 10-4 = 6 + infoLayout->addSpacing(6); QVBoxLayout *centralLayout = new QVBoxLayout; centralLayout->addLayout(infoLayout); diff --git a/plugins/network/networkitem.cpp b/plugins/network/networkitem.cpp index 2c9e8da6d..8d05bd179 100644 --- a/plugins/network/networkitem.cpp +++ b/plugins/network/networkitem.cpp @@ -76,7 +76,9 @@ NetworkItem::NetworkItem(QWidget *parent) QHBoxLayout *switchWirelessLayout = new QHBoxLayout; switchWirelessLayout->setMargin(0); switchWirelessLayout->setSpacing(0); - switchWirelessLayout->setContentsMargins(20, 0, 8, 0); + // DSwitchButton 按照设计要求: 在保持现有控件的尺寸下,这里需要预留绘制focusRect的区域,borderWidth为2,间隙宽度为2 + // 所以此处按设计的要求 10-4 = 6 right margin + switchWirelessLayout->setContentsMargins(20, 0, 6, 0); switchWirelessLayout->addWidget(wirelessTitle); switchWirelessLayout->addStretch(); switchWirelessLayout->addWidget(m_loadingIndicator); @@ -101,7 +103,7 @@ NetworkItem::NetworkItem(QWidget *parent) // 有线网络控制器 QHBoxLayout *switchWiredLayout = new QHBoxLayout; - switchWiredLayout->setContentsMargins(20, 0, 10, 0); + switchWiredLayout->setContentsMargins(20, 0, 6, 0); switchWiredLayout->addWidget(wiredTitle); switchWiredLayout->addStretch(); switchWiredLayout->addWidget(m_switchWiredBtn); @@ -1075,7 +1077,6 @@ void NetworkItem::getPluginState() void NetworkItem::updateView() { - int height = 0; // 固定显示高度即为固定示项目数 const int constDisplayItemCnt = 10; auto wirelessCnt = m_wirelessItems.size(); @@ -1085,18 +1086,14 @@ void NetworkItem::updateView() if (wirelessItem && wirelessItem->device()->enabled()) // 单个设备开关控制项 wirelessItem->setControlPanelVisible(wirelessCnt != 1); - height += wirelessItem->itemApplet()->height(); } } // 设备总控开关只与是否有设备相关 - m_wirelessControlPanel->setVisible(m_wirelessItems.size()); - height += m_wirelessItems.size() ? TITLE_HEIGHT + 2 : 0;// 分割线 + m_wirelessControlPanel->setVisible(wirelessCnt); m_wiredControlPanel->setVisible(m_wiredItems.size()); - height += m_wiredItems.size() ? TITLE_HEIGHT : 0; - height += m_wiredLayout->count() * ITEM_HEIGHT; - m_applet->widget()->setFixedHeight(height); - m_applet->setFixedHeight(qMin(height, constDisplayItemCnt * ITEM_HEIGHT)); + m_applet->widget()->adjustSize(); + m_applet->setFixedHeight(qMin(m_applet->widget()->height(), constDisplayItemCnt * ITEM_HEIGHT)); if (m_wirelessControlPanel->isVisible()) { if (!m_wirelessScanTimer->isActive())