diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 03925255..45f9162d 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -58,8 +58,8 @@ void WlanListItem::setExpanded(const bool &expanded) } this->setFixedHeight(expanded ? EXPANDED_HEIGHT : NORMAL_HEIGHT); - m_pwdFrame->setVisible(expanded); - m_autoConnectFrame->setVisible(expanded); +// m_pwdFrame->setVisible(false); +// m_autoConnectFrame->setVisible(false); emit this->itemHeightChanged(m_data->m_NetSsid); if (!expanded) { QPalette pal = qApp->palette(); @@ -68,6 +68,12 @@ void WlanListItem::setExpanded(const bool &expanded) } } +void WlanListItem::setWlanItemPwdVisible(const bool &expanded) +{ + m_pwdFrame->setVisible(expanded); + m_autoConnectFrame->setVisible(expanded); +} + QString WlanListItem::getSsid() { if (!m_data) { diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index 56b554d4..4a6d65f8 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -30,6 +30,7 @@ public: void setWlanSignal(const int &signal); void setWlanState(const int &state); void setExpanded(const bool &expanded); + void setWlanItemPwdVisible(const bool &expanded); QString getSsid(); KyWirelessNetItem *m_data = nullptr; protected: diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 3af9d7f6..260dc82f 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -386,6 +386,10 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid) int height = m_itemsMap.value(ssid).second->height(); m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING); m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height()); + QListWidgetItem * aItem = (m_itemsMap.value(ssid)).first; + delete aItem; + WlanListItem * awItem = (m_itemsMap.value(ssid)).second; + delete awItem; } m_itemsMap.remove(ssid); } @@ -605,22 +609,32 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec void WlanPage::onItemHeightChanged(const QString &ssid) { + qDebug() << "onItemHeightChanged" << __LINE__; if (!m_itemsMap.contains(ssid)) { return; } + //新的展开item QListWidgetItem *item = (m_itemsMap.value(ssid)).first; + WlanListItem * m_item = (m_itemsMap.value(ssid)).second; if (m_expandedItem && m_expandedItem != item) { + qDebug() << "onItemHeightChanged : the old fold and the new expanded" << m_expandedItem << item << __LINE__; QSize size(m_inactivatedNetListWidget->itemWidget(m_expandedItem)->size().width(), NORMAL_HEIGHT); //旧的收起 m_expandedItem->setSizeHint(size); m_inactivatedNetListWidget->itemWidget(m_expandedItem)->setFixedHeight(NORMAL_HEIGHT); + m_wlanExpandedItem->setWlanItemPwdVisible(false); //新的展开 m_expandedItem = item; + m_wlanExpandedItem = m_item; item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size()); + m_item->setWlanItemPwdVisible(true); } else if (!m_expandedItem) { + qDebug() << "onItemHeightChanged : only expanded the new one " << m_expandedItem << item << __LINE__; m_expandedItem = item; + m_wlanExpandedItem = m_item; m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_inactivatedNetListWidget->itemWidget(item)->height() - item->sizeHint().height()); m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height()); item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size()); + m_item->setWlanItemPwdVisible(true); } } diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index 51014334..1aaacb17 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -84,6 +84,7 @@ private: QMap> m_itemsMap; QListWidgetItem *m_expandedItem = nullptr; + WlanListItem *m_wlanExpandedItem = nullptr; QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr; QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr; QFrame * m_hiddenWlanWidget = nullptr; diff --git a/src/main.cpp b/src/main.cpp index f49bac11..cac828c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) // QApplication a(argc, argv); QString id = QString("kylin-nm"+ QLatin1String(getenv("DISPLAY"))); QtSingleApplication a(id, argc, argv); -// qInstallMessageHandler(messageOutput); + qInstallMessageHandler(messageOutput); if (a.isRunning()) { auto connection = QDBusConnection::sessionBus(); QDBusInterface iface("com.kylin.network",