From 58cbf07409a5f57e825e21e8ef319334a68effbc Mon Sep 17 00:00:00 2001 From: chenxuechao Date: Mon, 9 Jan 2023 14:42:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3BUG=20148868=EF=BC=8C=20?= =?UTF-8?q?=E3=80=90=E6=8E=A7=E5=88=B6=E9=9D=A2=E6=9D=BF-=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E3=80=91=E7=A7=BB=E5=8A=A8=E7=83=AD=E7=82=B9=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E6=9D=A1=E7=9B=AE?= =?UTF-8?q?=E6=96=87=E5=AD=97=E6=98=BE=E7=A4=BA=E6=9C=AA=E5=B1=85=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E4=B8=8B=E8=BE=B9=E7=BC=98=E4=B8=BA=E7=9B=B4=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mobilehotspot/blacklistpage.cpp | 16 ++++++++-------- plugins/mobilehotspot/blacklistpage.h | 15 ++++++++------- plugins/mobilehotspot/connectdevpage.cpp | 16 ++++++++-------- plugins/mobilehotspot/connectdevpage.h | 15 +++++++++------ 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/plugins/mobilehotspot/blacklistpage.cpp b/plugins/mobilehotspot/blacklistpage.cpp index 1b82d8bd..d923749c 100644 --- a/plugins/mobilehotspot/blacklistpage.cpp +++ b/plugins/mobilehotspot/blacklistpage.cpp @@ -34,12 +34,12 @@ BlacklistPage::BlacklistPage(QWidget *parent) : QWidget(parent) Vlayout->setContentsMargins(CONTENTS_MARGINS); Vlayout->setSpacing(0); - QFrame *blacklistFrame = new QFrame(this); - blacklistFrame->setMinimumSize(FRAME_MIN_SIZE); - blacklistFrame->setMaximumSize(FRAME_MAX_SIZE); - blacklistFrame->setFrameShape(QFrame::Box); + m_blacklistFrame = new QFrame(this); + m_blacklistFrame->setMinimumSize(FRAME_MIN_SIZE); + m_blacklistFrame->setMaximumSize(FRAME_MAX_SIZE); + m_blacklistFrame->setFrameShape(QFrame::Box); - m_blacklistLayout = new QVBoxLayout(blacklistFrame); + m_blacklistLayout = new QVBoxLayout(m_blacklistFrame); m_blacklistLayout->setContentsMargins(0, 0, 0, 0); m_blacklistLayout->setSpacing(0); @@ -48,7 +48,7 @@ BlacklistPage::BlacklistPage(QWidget *parent) : QWidget(parent) Vlayout->addWidget(m_titleLabel); Vlayout->addSpacing(8); - Vlayout->addWidget(blacklistFrame); + Vlayout->addWidget(m_blacklistFrame); } QFrame* BlacklistPage::myLine() @@ -87,7 +87,7 @@ void BlacklistPage::getBlacklistDevice(QMap &blacklistMap) for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) { QString macTemp = macList.at(index); macTemp = macTemp.trimmed(); - if (!blacklistMap.contains(macTemp)) { + if (!blacklistMap.contains(macTemp) && hostNameList.at(index) != nullptr) { blacklistMap[macTemp] = hostNameList.at(index); } } @@ -166,7 +166,7 @@ void BlacklistPage::resetLayoutHight() height += w->height(); } } - this->setFixedHeight(height + m_titleLabel->height() + 8); + m_blacklistFrame->setFixedHeight(height); if (m_blacklistMap.isEmpty()) { this->hide(); diff --git a/plugins/mobilehotspot/blacklistpage.h b/plugins/mobilehotspot/blacklistpage.h index a1e3f01d..8a511c1d 100644 --- a/plugins/mobilehotspot/blacklistpage.h +++ b/plugins/mobilehotspot/blacklistpage.h @@ -49,15 +49,8 @@ public: } private: - QFrame* myLine(); - TitleLabel *m_titleLabel = nullptr; - QVBoxLayout *m_blacklistLayout = nullptr; - QMap m_blacklistMap; - - QDBusInterface *m_settingPathInterface = nullptr; - void getBlacklistDevice(QMap &blacklistMap); bool removeStaFromBlacklist(QString staMac, QString staName); void initBlacklistDev(); @@ -65,6 +58,14 @@ private: void clearBlacklistLayout(); void resetLayoutHight(); +private: + QFrame *m_blacklistFrame = nullptr; + TitleLabel *m_titleLabel = nullptr; + QVBoxLayout *m_blacklistLayout = nullptr; + QMap m_blacklistMap; + + QDBusInterface *m_settingPathInterface = nullptr; + private slots: void onsetStaIntoBlacklist(QString staMac, QString staName); void onRemoveFromBlacklistBtnClicked(QString staMac, QString staName); diff --git a/plugins/mobilehotspot/connectdevpage.cpp b/plugins/mobilehotspot/connectdevpage.cpp index f8862e01..473a4c69 100644 --- a/plugins/mobilehotspot/connectdevpage.cpp +++ b/plugins/mobilehotspot/connectdevpage.cpp @@ -35,12 +35,12 @@ ConnectdevPage::ConnectdevPage(QWidget *parent) : Vlayout->setContentsMargins(CONTENTS_MARGINS); Vlayout->setSpacing(0); - QFrame *staistFrame = new QFrame(this); - staistFrame->setMinimumSize(FRAME_MIN_SIZE); - staistFrame->setMaximumSize(FRAME_MAX_SIZE); - staistFrame->setFrameShape(QFrame::Box); + m_staistFrame = new QFrame(this); + m_staistFrame->setMinimumSize(FRAME_MIN_SIZE); + m_staistFrame->setMaximumSize(FRAME_MAX_SIZE); + m_staistFrame->setFrameShape(QFrame::Box); - m_staListLayout = new QVBoxLayout(staistFrame); + m_staListLayout = new QVBoxLayout(m_staistFrame); m_staListLayout->setContentsMargins(0, 0, 0, 0); m_staListLayout->setSpacing(0); @@ -49,7 +49,7 @@ ConnectdevPage::ConnectdevPage(QWidget *parent) : Vlayout->addWidget(m_titleLabel); Vlayout->addSpacing(8); - Vlayout->addWidget(staistFrame); + Vlayout->addWidget(m_staistFrame); } QFrame* ConnectdevPage::myLine() @@ -90,7 +90,7 @@ void ConnectdevPage::getConnectStaDevice(QMap &staMap) QStringList macList = reply.arguments().at(0).toString().split(";"); QStringList hostNameList = reply.arguments().at(1).toString().split(";"); for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) { - if (!staMap.contains(macList.at(index))) { + if (!staMap.contains(macList.at(index)) && hostNameList.at(index) != nullptr) { staMap[macList.at(index)] = hostNameList.at(index); } } @@ -158,7 +158,7 @@ void ConnectdevPage::resetLayoutHight() height += w->height(); } } - this->setFixedHeight(height + m_titleLabel->height() + 8); + m_staistFrame->setFixedHeight(height); if (m_staMap.isEmpty()) { this->hide(); diff --git a/plugins/mobilehotspot/connectdevpage.h b/plugins/mobilehotspot/connectdevpage.h index 944fc995..ce9abb09 100644 --- a/plugins/mobilehotspot/connectdevpage.h +++ b/plugins/mobilehotspot/connectdevpage.h @@ -50,12 +50,6 @@ public: private: QFrame* myLine(); - TitleLabel *m_titleLabel = nullptr; - QVBoxLayout *m_staListLayout = nullptr; - QMap m_staMap; - - QDBusInterface *m_activePathInterface = nullptr; - void getConnectStaDevice(QMap &blacklistMap); bool removeStaFromBlacklist(QString staMac); void initStaDev(); @@ -67,6 +61,15 @@ private: void onStaDevChanged(bool istrue, QString staMac, QString staName); void resetLayoutHight(); +private: + QFrame *m_staistFrame = nullptr; + + TitleLabel *m_titleLabel = nullptr; + QVBoxLayout *m_staListLayout = nullptr; + QMap m_staMap; + + QDBusInterface *m_activePathInterface = nullptr; + signals: void setStaIntoBlacklist(QString staMac, QString staName);