Skip to content

Commit

Permalink
fix: Implement entering the dde-control-center network configuration …
Browse files Browse the repository at this point in the history
…page from the dock

Implement entering the dde-control-center network configuration page from the dock

Log:
pms: TASK-361721
  • Loading branch information
caixr23 committed Dec 7, 2024
1 parent cc67407 commit df3774f
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 34 deletions.
3 changes: 0 additions & 3 deletions dcc-network/qml/PageHotspot.qml
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ DccObject {
}, {
"text": qsTr("WPA/WPA2 Personal"),
"value": "wpa-psk"
}, {
"text": qsTr("WPA3 Personal"),
"value": "sae"
}]
currentIndex: indexOfValue(keyMgmt)
onActivated: {
Expand Down
11 changes: 0 additions & 11 deletions dcc-network/qml/network.qml

This file was deleted.

10 changes: 10 additions & 0 deletions dcc-network/qml/networkMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ DccObject {
property var wiredDevs: []
property var wirelessDevs: []

name: "network"
parentName: "root"
displayName: qsTr("Network")
icon: "dcc_network"
weight: 50
Component {
id: wiredComponent
PageWiredDevice {}
Expand Down Expand Up @@ -153,6 +158,11 @@ DccObject {
updateDevice()
}
}
onActive: cmd => {
if (cmd.length !== 0) {
dccData.exec(NetManager.FindConnectInfo, cmd, {})
}
}
Component.onCompleted: {
updateDevice()
}
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_az.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_bo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_nb_NO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation>网络</translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_zh_HK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 1 addition & 1 deletion dcc-network/translations/network_zh_TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@
</message>
</context>
<context>
<name>network</name>
<name>networkMain</name>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
Expand Down
5 changes: 5 additions & 0 deletions net-view/operation/netmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ void NetManagerPrivate::exec(NetManager::CmdType cmd, const QString &id, const Q
QString file = param.value("file").toString();
m_managerThread->exportConnect(id, file);
} break;
case NetManager::FindConnectInfo: {
if (!id.isEmpty()) {
m_managerThread->findConnectInfo(id);
}
} break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions net-view/operation/netmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class NetManager : public QObject
ImportConnect, // 导入配置
ImportError, // 导入出错
ExportConnect, // 导出配置
FindConnectInfo, // 查找配置 任务栏打开网络配置界面
};
Q_ENUM(CmdType)

Expand Down
73 changes: 72 additions & 1 deletion net-view/operation/private/netmanagerthreadprivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ NetManagerThreadPrivate::NetManagerThreadPrivate()
, m_secretAgent(nullptr)
, m_netCheckAvailable(false)
, m_isSleeping(false)
, m_findApTimer(nullptr)
{
moveToThread(m_thread);
m_thread->start();
Expand Down Expand Up @@ -380,6 +381,11 @@ void NetManagerThreadPrivate::exportConnect(const QString &id, const QString &fi
QMetaObject::invokeMethod(this, "doExportConnect", Qt::QueuedConnection, Q_ARG(QString, id), Q_ARG(QString, file));
}

void NetManagerThreadPrivate::findConnectInfo(const QString &cmd)
{
QMetaObject::invokeMethod(this, "doFindConnectInfo", Qt::QueuedConnection, Q_ARG(QString, cmd));
}

void NetManagerThreadPrivate::doInit()
{
if (m_isInitialized)
Expand Down Expand Up @@ -747,7 +753,7 @@ void NetManagerThreadPrivate::doGotoControlCenter(const QString &page)
{
if (!m_enabled)
return;
QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.dde.ControlCenter", "/com/deepin/dde/ControlCenter", "com.deepin.dde.ControlCenter", "ShowPage");
QDBusMessage message = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1", "/org/deepin/dde/ControlCenter1", "org.deepin.dde.ControlCenter1", "ShowPage");
message << "network" << page;
QDBusConnection::sessionBus().asyncCall(message);
Q_EMIT toControlCenter();
Expand Down Expand Up @@ -1605,6 +1611,71 @@ void NetManagerThreadPrivate::doSetAppProxy(const QVariantMap &param)
}
}

void NetManagerThreadPrivate::clearFindApConnectInfo()
{
m_findApcmd.clear();
if (m_findApTimer) {
m_findApTimer->stop();
m_findApTimer->deleteLater();
m_findApTimer = nullptr;
}
}

bool NetManagerThreadPrivate::findApConnectInfo()
{
QString devPath;
QString ssid;
QStringList params = m_findApcmd.split('&');
for (auto param : params) {
auto keyMap = param.split('=');
if (keyMap.size() != 2) {
continue;
}
if (keyMap.at(0) == "device") {
devPath = keyMap.at(1);
} else if (keyMap.at(0) == "ssid") {
ssid = keyMap.at(1);
}
}
if (ssid.isEmpty()) {
clearFindApConnectInfo();
return true;
}
for (auto dev : NetworkController::instance()->devices()) {
if (dev->deviceType() == DeviceType::Wireless && (devPath.isEmpty() || dev->path() == devPath)) {
WirelessDevice *wDev = qobject_cast<WirelessDevice *>(dev);
if (!wDev) {
continue;
}
for (auto ap : wDev->accessPointItems()) {
if (ap->ssid() == ssid) {
doGetConnectInfo(apID(ap), NetType::WirelessItem, QVariantMap());
QDBusMessage message = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1", "/org/deepin/dde/ControlCenter1", "org.deepin.dde.ControlCenter1", "Show");
QDBusConnection::sessionBus().asyncCall(message);
clearFindApConnectInfo();
return true;
}
}
}
}
return false;
}

void NetManagerThreadPrivate::doFindConnectInfo(const QString &cmd)
{
if (m_findApcmd != cmd) {
m_findApcmd = cmd;
if (!findApConnectInfo()) {
if (!m_findApTimer) {
m_findApTimer = new QTimer(this);
connect(m_findApTimer, &QTimer::timeout, this, &NetManagerThreadPrivate::findApConnectInfo);
QTimer::singleShot(10000, this, &NetManagerThreadPrivate::clearFindApConnectInfo);
m_findApTimer->start(100);
}
}
}
}

void NetManagerThreadPrivate::sendRequest(NetManager::CmdType cmd, const QString &id, const QVariantMap &param)
{
if (!m_enabled)
Expand Down
6 changes: 6 additions & 0 deletions net-view/operation/private/netmanagerthreadprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public Q_SLOTS:
void deleteConnect(const QString &uuid);
void importConnect(const QString &id, const QString &file);
void exportConnect(const QString &id, const QString &file);
void findConnectInfo(const QString &cmd);

protected Q_SLOTS:
void doInit();
Expand Down Expand Up @@ -163,6 +164,9 @@ protected Q_SLOTS:
void doExportConnect(const QString &id, const QString &file);
void doSetSystemProxy(const QVariantMap &param);
void doSetAppProxy(const QVariantMap &param);
void clearFindApConnectInfo();
bool findApConnectInfo();
void doFindConnectInfo(const QString &cmd);

void sendRequest(NetManager::CmdType cmd, const QString &id, const QVariantMap &param = QVariantMap());

Expand Down Expand Up @@ -283,6 +287,8 @@ protected Q_SLOTS:
bool m_isSleeping;
QString m_serverKey;
QSet<QString> m_detailsItems;
QString m_findApcmd;
QTimer *m_findApTimer;
};

} // namespace network
Expand Down

0 comments on commit df3774f

Please sign in to comment.