Enhance WiFi connection handler, auto-update connection status, fix layout glitch

pull/2/head
Aaron Rainbolt 5 months ago committed by Aaron Rainbolt
parent 7ddbe923e2
commit 22819a4443

@ -37,9 +37,6 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
palette.setBrush(QPalette::Window, bg);
this->setPalette(palette);
// Resize the layout widget to the screen size
ui->gridLayoutWidget->resize(screenGeometry.size());
// Initialize process for external app launch
process = new QProcess(this);
@ -58,6 +55,7 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
foreach (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Wifi) {
wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
connect(wifiDevice.data(), &NetworkManager::Device::stateChanged, this, [this]{updateConnectionStatus();});
break;
}
}
@ -183,6 +181,7 @@ void InstallerPrompt::handleWifiConnection(const QString &ssid) {
// Update the connection settings
qDebug() << "Saving the connection...";
QDBusObjectPath path;
NetworkManager::ConnectionSettings::Ptr newConnectionSettings(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
newConnectionSettings->fromMap(nmMap);
QDBusPendingReply<QDBusObjectPath> addreply = NetworkManager::addConnection(nmMap);
@ -190,26 +189,25 @@ void InstallerPrompt::handleWifiConnection(const QString &ssid) {
if (addreply.isError()) {
qDebug() << nmMap;
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::findConnectionByUuid(uuid);
NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(path.path());
if (!connection) {
qDebug() << "Unable to retrieve the connection after saving:" << addreply.error().message();
return;
}
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::activateConnection(connection->path(), wifiDevice->uni(), QString());
reply.waitForFinished();
if (reply.isError()) {
qDebug() << "Unable to activate the connection:" << addreply.error().message();
} else {
NetworkManager::reloadConnections();
qDebug() << "Successfully connected:" << ssid;
return;
}
NetworkManager::reloadConnections();
qDebug() << "Successfully connected:" << ssid;
return;
}
label.setStyleSheet("color: red;");

@ -30,6 +30,7 @@ private slots:
void refreshNetworkList();
void onLanguageChanged(int index);
void onConnectWifiClicked();
void updateConnectionStatus();
void tryLubuntu();
void installLubuntu();
@ -43,7 +44,6 @@ private:
void initLanguageComboBox();
QStringList getAvailableLanguages() const;
void showWifiOptions();
void updateConnectionStatus();
NetworkManager::Connection::Ptr findConnectionBySsid(const QString &ssid);
QMap<QString, QVariant> createSettingsBySSID(const QString &ssid);
};

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save