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

pull/2/head
Aaron Rainbolt 6 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,27 +189,26 @@ 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();
return;
}
} else {
NetworkManager::reloadConnections();
qDebug() << "Successfully connected:" << ssid;
return;
}
}
label.setStyleSheet("color: red;");
label.setText(tr("Incorrect password. Please try again:"));

@ -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);
};

@ -68,15 +68,8 @@ QLabel#logoLabel {
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>1921</width>
<height>1031</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="mainLayout">
<item>
<spacer name="verticalSpacer">
@ -135,7 +128,6 @@ QLabel#logoLabel {
<property name="font">
<font>
<family>Ubuntu</family>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
@ -208,7 +200,6 @@ QLabel#logoLabel {
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -286,7 +277,6 @@ QLabel#logoLabel {
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -332,7 +322,6 @@ QLabel#logoLabel {
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -375,7 +364,6 @@ QLabel#logoLabel {
<widget class="QLabel" name="WiFiInfoLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -471,7 +459,6 @@ QLabel#logoLabel {
<font>
<family>Ubuntu</family>
<pointsize>24</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -548,7 +535,6 @@ QToolTip {
<font>
<family>Ubuntu</family>
<pointsize>24</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -691,7 +677,6 @@ QToolTip {
<property name="font">
<font>
<pointsize>24</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -729,7 +714,8 @@ QToolTip {
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>

Loading…
Cancel
Save