Finish correct state transitions for WiFi status, next step is actually being able to enter a password

pull/2/head
Simon Quigley 12 months ago
parent 2d7fcde06a
commit acfd803cd4

@ -44,36 +44,42 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
initLanguageComboBox();
// Check initial network status and update UI
updateConnectionStatus(checkInternetConnection());
updateConnectionStatus();
// Set up network manager signals for dynamic updates
auto nm = NetworkManager::notifier();
connect(nm, &NetworkManager::Notifier::deviceAdded, this, &InstallerPrompt::refreshNetworkList);
connect(nm, &NetworkManager::Notifier::deviceRemoved, this, &InstallerPrompt::refreshNetworkList);
connect(nm, &NetworkManager::Notifier::networkingEnabledChanged, this, &InstallerPrompt::refreshNetworkList);
connect(nm, &NetworkManager::Notifier::deviceAdded, this, &InstallerPrompt::updateConnectionStatus);
connect(nm, &NetworkManager::Notifier::deviceRemoved, this, &InstallerPrompt::updateConnectionStatus);
connect(nm, &NetworkManager::Notifier::activeConnectionsChanged, this, &InstallerPrompt::updateConnectionStatus);
connect(nm, &NetworkManager::Notifier::wirelessEnabledChanged, this, &InstallerPrompt::updateConnectionStatus);
connect(nm, &NetworkManager::Notifier::activeConnectionAdded, this, &InstallerPrompt::updateConnectionStatus);
connect(nm, &NetworkManager::Notifier::connectivityChanged, this, &InstallerPrompt::updateConnectionStatus);
connect(nm, &NetworkManager::Notifier::primaryConnectionChanged, this, &InstallerPrompt::updateConnectionStatus);
}
bool InstallerPrompt::checkInternetConnection() {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Wifi) {
auto wifiDevice = device.staticCast<NetworkManager::WirelessDevice>();
if (!wifiDevice->isActive()) {
showWifiOptions();
}
return wifiDevice->isActive();
}
}
return false;
return NetworkManager::status() == NetworkManager::Status::Connected;
}
void InstallerPrompt::updateConnectionStatus(bool online) {
if (online) {
ui->connectionStatusLabel->setText(tr("Connected to the internet"));
ui->connectWifiButton->setVisible(false);
} else {
ui->connectionStatusLabel->setText(tr("Not connected to the internet"));
ui->connectWifiButton->setVisible(true);
void InstallerPrompt::updateConnectionStatus() {
bool online = checkInternetConnection();
const auto devices = NetworkManager::networkInterfaces();
bool wifiEnabled = false;
if (NetworkManager::isNetworkingEnabled()) {
for (const auto &device : devices) {
if (device->type() == NetworkManager::Device::Wifi && NetworkManager::isWirelessEnabled()) wifiEnabled = true;
}
}
bool connectable = !online && wifiEnabled;
if (connectable) refreshNetworkList();
ui->connectionStatusLabel->setText(online ? tr("Connected to the internet") : tr("Not connected to the internet"));
ui->connectWiFiButton->setVisible(connectable);
ui->WiFiLabel->setVisible(connectable);
ui->networkComboBox->setVisible(connectable);
ui->WiFiInfoLabel->setVisible(connectable);
}
void InstallerPrompt::onConnectWifiClicked() {
@ -135,7 +141,7 @@ void InstallerPrompt::refreshNetworkList() {
if (!wirelessDevice) {
// No wireless device found, handle appropriately
ui->networkComboBox->setVisible(false);
connectWifiButton->setVisible(false);
ui->connectWiFiButton->setVisible(false);
return;
}
@ -148,7 +154,7 @@ void InstallerPrompt::refreshNetworkList() {
// Adjust visibility based on whether any networks are found
ui->networkComboBox->setVisible(!networks.isEmpty());
connectWifiButton->setVisible(!networks.isEmpty());
ui->connectWiFiButton->setVisible(!networks.isEmpty());
}
void InstallerPrompt::initLanguageComboBox() {

@ -34,14 +34,12 @@ private slots:
private:
Ui::InstallerPrompt *ui;
QProcess *process;
QPushButton *connectWifiButton;
QLabel *connectionStatusLabel;
void initLanguageComboBox();
QStringList getAvailableLanguages() const;
bool checkInternetConnection();
void showWifiOptions();
void updateConnectionStatus(bool online);
void updateConnectionStatus();
};
#endif // INSTALLERPROMPT_H

@ -277,7 +277,7 @@ QLabel#logoLabel {
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="WiFiLabel">
<property name="font">
<font>
<pointsize>14</pointsize>
@ -307,7 +307,7 @@ QLabel#logoLabel {
</widget>
</item>
<item>
<widget class="QPushButton" name="connectWifiButton">
<widget class="QPushButton" name="connectWiFiButton">
<property name="minimumSize">
<size>
<width>100</width>
@ -362,7 +362,7 @@ QLabel#logoLabel {
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="WiFiInfoLabel">
<property name="font">
<font>
<weight>75</weight>

Loading…
Cancel
Save