Merge branch '1209' into 'dbus-interface'
bug#93043插入网线切换当前网卡 See merge request kylin-desktop/kylin-nm!471
This commit is contained in:
commit
d6a881615b
|
@ -61,20 +61,39 @@ LanPage::~LanPage()
|
||||||
|
|
||||||
void LanPage::initLanDevice()
|
void LanPage::initLanDevice()
|
||||||
{
|
{
|
||||||
m_currentDeviceName = getDefaultDeviceName(WIRED);
|
|
||||||
|
|
||||||
m_devList.clear();
|
m_devList.clear();
|
||||||
m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, m_devList);
|
m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, m_devList);
|
||||||
if (m_currentDeviceName.isEmpty()) {
|
|
||||||
for (int index = 0; index < m_devList.size(); ++index) {
|
m_currentDeviceName = getDefaultDeviceName(WIRED);
|
||||||
if (m_deviceResource->wiredDeviceIsCarriered(m_devList.at(index))) {
|
bool getDefault = !m_currentDeviceName.isEmpty();
|
||||||
m_currentDeviceName = m_devList.at(index);
|
if (getDefault) {
|
||||||
setDefaultDevice(WIRED, m_currentDeviceName);
|
if (m_deviceResource->wiredDeviceIsCarriered(m_currentDeviceName)) {
|
||||||
break;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<KyConnectItem *> activedList;
|
||||||
|
for (int index = 0; index < m_devList.size(); ++index) {
|
||||||
|
m_activeResourse->getActiveConnectionList(m_devList.at(index),
|
||||||
|
NetworkManager::ConnectionSettings::Wired, activedList);
|
||||||
|
if (!activedList.isEmpty()) {
|
||||||
|
m_currentDeviceName = m_devList.at(index);
|
||||||
|
if (!getDefault) {
|
||||||
|
setDefaultDevice(WIRED, m_currentDeviceName);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < m_devList.size(); ++index) {
|
||||||
|
if (m_deviceResource->wiredDeviceIsCarriered(m_devList.at(index))) {
|
||||||
|
m_currentDeviceName = m_devList.at(index);
|
||||||
|
if (!getDefault) {
|
||||||
|
setDefaultDevice(WIRED, m_currentDeviceName);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +321,7 @@ void LanPage::addEmptyConnectItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||||
|
|
||||||
void LanPage::deleteConnectionMapItem(QMap<QString, QListWidgetItem *> &connectMap,
|
void LanPage::deleteConnectionMapItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||||
QListWidget *lanListWidget, QString uuid)
|
QListWidget *lanListWidget, QString uuid)
|
||||||
{
|
{
|
||||||
QListWidgetItem *p_listWidgetItem = connectMap.value(uuid);
|
QListWidgetItem *p_listWidgetItem = connectMap.value(uuid);
|
||||||
if (p_listWidgetItem) {
|
if (p_listWidgetItem) {
|
||||||
connectMap.remove(uuid);
|
connectMap.remove(uuid);
|
||||||
|
@ -644,7 +663,7 @@ void LanPage::onDeviceRemove(QString deviceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanPage::updateDeviceCombox(QString oldDeviceName, QString newDeviceName)
|
void LanPage::updateDeviceCombox(QString oldDeviceName, QString newDeviceName)
|
||||||
{
|
{
|
||||||
if (m_currentDeviceName == oldDeviceName) {
|
if (m_currentDeviceName == oldDeviceName) {
|
||||||
m_currentDeviceName = newDeviceName;
|
m_currentDeviceName = newDeviceName;
|
||||||
setDefaultDevice(WIRED, m_currentDeviceName);
|
setDefaultDevice(WIRED, m_currentDeviceName);
|
||||||
|
@ -684,11 +703,10 @@ void LanPage::onDeviceCarriered(QString deviceName, bool pluged)
|
||||||
if (!pluged) {
|
if (!pluged) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_enableDeviceList.contains(deviceName)) {
|
if (m_enableDeviceList.contains(deviceName)) {
|
||||||
m_wiredConnectOperation->openWiredNetworkWithDevice(deviceName);
|
m_wiredConnectOperation->openWiredNetworkWithDevice(deviceName);
|
||||||
|
updateCurrentDevice(deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,6 +881,19 @@ QString LanPage::getConnectionDevice(QString uuid)
|
||||||
return deviceName;
|
return deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LanPage::updateCurrentDevice(QString deviceName)
|
||||||
|
{
|
||||||
|
if (m_currentDeviceName != deviceName) {
|
||||||
|
int index = m_deviceComboBox->findText(deviceName);
|
||||||
|
if (index < 0) {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
m_deviceComboBox->setCurrentIndex(index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void LanPage::onConnectionStateChange(QString uuid,
|
void LanPage::onConnectionStateChange(QString uuid,
|
||||||
NetworkManager::ActiveConnection::State state,
|
NetworkManager::ActiveConnection::State state,
|
||||||
NetworkManager::ActiveConnection::Reason reason)
|
NetworkManager::ActiveConnection::Reason reason)
|
||||||
|
|
|
@ -79,6 +79,8 @@ private:
|
||||||
void deleteConnectionMapItem(QMap<QString, QListWidgetItem *> &connectMap,
|
void deleteConnectionMapItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||||
QListWidget *lanListWidget, QString uuid);
|
QListWidget *lanListWidget, QString uuid);
|
||||||
|
|
||||||
|
void updateCurrentDevice(QString deviceName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void lanAdd(QString devName, QStringList info);
|
void lanAdd(QString devName, QStringList info);
|
||||||
void lanRemove(QString dbusPath);
|
void lanRemove(QString dbusPath);
|
||||||
|
|
Loading…
Reference in New Issue