From b542af10ee248f045967fd91bf37e61125d6c3e6 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Fri, 9 Sep 2022 14:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=89=E7=BA=BFdeleteConnect=20dbus=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/netconnect/netconnect.cpp | 20 +++++++++++++++++--- plugins/netconnect/netconnect.h | 4 +--- src/backend/dbusadaptor.cpp | 12 ++++++++++++ src/backend/dbusadaptor.h | 2 ++ src/frontend/mainwindow.cpp | 6 ++++++ src/frontend/mainwindow.h | 2 ++ src/frontend/tab-pages/lanpage.cpp | 9 +++++++++ src/frontend/tab-pages/lanpage.h | 1 + 8 files changed, 50 insertions(+), 6 deletions(-) diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index 3a933302..d4b4c0e3 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -356,9 +356,11 @@ void NetConnect::runExternalApp() { } //刪除 -void NetConnect::deleteOneLan(QString ssid) +void NetConnect::deleteOneLan(QString ssid, int type) { - Q_EMIT lanRemove(ssid); + qDebug() << "[NetConnect]call deleteConnect" << __LINE__; + m_interface->call(QStringLiteral("deleteConnect"), type, ssid); + qDebug() << "[NetConnect]call deleteConnect respond" << __LINE__; } //激活 @@ -457,6 +459,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL }); lanItem->isAcitve = isActived; + lanItem->setConnectActionText(lanItem->isAcitve); connect(lanItem, &QPushButton::clicked, this, [=] { if (lanItem->isAcitve || lanItem->loading) { @@ -473,7 +476,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL deActiveConnect(lanItem->uuid, devName, WIRED_TYPE); }); connect(lanItem, &LanItem::deleteActionTriggered, this, [=] { - deleteOneLan(lanItem->dbusPath); + deleteOneLan(lanItem->uuid, WIRED_TYPE); }); //记录到deviceFrame的itemMap中 @@ -736,6 +739,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis }); lanItem->isAcitve = false; + lanItem->setConnectActionText(lanItem->isAcitve); connect(lanItem, &QPushButton::clicked, this, [=] { if (lanItem->isAcitve || lanItem->loading) { @@ -745,6 +749,16 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis } }); + connect(lanItem, &LanItem::connectActionTriggered, this, [=] { + activeConnect(lanItem->uuid, deviceName, WIRED_TYPE); + }); + connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] { + deActiveConnect(lanItem->uuid, deviceName, WIRED_TYPE); + }); + connect(lanItem, &LanItem::deleteActionTriggered, this, [=] { + deleteOneLan(lanItem->uuid, WIRED_TYPE); + }); + //记录到deviceFrame的itemMap中 deviceFrameMap[deviceName]->itemMap.insert(connUuid, lanItem); int index = getInsertPos(connName, deviceName); diff --git a/plugins/netconnect/netconnect.h b/plugins/netconnect/netconnect.h index ac754d76..644f39f3 100644 --- a/plugins/netconnect/netconnect.h +++ b/plugins/netconnect/netconnect.h @@ -101,7 +101,7 @@ private: int getInsertPos(QString connName, QString deviceName); - void deleteOneLan(QString ssid); + void deleteOneLan(QString ssid, int type); void activeConnect(QString ssid, QString deviceName, int type); void deActiveConnect(QString ssid, QString deviceName, int type); @@ -153,8 +153,6 @@ private slots: void onDeviceStatusChanged(); void onDeviceNameChanged(QString, QString, int); -Q_SIGNALS: - void lanRemove(QString dbusPath); }; Q_DECLARE_METATYPE(QList); diff --git a/src/backend/dbusadaptor.cpp b/src/backend/dbusadaptor.cpp index 47129adf..bc49fc94 100644 --- a/src/backend/dbusadaptor.cpp +++ b/src/backend/dbusadaptor.cpp @@ -148,6 +148,18 @@ void DbusAdaptor::setDeviceEnable(QString devName, bool enable) // return deviceName; //} +//删除 +void DbusAdaptor::deleteConnect(int type, QString ssid) +{ + if (type == WIRED) { + parent()->deleteWired(ssid); + } else if (type == WIRELESS) { + //待实现 + } else { + qDebug() << "[DbusAdaptor] deleteConnect type is invalid"; + } +} + //连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid void DbusAdaptor::activateConnect(int type, QString devName, QString ssid) { diff --git a/src/backend/dbusadaptor.h b/src/backend/dbusadaptor.h index 6cb0f411..500ebfa3 100644 --- a/src/backend/dbusadaptor.h +++ b/src/backend/dbusadaptor.h @@ -62,6 +62,8 @@ public Q_SLOTS: // METHODS // QString getDefaultWiredDevice(); // Q_NOREPLY void setDefaultWirelessDevice(QString deviceName); // QString getDefaultWirelessDevice(); + //刪除 根据网络名称 参数1 0:lan 1:wlan 参数2 为ssid/uuid + Q_NOREPLY void deleteConnect(int type, QString ssid); //连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid Q_NOREPLY void activateConnect(int type, QString devName, QString ssid); //断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index a7cc6c7d..4433f9f1 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -868,6 +868,12 @@ void MainWindow::getWirelessDeviceCap(QMap &map) m_wlanWidget->getWirelessDeviceCap(map); } +//有线连接删除 +void MainWindow::deleteWired(const QString &connUuid) +{ + m_lanWidget->deleteWired(connUuid); +} + //有线连接断开 void MainWindow::activateWired(const QString& devName, const QString& connUuid) { diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index b1e3ac57..269abf50 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -81,6 +81,8 @@ public: void getApConnectionPath(QString &path, QString uuid); //获取热点ActivePath void getActiveConnectionPath(QString &path, QString uuid); + //删除有线连接 + void deleteWired(const QString& connUuid); //有线连接断开 void activateWired(const QString& devName, const QString& connUuid); void deactivateWired(const QString& devName, const QString& connUuid); diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 82f85f0d..ab5eadea 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -1270,6 +1270,15 @@ bool LanPage::eventFilter(QObject *watched, QEvent *event) return QWidget::eventFilter(watched, event); } +void LanPage::deleteWired(const QString &connUuid) +{ + qDebug() << "[LanPage] deleteWired" << connUuid; + if (connUuid == nullptr) { + return; + } + m_wiredConnectOperation->deleteWiredConnect(connUuid); +} + void LanPage::activateWired(const QString& devName, const QString& connUuid) { qDebug() << "[LanPage] activateWired" << devName << connUuid; diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index 73ccc09a..602a693d 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -44,6 +44,7 @@ public: //for dbus void getWiredList(QMap > &map); + void deleteWired(const QString& connUuid); void activateWired(const QString& devName, const QString& connUuid); void deactivateWired(const QString& devName, const QString& connUuid); void showDetailPage(QString devName, QString uuid);