add device name when actvating or deactivating && lan list sort

This commit is contained in:
jzxc95 2021-10-14 20:30:53 +08:00
parent b1690dc2ec
commit 92efbe52c3
5 changed files with 56 additions and 1 deletions

View File

@ -560,3 +560,23 @@ bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devN
}
}
}
QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
{
QString deviceName = "";
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(conUuid);
if (nullptr == activeConnectPtr) {
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< conUuid;
return deviceName;
}
QStringList interfaces = activeConnectPtr->devices();
QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
deviceName = devicePtr->interfaceName();
return deviceName;
}

View File

@ -37,6 +37,8 @@ public:
bool isActiveConnection(QString uuid, QStringList &devName);
QString getDeviceOfActivateConnect(QString conUuid);
private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QString &ipv4Address,

View File

@ -208,9 +208,14 @@ void KyConnectOperation::activateConnection(const QString connectUuid, const QSt
void KyConnectOperation::deactivateConnection(const QString activeConnectName, const QString &activeConnectUuid)
{
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
qDebug()<<"deactivetate connect name"<<activeConnectName<<"uuid"<<activeConnectUuid;
if (nullptr == m_networkResourceInstance) {
qDebug() << "NULL!";
}
activateConnectPtr = m_networkResourceInstance->getActiveConnect(activeConnectUuid);
if (nullptr == activateConnectPtr) {
QString errorMessage = tr("it can not find the activate connect")

View File

@ -8,6 +8,22 @@
#include <NetworkManagerQt/VpnPlugin>
#include <NetworkManagerQt/VpnSetting>
static bool subLanListSort(const KyConnectItem* info1, const KyConnectItem* info2)
{
QString name1 = info1->m_connectName;
QString name2 = info2->m_connectName;
bool result = true;
if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
result = false;
}
return result;
}
static void lanListSort(QList<KyConnectItem *> &list)
{
qSort(list.begin(), list.end(), subLanListSort);
}
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
{
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
@ -152,6 +168,9 @@ void KyConnectResourse::getConnectionList(QString deviceName,
connectPtr = nullptr;
}
if (connectItemList.size() > 1) {
lanListSort(connectItemList);
}
return;
}

View File

@ -22,6 +22,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
m_activeResourse = new KyActiveConnectResourse(this);
m_connectResourse = new KyConnectResourse(this);
m_deviceResource = new KyNetworkDeviceResourse(this);
m_wiredConnectOperation = new KyWiredConnectOperation(this);
initUI();
initNetSwitch();
@ -792,11 +793,19 @@ void LanPage::onUpdateLanlist(QString uuid,
updateActivatedConnectionArea(uuid);
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
updateConnectionArea(uuid);
} else if (state == NetworkManager::ActiveConnection::State::Activating
|| state == NetworkManager::ActiveConnection::State::Deactivating) {
QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid);
if (devName.isEmpty()) {
NetworkManager::ConnectionSettings::ConnectionType type = NetworkManager::ConnectionSettings::Wired;
m_connectResourse->getInterfaceByUuid(devName, type, uuid);
}
emit lanActiveConnectionStateChanged(devName, uuid, state);
}
return;
}
void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
{
QStringList devlist;