Wi-Fi icon improvements

Don't update it if it isn't necessary.
This commit is contained in:
Nicolas Mailloux 2022-04-02 10:27:44 -04:00
parent cfdace7dab
commit e4a21f5c85
2 changed files with 17 additions and 6 deletions

View file

@ -66,6 +66,7 @@ MainWindow::MainWindow(QWidget *parent)
global::mainwindow::tabSwitcher::repaint = true; global::mainwindow::tabSwitcher::repaint = true;
resetFullWindowException = false; resetFullWindowException = false;
wifiIconClickedWhileReconnecting = false; wifiIconClickedWhileReconnecting = false;
lastWifiState = 0;
// Getting the screen's size // Getting the screen's size
sW = QGuiApplication::screens()[0]->size().width(); sW = QGuiApplication::screens()[0]->size().width();
@ -954,17 +955,26 @@ void MainWindow::setWifiIcon() {
global::device::isWifiAble = true; global::device::isWifiAble = true;
if(checkWifiState() == true) { if(checkWifiState() == true) {
if(testPing() == 0) { if(testPing() == 0) {
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png")); if(lastWifiState != 3) {
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); lastWifiState = 3;
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
}
} }
else { else {
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png")); if(lastWifiState != 2) {
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); lastWifiState = 2;
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
}
} }
} }
else { else {
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png")); if(lastWifiState != 1) {
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); lastWifiState = 1;
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
}
} }
} }
else { else {

View file

@ -49,6 +49,7 @@ public:
bool reboot_after_update = false; bool reboot_after_update = false;
bool resetFullWindowException; bool resetFullWindowException;
bool wifiIconClickedWhileReconnecting; bool wifiIconClickedWhileReconnecting;
int lastWifiState;
int timerTime = 0; int timerTime = 0;
QString relative_path; QString relative_path;
QString usbmsStatus; QString usbmsStatus;