Enhance WiFi connection handler, auto-update connection status, fix layout glitch
This commit is contained in:
parent
7ddbe923e2
commit
22819a4443
@ -37,9 +37,6 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
|
|||||||
palette.setBrush(QPalette::Window, bg);
|
palette.setBrush(QPalette::Window, bg);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
|
|
||||||
// Resize the layout widget to the screen size
|
|
||||||
ui->gridLayoutWidget->resize(screenGeometry.size());
|
|
||||||
|
|
||||||
// Initialize process for external app launch
|
// Initialize process for external app launch
|
||||||
process = new QProcess(this);
|
process = new QProcess(this);
|
||||||
|
|
||||||
@ -58,6 +55,7 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
|
|||||||
foreach (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
|
foreach (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
|
||||||
if (device->type() == NetworkManager::Device::Wifi) {
|
if (device->type() == NetworkManager::Device::Wifi) {
|
||||||
wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
|
wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
|
||||||
|
connect(wifiDevice.data(), &NetworkManager::Device::stateChanged, this, [this]{updateConnectionStatus();});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,6 +181,7 @@ void InstallerPrompt::handleWifiConnection(const QString &ssid) {
|
|||||||
|
|
||||||
// Update the connection settings
|
// Update the connection settings
|
||||||
qDebug() << "Saving the connection...";
|
qDebug() << "Saving the connection...";
|
||||||
|
QDBusObjectPath path;
|
||||||
NetworkManager::ConnectionSettings::Ptr newConnectionSettings(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
|
NetworkManager::ConnectionSettings::Ptr newConnectionSettings(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
|
||||||
newConnectionSettings->fromMap(nmMap);
|
newConnectionSettings->fromMap(nmMap);
|
||||||
QDBusPendingReply<QDBusObjectPath> addreply = NetworkManager::addConnection(nmMap);
|
QDBusPendingReply<QDBusObjectPath> addreply = NetworkManager::addConnection(nmMap);
|
||||||
@ -190,26 +189,25 @@ void InstallerPrompt::handleWifiConnection(const QString &ssid) {
|
|||||||
if (addreply.isError()) {
|
if (addreply.isError()) {
|
||||||
qDebug() << nmMap;
|
qDebug() << nmMap;
|
||||||
qDebug() << "Unable to save the connection:" << addreply.error().message();
|
qDebug() << "Unable to save the connection:" << addreply.error().message();
|
||||||
return;
|
} else {
|
||||||
|
path = addreply.value();
|
||||||
|
qDebug() << "Added connection path:" << path.path();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString uuid = fullSettings.value("connection").toMap().value("uuid").toString();
|
NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(path.path());
|
||||||
NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
|
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
qDebug() << "Unable to retrieve the connection after saving:" << addreply.error().message();
|
qDebug() << "Unable to retrieve the connection after saving:" << addreply.error().message();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::activateConnection(connection->path(), wifiDevice->uni(), QString());
|
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::activateConnection(connection->path(), wifiDevice->uni(), QString());
|
||||||
reply.waitForFinished();
|
reply.waitForFinished();
|
||||||
if (reply.isError()) {
|
if (reply.isError()) {
|
||||||
qDebug() << "Unable to activate the connection:" << addreply.error().message();
|
qDebug() << "Unable to activate the connection:" << addreply.error().message();
|
||||||
|
} else {
|
||||||
|
NetworkManager::reloadConnections();
|
||||||
|
qDebug() << "Successfully connected:" << ssid;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::reloadConnections();
|
|
||||||
qDebug() << "Successfully connected:" << ssid;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
label.setStyleSheet("color: red;");
|
label.setStyleSheet("color: red;");
|
||||||
|
@ -30,6 +30,7 @@ private slots:
|
|||||||
void refreshNetworkList();
|
void refreshNetworkList();
|
||||||
void onLanguageChanged(int index);
|
void onLanguageChanged(int index);
|
||||||
void onConnectWifiClicked();
|
void onConnectWifiClicked();
|
||||||
|
void updateConnectionStatus();
|
||||||
void tryLubuntu();
|
void tryLubuntu();
|
||||||
void installLubuntu();
|
void installLubuntu();
|
||||||
|
|
||||||
@ -43,7 +44,6 @@ private:
|
|||||||
void initLanguageComboBox();
|
void initLanguageComboBox();
|
||||||
QStringList getAvailableLanguages() const;
|
QStringList getAvailableLanguages() const;
|
||||||
void showWifiOptions();
|
void showWifiOptions();
|
||||||
void updateConnectionStatus();
|
|
||||||
NetworkManager::Connection::Ptr findConnectionBySsid(const QString &ssid);
|
NetworkManager::Connection::Ptr findConnectionBySsid(const QString &ssid);
|
||||||
QMap<QString, QVariant> createSettingsBySSID(const QString &ssid);
|
QMap<QString, QVariant> createSettingsBySSID(const QString &ssid);
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user