diff --git a/inkbox.pro b/inkbox.pro
index 0b7c70d..926528e 100644
--- a/inkbox.pro
+++ b/inkbox.pro
@@ -32,6 +32,9 @@ SOURCES += \
src/apps/calendarapp.cpp \
src/widgets/dialogs/reader/highlightslistdialog.cpp \
src/widgets/dialogs/reader/textdialog.cpp \
+ src/widgets/dialogs/wifi/connectiondialog.cpp \
+ src/widgets/dialogs/wifi/network.cpp \
+ src/widgets/dialogs/wifi/wifilogger.cpp \
src/widgets/reader/dictionarywidget.cpp \
src/encfs/encryptionmanager.cpp \
src/widgets/dialogs/generaldialog.cpp \
@@ -54,7 +57,7 @@ SOURCES += \
src/settings/settingschooser.cpp \
src/widgets/text/textwidget.cpp \
src/widgets/interfaceWidgets/toast.cpp \
- src/splash/usbms_splash.cpp \
+ src/splash/usbmsSplash.cpp \
src/apps/userapps.cpp \
src/widgets/virtualKeyboard/virtualkeyboard.cpp \
src/widgets/virtualKeyboard/virtualkeypad.cpp \
@@ -72,6 +75,9 @@ HEADERS += \
src/apps/calendarapp.h \
src/widgets/dialogs/reader/highlightslistdialog.h \
src/widgets/dialogs/reader/textdialog.h \
+ src/widgets/dialogs/wifi/connectiondialog.h \
+ src/widgets/dialogs/wifi/network.h \
+ src/widgets/dialogs/wifi/wifilogger.h \
src/widgets/reader/dictionarywidget.h \
src/encfs/encryptionmanager.h \
src/functions.h \
@@ -94,7 +100,7 @@ HEADERS += \
src/settings/settingschooser.h \
src/widgets/text/textwidget.h \
src/widgets/interfaceWidgets/toast.h \
- src/splash/usbms_splash.h \
+ src/splash/usbmsSplash.h \
src/apps/userapps.h \
src/widgets/virtualKeyboard/virtualkeyboard.h \
src/widgets/virtualKeyboard/virtualkeypad.h \
@@ -112,6 +118,9 @@ FORMS += \
src/apps/calendarapp.ui \
src/widgets/dialogs/reader/highlightslistdialog.ui \
src/widgets/dialogs/reader/textdialog.ui \
+ src/widgets/dialogs/wifi/connectiondialog.ui \
+ src/widgets/dialogs/wifi/network.ui \
+ src/widgets/dialogs/wifi/wifilogger.ui \
src/widgets/reader/dictionarywidget.ui \
src/encfs/encryptionmanager.ui \
src/widgets/dialogs/generaldialog.ui \
@@ -131,7 +140,7 @@ FORMS += \
src/settings/settingschooser.ui \
src/widgets/text/textwidget.ui \
src/widgets/interfaceWidgets/toast.ui \
- src/splash/usbms_splash.ui \
+ src/splash/usbmsSplash.ui \
src/apps/userapps.ui \
src/widgets/virtualKeyboard/virtualkeyboard.ui \
src/widgets/virtualKeyboard/virtualkeypad.ui \
diff --git a/src/apps/userapps.cpp b/src/apps/userapps.cpp
index 1517aa2..29c156b 100644
--- a/src/apps/userapps.cpp
+++ b/src/apps/userapps.cpp
@@ -185,7 +185,7 @@ bool userapps::manageRequiredFeatures()
if(featureId == 0) {
// Double 'if' conditions to avoid launching unnecesery testPing() in emu
if(global::deviceID != "emu\n") {
- if(testPing(true) != 0) {
+ if(testPing() != 0) {
global::userApps::appCompatibilityText = "This app needs a Wi-Fi connection, continue anyway?";
launchDialog = true;
}
diff --git a/src/eink.qrc b/src/eink.qrc
index ab45a56..91f1794 100644
--- a/src/eink.qrc
+++ b/src/eink.qrc
@@ -84,5 +84,19 @@
resources/highlight.png
resources/unhighlight.png
resources/view-highlights.png
+ resources/stop.png
+ resources/refresh.png
+ resources/hide.png
+ resources/show.png
+ resources/christie.jpg
+ resources/encryption-small.png
+ resources/lock.png
+ resources/public.png
+ resources/wifi-0.png
+ resources/wifi-25.png
+ resources/wifi-50.png
+ resources/wifi-75.png
+ resources/wifi-100.png
+ resources/log.png
diff --git a/src/encfs/encryptionmanager.cpp b/src/encfs/encryptionmanager.cpp
index 34a5e46..7493770 100644
--- a/src/encfs/encryptionmanager.cpp
+++ b/src/encfs/encryptionmanager.cpp
@@ -8,7 +8,7 @@
#include
#include
#include
-#include "usbms_splash.h"
+#include "usbmsSplash.h"
#include "functions.h"
encryptionManager::encryptionManager(QWidget *parent) :
@@ -346,7 +346,7 @@ void encryptionManager::on_usbmsBtn_clicked()
{
log("Showing USBMS splash", className);
global::usbms::launchUsbms = true;
- usbmsWindow = new usbms_splash();
+ usbmsWindow = new usbmsSplash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
usbmsWindow->show();
diff --git a/src/encfs/encryptionmanager.h b/src/encfs/encryptionmanager.h
index ac14c91..e90fdb3 100644
--- a/src/encfs/encryptionmanager.h
+++ b/src/encfs/encryptionmanager.h
@@ -48,7 +48,7 @@ private:
toast * toastWindow;
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
alert * alertWindow;
- usbms_splash *usbmsWindow;
+ usbmsSplash *usbmsWindow;
};
#endif // ENCRYPTIONMANAGER_H
diff --git a/src/functions.h b/src/functions.h
index 7329da0..1060e2a 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -92,7 +92,6 @@ namespace global {
}
namespace toast {
inline QString message;
- inline bool wifiToast;
inline bool modalToast;
inline bool indefiniteToast;
inline int delay;
@@ -100,9 +99,6 @@ namespace global {
namespace device {
inline bool isWifiAble;
}
- namespace network {
- inline bool isConnected;
- }
namespace otaUpdate {
inline bool isUpdateOta;
inline bool downloadOta;
@@ -169,6 +165,22 @@ namespace global {
namespace highlightsListDialog {
inline QString bookPath;
}
+ namespace wifi {
+ enum class wifiState {
+ configured,
+ enabled,
+ disabled,
+ unknown, // To not confuse lastWifiState
+ };
+ inline bool isConnected;
+ class wifiNetworkData {
+ public:
+ QString mac;
+ QString name;
+ bool encryption;
+ int signal;
+ };
+ }
inline QString systemInfoText;
inline bool forbidOpenSearchDialog;
inline bool isN705 = false;
@@ -780,41 +792,6 @@ namespace {
}
}
}
- bool connectToNetwork(QString essid, QString passphrase) {
- log("Connecting to network '" + essid + "'", "functions");
- std::string essid_str = essid.toStdString();
- std::string passphrase_str = passphrase.toStdString();
- string_writeconfig("/run/wifi_network_essid", essid_str);
- string_writeconfig("/run/wifi_network_passphrase", passphrase_str);
- string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n");
-
- int connectionSuccessful = 0;
-
- while(connectionSuccessful == 0) {
- if(QFile::exists("/run/wifi_connected_successfully")) {
- if(checkconfig("/run/wifi_connected_successfully") == true) {
- QFile::remove("/run/wifi_connected_successfully");
- connectionSuccessful = 1;
- global::network::isConnected = true;
- setDefaultWorkDir();
- string_writeconfig(".config/17-wifi_connection_information/essid", essid_str);
- string_writeconfig(".config/17-wifi_connection_information/passphrase", passphrase_str);
- QString function = __func__; log(function + ": Connection successful", "functions");
- return true;
- }
- else {
- QFile::remove("/run/wifi_connected_successfully");
- connectionSuccessful = 0;
- global::network::isConnected = false;
- QString function = __func__; log(function + ": Connection failed", "functions");
- return false;
- }
- }
- else {
- QThread::msleep(100);
- }
- }
- }
int get_warmth() {
QString sysfsWarmthPath;
if(global::deviceID == "n873\n") {
@@ -866,51 +843,6 @@ namespace {
return !!ptr;
}
}
- int testPing(bool blocking) {
- QProcess *pingProcess = new QProcess();
- if(blocking == true) {
- QString pingProg = "ping";
- QStringList pingArgs;
- pingArgs << "-c" << "1" << "1.1.1.1";
- pingProcess->start(pingProg, pingArgs);
- pingProcess->waitForFinished();
- int exitCode = pingProcess->exitCode();
- pingProcess->deleteLater();
- if(exitCode == 0) {
- global::network::isConnected = true;
- }
- else {
- global::network::isConnected = false;
- }
- return exitCode;
- }
- /* For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
- else {
- QString pingProg = "sh";
- QStringList pingArgs;
- pingArgs << "/mnt/onboard/.adds/inkbox/test_ping.sh";
- pingProcess->startDetached(pingProg, pingArgs);
- }
- */
- pingProcess->deleteLater();
- }
- bool getTestPingResults() {
- // To be used when the testPing() function is used in non-blocking mode.
- if(QFile::exists("/run/test_ping_status")) {
- if(checkconfig("/run/test_ping_status") == true) {
- global::network::isConnected = true;
- return true;
- }
- else {
- global::network::isConnected = false;
- return false;
- }
- }
- else {
- global::network::isConnected = false;
- return false;
- }
- }
void updateUserAppsMainJsonFile() {
QDirIterator appsDir("/mnt/onboard/onboard/.apps", QDirIterator::NoIteratorFlags);
QFile newJsonFile = QFile{"/mnt/onboard/onboard/.apps/apps.json"};
@@ -1135,6 +1067,72 @@ namespace {
return 2;
}
}
+ global::wifi::wifiState checkWifiState() {
+ QProcess *wifiStateProcess = new QProcess();
+ QString path = "/external_root/usr/local/bin/wifi/wifi_status.sh";
+ QStringList args;
+ wifiStateProcess->start(path, args);
+ wifiStateProcess->waitForFinished();
+ wifiStateProcess->deleteLater();
+
+ QString currentWifiState;
+ if(QFile("/run/wifi_status").exists() == true) {
+ currentWifiState = readFile("/run/wifi_status");
+ } else {
+ log("/run/wifi_status doesn't exist", "functions");
+ }
+ if (currentWifiState.contains("configured") == true) {
+ global::wifi::isConnected = true;
+ return global::wifi::wifiState::configured;
+ }
+ else if (currentWifiState.contains("enabled") == true) {
+ global::wifi::isConnected = false;
+ return global::wifi::wifiState::enabled;
+ }
+ else if (currentWifiState.contains("disabled") == true) {
+ global::wifi::isConnected = false;
+ return global::wifi::wifiState::disabled;
+ } else {
+ global::wifi::isConnected = false;
+ QString function = __func__; log(function + ": Critical error", "functions");
+ return global::wifi::wifiState::unknown;
+ }
+ }
+ int testPing() {
+ // For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
+ QProcess *pingProcess = new QProcess();
+ QString pingProg = "ping";
+ QStringList pingArgs;
+ pingArgs << "-c" << "1" << "1.1.1.1";
+ pingProcess->start(pingProg, pingArgs);
+ pingProcess->waitForFinished();
+ int exitCode = pingProcess->exitCode();
+ pingProcess->deleteLater();
+ if(exitCode == 0) {
+ global::wifi::isConnected = true;
+ }
+ else {
+ global::wifi::isConnected = false;
+ }
+ return exitCode;
+ }
+ bool checkProcessName(QString name) {
+ QDirIterator appsDir("/proc", QDirIterator::NoIteratorFlags);
+ while (appsDir.hasNext()) {
+ QDir dir(appsDir.next());
+ QFile process = QFile(dir.path() + "/cmdline");
+ if(process.exists() == true) {
+ process.open(QIODevice::ReadOnly);
+ QTextStream stream(&process);
+ if(stream.readLine().contains(name) == true) {
+ process.close();
+ return true;
+ }
+ process.close();
+ }
+ }
+ return false;
+ }
}
#endif // FUNCTIONS_H
diff --git a/src/homeWidget/mainwindow.cpp b/src/homeWidget/mainwindow.cpp
index e2e9cef..4b3406f 100644
--- a/src/homeWidget/mainwindow.cpp
+++ b/src/homeWidget/mainwindow.cpp
@@ -65,8 +65,6 @@ MainWindow::MainWindow(QWidget *parent)
global::usbms::koboxExportExtensions = false;
global::mainwindow::tabSwitcher::repaint = true;
resetFullWindowException = false;
- wifiIconClickedWhileReconnecting = false;
- lastWifiState = 0;
// Getting the screen's size
sW = QGuiApplication::screens()[0]->size().width();
@@ -134,9 +132,13 @@ MainWindow::MainWindow(QWidget *parent)
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
- setWifiIcon();
+ updateWifiAble();
if(global::device::isWifiAble == true) {
- updateWifiIcon(0);
+ // Start Wi-Fi icon updater
+ QTimer *wifiIconTimer = new QTimer(this);
+ wifiIconTimer->setInterval(2500);
+ connect(wifiIconTimer, SIGNAL(timeout()), this, SLOT(updateWifiIcon()));
+ wifiIconTimer->start();
}
setBatteryIcon();
@@ -632,13 +634,13 @@ void MainWindow::setBatteryIcon() {
stdIconHeight = sH / 16;
QPixmap chargingPixmap(":/resources/battery_charging.png");
- QPixmap scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap fullPixmap(":/resources/battery_full.png");
- QPixmap scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap halfPixmap(":/resources/battery_half.png");
- QPixmap scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap emptyPixmap(":/resources/battery_empty.png");
- QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
// Checking battery level and status, then displaying the relevant icon on batteryIcon
if(isUsbPluggedIn() == true) {
@@ -662,13 +664,13 @@ void MainWindow::setBatteryIcon() {
stdIconWidth = sW / 19;
stdIconHeight = sH / 19;
QPixmap chargingPixmap(":/resources/battery_charging.png");
- QPixmap scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap fullPixmap(":/resources/battery_full.png");
- QPixmap scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap halfPixmap(":/resources/battery_half.png");
- QPixmap scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap emptyPixmap(":/resources/battery_empty.png");
- QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
// Checking battery level and status, then displaying the relevant icon on batteryIcon
if(isUsbPluggedIn() == true) {
@@ -709,11 +711,12 @@ void MainWindow::setInitialBrightness() {
// Coming from OOBE setup; not doing that fancy stuff again ;p
QFile::remove("/tmp/oobe-inkbox_completed");
pre_set_brightness(brightness_value);
+ log("Ignoring cinematic brightness call because it has already been done", className);
}
else {
// Fancy brightness fade-in
- if(checkconfig("/tmp/inkbox-cinematic_brightness_auto") == true) {
- QFile::remove("/tmp/inkbox-cinematic_brightness_auto");
+ if(checkconfig("/tmp/inkbox-cinematicBrightness_auto") == true) {
+ QFile::remove("/tmp/inkbox-cinematicBrightness_auto");
cinematicBrightness(brightness_value, 2);
}
else {
@@ -721,6 +724,9 @@ void MainWindow::setInitialBrightness() {
string_writeconfig("/tmp/inkbox-cinematicBrightness_ran", "true");
cinematicBrightness(brightness_value, 0);
}
+ else {
+ log("Ignoring cinematic brightness call because it has already been done", className);
+ }
}
}
}
@@ -749,136 +755,102 @@ void MainWindow::setupSearchDialog() {
}
}
-void MainWindow::updateWifiIcon(int mode) {
+void MainWindow::updateWifiIcon() {
/* Usage:
- * mode 0: auto
- * mode 1: off
- * mode 2: standby
- * mode 3: connected
+ * Mode 0 (looping it) is handled in MainWindow
*/
- if(mode == 0) {
- lastWifiState = 0;
- QTimer *wifiIconTimer = new QTimer(this);
- wifiIconTimer->setInterval(10000);
- connect(wifiIconTimer, SIGNAL(timeout()), this, SLOT(setWifiIcon()));
- wifiIconTimer->start();
- }
- if(mode == 1) {
- lastWifiState = 1;
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
- }
- if(mode == 2) {
- lastWifiState = 2;
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
- }
- if(mode == 3) {
- lastWifiState = 3;
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
- }
-}
-bool MainWindow::checkWifiState() {
- /* Return value:
- * true: interface UP
- * false: interface DOWN
- */
- if(global::deviceID == "n437\n") {
- string_checkconfig_ro("/sys/class/net/wlan0/operstate");
- }
- else {
- string_checkconfig_ro("/sys/class/net/eth0/operstate");
- }
+ global::wifi::wifiState currentWifiState = checkWifiState();
- if(checkconfig_str_val == "up\n") {
- return true;
- }
- else {
- return false;
- }
-}
-
-void MainWindow::setWifiIcon() {
- if(global::device::isWifiAble == true) {
- if(checkWifiState() == true) {
- // testPing() the non-blocking way
- QProcess * pingProcess = new QProcess();
- QString pingProg = "sh";
- QStringList pingArgs;
- pingArgs << "/mnt/onboard/.adds/inkbox/test_ping.sh";
- pingProcess->startDetached(pingProg, pingArgs);
- pingProcess->deleteLater();
-
- getTestPingResults();
- if(global::network::isConnected == true) {
- if(lastWifiState != 3) {
- lastWifiState = 3;
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
- }
+ // It's executing only in enabled mode, which is a mode between connected and disabled, so don't worry about performance
+ if(isConnecting == false and isReconnecting == false) {
+ if(currentWifiState == global::wifi::wifiState::enabled) {
+ if(checkProcessName("connection_manager.sh") == true) {
+ isConnecting = true;
}
- else {
- if(lastWifiState != 2) {
- lastWifiState = 2;
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
- }
- }
- }
- else {
- if(lastWifiState != 1) {
- lastWifiState = 1;
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ else if(checkProcessName("connect_to_network.sh") == true){
+ isConnecting = true;
+ isReconnecting = true;
}
}
}
- else {
+
+ // ms can make a difference, so:
+ currentWifiState = checkWifiState();
+
+ if(lastWifiState != currentWifiState) {
+ if(currentWifiState == global::wifi::wifiState::disabled) {
+ if(isConnecting == true) {
+ if(checkconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped") == false) {
+ if(isReconnecting == true) {
+ showToast("Reconnection failed");
+ isReconnecting = false;
+ }
+ else {
+ showToast("Connection failed");
+ }
+ isConnecting = false;
+ QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").remove();
+ QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase").remove();
+ }
+ else {
+ QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped").remove();
+ }
+ }
+ lastWifiState = global::wifi::wifiState::disabled;
+ ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
+ ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ }
+ if(currentWifiState == global::wifi::wifiState::enabled) {
+ lastWifiState = global::wifi::wifiState::enabled;
+ ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
+ ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ }
+ if(currentWifiState == global::wifi::wifiState::configured) {
+ if(isConnecting == true) {
+ setDefaultWorkDir();
+ if(isReconnecting == true) {
+ showToast("Reconnection successful");
+ isReconnecting = false;
+ }
+ else {
+ showToast("Connection successful");
+ }
+ isConnecting = false;
+ QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped").remove();
+ }
+ lastWifiState = global::wifi::wifiState::configured;
+ ui->wifiBtn->setIcon(QIcon(":/resources/wifi-100.png"));
+ ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ }
+ }
+}
+
+void MainWindow::updateWifiAble() {
+ if(global::device::isWifiAble == false) {
ui->wifiBtn->hide();
ui->line_9->hide();
}
}
-void MainWindow::openWifiDialog() {
- log("Opening Wi-Fi connection interface", className);
- if(checkconfig("/external_root/run/was_connected_to_wifi") == true and wifiIconClickedWhileReconnecting == false) {
- showToast("Reconnection in progress\nTap again to cancel");
- wifiIconClickedWhileReconnecting = true;
- QTimer::singleShot(10000, this, SLOT(resetWifiIconClickedWhileReconnecting()));
- }
- else {
- if(wifiIconClickedWhileReconnecting == true) {
- string_writeconfig("/opt/ibxd", "stop_wifi_reconnection\n");
- while(true) {
- if(QFile::exists("/run/stop_wifi_reconnection_done")) {
- QFile::remove("/run/stop_wifi_reconnection_done");
- break;
- }
- }
- }
- global::toast::wifiToast = true;
- showToast("Searching for networks");
- }
-}
-
void MainWindow::on_wifiBtn_clicked()
{
- openWifiDialog();
+ wifiDialog* newWifiDialog = new wifiDialog();
+ QObject::connect(newWifiDialog, &wifiDialog::showToast, this, &MainWindow::showToast);
+ newWifiDialog->exec();
}
void MainWindow::showToast(QString messageToDisplay) {
global::toast::message = messageToDisplay;
toastWindow = new toast(this);
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
- connect(toastWindow, SIGNAL(updateWifiIconSig(int)), SLOT(updateWifiIcon(int)));
connect(toastWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
connect(toastWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
connect(toastWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
toastWindow->show();
- if(messageToDisplay == "Connection successful") {
+ // I will soon manage the update thing in a more proper way somewhere else... ~ Szybet
+ if(messageToDisplay.contains("onnected successfully") == true) {
// Give the toast some time to vanish away, then launch OTA updater
QTimer::singleShot(5000, this, SLOT(launchOtaUpdater()));
}
@@ -963,7 +935,7 @@ void MainWindow::openEncfsRepackDialog() {
void MainWindow::on_libraryButton_clicked()
{
log("Launching Online Library", className);
- if(testPing(true) == 0 or global::deviceID == "emu\n") {
+ if(testPing() == 0 or global::deviceID == "emu\n") {
resetFullWindowException = true;
resetWindow(false);
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
@@ -1000,7 +972,7 @@ void MainWindow::resetFullWindow() {
}
void MainWindow::checkForOtaUpdate() {
- if(global::network::isConnected == true) {
+ if(global::wifi::isConnected == true) {
string_checkconfig_ro("/external_root/opt/storage/update/last_sync");
if(!checkconfig_str_val.isEmpty()) {
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
@@ -1016,10 +988,6 @@ void MainWindow::checkForOtaUpdate() {
}
}
-void MainWindow::resetWifiIconClickedWhileReconnecting() {
- wifiIconClickedWhileReconnecting = false;
-}
-
void MainWindow::setupLocalLibraryWidget() {
localLibraryWidgetWindow = new localLibraryWidget(this);
QObject::connect(localLibraryWidgetWindow, &localLibraryWidget::openBookSignal, this, &MainWindow::openBookFile);
diff --git a/src/homeWidget/mainwindow.h b/src/homeWidget/mainwindow.h
index 9cebc0c..b793017 100644
--- a/src/homeWidget/mainwindow.h
+++ b/src/homeWidget/mainwindow.h
@@ -8,7 +8,7 @@
#include "reader.h"
#include "quit.h"
#include "alert.h"
-#include "usbms_splash.h"
+#include "usbmsSplash.h"
#include "brightnessdialog.h"
#include "generaldialog.h"
#include "koboxsettings.h"
@@ -51,8 +51,11 @@ public:
bool existing_recent_books = false;
bool reboot_after_update = false;
bool resetFullWindowException;
- bool wifiIconClickedWhileReconnecting;
- int lastWifiState;
+
+ global::wifi::wifiState lastWifiState = global::wifi::wifiState::unknown;
+ bool isConnecting = false;
+ bool isReconnecting = false;
+
int timerTime = 0;
QString relative_path;
QString usbmsStatus;
@@ -62,9 +65,10 @@ public:
void openUsbmsDialog();
void resetIcons();
void setBatteryIcon();
- bool checkWifiState();
public slots:
+ void showToast(QString messageToDisplay);
+ void closeIndefiniteToast();
private slots:
void on_settingsBtn_clicked();
@@ -74,17 +78,14 @@ private slots:
void on_quitBtn_clicked();
void on_brightnessBtn_clicked();
void openUpdateDialog();
- void openWifiDialog();
void setInitialBrightness();
void on_homeBtn_clicked();
void refreshScreen();
void setupSearchDialog();
- void setWifiIcon();
+ void updateWifiAble();
void on_wifiBtn_clicked();
- void updateWifiIcon(int mode);
+ void updateWifiIcon();
void hello(int testNumber);
- void showToast(QString messageToDisplay);
- void closeIndefiniteToast();
void openUpdateDialogOTA(bool open);
void launchOtaUpdater();
void openBookFile(QString book, bool relativePath);
@@ -95,7 +96,6 @@ private slots:
void on_libraryButton_clicked();
void resetWindow(bool resetStackedWidget);
void resetFullWindow();
- void resetWifiIconClickedWhileReconnecting();
void setupLocalLibraryWidget();
void setupHomePageWidget();
@@ -106,7 +106,7 @@ private:
reader * readerWindow;
quit * quitWindow;
alert * alertWindow;
- usbms_splash * usbmsWindow;
+ usbmsSplash * usbmsWindow;
brightnessDialog * brightnessDialogWindow;
generalDialog * generalDialogWindow;
koboxSettings * koboxSettingsWindow;
diff --git a/src/main.cpp b/src/main.cpp
index 6fc6653..bd4fea0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -41,6 +41,7 @@ int main(int argc, char *argv[])
global::logger::status = true;
}
}
+
global::deviceID = readFile("/opt/inkbox_device");
log("Running on device " + global::deviceID, "main", true);
@@ -226,7 +227,7 @@ int main(int argc, char *argv[])
}
const QScreen * screen = qApp->primaryScreen();
- w.setGeometry(QRect(QPoint(0,0), screen->geometry ().size()));
+ w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
w.show();
return a.exec();
}
diff --git a/src/reader/reader.cpp b/src/reader/reader.cpp
index 5893852..2c95bff 100644
--- a/src/reader/reader.cpp
+++ b/src/reader/reader.cpp
@@ -366,30 +366,24 @@ reader::reader(QWidget *parent) :
float sH = QGuiApplication::screens()[0]->size().height();
// Defining what the icons' size will be
if(checkconfig("/opt/inkbox_genuine") == true) {
+ float stdIconWidth;
+ float stdIconHeight;
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "kt\n" or global::deviceID == "emu\n") {
- float stdIconWidth = sW / 16;
- float stdIconHeight = sW / 16;
- QPixmap chargingPixmap(":/resources/battery_charging.png");
- scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
- QPixmap fullPixmap(":/resources/battery_full.png");
- scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
- QPixmap halfPixmap(":/resources/battery_half.png");
- scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
- QPixmap emptyPixmap(":/resources/battery_empty.png");
- scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ stdIconWidth = sW / 16;
+ stdIconHeight = sW / 16;
}
else {
- float stdIconWidth = sW / 19;
- float stdIconHeight = sH / 19;
- QPixmap chargingPixmap(":/resources/battery_charging.png");
- scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
- QPixmap fullPixmap(":/resources/battery_full.png");
- scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
- QPixmap halfPixmap(":/resources/battery_half.png");
- scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
- QPixmap emptyPixmap(":/resources/battery_empty.png");
- scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
+ stdIconWidth = sW / 19;
+ stdIconHeight = sH / 19;
}
+ QPixmap chargingPixmap(":/resources/battery_charging.png");
+ scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ QPixmap fullPixmap(":/resources/battery_full.png");
+ scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ QPixmap halfPixmap(":/resources/battery_half.png");
+ scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ QPixmap emptyPixmap(":/resources/battery_empty.png");
+ scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
else {
float stdIconWidth = sW / 19;
@@ -1282,7 +1276,7 @@ void reader::on_homeBtn_clicked()
// Remount tmpfs
string_writeconfig("/inkbox/remount", "true");
// Specify cinematic brightness mode
- string_writeconfig("/tmp/inkbox-cinematic_brightness_auto", "true");
+ string_writeconfig("/tmp/inkbox-cinematicBrightness_auto", "true");
// Relaunching process
quit_restart();
diff --git a/src/resources/hide.png b/src/resources/hide.png
new file mode 100644
index 0000000..3d2533a
Binary files /dev/null and b/src/resources/hide.png differ
diff --git a/src/resources/log.png b/src/resources/log.png
new file mode 100644
index 0000000..7785a37
Binary files /dev/null and b/src/resources/log.png differ
diff --git a/src/resources/refresh.png b/src/resources/refresh.png
index 6b34e09..e8804d1 100644
Binary files a/src/resources/refresh.png and b/src/resources/refresh.png differ
diff --git a/src/resources/show.png b/src/resources/show.png
new file mode 100644
index 0000000..0694e9c
Binary files /dev/null and b/src/resources/show.png differ
diff --git a/src/resources/stop.png b/src/resources/stop.png
new file mode 100644
index 0000000..0b8f02c
Binary files /dev/null and b/src/resources/stop.png differ
diff --git a/src/settings/koboxsettings.cpp b/src/settings/koboxsettings.cpp
index 119ebf6..1a9e45e 100644
--- a/src/settings/koboxsettings.cpp
+++ b/src/settings/koboxsettings.cpp
@@ -126,7 +126,7 @@ void koboxSettings::on_pushButton_clicked()
log("Exporting KoBox extensions onboard storage via USB", className);
log("Showing USBMS splash", className);
- usbmsWindow = new usbms_splash();
+ usbmsWindow = new usbmsSplash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
usbmsWindow->show();
diff --git a/src/settings/koboxsettings.h b/src/settings/koboxsettings.h
index 43b254a..fbced89 100644
--- a/src/settings/koboxsettings.h
+++ b/src/settings/koboxsettings.h
@@ -4,7 +4,7 @@
#include
#include "generaldialog.h"
-#include "usbms_splash.h"
+#include "usbmsSplash.h"
namespace Ui {
class koboxSettings;
@@ -33,7 +33,7 @@ private slots:
private:
Ui::koboxSettings *ui;
generalDialog *generalDialogWindow;
- usbms_splash *usbmsWindow;
+ usbmsSplash *usbmsWindow;
};
#endif // KOBOXSETTINGS_H
diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp
index 9811b86..3133a81 100644
--- a/src/settings/settings.cpp
+++ b/src/settings/settings.cpp
@@ -846,7 +846,7 @@ void settings::on_globalReadingSettingsCheckBox_toggled(bool checked)
void settings::on_checkOtaUpdateBtn_clicked()
{
log("'Check for OTA update' button clicked", className);
- if(testPing(true) == 0 or global::deviceID == "emu\n") {
+ if(testPing() == 0 or global::deviceID == "emu\n") {
launchOtaUpdater();
}
else {
@@ -901,7 +901,7 @@ void settings::usbms_launch()
log("Showing USBMS splash", className);
global::usbms::launchUsbms = true;
- usbmsWindow = new usbms_splash();
+ usbmsWindow = new usbmsSplash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
usbmsWindow->show();
diff --git a/src/settings/settings.h b/src/settings/settings.h
index 4ad0205..0089283 100644
--- a/src/settings/settings.h
+++ b/src/settings/settings.h
@@ -3,7 +3,7 @@
#include
-#include
+#include
#include "generaldialog.h"
#include "otamanager.h"
#include "toast.h"
@@ -79,7 +79,7 @@ signals:
private:
Ui::settings *ui;
- usbms_splash *usbmsWindow;
+ usbmsSplash *usbmsWindow;
generalDialog *generalDialogWindow;
otaManager *otaManagerWindow;
toast *toastWindow;
diff --git a/src/splash/usbms_splash.cpp b/src/splash/usbmsSplash.cpp
similarity index 94%
rename from src/splash/usbms_splash.cpp
rename to src/splash/usbmsSplash.cpp
index 774b9bd..b99fa90 100644
--- a/src/splash/usbms_splash.cpp
+++ b/src/splash/usbmsSplash.cpp
@@ -1,5 +1,5 @@
-#include "usbms_splash.h"
-#include "ui_usbms_splash.h"
+#include "usbmsSplash.h"
+#include "ui_usbmsSplash.h"
#include
#include
@@ -7,12 +7,12 @@
#include "functions.h"
-usbms_splash::usbms_splash(QWidget *parent) :
+usbmsSplash::usbmsSplash(QWidget *parent) :
QWidget(parent),
- ui(new Ui::usbms_splash)
+ ui(new Ui::usbmsSplash)
{
ui->setupUi(this);
- usbms_splash::setFont(QFont("u001"));
+ usbmsSplash::setFont(QFont("u001"));
ui->label->setFont(QFont("Inter"));
// Getting the screen's size
@@ -60,11 +60,11 @@ usbms_splash::usbms_splash(QWidget *parent) :
if(global::usbms::launchUsbms == true) {
global::usbms::launchUsbms = false;
- usbms_launch();
+ usbmsLaunch();
}
}
-void usbms_splash::usbms_launch()
+void usbmsSplash::usbmsLaunch()
{
log("Entering USBMS session", className);
string_writeconfig("/tmp/in_usbms", "true");
@@ -169,16 +169,17 @@ void usbms_splash::usbms_launch()
usbms_t->start();
}
-usbms_splash::~usbms_splash()
+usbmsSplash::~usbmsSplash()
{
delete ui;
}
-void usbms_splash::brightnessDown() {
+void usbmsSplash::brightnessDown() {
cinematicBrightness(0, 1);
+ writeFile("/tmp/inkbox-cinematicBrightness_ran", "false");
}
-void usbms_splash::quit_restart() {
+void usbmsSplash::quit_restart() {
// If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
@@ -188,7 +189,7 @@ void usbms_splash::quit_restart() {
qApp->quit();
}
-void usbms_splash::restartServices() {
+void usbmsSplash::restartServices() {
// Restarting USBNet
// NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet)
string_writeconfig("/opt/ibxd", "usbnet_start\n");
diff --git a/src/splash/usbms_splash.h b/src/splash/usbmsSplash.h
similarity index 66%
rename from src/splash/usbms_splash.h
rename to src/splash/usbmsSplash.h
index 3d8d8af..cce0038 100644
--- a/src/splash/usbms_splash.h
+++ b/src/splash/usbmsSplash.h
@@ -4,22 +4,22 @@
#include
namespace Ui {
-class usbms_splash;
+class usbmsSplash;
}
-class usbms_splash : public QWidget
+class usbmsSplash : public QWidget
{
Q_OBJECT
public:
QString className = this->metaObject()->className();
- explicit usbms_splash(QWidget *parent = nullptr);
- ~usbms_splash();
+ explicit usbmsSplash(QWidget *parent = nullptr);
+ ~usbmsSplash();
float sW;
float sH;
QString massStorageModule;
- void usbms_launch();
+ void usbmsLaunch();
private slots:
void brightnessDown();
@@ -27,7 +27,7 @@ private slots:
void restartServices();
private:
- Ui::usbms_splash *ui;
+ Ui::usbmsSplash *ui;
};
#endif // USBMS_SPLASH_H
diff --git a/src/splash/usbms_splash.ui b/src/splash/usbmsSplash.ui
similarity index 97%
rename from src/splash/usbms_splash.ui
rename to src/splash/usbmsSplash.ui
index 5b4fde8..57b7cda 100644
--- a/src/splash/usbms_splash.ui
+++ b/src/splash/usbmsSplash.ui
@@ -1,7 +1,7 @@
- usbms_splash
-
+ usbmsSplash
+
0
diff --git a/src/widgets/dialogs/generaldialog.cpp b/src/widgets/dialogs/generaldialog.cpp
index 0a8cd1c..c3d0db0 100644
--- a/src/widgets/dialogs/generaldialog.cpp
+++ b/src/widgets/dialogs/generaldialog.cpp
@@ -337,7 +337,7 @@ void generalDialog::on_okBtn_clicked()
global::usbms::usbmsDialog = false;
global::usbms::launchUsbms = true;
- usbmsWindow = new usbms_splash();
+ usbmsWindow = new usbmsSplash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
usbmsWindow->show();
@@ -419,7 +419,7 @@ void generalDialog::on_okBtn_clicked()
}
}
else if(ui->searchComboBox->currentText() == "Online library") {
- if(testPing(true) == 0 or global::deviceID == "emu\n") {
+ if(testPing() == 0 or global::deviceID == "emu\n") {
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
log("Searching online library for '" + global::keyboard::keyboardText + "'", className);
@@ -495,15 +495,13 @@ void generalDialog::on_okBtn_clicked()
}
else if(global::keyboard::wifiPassphraseDialog == true) {
if(!global::keyboard::keyboardText.isEmpty()) {
- log("Attempting connection to Wi-Fi network '" + wifiEssid + "'", className);
- this->hide();
- wifiPassphrase = global::keyboard::keyboardText;
- global::toast::indefiniteToast = true;
- global::toast::modalToast = true;
- emit showToast("Connecting");
- QTimer::singleShot(100, this, SLOT(connectToNetworkSlot()));
- global::keyboard::wifiPassphraseDialog = false;
- global::keyboard::keyboardDialog = false;
+ if(global::keyboard::keyboardText.count() < 8) {
+ global::toast::delay = 3000;
+ showToast("Minimum passphrase length is 8 characters");
+ }
+ else {
+ generalDialog::close();
+ }
}
else {
global::toast::delay = 3000;
@@ -596,6 +594,7 @@ void generalDialog::restartSearchDialog() {
}
void generalDialog::setupKeyboardDialog() {
+ adjust_size();
ui->stackedWidget->setCurrentIndex(0);
keyboardDialog = true;
ui->stackedWidget->setVisible(true);
@@ -612,7 +611,7 @@ void generalDialog::setupKeyboardDialog() {
}
else if(global::keyboard::wifiPassphraseDialog == true) {
ui->headerLabel->setText("Enter the network's passphrase");
- ui->okBtn->setText("Connect");
+ ui->okBtn->setText("Enter");
ui->cancelBtn->setText("Cancel");
}
else if(global::keyboard::encfsDialog == true) {
@@ -629,6 +628,7 @@ void generalDialog::setupKeyboardDialog() {
connect(keyboardWidget, SIGNAL(adjust_size()), SLOT(adjust_size()));
ui->mainStackedWidget->insertWidget(1, keyboardWidget);
ui->mainStackedWidget->setCurrentIndex(1);
+ adjust_size();
QTimer::singleShot(1000, this, SLOT(adjust_size()));
}
@@ -648,20 +648,6 @@ void generalDialog::startVNC(QString server, QString password, QString port) {
qApp->quit();
}
-void generalDialog::connectToNetworkSlot() {
- if(connectToNetwork(wifiEssid, wifiPassphrase) == true) {
- emit updateWifiIcon(3);
- emit closeIndefiniteToast();
- emit showToast("Connection successful");
- }
- else {
- emit updateWifiIcon(2);
- emit closeIndefiniteToast();
- emit showToast("Connection failed");
- }
- generalDialog::close();
-}
-
void generalDialog::startOtaUpdate(bool wasDownloadSuccessful) {
emit closeIndefiniteToast();
if(wasDownloadSuccessful == true) {
diff --git a/src/widgets/dialogs/generaldialog.h b/src/widgets/dialogs/generaldialog.h
index 08d1001..9f91738 100644
--- a/src/widgets/dialogs/generaldialog.h
+++ b/src/widgets/dialogs/generaldialog.h
@@ -3,7 +3,7 @@
#include
-#include "usbms_splash.h"
+#include "usbmsSplash.h"
#include "textwidget.h"
#include "virtualkeyboard.h"
#include "virtualkeypad.h"
@@ -63,7 +63,6 @@ private slots:
void adjust_size();
void restartSearchDialog();
void refreshScreenNative();
- void connectToNetworkSlot();
void startOtaUpdate(bool wasDownloadSuccessful);
void openBookFileNative(QString book, bool relativePath);
void showToastNative(QString messageToDisplay);
@@ -74,7 +73,7 @@ private slots:
private:
Ui::generalDialog *ui;
- usbms_splash *usbmsWindow;
+ usbmsSplash *usbmsWindow;
textwidget *textwidgetWindow;
virtualkeyboard *keyboardWidget;
virtualkeypad *keypadWidget;
diff --git a/src/widgets/dialogs/kobox/koboxappsdialog.cpp b/src/widgets/dialogs/kobox/koboxappsdialog.cpp
index 2a8dd8f..2ad0c50 100644
--- a/src/widgets/dialogs/kobox/koboxappsdialog.cpp
+++ b/src/widgets/dialogs/kobox/koboxappsdialog.cpp
@@ -166,7 +166,7 @@ void koboxAppsDialog::on_launchBtn_clicked()
// Re-use USBMS splash window for KoBox splash, since it's pretty much the same layout
log("Showing KoBox splash", className);
- usbmsSplashWindow = new usbms_splash();
+ usbmsSplashWindow = new usbmsSplash();
usbmsSplashWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsSplashWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry().size()));
usbmsSplashWindow->show();
diff --git a/src/widgets/dialogs/kobox/koboxappsdialog.h b/src/widgets/dialogs/kobox/koboxappsdialog.h
index f3861f3..fa95967 100644
--- a/src/widgets/dialogs/kobox/koboxappsdialog.h
+++ b/src/widgets/dialogs/kobox/koboxappsdialog.h
@@ -4,7 +4,7 @@
#include
#include
-#include "usbms_splash.h"
+#include "usbmsSplash.h"
namespace Ui {
class koboxAppsDialog;
@@ -36,7 +36,7 @@ signals:
private:
Ui::koboxAppsDialog *ui;
- usbms_splash *usbmsSplashWindow;
+ usbmsSplash *usbmsSplashWindow;
};
#endif // KOBOXAPPSDIALOG_H
diff --git a/src/widgets/dialogs/wifi/connectiondialog.cpp b/src/widgets/dialogs/wifi/connectiondialog.cpp
new file mode 100644
index 0000000..e783dc2
--- /dev/null
+++ b/src/widgets/dialogs/wifi/connectiondialog.cpp
@@ -0,0 +1,387 @@
+#include
+#include
+
+#include "connectiondialog.h"
+#include "ui_connectiondialog.h"
+#include "generaldialog.h"
+#include "functions.h"
+
+connectiondialog::connectiondialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::connectiondialog)
+{
+ ui->setupUi(this);
+ this->setFont(QFont("u001"));
+ ui->passphraseTextEdit->setFont(QFont("Noto Mono"));
+ ui->label->setFont(QFont("Inter"));
+ ui->label_2->setFont(QFont("Inter"));
+
+ // Stylesheet, style & misc.
+ QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
+ stylesheetFile.open(QFile::ReadOnly);
+ this->setStyleSheet(stylesheetFile.readAll());
+ stylesheetFile.close();
+
+ ui->cancelBtn->setProperty("type", "borderless");
+ ui->connectBtn->setProperty("type", "borderless");
+ ui->showPassphraseBtn->setProperty("type", "borderless");
+
+ ui->label->setStyleSheet("font-weight: bold");
+ ui->label_2->setStyleSheet("font-weight: bold");
+
+ ui->cancelBtn->setIcon(QIcon(":/resources/close.png"));
+ ui->connectBtn->setIcon(QIcon(":/resources/arrow-right.png"));
+
+ // Size
+ QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
+ if(global::deviceID == "n705\n") {
+ this->setFixedWidth(screenGeometry.width() / 1.2);
+ }
+ else {
+ this->setFixedWidth(screenGeometry.width() / 1.5);
+ }
+
+ int halfOfHalfHeight = ((screenGeometry.height() / 2) / 2) / 2;
+ int finalHeight;
+ if(global::deviceID == "n705\n") {
+ finalHeight = screenGeometry.height() - halfOfHalfHeight * 5.9;
+ }
+ else {
+ finalHeight = screenGeometry.height() - halfOfHalfHeight * 6.3;
+ }
+
+ this->setFixedHeight(finalHeight);
+
+ // Centering dialog
+ int x = (screenGeometry.width() - this->width()) / 2;
+ int y = (screenGeometry.height() - this->height()) / 2;
+ this->move(x, y);
+}
+
+connectiondialog::~connectiondialog()
+{
+ delete ui;
+}
+
+void connectiondialog::applyVariables() {
+ // Limit name size
+ int truncateThreshold;
+ if(global::deviceID == "n705\n") {
+ truncateThreshold = 20;
+ }
+ else {
+ truncateThreshold = 30;
+ }
+ int nameLength = connectedNetworkData.name.length();
+ QString name = connectedNetworkData.name;
+ if(nameLength > truncateThreshold) {
+ name.chop(nameLength - truncateThreshold);
+ name.append("...");
+ }
+ ui->nameLabel->setText(name);
+ ui->macLabel->setText(connectedNetworkData.mac);
+ ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
+
+ if(connectedNetworkData.encryption == false) {
+ ui->showPassphraseBtn->hide();
+ ui->passphraseTextEdit->setText("No passphrase required");
+ ui->passphraseTextEdit->setDisabled(true);
+ }
+ else {
+ if(passphraseDatabase.exists() == false) {
+ log("Creating empty database", className);
+ // https://forum.qt.io/topic/104791/how-i-can-create-json-format-in-qt/5
+ QJsonObject root;
+ QJsonArray array;
+ QJsonDocument newJsonDocument;
+ root["list"] = array;
+ newJsonDocument.setObject(root);
+
+ passphraseDatabase.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
+ passphraseDatabase.write(newJsonDocument.toJson());
+ passphraseDatabase.flush();
+ passphraseDatabase.close();
+ }
+ QString passphrase = searchDatabase(connectedNetworkData.name);
+ if(passphrase.isEmpty() == false) {
+ log("Found passphrase: '" + passphrase + "'", className);
+ ui->showPassphraseBtn->setIcon(QIcon(":/resources/show.png"));
+ showedPassphrase = false;
+ savedPassphrase = passphrase;
+
+ int passphraseLength = passphrase.length();
+ QString hiddenPassphrase;
+ for(int i = 0; i < passphraseLength; i++) {
+ hiddenPassphrase.append("•");
+ }
+ ui->passphraseTextEdit->setText(hiddenPassphrase);
+ }
+ else {
+ log("No passphrase found", className);
+ ui->passphraseTextEdit->setText("No passphrase was saved");
+ showedPassphrase = true;
+ ui->showPassphraseBtn->hide();
+ }
+ }
+}
+
+QString connectiondialog::searchDatabase(QString key) {
+ passphraseDatabase.open(QIODevice::ReadOnly | QIODevice::Text);
+ QString fileRead = passphraseDatabase.readAll();
+ passphraseDatabase.close();
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(fileRead.toUtf8());
+
+ if(jsonDocument["list"].isArray() == true) {
+ QJsonArray jsonArray = jsonDocument["list"].toArray();
+ for(QJsonValueRef refJsonObject: jsonArray) {
+ QJsonObject jsonMainObject = refJsonObject.toObject();
+ QString searchedName = jsonMainObject.keys().first().toUtf8();
+ log("Found in database: '" + searchedName + "'", className);
+ if(searchedName == key) {
+ QString returnedPassphrase = jsonMainObject.value(key).toString();
+ log("Searched name '" + searchedName + "' matched '" + key + "' and the passphrase is: '" + returnedPassphrase + "'", className);
+ return returnedPassphrase;
+ }
+ else {
+ log("Searched name '" + searchedName + "' doesn't match '" + key + "'", className);
+ }
+ }
+ return "";
+ }
+ else {
+ log("Something went horribly wrong", className);
+ }
+}
+
+void connectiondialog::writeToDatabase(QString name, QString passphrase) {
+ if(searchDatabase(name).isEmpty() == false) {
+ removeFromDatabase(name);
+ }
+
+ passphraseDatabase.open(QIODevice::ReadOnly | QIODevice::Text);
+ QString fileRead = passphraseDatabase.readAll();
+ passphraseDatabase.close();
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(fileRead.toUtf8());
+
+ if(jsonDocument["list"].isArray() == true) {
+ QJsonArray jsonArray = jsonDocument["list"].toArray();
+ QJsonValue newValue;
+
+ // https://stackoverflow.com/questions/26804660/how-to-initialize-qjsonobject-from-qstring
+ // I hoped this would be easier
+ QJsonObject newObject = QJsonDocument::fromJson(QString("{\"" + name + "\" : \"" + passphrase + "\" }").toUtf8()).object();
+ jsonArray.append(newObject);
+
+ QJsonDocument newJsonDocument;
+ QJsonObject root;
+ root["list"] = jsonArray;
+ newJsonDocument.setObject(root);
+
+ passphraseDatabase.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
+ passphraseDatabase.write(newJsonDocument.toJson());
+ passphraseDatabase.flush();
+ passphraseDatabase.close();
+ }
+ else {
+ log("Something went horribly wrong", className);
+ }
+}
+
+void connectiondialog::removeFromDatabase(QString name) {
+ passphraseDatabase.open(QIODevice::ReadOnly | QIODevice::Text);
+ QString fileRead = passphraseDatabase.readAll();
+ passphraseDatabase.close();
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(fileRead.toUtf8());
+
+ int counter = 0;
+ bool remove = false;
+ if(jsonDocument["list"].isArray() == true) {
+ QJsonArray jsonArray = jsonDocument["list"].toArray();
+ for(QJsonValueRef refJsonObject: jsonArray) {
+ QJsonObject jsonMainObject = refJsonObject.toObject();
+ QString searchedName = jsonMainObject.keys().first().toUtf8();
+ log("Found in database: '" + searchedName + "'", className);
+ if(searchedName == name) {
+ remove = true;
+ }
+ if(remove == false) {
+ counter = counter + 1;
+ }
+ }
+ if(remove == true) {
+ jsonArray.removeAt(counter);
+ QJsonDocument newJsonDocument;
+ QJsonObject root;
+ root["list"] = jsonArray;
+ newJsonDocument.setObject(root);
+
+ passphraseDatabase.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
+ passphraseDatabase.write(newJsonDocument.toJson());
+ passphraseDatabase.flush();
+ passphraseDatabase.close();
+ }
+ else {
+ log("ERROR: tried to remove from database, but couldn't find key", className);
+ }
+ }
+}
+
+void connectiondialog::on_cancelBtn_clicked()
+{
+ this->deleteLater();
+ this->close();
+}
+
+void connectiondialog::on_passphraseTextEdit_selectionChanged()
+{
+ ui->passphraseTextEdit->setSelection(0, 0);
+}
+
+void connectiondialog::on_passphraseTextEdit_cursorPositionChanged(int oldpos, int newpos)
+{
+ log("Detected click on text edit widget", className);
+ if(cursorPositionIgnore == true) {
+ if(newpos != 0) {
+ if(showedPassphrase == true) {
+ ui->passphraseTextEdit->setCursorPosition(0);
+ global::keyboard::keyboardDialog = true;
+ global::keyboard::wifiPassphraseDialog = true;
+ global::keyboard::keyboardText = "";
+ generalDialog* generalDialogWindow = new generalDialog();
+ generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
+ generalDialogWindow->wifiEssid = connectedNetworkData.name;
+ connect(generalDialogWindow, &generalDialog::showToast, this, &connectiondialog::showToastSlot);
+ connect(generalDialogWindow, &generalDialog::refreshScreen, this, &connectiondialog::refreshScreenSlot);
+
+ generalDialogWindow->exec();
+
+ global::keyboard::keyboardDialog = false;
+ global::keyboard::wifiPassphraseDialog = false;
+ if(global::keyboard::keyboardText.isEmpty() == false) {
+ // A bit hacky: avoid summoning the keyboard back when the text is changing (and the cursor too) showedPassphrase shouldn't be used for this, but it works and adding another boolean would start being messy
+ showedPassphrase = false;
+ ui->passphraseTextEdit->setText(global::keyboard::keyboardText);
+ ui->showPassphraseBtn->setIcon(QIcon(":/resources/hide.png"));
+ ui->showPassphraseBtn->show();
+ showedPassphrase = true;
+ savedPassphrase = global::keyboard::keyboardText;
+ ui->showPassphraseBtn->show();
+ }
+ global::keyboard::keyboardText = "";
+ }
+ else {
+ log("Passphrase is not saved; ignoring text edit widget call", className);
+ }
+ }
+ }
+ else {
+ log("Ignoring click on text edit widget", className);
+ cursorPositionIgnore = true;
+ }
+}
+
+void connectiondialog::showToastSlot(QString message) {
+ emit showToastSignal(message);
+}
+
+void connectiondialog::on_showPassphraseBtn_clicked()
+{
+ if(showedPassphrase == false) {
+ ui->showPassphraseBtn->setIcon(QIcon(":/resources/hide.png"));
+ ui->passphraseTextEdit->setText(savedPassphrase);
+ showedPassphrase = true;
+ }
+ else {
+ showedPassphrase = false;
+ ui->showPassphraseBtn->setIcon(QIcon(":/resources/show.png"));
+
+ int passphraseLength = searchDatabase(connectedNetworkData.name).length();
+ if(passphraseLength != 0) {
+ QString hiddenPassphrase;
+ for(int i = 0; i < passphraseLength; i++) {
+ hiddenPassphrase.append("•");
+ }
+ ui->passphraseTextEdit->setText(hiddenPassphrase);
+ }
+ else {
+ // This is executed if the user asks to hide the passphrase but it isn't saved yet (upon first connection to a network)
+ QString hiddenPassphrase;
+ int passphraseLength = ui->passphraseTextEdit->text().length();
+ for(int i = 0; i < passphraseLength; i++) {
+ hiddenPassphrase.append("•");
+ }
+ ui->passphraseTextEdit->setText(hiddenPassphrase);
+ }
+ }
+}
+
+void connectiondialog::refreshScreenSlot() {
+ this->repaint();
+ emit refreshScreenSignal();
+}
+
+void connectiondialog::on_connectBtn_clicked()
+{
+ QString finalPassphrase;
+ if(connectedNetworkData.encryption == false) {
+ finalPassphrase = "NONE";
+ }
+ else {
+ if(savedPassphrase.isEmpty() == false) {
+ finalPassphrase = savedPassphrase;
+ writeToDatabase(connectedNetworkData.name, savedPassphrase);
+ }
+ else {
+ showToastSlot("Provide a passphrase first");
+ return void();
+ }
+ }
+ passphraseForReconnecting = finalPassphrase;
+
+ ui->cancelBtn->setEnabled(false);
+ if(checkWifiState() == global::wifi::wifiState::configured) {
+ string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
+ }
+ writeFile("/run/wifi_network_essid", connectedNetworkData.name);
+ writeFile("/run/wifi_network_passphrase", finalPassphrase);
+ finalConnectWait();
+}
+
+void connectiondialog::finalConnectWait() {
+ if(checkIfWifiBusy() == true) {
+ // To be sure
+ if(waitTry == 10) {
+ string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
+ }
+ // Wait for everything to shut down; 10 seconds timeout
+ if(waitTry == 20) {
+ string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
+ emit showToastSignal("Failed to stop other Wi-Fi processes");
+ ui->cancelBtn->setEnabled(true);
+ }
+ else {
+ QTimer::singleShot(500, this, SLOT(finalConnectWait()));
+ waitTry = waitTry + 1;
+ }
+ }
+ else {
+ string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n");
+
+ // This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script
+ log("Writing to config directory with connection information data", className);
+ string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString());
+ string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting.toStdString());
+
+ this->deleteLater();
+ this->close();
+ }
+}
+
+bool connectiondialog::checkIfWifiBusy() {
+ if(checkProcessName("connect_to_network.sh") == true or checkProcessName("connection_manager.sh") == true or checkProcessName("prepare_changing_wifi.sh") == true) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
diff --git a/src/widgets/dialogs/wifi/connectiondialog.h b/src/widgets/dialogs/wifi/connectiondialog.h
new file mode 100644
index 0000000..ab4e1d0
--- /dev/null
+++ b/src/widgets/dialogs/wifi/connectiondialog.h
@@ -0,0 +1,58 @@
+#ifndef CONNECTIONDIALOG_H
+#define CONNECTIONDIALOG_H
+
+#include
+#include "functions.h"
+
+namespace Ui {
+class connectiondialog;
+}
+
+class connectiondialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ QString className = this->metaObject()->className();
+ explicit connectiondialog(QWidget *parent = nullptr);
+ ~connectiondialog();
+ global::wifi::wifiNetworkData connectedNetworkData;
+ QString currentlyConnectedNetworkName;
+ QFile passphraseDatabase = QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrases.json");
+
+signals:
+ void showToastSignal(QString message);
+ void refreshScreenSignal();
+
+public slots:
+ void applyVariables();
+ void showToastSlot(QString message);
+ void refreshScreenSlot();
+
+private slots:
+ // We are opening/loading the JSON database many times, it might not be efficient, but:
+ // 1. It's modular
+ // 2. Those operations are rare
+ QString searchDatabase(QString key);
+ void writeToDatabase(QString name, QString passphrase);
+ void removeFromDatabase(QString name);
+
+ void finalConnectWait();
+ bool checkIfWifiBusy();
+
+ void on_cancelBtn_clicked();
+ void on_passphraseTextEdit_selectionChanged();
+ void on_passphraseTextEdit_cursorPositionChanged(int arg1, int arg2);
+ void on_showPassphraseBtn_clicked();
+ void on_connectBtn_clicked();
+
+private:
+ Ui::connectiondialog *ui;
+ bool cursorPositionIgnore = false;
+ bool showedPassphrase;
+ QString savedPassphrase;
+ int waitTry = 0;
+ QString passphraseForReconnecting;
+};
+
+#endif // CONNECTIONDIALOG_H
diff --git a/src/widgets/dialogs/wifi/connectiondialog.ui b/src/widgets/dialogs/wifi/connectiondialog.ui
new file mode 100644
index 0000000..7c97ade
--- /dev/null
+++ b/src/widgets/dialogs/wifi/connectiondialog.ui
@@ -0,0 +1,189 @@
+
+
+ connectiondialog
+
+
+
+ 0
+ 0
+ 263
+ 136
+
+
+
+ Dialog
+
+
+ -
+
+
+ QLayout::SetFixedSize
+
+
-
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+ BlankCursor
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Signal strength:
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ MAC address:
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
diff --git a/src/widgets/dialogs/wifi/network.cpp b/src/widgets/dialogs/wifi/network.cpp
new file mode 100644
index 0000000..cc50f43
--- /dev/null
+++ b/src/widgets/dialogs/wifi/network.cpp
@@ -0,0 +1,119 @@
+#include "network.h"
+#include "ui_network.h"
+#include "connectiondialog.h"
+
+#include
+
+network::network(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::network)
+{
+ ui->setupUi(this);
+ this->setFont(QFont("u001"));
+
+ // Stylesheet, style & misc.
+ QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
+ stylesheetFile.open(QFile::ReadOnly);
+ this->setStyleSheet(stylesheetFile.readAll());
+ stylesheetFile.close();
+
+ // Buttons
+ ui->encryptionIcon->setProperty("type", "borderless");
+ ui->encryptionIcon->setStyleSheet("QPushButton[type='borderless']:pressed { background: white; color: white; border: none; }");
+ ui->signalStrengthIcon->setProperty("type", "borderless");
+ ui->signalStrengthIcon->setStyleSheet("QPushButton[type='borderless']:pressed { background: white; color: white; border: none; }");
+ ui->enterButton->setProperty("type", "borderless");
+}
+
+network::~network()
+{
+ delete ui;
+}
+
+void network::applyVariables() {
+ log("Applying variables for network", className);
+
+ QString percent = "%";
+ if(mainData.signal < 100) {
+ percent.append(" ");
+ }
+ ui->signalStrengthLabel->setText(QString::number(mainData.signal) + percent);
+
+ // Limit name size
+ int truncateThreshold;
+ if(global::deviceID == "n705\n") {
+ truncateThreshold = 12;
+ }
+ else {
+ truncateThreshold = 20;
+ }
+ int nameLength = mainData.name.length();
+ QString name = mainData.name;
+ if(nameLength > truncateThreshold) {
+ name.chop(nameLength - truncateThreshold);
+ name.append("...");
+ }
+ ui->nameLabel->setText(name);
+
+ if(mainData.encryption == true) {
+ ui->encryptionIcon->setIcon(QIcon(":/resources/lock.png"));
+ }
+ else {
+ ui->encryptionIcon->setIcon(QIcon(":/resources/public.png"));
+ }
+
+ if(currentlyConnectedNetwork == mainData.name) {
+ ui->frame->setStyleSheet(".QFrame{background-color: lightGray; border: 2px solid black; border-radius: 10px;}");
+ ui->signalStrengthLabel->setStyleSheet("background-color: lightGray;");
+ ui->nameLabel->setStyleSheet("background-color: lightGray;");
+ ui->encryptionIcon->setStyleSheet("background-color: lightGray;");
+ ui->enterButton->setStyleSheet("background-color: lightGray;");
+
+ ui->signalStrengthIcon->setStyleSheet("QPushButton {background-color: lightGray; border: none}; QPushButton[type='borderless']:pressed { background: lightGray; color: lightGray; border: none; }");
+ ui->encryptionIcon->setStyleSheet("QPushButton {background-color: lightGray; border: none}; QPushButton[type='borderless']:pressed { background: lightGray; color: lightGray; border: none; }");
+ ui->enterButton->setStyleSheet("QPushButton {background-color: lightGray; border: none}; QPushButton[type='borderless']:pressed { background: lightGray; color: lightGray; border: none; }");
+ }
+ else {
+ ui->frame->setStyleSheet(".QFrame{background-color: white; border: 2px solid black; border-radius: 10px;}");
+ }
+
+ if(mainData.signal >= 0 and mainData.signal <= 25) {
+ ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-0.png"));
+ }
+ else if(mainData.signal >= 25 and mainData.signal < 50) {
+ ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-25.png"));
+ }
+ else if(mainData.signal >= 50 and mainData.signal < 75) {
+ ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-50.png"));
+ }
+ else if(mainData.signal >= 75 and mainData.signal < 100) {
+ ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-75.png"));
+ }
+ else if(mainData.signal == 100) {
+ ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-100.png"));
+ }
+}
+
+void network::on_enterButton_clicked()
+{
+ connectiondialog* newConnectionDialog = new connectiondialog;
+ newConnectionDialog->connectedNetworkData = mainData;
+ newConnectionDialog->currentlyConnectedNetworkName = currentlyConnectedNetwork;
+ newConnectionDialog->applyVariables();
+ connect(newConnectionDialog, &connectiondialog::showToastSignal, this, &network::showToastSlot);
+ connect(newConnectionDialog, &connectiondialog::refreshScreenSignal, this, &network::refreshScreenSlot);
+ newConnectionDialog->exec();
+}
+
+void network::closeWrapper() {
+ this->deleteLater();
+ this->close();
+}
+
+void network::showToastSlot(QString message) {
+ emit showToastSignal(message);
+}
+
+void network::refreshScreenSlot() {
+ emit refreshScreenSignal();
+}
diff --git a/src/widgets/dialogs/wifi/network.h b/src/widgets/dialogs/wifi/network.h
new file mode 100644
index 0000000..2649b0d
--- /dev/null
+++ b/src/widgets/dialogs/wifi/network.h
@@ -0,0 +1,40 @@
+#ifndef NETWORK_H
+#define NETWORK_H
+
+#include
+
+#include "functions.h"
+
+namespace Ui {
+class network;
+}
+
+class network : public QWidget
+{
+ Q_OBJECT
+
+public:
+ QString className = this->metaObject()->className();
+ explicit network(QWidget *parent = nullptr);
+ ~network();
+ global::wifi::wifiNetworkData mainData;
+ QString currentlyConnectedNetwork;
+
+signals:
+ void showToastSignal(QString message);
+ void refreshScreenSignal();
+
+public slots:
+ void applyVariables();
+ void closeWrapper();
+ void showToastSlot(QString message);
+ void refreshScreenSlot();
+
+private slots:
+ void on_enterButton_clicked();
+
+private:
+ Ui::network *ui;
+};
+
+#endif // NETWORK_H
diff --git a/src/widgets/dialogs/wifi/network.ui b/src/widgets/dialogs/wifi/network.ui
new file mode 100644
index 0000000..3a44c2f
--- /dev/null
+++ b/src/widgets/dialogs/wifi/network.ui
@@ -0,0 +1,149 @@
+
+
+ network
+
+
+
+ 0
+ 0
+ 605
+ 62
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+
+ 0
+
+
+ 4
+
+
+ 0
+
+
+ 4
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Plain
+
+
+ 1
+
+
+
+ 16
+
+
+ 10
+
+
+ 3
+
+
+ 10
+
+
-
+
+
+
+
+
+
+ -
+
+
+
+ U001
+
+
+
+ Signal strength
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ 1
+
+
+ Qt::Vertical
+
+
+
+ -
+
+
+
+ U001
+
+
+
+ Wi-Fi network name
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ :/resources/chevron-right.png:/resources/chevron-right.png
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/widgets/dialogs/wifi/wifidialog.cpp b/src/widgets/dialogs/wifi/wifidialog.cpp
index 34e3f6c..971987f 100644
--- a/src/widgets/dialogs/wifi/wifidialog.cpp
+++ b/src/widgets/dialogs/wifi/wifidialog.cpp
@@ -3,18 +3,21 @@
#include
#include
#include
+#include
#include "wifidialog.h"
#include "ui_wifidialog.h"
#include "functions.h"
#include "mainwindow.h"
+#include "network.h"
+#include "wifilogger.h"
wifiDialog::wifiDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::wifiDialog)
{
ui->setupUi(this);
- wifiListTimer = new QTimer(this);
+ this->setFont(QFont("u001"));
// Stylesheet, style & misc.
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
@@ -23,15 +26,60 @@ wifiDialog::wifiDialog(QWidget *parent) :
stylesheetFile.close();
this->setModal(true);
- ui->cancelBtn->setProperty("type", "borderless");
- ui->connectBtn->setProperty("type", "borderless");
- ui->cancelBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
- ui->connectBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
- ui->mainLabel->setStyleSheet("padding-left: 125px; padding-right: 125px");
- ui->networksListWidget->setFont(QFont("u001"));
- ui->networksListWidget->setStyleSheet("font-size: 9pt");
+ ui->wifiCheckBox->setFont(QFont("Inter"));
+ ui->returnBtn->setFont(QFont("Inter"));
+ ui->returnBtn->setStyleSheet("font-weight: bold");
- checkWifiNetworks();
+ ui->refreshBtn->setProperty("type", "borderless");
+ ui->stopBtn->setProperty("type", "borderless");
+ ui->logBtn->setProperty("type", "borderless");
+ ui->returnBtn->setProperty("type", "borderless");
+
+ ui->refreshBtn->setIcon(QIcon(":/resources/refresh.png"));
+ ui->stopBtn->setIcon(QIcon(":/resources/stop.png"));
+ ui->logBtn->setIcon(QIcon(":/resources/log.png"));
+
+ // Size
+ QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
+ this->setFixedWidth(screenGeometry.width() / 1.1);
+
+ int halfOfHalfHeight = ((screenGeometry.height() / 2) / 2) / 2;
+ int finalHeight = screenGeometry.height() - halfOfHalfHeight * 2;
+
+ this->setFixedHeight(finalHeight);
+
+ // Centering dialog
+ int x = (screenGeometry.width() - this->width()) / 2;
+ int y = (screenGeometry.height() - this->height()) / 2;
+ this->move(x, y);
+
+ // Button sizes
+ if(global::deviceID == "n705\n") {
+ ui->refreshBtn->setStyleSheet("padding: 20px;");
+ ui->stopBtn->setStyleSheet("padding: 20px;");
+ ui->logBtn->setStyleSheet("padding: 20px;");
+ }
+ else {
+ ui->refreshBtn->setStyleSheet("padding: 25px;");
+ ui->stopBtn->setStyleSheet("padding: 25px;");
+ ui->logBtn->setStyleSheet("padding: 25px;");
+ }
+
+ // Set Wi-Fi checkbox state. Ignore the first call.
+ global::wifi::wifiState currentWifiState = checkWifiState();
+ if(currentWifiState != global::wifi::wifiState::disabled and currentWifiState != global::wifi::wifiState::unknown) {
+ ui->wifiCheckBox->setChecked(true);
+ // To be sure nothing breaks
+ refreshFromWatcher = true;
+ ui->refreshBtn->click();
+ } else {
+ wifiButtonEnabled = true;
+ ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;");
+ ui->stopBtn->setEnabled(false);
+ }
+
+ // To avoid confusion with reconnecting
+ QTimer::singleShot(0, this, SLOT(watcher()));
}
wifiDialog::~wifiDialog()
@@ -39,105 +87,443 @@ wifiDialog::~wifiDialog()
delete ui;
}
-void wifiDialog::checkWifiNetworks() {
- string_writeconfig("/opt/ibxd", "list_wifi_networks\n");
- wifiListTimer->setInterval(100);
- connect(wifiListTimer, &QTimer::timeout, [&]() {
- if(QFile::exists("/run/wifi_networks_list")) {
- printWifiNetworks();
- wifiListTimer->stop();
+void wifiDialog::on_refreshBtn_clicked()
+{
+ log("Clicked refresh button", className);
+ if(checkWifiState() == global::wifi::wifiState::disabled) {
+ if(refreshFromWatcher == true) {
+ refreshFromWatcher = false;
+ emit showToast("To scan, turn Wi-Fi on first");
}
- } );
- wifiListTimer->start();
-}
-
-void wifiDialog::printWifiNetworks() {
- if(readFile("/run/wifi_networks_list").isEmpty()) {
- log("Wi-Fi networks list empty", className);
- QFile::remove("/run/wifi_networks_list");
- emit quit(1);
- wifiDialog::close();
}
else {
- log("Parsing Wi-Fi networks list", className);
- QFile wifiNetworksListFile("/run/wifi_networks_list");
- wifiNetworksListFile.open(QIODevice::ReadWrite);
- QTextStream in (&wifiNetworksListFile);
- wifiNetworksList = in.readAll();
- wifiNetworksListFile.close();
- QFile::remove("/run/wifi_networks_list");
-
- QStringListModel* model = new QStringListModel(this);
- QStringList list = wifiNetworksList.split("\n", QString::SkipEmptyParts);
- model->setStringList(list);
- ui->networksListWidget->setModel(model);
- ui->networksListWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
-
- emit wifiNetworksListReady(1);
+ refreshFromWatcher = false;
+ launchRefresh();
}
}
-void wifiDialog::centerDialog() {
- // Centering dialog
- // Get current screen size
- QRect rec = QGuiApplication::screenAt(this->pos())->geometry();
- // Using minimum size of window
- QSize size = this->minimumSize();
- // Set top left point
- QPoint topLeft = QPoint((rec.width() / 2) - (size.width() / 2), (rec.height() / 2) - (size.height() / 2));
- // set window position
- setGeometry(QRect(topLeft, size));
+void wifiDialog::launchRefresh() {
+ // Order is important
+ if(scanInProgress == false) {
+ scanInProgress = true;
+ ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: lightGray;");
+ ui->refreshBtn->setEnabled(false);
+
+ elapsedSeconds = 0;
+ fullList.remove();
+ formattedList.remove();
+ writeFile("/opt/ibxd", "list_wifi_networks\n");
+ QTimer::singleShot(0, this, SLOT(refreshWait()));
+ }
+ else {
+ log("Scan is already in progress", className);
+ }
}
-void wifiDialog::on_cancelBtn_clicked()
+void wifiDialog::refreshWait() {
+ if(fullList.exists() == false and formattedList.exists() == false) {
+ if(elapsedSeconds == 6) {
+ emit showToast("Failed to get networks list");
+ ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: white;");
+ ui->refreshBtn->setEnabled(true);
+ scanInProgress = false;
+ }
+ else {
+ elapsedSeconds = elapsedSeconds + 1;
+ QTimer::singleShot(1000, this, SLOT(refreshWait()));
+ }
+ } else {
+ log("Retrieved network list successfully", className);
+ refreshNetworksList();
+ }
+}
+
+void wifiDialog::refreshNetworksList() {
+ emit killNetworkWidgets();
+ QStringList networkList = readFile("/external_root/run/wifi_list_format").split("%%==SPLIT==%%\n");
+ QVector pureNetworkList;
+ for(QString network: networkList) {
+ QStringList data = network.split("\n");
+ int count = 1;
+ global::wifi::wifiNetworkData singleNetwork;
+ if(data.count() < 4) {
+ log("Data lines count is below 4; skipping", className);
+ continue;
+ }
+ for(QString singleData: data) {
+ if(count == 1) {
+ singleNetwork.mac = singleData;
+ log("MAC is: " + singleData, className);
+ }
+ if(count == 2) {
+ if(singleData.isEmpty() == true) {
+ log("Network name is empty", className);
+ }
+ else {
+ log("Network name is: '" + singleData + "'", className);
+ }
+ singleNetwork.name = singleData;
+ }
+ if(count == 3) {
+ log("Encryption type is: " + singleData, className);
+ singleNetwork.encryption = QVariant(singleData).toBool();
+ }
+ if(count == 4) {
+ log("Signal strength is: " + singleData, className);
+ singleNetwork.signal = QVariant(singleData).toInt();
+ }
+ if(count >= 5) {
+ log("Skipping additional items from network information", className);
+ }
+ count = count + 1;
+ }
+ // Filter out remaining empty networks
+ if(singleNetwork.name.isEmpty() == false) {
+ pureNetworkList.append(singleNetwork);
+ }
+ }
+ log("Found " + QString::number(pureNetworkList.count()) + " valid networks", className);
+ if(pureNetworkList.count() == 0) {
+ if(secondScanTry == false) {
+ secondScanTry = true;
+ if(checkWifiState() != global::wifi::wifiState::disabled) {
+ scanInProgress = false;
+ QTimer::singleShot(0, this, SLOT(launchRefresh()));
+ log("No networks found. Trying one more time");
+ return void();
+ }
+ else {
+ return void();
+ }
+ }
+ else {
+ secondScanTry = false;
+ log("No networks found, skipping", className);
+ showToastSlot("No networks found");
+ ui->refreshBtn->setEnabled(true);
+ ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: white;");
+ scanInProgress = false;
+ return void();
+ }
+ }
+ QFile currentWifiNameFile = QFile("/external_root/run/current_wifi_name");
+ currentWifiNameFile.remove();
+ writeFile("/opt/ibxd", "get_current_wifi_name\n");
+ usleep(300000); // 0.3s
+ // Here, it's looking for the currently connected network to put it on top of the list
+ QString currentNetwork = "";
+ if(currentWifiNameFile.exists() == true) {
+ QString currentWifiNetwork = readFile(currentWifiNameFile.fileName());
+ currentWifiNetwork = currentWifiNetwork.replace("\n", "");
+ log("Current network name is: " + currentWifiNetwork, className);
+ int countVec = 0;
+ int vectorNetworkLocation = 9999;
+ for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
+ if(currentWifiNetwork.isEmpty() == false and wifiNetwork.name == currentWifiNetwork) {
+ log("Found current network in vector", className);
+ vectorNetworkLocation = countVec;
+ currentNetwork = wifiNetwork.name;
+ network* connectedNetwork = new network;
+ connectedNetwork->mainData = wifiNetwork;
+ // To be really sure that the the info is put there
+ connectedNetwork->currentlyConnectedNetwork = currentNetwork;
+ connectedNetworkDataParent = wifiNetwork;
+ connectedNetworkDataParentSet = true;
+
+ // This doesn't work, so a layout is needed
+ // ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
+ connectedNetwork->applyVariables();
+ connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::closeWrapper);
+ connect(connectedNetwork, &network::showToastSignal, this, &wifiDialog::showToastSlot);
+ connect(connectedNetwork, &network::refreshScreenSignal, this, &wifiDialog::refreshScreenSlot);
+ ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
+ }
+ else {
+ countVec = countVec + 1;
+ }
+ }
+ if(vectorNetworkLocation != 9999) {
+ log("pureNetworkList size is: " + QString::number(pureNetworkList.count()) + ", entry at " + QString::number(vectorNetworkLocation) + " slated for removal", className);
+ pureNetworkList.removeAt(vectorNetworkLocation);
+ }
+ }
+
+ // Sort based on signal strength
+ QVector sortedPureNetworkList;
+ sortedPureNetworkList.append(pureNetworkList.first());
+ pureNetworkList.removeFirst();
+ // Possible fix for a segmentation fault
+ if(pureNetworkList.isEmpty() == false) {
+ for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
+ bool stopIterating = false;
+ int counter = 0;
+ for(global::wifi::wifiNetworkData wifiNetworkToSort: sortedPureNetworkList) {
+ if(stopIterating == false) {
+ if(wifiNetwork.signal >= wifiNetworkToSort.signal) {
+ sortedPureNetworkList.insert(counter, wifiNetwork);
+ stopIterating = true;
+ }
+ counter = counter + 1;
+ }
+ }
+ // This happens if it's the smallest value, so insert it at the end
+ if(stopIterating == false) {
+ sortedPureNetworkList.append(wifiNetwork);
+ }
+ }
+ }
+ log("There are " + QString::number(sortedPureNetworkList.count()) + " sorted networks", className);
+
+ for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
+ log("Signal strength with sorting: " + QString::number(wifiNetwork.signal), className);
+ }
+
+ // And now, handle the remainder of the networks
+ for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
+ network* connectedNetwork = new network;
+ connectedNetwork->mainData = wifiNetwork;
+ connectedNetwork->currentlyConnectedNetwork = currentNetwork;
+ connectedNetwork->applyVariables();
+ connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::closeWrapper);
+ connect(connectedNetwork, &network::showToastSignal, this, &wifiDialog::showToastSlot);
+ connect(connectedNetwork, &network::refreshScreenSignal, this, &wifiDialog::refreshScreenSlot);
+ ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
+ }
+ scannedAtLeastOnce = true;
+ ui->refreshBtn->setEnabled(true);
+ ui->refreshBtn->setStyleSheet(ui->refreshBtn->styleSheet() + "background-color: white;");
+ scanInProgress = false;
+ secondScanTry = false;
+}
+
+
+void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
{
+ if(ignoreCheckBoxCall == false) {
+ connectedNetworkDataParentSet = false;
+ log("Wi-Fi dialog checkbox clicked: " + QString::number(arg1), className);
+ if(wifiButtonEnabled == true) {
+ if(arg1 == 2) {
+ log("Turning Wi-Fi on", className);
+ // The watcher will scan Wi-Fi
+ QTimer::singleShot(0, this, SLOT(turnOnWifi()));
+ ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: white;");
+ ui->stopBtn->setEnabled(true);
+ } else {
+ log("Turning Wi-Fi off", className);
+ QTimer::singleShot(0, this, SLOT(turnOffWifi()));
+ // To inform the Wi-Fi icon updater to not show the connected/failed to connect message
+ string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
+ ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;");
+ ui->stopBtn->setEnabled(false);
+ }
+ emit killNetworkWidgets();
+ }
+ if(wifiButtonEnabled == false){
+ wifiButtonEnabled = true;
+ }
+ }
+ else {
+ ignoreCheckBoxCall = false;
+ if(checkWifiState() != global::wifi::wifiState::disabled) {
+ emit killNetworkWidgets();
+ forceRefresh = true;
+ }
+ else {
+ emit killNetworkWidgets();
+ }
+ }
+
+}
+
+void wifiDialog::turnOnWifi() {
+ string_writeconfig("/opt/ibxd", "toggle_wifi_on\n");
+ // No one will notice this freeze :>
+ waitToScan();
+}
+
+void wifiDialog::turnOffWifi() {
string_writeconfig("/opt/ibxd", "toggle_wifi_off\n");
- while(true) {
- if(QFile::exists("/run/toggle_wifi_off_done")) {
- QFile::remove("/run/toggle_wifi_off_done");
- break;
+}
+
+void wifiDialog::on_logBtn_clicked()
+{
+ // To avoid half of the information
+ if(scannedAtLeastOnce == false and checkWifiState() == global::wifi::wifiState::configured) {
+ log("Scanning at least once is needed");
+ emit showToast("Scan at least once");
+ } else {
+ wifilogger* wifiLoggerDialog = new wifilogger;
+ if(connectedNetworkDataParentSet == true) {
+ wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
+ wifiLoggerDialog->isThereData = true;
+ }
+ wifiLoggerDialog->exec();
+ }
+}
+
+void wifiDialog::showToastSlot(QString message) {
+ emit showToast(message);
+}
+
+void wifiDialog::refreshScreenSlot() {
+ this->repaint();
+}
+
+/*
+ Some documentation used by the watcher
+ * connection_manager.sh - Manages all things, launches other processes
+ * connect_to_network.sh - All-in-one connection manager. Manages everything, used by IPD, should be used for Wi-Fi reconnections after sleeping/booting
+ * get_dhcp.sh - Gets dhcp addresses
+ * prepare_changing_wifi.sh - Kills everything, prepares to changing network
+ * timesync.sh - Syncs time
+ * toggle.sh - Turns Wi-Fi adapter on/off
+ * list_networks - Lists networks
+ * check_wifi_passphrase.sh - Checks Wi-Fi network passphrase
+ * watcher() first watches at processes that could kill other ones
+*/
+
+void wifiDialog::watcher() {
+ bool killing = checkProcessName("toggle.sh");
+ bool changing = checkProcessName("prepare_changing_wifi.sh");
+ if(killing == true) {
+ setStatusText("Changing Wi-Fi adapter status");
+ isToggleRunning = true;
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ if(changing == true) {
+ setStatusText("Disconnecting from a network or cleaning up");
+ log("prepare_changing_wifi.sh is active", className);
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ bool reconnection = checkProcessName("connect_to_network.sh");
+ if(reconnection == true) {
+ forceRefresh = true;
+ QFile recName = QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid");
+ if(recName.exists() == true) {
+ setStatusText("Reconnecting after suspending to " + readFile(recName.fileName()).replace("\n", ""));
+ }
+ else {
+ // Shouldn't be possible
+ setStatusText("Reconnecting after sleep");
+ }
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ bool listing = checkProcessName("list_networks");
+ if(listing == true) {
+ setStatusText("Scanning available networks");
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ bool dhcp = checkProcessName("get_dhcp.sh");
+ if(dhcp == true) {
+ forceRefresh = true;
+ setStatusText("Getting IP address");
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ bool passphraseCheck = checkProcessName("check_wifi_passphrase.sh");
+ if(passphraseCheck == true) {
+ forceRefresh = true;
+ setStatusText("Checking Wi-Fi network passphrase");
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ bool time = checkProcessName("timesync.sh");
+ if(time == true) {
+ forceRefresh = true;
+ setStatusText("Syncing time");
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ bool connecting = checkProcessName("connection_manager.sh");
+ if(connecting == true) {
+ forceRefresh = true;
+ setStatusText("Connecting to Wi-Fi network");
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
+ return void();
+ }
+
+ if(ui->statusLabel->text() != "Idle") {
+ setStatusText("Idle");
+ }
+
+ if(unlockCheckBox == true) {
+ ui->wifiCheckBox->setEnabled(true);
+ unlockCheckBox = false;
+ }
+
+ if(isToggleRunning == true) {
+ isToggleRunning = false;
+ // Make sure the checkbox is in the right state
+ if(checkWifiState() == global::wifi::wifiState::disabled) {
+ // In this state, ignore forceRefresh to avoid message
+ forceRefresh = false;
+ if(ui->wifiCheckBox->isChecked() == true) {
+ ignoreCheckBoxCall = true;
+ ui->wifiCheckBox->setChecked(false);
+ }
+ }
+ else {
+ if(ui->wifiCheckBox->isChecked() == false) {
+ ignoreCheckBoxCall = true;
+ ui->wifiCheckBox->setChecked(true);
+ }
}
}
- emit quit(0);
- wifiDialog::close();
+
+ if(forceRefresh == true) {
+ forceRefresh = false;
+ refreshFromWatcher = true;
+ QTimer::singleShot(1500, this, SLOT(waitToScan()));
+ }
+
+ QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
}
-void wifiDialog::on_connectBtn_clicked()
+void wifiDialog::setStatusText(QString message) {
+ ui->statusLabel->setText(message);
+}
+
+void wifiDialog::on_stopBtn_clicked()
{
- index = ui->networksListWidget->currentIndex();
- itemText = index.data(Qt::DisplayRole).toString();
- if(itemText.isEmpty()) {
- showToast("You must select a network");
+ log("Stop button was clicked", className);
+ connectedNetworkDataParentSet = false;
+ ui->wifiCheckBox->setEnabled(false);
+ unlockCheckBox = true;
+
+ // To inform the wifi icon GUI to don't show the connected/failed to connect message
+ writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
+ writeFile("/opt/ibxd", "stop_wifi_operations\n");
+
+ QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").remove();
+ QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase").remove();
+
+ // This variable just avoids showing the toast, so it is usable here too
+ waitToScan();
+}
+
+void wifiDialog::on_returnBtn_clicked()
+{
+ this->deleteLater();
+ this->close();
+}
+
+void wifiDialog::waitToScan() {
+ if(checkWifiState() != global::wifi::wifiState::disabled) {
+ ui->refreshBtn->click();
}
else {
- this->hide();
- global::keyboard::keyboardDialog = true;
- global::keyboard::wifiPassphraseDialog = true;
- global::keyboard::keyboardText = "";
- generalDialogWindow = new generalDialog();
- generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
- generalDialogWindow->wifiEssid = itemText;
- connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreenNative()));
- connect(generalDialogWindow, SIGNAL(updateWifiIcon(int)), SLOT(updateWifiIcon(int)));
- connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
- connect(generalDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToastNative()));
- connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(close()));
- generalDialogWindow->show();
+ QTimer::singleShot(750, this, SLOT(waitToScan()));
}
}
-
-void wifiDialog::refreshScreenNative() {
- emit refreshScreen();
-}
-
-void wifiDialog::updateWifiIcon(int mode) {
- emit updateWifiIconSig(mode);
-}
-
-void wifiDialog::showToastNative(QString messageToDisplay) {
- emit showToast(messageToDisplay);
-}
-
-void wifiDialog::closeIndefiniteToastNative() {
- emit closeIndefiniteToast();
-}
diff --git a/src/widgets/dialogs/wifi/wifidialog.h b/src/widgets/dialogs/wifi/wifidialog.h
index cd98c92..92754c5 100644
--- a/src/widgets/dialogs/wifi/wifidialog.h
+++ b/src/widgets/dialogs/wifi/wifidialog.h
@@ -5,6 +5,7 @@
#include
#include "generaldialog.h"
+#include "wifilogger.h"
namespace Ui {
class wifiDialog;
@@ -18,33 +19,60 @@ public:
QString className = this->metaObject()->className();
explicit wifiDialog(QWidget *parent = nullptr);
~wifiDialog();
- QString wifiNetworksList;
- QString itemText;
- QModelIndex index;
- void checkWifiNetworks();
- void printWifiNetworks();
- void centerDialog();
+ global::wifi::wifiNetworkData connectedNetworkDataParent;
+ bool connectedNetworkDataParentSet = false;
private:
Ui::wifiDialog *ui;
- QTimer * wifiListTimer;
- generalDialog * generalDialogWindow;
+ bool wifiButtonEnabled = false;
+ bool scannedAtLeastOnce = false;
+
+ // Variables for refreshWait() and network refresh in general
+ int elapsedSeconds = 0;
+ QFile fullList = QFile("/external_root/run/wifi_list_full");
+ QFile formattedList = QFile("/external_root/run/wifi_list_format");
+
+ // Used by watcher
+ bool forceRefresh = false;
+ int relaunchMs = 300;
+ bool refreshFromWatcher = false;
+ bool unlockCheckBox = false;
+ bool scanInProgress = false;
+
+ bool isToggleRunning = false;
+ bool ignoreCheckBoxCall = false;
+
+ bool secondScanTry = false;
+
+public slots:
+ void launchRefresh();
+ void refreshNetworksList();
+ void showToastSlot(QString message);
+ void refreshScreenSlot();
+
+ // Shows status of Wi-Fi processes, like reconnection and others. Also manages refreshing the networks list after connection
+ void watcher();
signals:
- void wifiNetworksListReady(int networksFound);
- void quit(int exitCode);
void refreshScreen();
void updateWifiIconSig(int mode);
void showToast(QString messageToDisplay);
- void closeIndefiniteToast();
+ void killNetworkWidgets();
private slots:
- void on_cancelBtn_clicked();
- void on_connectBtn_clicked();
- void refreshScreenNative();
- void updateWifiIcon(int mode);
- void showToastNative(QString messageToDisplay);
- void closeIndefiniteToastNative();
+ void on_refreshBtn_clicked();
+ void on_wifiCheckBox_stateChanged(int arg1);
+ void turnOnWifi();
+ void turnOffWifi();
+ void on_logBtn_clicked();
+
+ // This function is a more clever sleep(1), non-blocking
+ void refreshWait();
+
+ void setStatusText(QString message);
+ void on_stopBtn_clicked();
+ void on_returnBtn_clicked();
+ void waitToScan();
};
#endif // WIFIDIALOG_H
diff --git a/src/widgets/dialogs/wifi/wifidialog.ui b/src/widgets/dialogs/wifi/wifidialog.ui
index 10409eb..361f044 100644
--- a/src/widgets/dialogs/wifi/wifidialog.ui
+++ b/src/widgets/dialogs/wifi/wifidialog.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 603
+ 679
@@ -15,82 +15,270 @@
-
-
-
-
-
-
+
+
+ QLayout::SetFixedSize
+
+
-
+
+
+ QLayout::SetMaximumSize
+
+
-
+
+
+ 2
+
+
-
+
+
+ 10
+
+
-
+
+
+
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ Qt::Vertical
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ Qt::Vertical
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Qt::RightToLeft
+
+
+ font-family: Inter; font-weight: bold
+
+
+ Wi-Fi
+
+
+
+
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+
+ u001
+ 9
+
+
+
+ padding-left: 10px; font-family: u001
+
+
+
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Plain
+
+
+ 0
+
+
+ Qt::ScrollBarAsNeeded
+
+
+ Qt::ScrollBarAlwaysOff
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 591
+ 526
+
+
+
+
0
-
-
-
- 0
-
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
0
0
-
- 0
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- -
-
-
-
- 75
- true
-
-
-
- Select a network
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- 0
-
-
-
-
-
- Connect
-
-
-
- -
-
-
- Cancel
-
-
-
-
-
-
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
-
-
-
-
+
+
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ 2
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ Return
+
+
diff --git a/src/widgets/dialogs/wifi/wifilogger.cpp b/src/widgets/dialogs/wifi/wifilogger.cpp
new file mode 100644
index 0000000..1b59149
--- /dev/null
+++ b/src/widgets/dialogs/wifi/wifilogger.cpp
@@ -0,0 +1,206 @@
+#include
+#include
+#include
+
+#include "wifilogger.h"
+#include "ui_wifilogger.h"
+#include "functions.h"
+
+wifilogger::wifilogger(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::wifilogger)
+{
+ ui->setupUi(this);
+ this->setFont(QFont("u001"));
+ // 'Not currently connected to a network' label
+ ui->label_8->setFont(QFont("Inter"));
+ ui->returnBtn->setFont(QFont("Inter"));
+ ui->nameLabel->setFont(QFont("Inter"));
+ ui->allLogsText->setFont(QFont("Noto Mono"));
+ ui->fancyLogsText->setFont(QFont("Noto Mono"));
+ ui->nameLabel->setStyleSheet("font-weight: bold");
+ ui->returnBtn->setStyleSheet("font-weight: bold");
+ ui->allLogsText->setStyleSheet("font-size: 7pt");
+ ui->fancyLogsText->setStyleSheet("font-size: 7pt");
+
+ // Stylesheet, style & misc.
+ QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
+ stylesheetFile.open(QFile::ReadOnly);
+ this->setStyleSheet(stylesheetFile.readAll());
+ stylesheetFile.close();
+ this->setModal(true);
+
+ // Scroll bar
+ // Needed for the nia.
+ // ui->allLogsText->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 50px; }");
+ // ui->fancyLogsText->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 50px; }");
+
+ log("Entered wifilogger", className);
+ setWifiInfoPage();
+ ui->previousBtn->setProperty("type", "borderless");
+ ui->nextBtn->setProperty("type", "borderless");
+ ui->returnBtn->setProperty("type", "borderless");
+ ui->refreshBtn->setProperty("type", "borderless");
+
+ // Size
+ QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
+ this->setFixedWidth(screenGeometry.width() / 1.2);
+
+ int halfOfHalfHeight = ((screenGeometry.height() / 2) / 2) / 2;
+ int finalHeight = screenGeometry.height() - halfOfHalfHeight * 2.4;
+
+ this->setFixedHeight(finalHeight);
+
+ // Centering dialog
+ int x = (screenGeometry.width() - this->width()) / 2;
+ int y = (screenGeometry.height() - this->height()) / 2;
+ this->move(x, y);
+}
+
+wifilogger::~wifilogger()
+{
+ delete ui;
+}
+
+void wifilogger::setWifiInfoPage() {
+ if(checkWifiState() == global::wifi::wifiState::configured) {
+ getWifiInformationTimer.singleShot(0, this, SLOT(getWifiInformation()));
+ ui->stackedWidget->setCurrentIndex(0);
+ ui->nameLabel->setText("Network information");
+ }
+ else {
+ ui->stackedWidget->setCurrentIndex(1);
+ ui->nameLabel->setText("Not connected to a network");
+ }
+}
+
+void wifilogger::setFancyLoggingPage() {
+ updateLogs();
+ ui->stackedWidget->setCurrentIndex(2);
+ ui->nameLabel->setText("Important logs");
+}
+
+void wifilogger::setAllLogsPage() {
+ updateLogs();
+ ui->stackedWidget->setCurrentIndex(3);
+ ui->nameLabel->setText("All logs");
+}
+
+void wifilogger::on_nextBtn_clicked()
+{
+ if(currentPage == 2) {
+ currentPage = 0;
+ }
+ else {
+ currentPage = currentPage + 1;
+ }
+ changePage();
+}
+
+void wifilogger::on_previousBtn_clicked()
+{
+ if(currentPage == 0) {
+ currentPage = 2;
+ }
+ else {
+ currentPage = currentPage - 1;
+ }
+ changePage();
+}
+
+void wifilogger::changePage() {
+ if(currentPage == 0) {
+ setWifiInfoPage();
+ }
+ else if(currentPage == 1) {
+ setFancyLoggingPage();
+ }
+ else if(currentPage == 2) {
+ setAllLogsPage();
+ }
+ else {
+ log("This shouldn't happen", className);
+ }
+}
+
+void wifilogger::getWifiInformation() {
+ log("Retrieving Wi-Fi information", className);
+ QFile wifiInformationPath = QFile("/external_root/run/wifi_information");
+ if(waitingForFile == false) {
+ wifiInformationPath.remove();
+ log("Sending get_wifi_information ibxd call", className);
+ string_writeconfig("/opt/ibxd", "get_wifi_information\n");
+ waitingForFile = true;
+ }
+
+ if(waitingForFile == true) {
+ if(wifiInformationPath.exists() == false) {
+ getWifiInformationTimer.singleShot(1000, this, SLOT(getWifiInformation()));
+ return void();
+ }
+ }
+
+ waitingForFile = false;
+ log("Setting variables", className);
+ QString wifiInfo = readFile(wifiInformationPath.fileName());
+ QStringList wifiInfoList = wifiInfo.split("\n");
+ int counter = 0;
+ for(QString infomation: wifiInfoList) {
+ if(counter == 0) {
+ ui->netNameLabel->setText(infomation);
+ }
+ if(counter == 1) {
+ ui->ipLabel->setText(infomation);
+ }
+ if(counter == 2) {
+ ui->maskLabel->setText(infomation);
+ }
+ if(counter == 3) {
+ ui->gatewayLabel->setText(infomation);
+ }
+ counter = counter + 1;
+ }
+
+ if(isThereData == true) {
+ ui->encryptionLabel->setText(QVariant(connectedNetworkData.encryption).toString());
+ ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
+ ui->macLabel->setText(connectedNetworkData.mac);
+ }
+ else {
+ // Shouldn't happen for 99%, but if anyway... it's designed to be non-blocking, so I can't really wait for this.
+ ui->encryptionLabel->setText("Rescan needed");
+ ui->signalLabel->setText("Rescan needed");
+ ui->macLabel->setText("Rescan needed");
+ }
+}
+
+
+void wifilogger::on_returnBtn_clicked()
+{
+ log("Exiting wifilogger", className);
+ getWifiInformationTimer.stop();
+ this->deleteLater();
+ this->close();
+}
+
+void wifilogger::updateLogs() {
+ if(fancyLogs.exists() == true and allLogs.exists() == true) {
+ QString fancyLogsText = readFile(fancyLogs.fileName());
+ QString allLogsText = readFile(allLogs.fileName());
+
+ ui->fancyLogsText->setText(fancyLogsText);
+ ui->allLogsText->setText(allLogsText);
+ }
+}
+
+void wifilogger::on_refreshBtn_clicked()
+{
+ if(currentPage == 0) {
+ if(waitingForFile == false) {
+ setWifiInfoPage();
+ }
+ }
+ else {
+ updateLogs();
+ }
+}
diff --git a/src/widgets/dialogs/wifi/wifilogger.h b/src/widgets/dialogs/wifi/wifilogger.h
new file mode 100644
index 0000000..e10bd92
--- /dev/null
+++ b/src/widgets/dialogs/wifi/wifilogger.h
@@ -0,0 +1,49 @@
+#ifndef WIFILOGGER_H
+#define WIFILOGGER_H
+
+#include
+#include "functions.h"
+
+namespace Ui {
+class wifilogger;
+}
+
+class wifilogger : public QDialog
+{
+ Q_OBJECT
+
+public:
+ QString className = this->metaObject()->className();
+ explicit wifilogger(QWidget *parent = nullptr);
+ ~wifilogger();
+ global::wifi::wifiNetworkData connectedNetworkData;
+ // To the above value
+ bool isThereData = false;
+
+private:
+ Ui::wifilogger *ui;
+ /*
+ * 0 Is Wi-Fi info/no Wi-Fi info page
+ * 1 Is fancy logs page
+ * 2 Is all logs page
+ */
+ int currentPage = 0;
+ QFile fancyLogs = QFile("/external_root/run/wifi_stats");
+ QFile allLogs = QFile("/external_root/var/log/wifi.log");
+ bool waitingForFile = false;
+ QTimer getWifiInformationTimer;
+
+private slots:
+ void setWifiInfoPage();
+ void setFancyLoggingPage();
+ void setAllLogsPage();
+ void on_nextBtn_clicked();
+ void on_previousBtn_clicked();
+ void changePage();
+ void getWifiInformation();
+ void on_returnBtn_clicked();
+ void updateLogs();
+ void on_refreshBtn_clicked();
+};
+
+#endif // WIFILOGGER_H
diff --git a/src/widgets/dialogs/wifi/wifilogger.ui b/src/widgets/dialogs/wifi/wifilogger.ui
new file mode 100644
index 0000000..2c4a561
--- /dev/null
+++ b/src/widgets/dialogs/wifi/wifilogger.ui
@@ -0,0 +1,565 @@
+
+
+ wifilogger
+
+
+
+ 0
+ 0
+ 476
+ 317
+
+
+
+
+ 0
+ 0
+
+
+
+ Dialog
+
+
+ -
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 460
+ 210
+
+
+
+
+ 9
+
+
+ 9
+
+
+ 9
+
+
+ 9
+
+
-
+
+
+ 0
+
+
+ 0
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Network name:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ false
+ true
+
+
+
+ IP address:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Mask:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Gateway:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Passphrase-protected:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Signal strength:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ MAC address:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ Inter
+ 75
+ true
+
+
+
+ font-family: Inter; font-weight: bold
+
+
+ 0
+
+
+ Not currently connected to a network
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Qt::NoTextInteraction
+
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Qt::NoTextInteraction
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+
+
+
+ :/resources/chevron-left.png:/resources/chevron-left.png
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
+ :/resources/chevron-right.png:/resources/chevron-right.png
+
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ Return
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ Qt::Vertical
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ :/resources/refresh.png:/resources/refresh.png
+
+
+
+
+
+ -
+
+
+ QFrame::Plain
+
+
+ 2
+
+
+ Qt::Horizontal
+
+
+
+
+
+
+
+
+
+
diff --git a/src/widgets/interfaceWidgets/toast.cpp b/src/widgets/interfaceWidgets/toast.cpp
index 305d4f8..c89a439 100644
--- a/src/widgets/interfaceWidgets/toast.cpp
+++ b/src/widgets/interfaceWidgets/toast.cpp
@@ -27,27 +27,12 @@ toast::toast(QWidget *parent) :
global::toast::delay = 5000;
}
}
- if(global::toast::wifiToast == true) {
- global::toast::wifiToast = false;
- this->setModal(true);
- wifiDialogWindow = new wifiDialog(this);
- wifiDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
- connect(wifiDialogWindow, SIGNAL(wifiNetworksListReady(int)), SLOT(showWifiDialog(int)));
- connect(wifiDialogWindow, SIGNAL(quit(int)), SLOT(exitSlot(int)));
- connect(wifiDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreenNative()));
- connect(wifiDialogWindow, SIGNAL(updateWifiIconSig(int)), SLOT(updateWifiIcon(int)));
- connect(wifiDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
- connect(wifiDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToastNative()));
- connect(wifiDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(close()));
+ if(global::toast::indefiniteToast == false) {
+ QTimer::singleShot(global::toast::delay, this, SLOT(close()));
+ global::toast::delay = 0;
}
else {
- if(global::toast::indefiniteToast == false) {
- QTimer::singleShot(global::toast::delay, this, SLOT(close()));
- global::toast::delay = 0;
- }
- else {
- global::toast::indefiniteToast = false;
- }
+ global::toast::indefiniteToast = false;
}
}
@@ -56,16 +41,6 @@ toast::~toast()
delete ui;
}
-void toast::showWifiDialog(int networksFound) {
- if(networksFound == 1) {
- emit updateWifiIconSig(2);
- this->hide();
- wifiDialogWindow->show();
- wifiDialogWindow->adjustSize();
- wifiDialogWindow->centerDialog();
- }
-}
-
void toast::centerToast() {
// Centering toast (https://stackoverflow.com/a/58682351)
// Get current screen size
@@ -91,10 +66,6 @@ void toast::refreshScreenNative() {
emit refreshScreen();
}
-void toast::updateWifiIcon(int mode) {
- emit updateWifiIconSig(mode);
-}
-
void toast::showToastNative(QString messageToDisplay) {
emit showToast(messageToDisplay);
}
diff --git a/src/widgets/interfaceWidgets/toast.h b/src/widgets/interfaceWidgets/toast.h
index fa1cac8..5b4b427 100644
--- a/src/widgets/interfaceWidgets/toast.h
+++ b/src/widgets/interfaceWidgets/toast.h
@@ -21,13 +21,10 @@ public:
private:
Ui::toast *ui;
- wifiDialog *wifiDialogWindow;
private slots:
- void showWifiDialog(int networksFound);
void exitSlot(int exitCode);
void refreshScreenNative();
- void updateWifiIcon(int mode);
void showToastNative(QString messageToDisplay);
void closeIndefiniteToastNative();