Merge branch 'kylin-nm-tip' into 'dbus-interface'

当虚拟网络连接的时候,托盘图标旋转的问题

See merge request kylin-desktop/kylin-nm!384
This commit is contained in:
ren peijia 2021-11-05 03:31:05 +00:00
commit 3bd1d09215
4 changed files with 46 additions and 26 deletions

View File

@ -541,27 +541,6 @@ void KyActiveConnectResourse::getApActivateConnect(QList<KyApConnectItem *> &apC
return; return;
} }
bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devName)
{
if (!m_networkResourceInstance->isActiveConnection(uuid)) {
return false;
} else {
NetworkManager::ActiveConnection::Ptr actPtr = m_networkResourceInstance->getActiveConnect(uuid);
if (actPtr.isNull()) {
return false;
} else {
QStringList interfaces = actPtr->devices();
for (int index = 0; index < interfaces.size(); ++index) {
QString ifaceUni = interfaces.at(index);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
devName <<devicePtr->interfaceName();
}
return true;
}
}
}
QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid) QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
{ {
QString deviceName = ""; QString deviceName = "";
@ -583,6 +562,26 @@ QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
return deviceName; return deviceName;
} }
bool KyActiveConnectResourse::connectionIsVirtual(QString uuid)
{
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(uuid);
if (activeConnectPtr.isNull()) {
return false;
}
QStringList interfaces = activeConnectPtr->devices();
QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
if (devicePtr.isNull()) {
return false;
}
return !m_networkdevice->deviceIsWired(devicePtr->interfaceName());
}
bool KyActiveConnectResourse::wiredConnectIsActived() bool KyActiveConnectResourse::wiredConnectIsActived()
{ {
int index = 0; int index = 0;
@ -609,6 +608,10 @@ bool KyActiveConnectResourse::wiredConnectIsActived()
continue; continue;
} }
if (connectionIsVirtual(activeConnectPtr->uuid())) {
continue;
}
if (activeConnectPtr->state() == NetworkManager::ActiveConnection::State::Activated) { if (activeConnectPtr->state() == NetworkManager::ActiveConnection::State::Activated) {
return true; return true;
} }

View File

@ -35,10 +35,9 @@ public:
void getApActivateConnect(QList<KyApConnectItem *> &apConnectItemList); void getApActivateConnect(QList<KyApConnectItem *> &apConnectItemList);
bool isActiveConnection(QString uuid, QStringList &devName);
QString getDeviceOfActivateConnect(QString conUuid); QString getDeviceOfActivateConnect(QString conUuid);
bool connectionIsVirtual(QString uuid);
bool wiredConnectIsActived(); bool wiredConnectIsActived();
bool wirelessConnectIsActived(); bool wirelessConnectIsActived();

View File

@ -825,7 +825,7 @@ void LanPage::onConnectionStateChange(QString uuid,
return; return;
} }
emit this->lanConnectChanged(state); sendLanStateChangeSignal(uuid, (ConnectState)state);
qDebug()<<"[LanPage] connection uuid"<< uuid qDebug()<<"[LanPage] connection uuid"<< uuid
<< "state change slot:"<< state; << "state change slot:"<< state;
@ -855,11 +855,15 @@ void LanPage::onConnectionStateChange(QString uuid,
updateConnectionArea(p_newItem); updateConnectionArea(p_newItem);
updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state); updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state);
} else if (state == NetworkManager::ActiveConnection::State::Activating) { } else if (state == NetworkManager::ActiveConnection::State::Activating) {
updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state);
deviceName = getConnectionDevice(uuid); deviceName = getConnectionDevice(uuid);
if (deviceName == m_currentDeviceName) {
updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state);
}
} else if (state == NetworkManager::ActiveConnection::State::Deactivating) { } else if (state == NetworkManager::ActiveConnection::State::Deactivating) {
updateConnectionState(m_activeConnectionMap, m_activatedLanListWidget, uuid, (ConnectState)state);
deviceName = getConnectionDevice(uuid); deviceName = getConnectionDevice(uuid);
if (deviceName == m_currentDeviceName) {
updateConnectionState(m_activeConnectionMap, m_activatedLanListWidget, uuid, (ConnectState)state);
}
} }
emit lanActiveConnectionStateChanged(deviceName, uuid, state); emit lanActiveConnectionStateChanged(deviceName, uuid, state);
@ -922,6 +926,19 @@ void LanPage::sendLanAddSignal(KyConnectItem *p_connectItem)
return; return;
} }
void LanPage::sendLanStateChangeSignal(QString uuid, ConnectState state)
{
if (state == Activating || state == Deactivating) {
if (m_activeResourse->connectionIsVirtual(uuid)) {
return;
}
}
emit this->lanConnectChanged(state);
return;
}
void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem) void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem)
{ {
QString newUuid = p_connectItem->m_connectUuid; QString newUuid = p_connectItem->m_connectUuid;

View File

@ -70,6 +70,7 @@ private:
void sendLanUpdateSignal(KyConnectItem *p_connectItem); void sendLanUpdateSignal(KyConnectItem *p_connectItem);
void sendLanAddSignal(KyConnectItem *p_connectItem); void sendLanAddSignal(KyConnectItem *p_connectItem);
void sendLanStateChangeSignal(QString uuid, ConnectState state);
void addEmptyConnectItem(QMap<QString, QListWidgetItem *> &connectMap, void addEmptyConnectItem(QMap<QString, QListWidgetItem *> &connectMap,
QListWidget *lanListWidget); QListWidget *lanListWidget);