mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
fixes :(
This commit is contained in:
parent
2acd7adf1f
commit
e310544fb5
11 changed files with 271 additions and 83 deletions
|
@ -132,12 +132,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
|
||||
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
|
||||
|
||||
updateWifiState();
|
||||
updateWifiAble();
|
||||
if(global::device::isWifiAble == true) {
|
||||
// Start wifi updater
|
||||
QTimer *wifiIconTimer = new QTimer(this);
|
||||
wifiIconTimer->setInterval(5000);
|
||||
connect(wifiIconTimer, SIGNAL(timeout()), this, SLOT(updateWifiState()));
|
||||
wifiIconTimer->setInterval(2500);
|
||||
connect(wifiIconTimer, SIGNAL(timeout()), this, SLOT(updateWifiIcon()));
|
||||
wifiIconTimer->start();
|
||||
}
|
||||
setBatteryIcon();
|
||||
|
@ -751,37 +751,84 @@ void MainWindow::setupSearchDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateWifiIcon(global::wifi::WifiState mode) {
|
||||
void MainWindow::updateWifiIcon() {
|
||||
/* Usage:
|
||||
* mode 0 is handled in mainwindow()
|
||||
* Mode 0 (looping it) is handled in mainwindow()
|
||||
*/
|
||||
if(mode == global::wifi::WifiState::Disabled) {
|
||||
lastWifiState = global::wifi::WifiState::Disabled;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
if(mode == global::wifi::WifiState::Enabled) {
|
||||
lastWifiState = global::wifi::WifiState::Enabled;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
if(mode == global::wifi::WifiState::Configured) {
|
||||
lastWifiState = global::wifi::WifiState::Configured;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateWifiState() {
|
||||
if(global::device::isWifiAble == true) {
|
||||
global::wifi::WifiState currentWifiState = checkWifiState();
|
||||
if(lastWifiState != currentWifiState) {
|
||||
// This is handled by updateWifiIcon()
|
||||
//lastWifiState = currentWifiState;
|
||||
updateWifiIcon(currentWifiState);
|
||||
|
||||
global::wifi::WifiState currentWifiState = checkWifiState();
|
||||
|
||||
// Its executing only in Enabled mode, which is a mode between connected and disabled so don't worry about performance
|
||||
if(isConnecting == false and isReconecting == false) {
|
||||
if(currentWifiState == global::wifi::WifiState::Enabled) {
|
||||
if(checkProcessName("connection_manager.sh") == true) {
|
||||
isConnecting = true;
|
||||
}
|
||||
else if(checkProcessName("connect_to_network.sh") == true){
|
||||
isConnecting = true;
|
||||
isReconecting = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if(lastWifiState != currentWifiState) {
|
||||
if(currentWifiState == global::wifi::WifiState::Disabled) {
|
||||
if(isConnecting == true) {
|
||||
setDefaultWorkDir();
|
||||
if(checkconfig(".config/17-wifi_connection_information/stopped") == false) {
|
||||
QString wifiName = readFile(".config/17-wifi_connection_information/essid").replace("\n", "");
|
||||
if(isReconecting == true) {
|
||||
showToast("Failed to reconnect to " + wifiName);
|
||||
isReconecting = false;
|
||||
}
|
||||
else {
|
||||
showToast("Failed to connect to " + wifiName);
|
||||
}
|
||||
isConnecting = false;
|
||||
QFile(".config/17-wifi_connection_information/essid").remove();
|
||||
QFile(".config/17-wifi_connection_information/passphrase").remove();
|
||||
}
|
||||
else {
|
||||
QFile(".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();
|
||||
QString wifiName = readFile(".config/17-wifi_connection_information/essid").replace("\n", "");
|
||||
if(isReconecting == true) {
|
||||
showToast("Reconnected successfully to " + wifiName);
|
||||
isReconecting = false;
|
||||
}
|
||||
else {
|
||||
showToast("Connected successfully to " + wifiName);
|
||||
}
|
||||
isConnecting = false;
|
||||
QFile(".config/17-wifi_connection_information/essid").remove();
|
||||
QFile(".config/17-wifi_connection_information/passphrase").remove();
|
||||
QFile(".config/17-wifi_connection_information/stopped").remove();
|
||||
}
|
||||
lastWifiState = global::wifi::WifiState::Configured;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::updateWifiAble() {
|
||||
if(global::device::isWifiAble == false) {
|
||||
ui->wifiBtn->hide();
|
||||
ui->line_9->hide();
|
||||
}
|
||||
|
@ -798,13 +845,13 @@ 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 propper 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()));
|
||||
}
|
||||
|
|
|
@ -51,7 +51,11 @@ public:
|
|||
bool existing_recent_books = false;
|
||||
bool reboot_after_update = false;
|
||||
bool resetFullWindowException;
|
||||
|
||||
global::wifi::WifiState lastWifiState = global::wifi::WifiState::Unknown;
|
||||
bool isConnecting = false;
|
||||
bool isReconecting = false;
|
||||
|
||||
int timerTime = 0;
|
||||
QString relative_path;
|
||||
QString usbmsStatus;
|
||||
|
@ -78,9 +82,9 @@ private slots:
|
|||
void on_homeBtn_clicked();
|
||||
void refreshScreen();
|
||||
void setupSearchDialog();
|
||||
void updateWifiState();
|
||||
void updateWifiAble();
|
||||
void on_wifiBtn_clicked();
|
||||
void updateWifiIcon(global::wifi::WifiState mode);
|
||||
void updateWifiIcon();
|
||||
void hello(int testNumber);
|
||||
void openUpdateDialogOTA(bool open);
|
||||
void launchOtaUpdater();
|
||||
|
|
|
@ -65,7 +65,7 @@ void connectiondialog::applyVariables() {
|
|||
if(password.isEmpty() == false) {
|
||||
log("found password: " + password, className);
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/show.png"));
|
||||
showedPasword = false;
|
||||
showedPassword = false;
|
||||
savedPassword = password;
|
||||
|
||||
ui->passwordTextEdit->setText("********");
|
||||
|
@ -189,10 +189,10 @@ void connectiondialog::on_passwordTextEdit_selectionChanged()
|
|||
|
||||
void connectiondialog::on_passwordTextEdit_cursorPositionChanged(int oldpos, int newpos)
|
||||
{
|
||||
log("detected click on text edit", className);
|
||||
log("Detected click on text edit", className);
|
||||
if(cursorPositionIgnore == true) {
|
||||
if(newpos != 0) {
|
||||
if(showedPasword == true) {
|
||||
if(showedPassword == true) {
|
||||
ui->passwordTextEdit->setCursorPosition(0);
|
||||
global::keyboard::keyboardDialog = true;
|
||||
global::keyboard::wifiPassphraseDialog = true;
|
||||
|
@ -208,12 +208,12 @@ void connectiondialog::on_passwordTextEdit_cursorPositionChanged(int oldpos, int
|
|||
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 ) showedPasword shouldnt be used for this, but it works and adding another bool would start being messy
|
||||
showedPasword = false;
|
||||
// A bit hacky: avoid summoning the keyboard back when the text is changing ( and the cursor too ) showedPassword shouldnt be used for this, but it works and adding another bool would start being messy
|
||||
showedPassword = false;
|
||||
ui->passwordTextEdit->setText(global::keyboard::keyboardText);
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/hide.png"));
|
||||
ui->showPasswordBtn->show();
|
||||
showedPasword = true;
|
||||
showedPassword = true;
|
||||
savedPassword = global::keyboard::keyboardText;
|
||||
}
|
||||
global::keyboard::keyboardText = "";
|
||||
|
@ -232,13 +232,13 @@ void connectiondialog::showToastSlot(QString message) {
|
|||
|
||||
void connectiondialog::on_showPasswordBtn_clicked()
|
||||
{
|
||||
if(showedPasword == false) {
|
||||
if(showedPassword == false) {
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/hide.png"));
|
||||
ui->passwordTextEdit->setText(savedPassword);
|
||||
showedPasword = true;
|
||||
showedPassword = true;
|
||||
}
|
||||
else {
|
||||
showedPasword = false;
|
||||
showedPassword = false;
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/show.png"));
|
||||
ui->passwordTextEdit->setText("********");
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ void connectiondialog::on_connectBtn_clicked()
|
|||
string_writeconfig("/run/wifi_network_essid", connectedNetworkData.name.toStdString());
|
||||
string_writeconfig("/run/wifi_network_passphrase", finalPassword.toStdString());
|
||||
setDefaultWorkDir();
|
||||
// this will be deleited later in mainwindow icon updater if it failed
|
||||
// This will be deleited later in mainwindow icon updater if it failed
|
||||
string_writeconfig(".config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString());
|
||||
string_writeconfig(".config/17-wifi_connection_information/passphrase", finalPassword.toStdString());
|
||||
finalConnectWait();
|
||||
|
|
|
@ -31,8 +31,8 @@ public slots:
|
|||
|
||||
private slots:
|
||||
// I know im opening / loading json many times, its maybe not efficient but:
|
||||
// 1. its modular
|
||||
// 2. those operations are rare
|
||||
// 1. Its modular
|
||||
// 2. Those operations are rare
|
||||
QString searchDatabase(QString key);
|
||||
void writeToDatabase(QString name, QString password);
|
||||
void removeFromDatabase(QString name);
|
||||
|
@ -54,7 +54,7 @@ private slots:
|
|||
private:
|
||||
Ui::connectiondialog *ui;
|
||||
bool cursorPositionIgnore = false;
|
||||
bool showedPasword;
|
||||
bool showedPassword;
|
||||
QString savedPassword;
|
||||
int waitTry = 0;
|
||||
};
|
||||
|
|
|
@ -29,9 +29,10 @@ network::~network()
|
|||
}
|
||||
|
||||
void network::applyVariables() {
|
||||
log("Applying variables for network", className);
|
||||
ui->signalStrengthLabel->setText(QString::number(mainData.signal) + "%");
|
||||
|
||||
// limit name size, maybe device specific
|
||||
// Limit name size, maybe device specific
|
||||
QString cuttedSingleData = mainData.name;
|
||||
if(cuttedSingleData.count() > 27)
|
||||
{
|
||||
|
|
|
@ -61,8 +61,13 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
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("background-color:grey;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
|
@ -173,24 +178,31 @@ void wifiDialog::on_refreshBtn_clicked()
|
|||
{
|
||||
log("Clicked refresh button", className);
|
||||
if(checkWifiState() == global::wifi::WifiState::Disabled) {
|
||||
emit showToast("To scan, turn on wi-fi first");
|
||||
log("To scan, turn on wi-fi first", className);
|
||||
if(refreshFromWatcher == true) {
|
||||
refreshFromWatcher = false;
|
||||
emit showToast("To scan, turn on wi-fi first");
|
||||
log("To scan, turn on wi-fi first", className);
|
||||
}
|
||||
}
|
||||
else {
|
||||
refreshFromWatcher = false;
|
||||
launchRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
void wifiDialog::launchRefresh() {
|
||||
// Order is important
|
||||
ui->refreshBtn->setStyleSheet("background-color:grey;");
|
||||
ui->refreshBtn->setEnabled(false);
|
||||
if(scanInProgress == false) {
|
||||
scanInProgress = true;
|
||||
ui->refreshBtn->setStyleSheet("background-color:grey;");
|
||||
ui->refreshBtn->setEnabled(false);
|
||||
|
||||
elapsedSeconds = 0;
|
||||
fullList.remove();
|
||||
formattedList.remove();
|
||||
string_writeconfig("/opt/ibxd", "list_wifi_networks\n");
|
||||
QTimer::singleShot(0, this, SLOT(refreshWait()));
|
||||
elapsedSeconds = 0;
|
||||
fullList.remove();
|
||||
formattedList.remove();
|
||||
string_writeconfig("/opt/ibxd", "list_wifi_networks\n");
|
||||
QTimer::singleShot(0, this, SLOT(refreshWait()));
|
||||
}
|
||||
}
|
||||
|
||||
void wifiDialog::refreshWait() {
|
||||
|
@ -198,6 +210,9 @@ void wifiDialog::refreshWait() {
|
|||
if(elapsedSeconds == 6) {
|
||||
emit showToast("Failed to get network list");
|
||||
log("Failed to get network list", className);
|
||||
ui->refreshBtn->setStyleSheet("background-color:white;");
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
scanInProgress = false;
|
||||
}
|
||||
else {
|
||||
elapsedSeconds = elapsedSeconds + 1;
|
||||
|
@ -252,6 +267,14 @@ void wifiDialog::refreshNetworksList() {
|
|||
}
|
||||
}
|
||||
log("found valid networks: " + QString::number(pureNetworkList.count()), className);
|
||||
if(pureNetworkList.count() == 0) {
|
||||
log("No networks found, skipping", className);
|
||||
showToastSlot("No networks found");
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
ui->refreshBtn->setStyleSheet("background-color:white;");
|
||||
scanInProgress = false;
|
||||
return void();
|
||||
}
|
||||
QFile currentWifiNameFile = QFile("/external_root/run/current_wifi_name");
|
||||
currentWifiNameFile.remove();
|
||||
string_writeconfig("/opt/ibxd", "get_current_wifi_name\n");
|
||||
|
@ -269,22 +292,29 @@ void wifiDialog::refreshNetworksList() {
|
|||
log("Found current network in vector", className);
|
||||
vectorNetworkLocation = countVec;
|
||||
currentNetwork = wifiNetwork.name;
|
||||
log("Test", className);
|
||||
network* connectedNetwork = new network;
|
||||
connectedNetwork->mainData = wifiNetwork;
|
||||
// to be really sure that the the info is put there
|
||||
log("Test", className);
|
||||
// To be really sure that the the info is put there
|
||||
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||
log("Test", className);
|
||||
connectedNetworkDataParent = wifiNetwork;
|
||||
wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
|
||||
connectedNetworkDataParentSetted = true;
|
||||
log("Test", className);
|
||||
|
||||
// this doesnt work so a layout is needed
|
||||
// This doesnt work so a layout is needed
|
||||
// ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
|
||||
connectedNetwork->applyVariables();
|
||||
log("Test", className);
|
||||
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);
|
||||
}
|
||||
countVec = countVec + 1;
|
||||
else {
|
||||
countVec = countVec + 1;
|
||||
}
|
||||
}
|
||||
if(vectorNetworkLocation != 9999) {
|
||||
log("pureNetworkList size is: " + QString::number(pureNetworkList.count()) + " And i want to remove at: " + QString::number(vectorNetworkLocation), className);
|
||||
|
@ -312,7 +342,7 @@ void wifiDialog::refreshNetworksList() {
|
|||
counter = counter + 1;
|
||||
}
|
||||
}
|
||||
// this happens if its the smallest value, so insert it at the end
|
||||
// This happens if its the smallest value, so insert it at the end
|
||||
if(stopIterating == false) {
|
||||
sortedPureNetworkList.append(wifiNetwork);
|
||||
}
|
||||
|
@ -338,19 +368,27 @@ void wifiDialog::refreshNetworksList() {
|
|||
scannedAtLeastOnce = true;
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
ui->refreshBtn->setStyleSheet("background-color:white;");
|
||||
scanInProgress = false;
|
||||
}
|
||||
|
||||
|
||||
void wifiDialog::on_Wificheckbox_stateChanged(int arg1)
|
||||
{
|
||||
connectedNetworkDataParentSetted = false;
|
||||
log("wifi dialog clicked: " + QString::number(arg1), className);
|
||||
if(wifiButtonEnabled == true) {
|
||||
if(arg1 == 2) {
|
||||
log("turning wifi on", className);
|
||||
// the watcher will scan wifi
|
||||
forceRefresh = true;
|
||||
QTimer::singleShot(0, this, SLOT(turnOnWifi()));
|
||||
ui->stopBtn->setStyleSheet("background-color:white;");
|
||||
ui->stopBtn->setEnabled(true);
|
||||
} else {
|
||||
log("turning wifi off", className);
|
||||
QTimer::singleShot(0, this, SLOT(turnOffWifi()));
|
||||
ui->stopBtn->setStyleSheet("background-color:grey;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
emit killNetworkWidgets();
|
||||
}
|
||||
|
@ -375,10 +413,13 @@ void wifiDialog::on_logBtn_clicked()
|
|||
log("Scanning at least once is needed");
|
||||
emit showToast("Scan at least once");
|
||||
} else {
|
||||
wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
|
||||
wifilogger* wifiLoggerDialog = new wifilogger;
|
||||
if(connectedNetworkDataParentSetted == true) {
|
||||
wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
|
||||
wifiLoggerDialog->isThereData = true;
|
||||
}
|
||||
wifiLoggerDialog->exec();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wifiDialog::showToastSlot(QString message) {
|
||||
|
@ -391,14 +432,14 @@ void wifiDialog::refreshScreenSlot() {
|
|||
|
||||
/*
|
||||
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 recconections after sleeping / booting
|
||||
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 recconections after sleeping / booting
|
||||
get_dhcp.sh - Gets dhcp addresses
|
||||
prepare_changing_wifi.sh - Kills everything, prepares to changing network
|
||||
smarter_time_sync.sh - synces time
|
||||
toggle.sh - turns on / off
|
||||
list_networks.bin - well lists networks
|
||||
the watcher first watches at processes that could kill other ones
|
||||
smarter_time_sync.sh - Synces time
|
||||
toggle.sh - Turns on / off
|
||||
list_networks.bin - Well lists networks
|
||||
theWatcher() first watches at processes that could kill other ones
|
||||
*/
|
||||
|
||||
void wifiDialog::theWatcher() {
|
||||
|
@ -407,12 +448,14 @@ void wifiDialog::theWatcher() {
|
|||
bool changing = checkProcessName("prepare_changing_wifi.sh");
|
||||
if(killing == true) {
|
||||
setStatusText("Changing wifi state");
|
||||
log("toggle.sh is active", className);
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
if(changing == true) {
|
||||
setStatusText("Disconnecting from a network or cleaning");
|
||||
log("prepare_changing_wifi.sh is active", className);
|
||||
forceRefresh = true;
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
return void();
|
||||
|
@ -456,7 +499,7 @@ void wifiDialog::theWatcher() {
|
|||
return void();
|
||||
}
|
||||
|
||||
bool connecting = checkProcessName("connect_to_network.sh");
|
||||
bool connecting = checkProcessName("connection_manager.sh");
|
||||
if(connecting == true) {
|
||||
forceRefresh = true;
|
||||
setStatusText("Connecting to wifi...");
|
||||
|
@ -464,11 +507,21 @@ void wifiDialog::theWatcher() {
|
|||
return void();
|
||||
}
|
||||
|
||||
setStatusText("Idling");
|
||||
if(ui->statusLabel->text() != "Idling") {
|
||||
setStatusText("Idling");
|
||||
}
|
||||
|
||||
if(forceRefresh == true) {
|
||||
forceRefresh = false;
|
||||
refreshFromWatcher = true;
|
||||
ui->refreshBtn->click();
|
||||
}
|
||||
|
||||
if(unlockCheckbox == true) {
|
||||
ui->Wificheckbox->setEnabled(true);
|
||||
unlockCheckbox = false;
|
||||
}
|
||||
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
}
|
||||
|
||||
|
@ -478,6 +531,27 @@ void wifiDialog::setStatusText(QString message) {
|
|||
|
||||
void wifiDialog::on_stopBtn_clicked()
|
||||
{
|
||||
connectedNetworkDataParentSetted = false;
|
||||
ui->Wificheckbox->setEnabled(false);
|
||||
unlockCheckbox = true;
|
||||
|
||||
// To inform the wifi icon GUI to don't show the connected / failed to connect message
|
||||
string_writeconfig(".config/17-wifi_connection_information/stopped", "true");
|
||||
|
||||
// Maybe limit this, idk
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
|
||||
setDefaultWorkDir();
|
||||
QFile(".config/17-wifi_connection_information/essid").remove();
|
||||
QFile(".config/17-wifi_connection_information/passphrase").remove();
|
||||
|
||||
// This variable just avoids showing the toast so i can use it here too...
|
||||
refreshFromWatcher = true;
|
||||
ui->refreshBtn->click();
|
||||
}
|
||||
|
||||
void wifiDialog::on_returnBtn_clicked()
|
||||
{
|
||||
this->deleteLater();
|
||||
this->close();
|
||||
}
|
||||
|
|
|
@ -20,15 +20,15 @@ public:
|
|||
explicit wifiDialog(QWidget *parent = nullptr);
|
||||
~wifiDialog();
|
||||
global::wifi::wifiNetworkData connectedNetworkDataParent;
|
||||
wifilogger* wifiLoggerDialog = new wifilogger;
|
||||
|
||||
// well dont touch this until there is something, *** Error in `/tmp/exec': double free or corruption (fasttop): 0x025ed170 ***
|
||||
bool connectedNetworkDataParentSetted = false;
|
||||
|
||||
private:
|
||||
Ui::wifiDialog *ui;
|
||||
bool wifiButtonEnabled = false;
|
||||
bool scannedAtLeastOnce = false;
|
||||
|
||||
// variables for refreshWait() and network refresh in general
|
||||
// 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");
|
||||
|
@ -36,6 +36,9 @@ private:
|
|||
// Used by watcher
|
||||
bool forceRefresh = false;
|
||||
int relaunchMs = 300;
|
||||
bool refreshFromWatcher = false;
|
||||
bool unlockCheckbox = false;
|
||||
bool scanInProgress = false;
|
||||
|
||||
public slots:
|
||||
void launchRefresh();
|
||||
|
@ -63,6 +66,7 @@ private slots:
|
|||
void refreshWait();
|
||||
void setStatusText(QString message);
|
||||
void on_stopBtn_clicked();
|
||||
void on_returnBtn_clicked();
|
||||
};
|
||||
|
||||
#endif // WIFIDIALOG_H
|
||||
|
|
|
@ -47,6 +47,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopBtn">
|
||||
<property name="sizePolicy">
|
||||
|
@ -60,6 +76,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refreshBtn">
|
||||
<property name="text">
|
||||
|
|
|
@ -18,6 +18,7 @@ wifilogger::wifilogger(QWidget *parent) :
|
|||
this->setModal(true);
|
||||
|
||||
|
||||
log("Entered wifilogger", className);
|
||||
setWifiInfoPage();
|
||||
ui->refreshBtn->setProperty("type", "borderless");
|
||||
|
||||
|
@ -91,14 +92,25 @@ void wifilogger::changePage() {
|
|||
}
|
||||
|
||||
void wifilogger::getWifiInformations() {
|
||||
log("getting wifi informations", className);
|
||||
QFile wifiInformationsPath = QFile("/external_root/run/wifi_informations");
|
||||
wifiInformationsPath.remove();
|
||||
if(waitingForFile == false) {
|
||||
wifiInformationsPath.remove();
|
||||
|
||||
string_writeconfig("/opt/ibxd", "get_wifi_informations\n");
|
||||
while(wifiInformationsPath.exists() == false) {
|
||||
sleep(1);
|
||||
log("Launching get_wifi_informations ibxd call", className);
|
||||
string_writeconfig("/opt/ibxd", "get_wifi_informations\n");
|
||||
waitingForFile = true;
|
||||
}
|
||||
|
||||
if(waitingForFile == true) {
|
||||
if(wifiInformationsPath.exists() == false) {
|
||||
QTimer::singleShot(1000, this, SLOT(getWifiInformations()));
|
||||
return void();
|
||||
}
|
||||
}
|
||||
|
||||
waitingForFile = false;
|
||||
log("Setting variables", className);
|
||||
QString wifiInfo = readFile(wifiInformationsPath.fileName());
|
||||
QStringList wifiInfoList = wifiInfo.split("\n");
|
||||
int counter = 0;
|
||||
|
@ -118,7 +130,7 @@ void wifilogger::getWifiInformations() {
|
|||
counter = counter + 1;
|
||||
}
|
||||
|
||||
if(connectedNetworkData.mac.isEmpty() == false) {
|
||||
if(isThereData == true) {
|
||||
ui->encryptionLabel->setText(QVariant(connectedNetworkData.encryption).toString());
|
||||
|
||||
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
|
||||
|
@ -138,6 +150,7 @@ void wifilogger::getWifiInformations() {
|
|||
|
||||
void wifilogger::on_returnBtn_clicked()
|
||||
{
|
||||
log("Exiting wifilogger", className);
|
||||
this->deleteLater();
|
||||
this->close();
|
||||
}
|
||||
|
@ -155,7 +168,9 @@ void wifilogger::updateLogs() {
|
|||
void wifilogger::on_refreshBtn_clicked()
|
||||
{
|
||||
if(currentPage == 0) {
|
||||
setWifiInfoPage();
|
||||
if(waitingForFile == false) {
|
||||
setWifiInfoPage();
|
||||
}
|
||||
}
|
||||
else {
|
||||
updateLogs();
|
||||
|
|
|
@ -17,6 +17,8 @@ public:
|
|||
explicit wifilogger(QWidget *parent = nullptr);
|
||||
~wifilogger();
|
||||
global::wifi::wifiNetworkData connectedNetworkData;
|
||||
// to the above value
|
||||
bool isThereData = false;
|
||||
|
||||
private:
|
||||
Ui::wifilogger *ui;
|
||||
|
@ -28,6 +30,7 @@ private:
|
|||
int currentPage = 0;
|
||||
QFile fancyLogs = QFile("/external_root/run/wifi_stats");
|
||||
QFile allLogs = QFile("/external_root/run/wifi_logs");
|
||||
bool waitingForFile = false;
|
||||
|
||||
private slots:
|
||||
void setWifiInfoPage();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
|
@ -312,14 +312,22 @@
|
|||
<widget class="QWidget" name="page_1">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextBrowser" name="fancyLogsText"/>
|
||||
<widget class="QTextBrowser" name="fancyLogsText">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::NoTextInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextBrowser" name="allLogsText"/>
|
||||
<widget class="QTextBrowser" name="allLogsText">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::NoTextInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue