From 22819a4443120ecabb7d02053eb0d2bdcc524054 Mon Sep 17 00:00:00 2001 From: Aaron Rainbolt Date: Mon, 4 Dec 2023 17:12:13 -0500 Subject: [PATCH] Enhance WiFi connection handler, auto-update connection status, fix layout glitch --- src/installerprompt.cpp | 20 +- src/installerprompt.h | 2 +- src/installerprompt.ui | 1290 +++++++++++++++++++-------------------- 3 files changed, 648 insertions(+), 664 deletions(-) diff --git a/src/installerprompt.cpp b/src/installerprompt.cpp index 47d3513..68aec4e 100644 --- a/src/installerprompt.cpp +++ b/src/installerprompt.cpp @@ -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(); + 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 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 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;"); diff --git a/src/installerprompt.h b/src/installerprompt.h index 020b6ca..0bb6471 100644 --- a/src/installerprompt.h +++ b/src/installerprompt.h @@ -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 createSettingsBySSID(const QString &ssid); }; diff --git a/src/installerprompt.ui b/src/installerprompt.ui index 4d524df..814efef 100644 --- a/src/installerprompt.ui +++ b/src/installerprompt.ui @@ -68,668 +68,654 @@ QLabel#logoLabel { 0 - - - - 0 - 20 - 1921 - 1031 - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - QLayout::SetMaximumSize - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 750 - 140 - - - - - 128 - 128 - - - - - Ubuntu - 50 - false - false - - - - false - - - - - - - - - Qt::MarkdownText - - - false - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 18 - 75 - true - - - - Select Your Language: - - - - - - - - 352 - 50 - - - - - 400 - 50 - - - - - 16 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 18 - 75 - true - - - - Select a Wi-Fi Network: - - - - - - - - 352 - 50 - - - - - 400 - 50 - - - - - 16 - - - - - - - - - 100 - 65 - - - - - 16777215 - 65 - - - - - 75 - true - - - - Connect - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - (For advanced network configuration, select "Try Lubuntu") - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 300 - 125 - - - - - 16777215 - 125 - - - - - Ubuntu - 24 - 75 - true - - - - <html><head/><body><p><span style=" font-size:12pt;">Try Lubuntu without installing it on your system. Allows you to use programs, browse the Web, and even temporarily install apps without modifying your system. Changes made within the live environment will be lost when the computer shuts down.</span></p></body></html> - - - false - - - QPushButton { + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + QLayout::SetMaximumSize + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 750 + 140 + + + + + 128 + 128 + + + + + Ubuntu + false + false + + + + false + + + + + + + + + Qt::MarkdownText + + + false + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 18 + true + + + + Select Your Language: + + + + + + + + 352 + 50 + + + + + 400 + 50 + + + + + 16 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 18 + true + + + + Select a Wi-Fi Network: + + + + + + + + 352 + 50 + + + + + 400 + 50 + + + + + 16 + + + + + + + + + 100 + 65 + + + + + 16777215 + 65 + + + + + true + + + + Connect + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + true + + + + (For advanced network configuration, select "Try Lubuntu") + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 300 + 125 + + + + + 16777215 + 125 + + + + + Ubuntu + 24 + true + + + + <html><head/><body><p><span style=" font-size:12pt;">Try Lubuntu without installing it on your system. Allows you to use programs, browse the Web, and even temporarily install apps without modifying your system. Changes made within the live environment will be lost when the computer shuts down.</span></p></body></html> + + + false + + + QPushButton { background-color: rgba(0, 104, 200, 100); color: white; border-radius: 15px; } QToolTip { background-color: rgba(0, 104, 200, 100); color: white; border: 1px solid black; } - - - Try Lubuntu - - - - :/symbol:/symbol - - - - 64 - 64 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 300 - 125 - - - - - 16777215 - 125 - - - - - Ubuntu - 24 - 75 - true - - - - <html><head/><body><p><span style=" font-size:12pt;">Install Lubuntu onto your system. You can install Lubuntu by itself, or alongside an existing operating system.</span></p></body></html> - - - QPushButton { + + + Try Lubuntu + + + + :/symbol:/symbol + + + + 64 + 64 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 300 + 125 + + + + + 16777215 + 125 + + + + + Ubuntu + 24 + true + + + + <html><head/><body><p><span style=" font-size:12pt;">Install Lubuntu onto your system. You can install Lubuntu by itself, or alongside an existing operating system.</span></p></body></html> + + + QPushButton { background-color: rgba(0, 104, 200, 100); color: white; border-radius: 15px; } QToolTip { background-color: rgba(0, 104, 200, 100); color: white; border: 1px solid black; } - - - Install Lubuntu - - - - :/installer:/installer - - - - 64 - 64 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 24 - 75 - true - - - - Connection Status: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + + Install Lubuntu + + + + :/installer:/installer + + + + 64 + 64 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 24 + true + + + + Connection Status: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + +