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

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

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

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

Loading…
Cancel
Save