Finish correct state transitions for WiFi status, next step is actually being able to enter a password
This commit is contained in:
parent
2d7fcde06a
commit
acfd803cd4
@ -44,36 +44,42 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
|
|||||||
initLanguageComboBox();
|
initLanguageComboBox();
|
||||||
|
|
||||||
// Check initial network status and update UI
|
// Check initial network status and update UI
|
||||||
updateConnectionStatus(checkInternetConnection());
|
updateConnectionStatus();
|
||||||
|
|
||||||
// Set up network manager signals for dynamic updates
|
// Set up network manager signals for dynamic updates
|
||||||
auto nm = NetworkManager::notifier();
|
auto nm = NetworkManager::notifier();
|
||||||
connect(nm, &NetworkManager::Notifier::deviceAdded, this, &InstallerPrompt::refreshNetworkList);
|
connect(nm, &NetworkManager::Notifier::deviceAdded, this, &InstallerPrompt::updateConnectionStatus);
|
||||||
connect(nm, &NetworkManager::Notifier::deviceRemoved, this, &InstallerPrompt::refreshNetworkList);
|
connect(nm, &NetworkManager::Notifier::deviceRemoved, this, &InstallerPrompt::updateConnectionStatus);
|
||||||
connect(nm, &NetworkManager::Notifier::networkingEnabledChanged, this, &InstallerPrompt::refreshNetworkList);
|
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() {
|
bool InstallerPrompt::checkInternetConnection() {
|
||||||
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
|
return NetworkManager::status() == NetworkManager::Status::Connected;
|
||||||
if (device->type() == NetworkManager::Device::Wifi) {
|
|
||||||
auto wifiDevice = device.staticCast<NetworkManager::WirelessDevice>();
|
|
||||||
if (!wifiDevice->isActive()) {
|
|
||||||
showWifiOptions();
|
|
||||||
}
|
|
||||||
return wifiDevice->isActive();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallerPrompt::updateConnectionStatus(bool online) {
|
void InstallerPrompt::updateConnectionStatus() {
|
||||||
if (online) {
|
bool online = checkInternetConnection();
|
||||||
ui->connectionStatusLabel->setText(tr("Connected to the internet"));
|
|
||||||
ui->connectWifiButton->setVisible(false);
|
const auto devices = NetworkManager::networkInterfaces();
|
||||||
} else {
|
bool wifiEnabled = false;
|
||||||
ui->connectionStatusLabel->setText(tr("Not connected to the internet"));
|
if (NetworkManager::isNetworkingEnabled()) {
|
||||||
ui->connectWifiButton->setVisible(true);
|
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() {
|
void InstallerPrompt::onConnectWifiClicked() {
|
||||||
@ -135,7 +141,7 @@ void InstallerPrompt::refreshNetworkList() {
|
|||||||
if (!wirelessDevice) {
|
if (!wirelessDevice) {
|
||||||
// No wireless device found, handle appropriately
|
// No wireless device found, handle appropriately
|
||||||
ui->networkComboBox->setVisible(false);
|
ui->networkComboBox->setVisible(false);
|
||||||
connectWifiButton->setVisible(false);
|
ui->connectWiFiButton->setVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +154,7 @@ void InstallerPrompt::refreshNetworkList() {
|
|||||||
|
|
||||||
// Adjust visibility based on whether any networks are found
|
// Adjust visibility based on whether any networks are found
|
||||||
ui->networkComboBox->setVisible(!networks.isEmpty());
|
ui->networkComboBox->setVisible(!networks.isEmpty());
|
||||||
connectWifiButton->setVisible(!networks.isEmpty());
|
ui->connectWiFiButton->setVisible(!networks.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallerPrompt::initLanguageComboBox() {
|
void InstallerPrompt::initLanguageComboBox() {
|
||||||
|
@ -34,14 +34,12 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
Ui::InstallerPrompt *ui;
|
Ui::InstallerPrompt *ui;
|
||||||
QProcess *process;
|
QProcess *process;
|
||||||
QPushButton *connectWifiButton;
|
|
||||||
QLabel *connectionStatusLabel;
|
|
||||||
|
|
||||||
void initLanguageComboBox();
|
void initLanguageComboBox();
|
||||||
QStringList getAvailableLanguages() const;
|
QStringList getAvailableLanguages() const;
|
||||||
bool checkInternetConnection();
|
bool checkInternetConnection();
|
||||||
void showWifiOptions();
|
void showWifiOptions();
|
||||||
void updateConnectionStatus(bool online);
|
void updateConnectionStatus();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INSTALLERPROMPT_H
|
#endif // INSTALLERPROMPT_H
|
||||||
|
@ -277,7 +277,7 @@ QLabel#logoLabel {
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="WiFiLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
@ -307,7 +307,7 @@ QLabel#logoLabel {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="connectWifiButton">
|
<widget class="QPushButton" name="connectWiFiButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
@ -362,7 +362,7 @@ QLabel#logoLabel {
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="WiFiInfoLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user