diff --git a/src/frontend/list-items/lanlistitem.cpp b/src/frontend/list-items/lanlistitem.cpp index c03218e4..ebbea431 100644 --- a/src/frontend/list-items/lanlistitem.cpp +++ b/src/frontend/list-items/lanlistitem.cpp @@ -25,8 +25,6 @@ LanListItem::LanListItem(const KyConnectItem *lanConnectItem, m_itemFrame->installEventFilter(this); connect(this->m_infoButton, &InfoButton::clicked, this, &LanListItem::onInfoButtonClicked); - - m_menu = new QMenu(this);//右键菜单 connect(m_menu, &QMenu::triggered, this, &LanListItem::onMenuTriggered); } @@ -49,10 +47,8 @@ LanListItem::~LanListItem() void LanListItem::setIcon(bool isOn) { if (isOn) { -// m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-connected-symbolic")); m_netButton->setActive(true); //设置图标显示不同颜色 } else { -// m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-connected-symbolic")); m_netButton->setActive(false); } } diff --git a/src/frontend/list-items/lanlistitem.h b/src/frontend/list-items/lanlistitem.h index c4ed583f..c778e7eb 100644 --- a/src/frontend/list-items/lanlistitem.h +++ b/src/frontend/list-items/lanlistitem.h @@ -5,7 +5,6 @@ #include #include -#include #include class LanListItem : public ListItem @@ -46,7 +45,6 @@ private: KyNetworkDeviceResourse *m_deviceResource = nullptr; QString m_deviceName = ""; - QMenu *m_menu = nullptr; }; #endif // LANLISTITEM_H diff --git a/src/frontend/list-items/listitem.cpp b/src/frontend/list-items/listitem.cpp index 9fdd02e2..ecf9cb56 100644 --- a/src/frontend/list-items/listitem.cpp +++ b/src/frontend/list-items/listitem.cpp @@ -15,6 +15,7 @@ ListItem::ListItem(QWidget *parent) : QFrame(parent) { m_connectState = UnknownState; isDetailShow = false; + initUI(); initConnection(); connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged); @@ -125,6 +126,11 @@ void ListItem::paintEvent(QPaintEvent *event) void ListItem::initUI() { + m_menu = new QMenu(this);//右键菜单 + m_menu->setStyleSheet("QMenu::item{border:3px; border-radius:3px}"); + m_menu->setStyleSheet("QMenu{border-radius:3px; margin:3px 3px 3px 3px}"); + connect(m_menu, &QMenu::triggered, this, &ListItem::onMenuTriggered); + m_mainLayout = new QVBoxLayout(this); m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING); diff --git a/src/frontend/list-items/listitem.h b/src/frontend/list-items/listitem.h index 8ae950a1..dc4d79a3 100644 --- a/src/frontend/list-items/listitem.h +++ b/src/frontend/list-items/listitem.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "radioitembutton.h" #include "infobutton.h" #include "netdetails/netdetail.h" @@ -46,6 +47,7 @@ protected: bool m_isActive = false; ConnectState m_connectState; + QMenu *m_menu = nullptr; public: QVBoxLayout * m_mainLayout = nullptr; QHBoxLayout * m_hItemLayout = nullptr; @@ -58,6 +60,7 @@ public slots: virtual void onNetButtonClicked() = 0; void onPaletteChanged(); void onDetailShow(bool isShow); + virtual void onMenuTriggered(QAction *action)=0; signals: void detailShow(bool isShow); diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index f3e4ad54..8d050712 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -17,8 +17,6 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q setExpanded(false); connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked); - - m_menu = new QMenu(this);//右键菜单 connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered); m_wirelessConnectOperation = new KyWirelessConnectOperation(this); @@ -515,3 +513,12 @@ void WlanListItem::onMenuTriggered(QAction *action) return; } +void WlanListItem::forgetPwd() +{ + if (!this->isConfigured()) { + m_pwdLineEdit->setText(""); + return; + } +} + + diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index 3f333074..c26200a7 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -7,7 +7,6 @@ #include "kywirelessconnectoperation.h" #include #include "kylinactiveconnectresource.h" -#include #include #include @@ -43,6 +42,8 @@ public: void updateWirelessNetSecurity(QString ssid, QString securityType); void updateWirelessNetItem(KyWirelessNetItem &wirelessNetItem); + void forgetPwd(); + protected: void resizeEvent(QResizeEvent *event); void onRightButtonClicked(); @@ -79,8 +80,6 @@ private: QCheckBox *m_autoConnectCheckBox = nullptr; QLabel *m_autoConnectLabel = nullptr; - QMenu *m_menu = nullptr; - bool m_focusIsOut = true; bool m_mouseIsOut = true; diff --git a/src/frontend/list-items/wlanmoreitem.cpp b/src/frontend/list-items/wlanmoreitem.cpp index d1dd47fc..7284d703 100644 --- a/src/frontend/list-items/wlanmoreitem.cpp +++ b/src/frontend/list-items/wlanmoreitem.cpp @@ -19,3 +19,7 @@ void WlanMoreItem::onNetButtonClicked() { void WlanMoreItem::onRightButtonClicked() { // Todo } + +void WlanMoreItem::onMenuTriggered(QAction *action) { + +} diff --git a/src/frontend/list-items/wlanmoreitem.h b/src/frontend/list-items/wlanmoreitem.h index 152095d6..52183403 100644 --- a/src/frontend/list-items/wlanmoreitem.h +++ b/src/frontend/list-items/wlanmoreitem.h @@ -18,6 +18,7 @@ public: ~WlanMoreItem(); void onNetButtonClicked(); + void onMenuTriggered(QAction *action); signals: void hiddenWlanClicked(); }; diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index eb6e5222..3c4cb433 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -119,11 +119,14 @@ void MainWindow::initWindowProperties() this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png"))); this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT); // //绘制毛玻璃特效 -// this->setAttribute(Qt::WA_TranslucentBackground, true); -// QPainterPath path; -// auto rect = this->rect(); -// path.addRoundedRect(rect, 6, 6); -// KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); +// this->setStyleSheet("background:transparent"); //透明 +// this->setAttribute(Qt::WA_TranslucentBackground, true); //半透明 + this->setWindowOpacity(0.8); + + QPainterPath path; + auto rect = this->rect(); + path.addRoundedRect(rect, 6, 6); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); //背景模糊 } /** @@ -151,6 +154,7 @@ void MainWindow::initUI() m_tabBarLayout->addWidget(m_lanLabel); m_tabBarLayout->addWidget(m_wlanLabel); m_centralWidget->tabBar()->setLayout(m_tabBarLayout); + connect(m_centralWidget, &QTabWidget::currentChanged, m_wlanWidget, &WlanPage::onWlanPageVisibleChanged); } /** diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 7a444bda..b533a18c 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -10,6 +10,7 @@ #define ICON_REFRESH_INTERVAL (5*1000) #define EMPTY_SSID "emptyssid" #define LOG_FLAG "[WlanPage]" +#define LAN_PAGE_INDEX 0 WlanPage::WlanPage(QWidget *parent) : TabPage(parent) { @@ -59,6 +60,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e) showControlCenter(); } } + return QWidget::eventFilter(w,e); } @@ -544,6 +546,7 @@ void WlanPage::onConnectionAdd(QString deviceName, QString ssid) return; } + void WlanPage::onConnectionRemove(QString deviceName, QString ssid) { qDebug() << LOG_FLAG << "one connection is removed, it's ssid " << ssid << "device name"<< deviceName; @@ -1254,11 +1257,35 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible) //界面关闭的时候,停止wifi扫描和刷新 m_scanTimer->stop(); // m_refreshIconTimer->stop(); + qDebug() << "wlanpage not visible"; + showNonePwd(); } return; } +void WlanPage::onWlanPageVisibleChanged(int index) +{ + if (index == LAN_PAGE_INDEX) { + qDebug() << "wlanpage not visible"; + showNonePwd(); + } +} + +void WlanPage::showNonePwd() +{ + QMap::iterator iter; + for(iter=m_wirelessNetItemMap.begin();iter!= m_wirelessNetItemMap.end();iter++) + { + if(iter.value() != nullptr) { + QListWidgetItem *p_listWidgetItem = iter.value(); + WlanListItem *p_wlanItem = (WlanListItem*)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem); + p_wlanItem->forgetPwd(); + } + } + return; +} + void WlanPage::showDetailPage(QString devName, QString ssid) { KyWirelessNetItem wirelessNetItem; diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index ad02a945..c0fddc7e 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -68,6 +68,7 @@ public slots: void onMainWindowVisibleChanged(const bool &visible); void onSecurityTypeChange(QString devName, QString ssid, QString secuType); void requestScan(); + void onWlanPageVisibleChanged(int index); private slots: void onWlanAdded(QString interface, KyWirelessNetItem &item); @@ -108,6 +109,8 @@ private: void initWlanArea(); void addWlanMoreItem(); + void showNonePwd(); + QListWidgetItem *addEmptyItem(QListWidget *wirelessListWidget); QListWidgetItem *addNewItem(KyWirelessNetItem &wirelessNetItem, QListWidget *wirelessListWidget); diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 8356eb85..e0f03578 100644 Binary files a/translations/kylin-nm_zh_CN.qm and b/translations/kylin-nm_zh_CN.qm differ diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 1bda8836..c0409085 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -550,7 +550,7 @@ Kylin NM - 麒麟网络工具 + 麒麟网络设置工具 @@ -595,7 +595,7 @@ Kylin NM - 麒麟网络工具 + 麒麟网络设置工具 @@ -891,7 +891,7 @@ Kylin NM - 麒麟网络工具 + 麒麟网络设置工具