From e4a21f5c85e5d1079de6f8434bf801e1cb936746 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sat, 2 Apr 2022 10:27:44 -0400 Subject: [PATCH] Wi-Fi icon improvements Don't update it if it isn't necessary. --- mainwindow.cpp | 22 ++++++++++++++++------ mainwindow.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index bc5f7aa..8b34aa9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -66,6 +66,7 @@ MainWindow::MainWindow(QWidget *parent) global::mainwindow::tabSwitcher::repaint = true; resetFullWindowException = false; wifiIconClickedWhileReconnecting = false; + lastWifiState = 0; // Getting the screen's size sW = QGuiApplication::screens()[0]->size().width(); @@ -954,17 +955,26 @@ void MainWindow::setWifiIcon() { global::device::isWifiAble = true; if(checkWifiState() == true) { if(testPing() == 0) { - ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png")); - ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); + if(lastWifiState != 3) { + lastWifiState = 3; + ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png")); + ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); + } } else { - ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png")); - ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); + if(lastWifiState != 2) { + lastWifiState = 2; + ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png")); + ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); + } } } else { - ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png")); - ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); + if(lastWifiState != 1) { + lastWifiState = 1; + ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png")); + ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight)); + } } } else { diff --git a/mainwindow.h b/mainwindow.h index fd29f61..5d0a99a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -49,6 +49,7 @@ public: bool reboot_after_update = false; bool resetFullWindowException; bool wifiIconClickedWhileReconnecting; + int lastWifiState; int timerTime = 0; QString relative_path; QString usbmsStatus;