further work

This commit is contained in:
Szybet 2022-08-17 21:36:23 +02:00
parent dc191269f3
commit b9617a52ac
13 changed files with 353 additions and 12 deletions

View file

@ -88,5 +88,7 @@
<file>resources/refresh.png</file>
<file>resources/lock-fill.png</file>
<file>resources/lock-unlock-fill.png</file>
<file>resources/hide.png</file>
<file>resources/show.png</file>
</qresource>
</RCC>

BIN
src/resources/hide.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

BIN
src/resources/show.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

View file

@ -0,0 +1,44 @@
#include <QFile>
#include <QScreen>
#include "connectiondialog.h"
#include "ui_connectiondialog.h"
connectiondialog::connectiondialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::connectiondialog)
{
ui->setupUi(this);
// Stylesheet, style & misc.
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->CancelBtn->setStyleSheet("font-size: 9pt");
ui->connectBtn->setStyleSheet("font-size: 9pt");
ui->showPasswordBtn->setStyleSheet("font-size: 9pt");
// Size
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
this->setFixedWidth(screenGeometry.width() - 50);
}
connectiondialog::~connectiondialog()
{
delete ui;
}
void connectiondialog::applyVariables() {
ui->nameLabel->setText(connectedNetworkData.name);
ui->macLabel->setText(connectedNetworkData.mac);
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
if(connectedNetworkData.encryption == false) {
ui->showPasswordBtn->hide();
ui->passwordTextEdit->setText("No password required");
}
}

View file

@ -0,0 +1,29 @@
#ifndef CONNECTIONDIALOG_H
#define CONNECTIONDIALOG_H
#include <QDialog>
#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;
public slots:
void applyVariables();
private:
Ui::connectiondialog *ui;
};
#endif // CONNECTIONDIALOG_H

View file

@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>connectiondialog</class>
<widget class="QDialog" name="connectiondialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>529</width>
<height>335</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<widget class="QPushButton" name="CancelBtn">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="connectBtn">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="passwordTextEdit">
<property name="cursor">
<cursorShape>BlankCursor</cursorShape>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="showPasswordBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Signal strength:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="signalLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>MAC address:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="macLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -1,5 +1,6 @@
#include "network.h"
#include "ui_network.h"
#include "connectiondialog.h"
network::network(QWidget *parent) :
QWidget(parent),
@ -19,7 +20,7 @@ network::network(QWidget *parent) :
ui->enterButton->setProperty("type", "borderless");
ui->enterButton->setFixedWidth(40);
}
network::~network()
@ -48,7 +49,26 @@ void network::applyVariables() {
if(currentlyConnectedNetwork == mainData.name) {
ui->frame->setStyleSheet(".QFrame{background-color: grey; border: 3px solid black; border-radius: 10px;}");
ui->signalStrengthLabel->setStyleSheet("background-color:grey;");
ui->nameLabel->setStyleSheet("background-color:grey;");
ui->encryptionIcon->setStyleSheet("background-color:grey;");
ui->enterButton->setStyleSheet("background-color:grey;");
// Some stylesheet magician could make it work that it cant be clicked
ui->encryptionIcon->setStyleSheet("QPushButton {background-color: grey; border: none}; QPushButton[type='borderless']:pressed { background: grey; color: grey; border: none; }");
ui->enterButton->setStyleSheet("QPushButton {background-color: grey; border: none}; QPushButton[type='borderless']:pressed { background: grey; color: grey; border: none; }");
} else {
ui->frame->setStyleSheet(".QFrame{background-color: white; border: 3px solid black; border-radius: 10px;}");
}
}
void network::on_enterButton_clicked()
{
connectiondialog* newConnectionDiallog = new connectiondialog;
newConnectionDiallog->connectedNetworkData = mainData;
newConnectionDiallog->currentlyConnectedNetworkName = currentlyConnectedNetwork;
newConnectionDiallog->applyVariables();
newConnectionDiallog->exec();
}

View file

@ -23,6 +23,9 @@ public:
public slots:
void applyVariables();
private slots:
void on_enterButton_clicked();
private:
Ui::network *ui;
};

View file

@ -170,12 +170,16 @@ wifiDialog::~wifiDialog()
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);
}
else {
QTimer::singleShot(0, this, SLOT(launchRefresh()));
ui->refreshBtn->setEnabled(false);
// for some reason this doesnt work here
//ui->refreshBtn->setStyleSheet("background-color:grey;");
QTimer::singleShot(100, this, SLOT(launchRefresh()));
}
}
@ -188,6 +192,7 @@ void wifiDialog::launchRefresh() {
QElapsedTimer elapsedTime;
elapsedTime.start();
bool continueLoop = true;
ui->refreshBtn->setStyleSheet("background-color:grey;");
while(fullList.exists() == false and formattedList.exists() == false and continueLoop == true) {
sleep(1);
if(elapsedTime.elapsed() > 6000) {
@ -265,16 +270,21 @@ void wifiDialog::refreshNetworksList() {
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;
wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
// this doesnt work so a layout is needed
// ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
connectedNetwork->applyVariables();
connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::close);
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
}
countVec = countVec + 1;
}
if(vectorNetworkLocation != 9999) {
log("pureNetworkList size is: " + QString::number(pureNetworkList.count()) + " And i want to remove at: " + QString::number(vectorNetworkLocation), className);
pureNetworkList.removeAt(vectorNetworkLocation);
}
}
@ -302,10 +312,12 @@ void wifiDialog::refreshNetworksList() {
connectedNetwork->mainData = wifiNetwork;
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
connectedNetwork->applyVariables();
connect(this, SIGNAL(killNetworkWidgets()), connectedNetwork, SLOT(close()));
connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::close);
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
}
scannedAtLeastOnce = true;
ui->refreshBtn->setEnabled(true);
ui->refreshBtn->setStyleSheet("background-color:white;");
}
@ -342,7 +354,6 @@ void wifiDialog::on_logBtn_clicked()
log("Scanning at least once is needed");
emit showToast("Scan at least once");
} else {
wifilogger* wifiLoggerDialog = new wifilogger;
wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
wifiLoggerDialog->exec();
}

View file

@ -5,6 +5,7 @@
#include <QModelIndex>
#include "generaldialog.h"
#include "wifilogger.h"
namespace Ui {
class wifiDialog;
@ -19,6 +20,8 @@ public:
explicit wifiDialog(QWidget *parent = nullptr);
~wifiDialog();
global::wifi::wifiNetworkData connectedNetworkDataParent;
wifilogger* wifiLoggerDialog = new wifilogger;
private:
Ui::wifiDialog *ui;

View file

@ -19,8 +19,10 @@ wifilogger::wifilogger(QWidget *parent) :
setWifiInfoPage();
QObject::connect(&updateLogsTimer, &QTimer::timeout, this, &wifilogger::updateLogs);
updateLogsTimer.start(1000);
ui->refreshBtn->setProperty("type", "borderless");
ui->nextBtn->setFixedWidth(70);
ui->previousBtn->setFixedWidth(70);
}
wifilogger::~wifilogger()
@ -41,11 +43,13 @@ void wifilogger::setWifiInfoPage() {
}
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");
}
@ -114,17 +118,26 @@ void wifilogger::getWifiInformations() {
counter = counter + 1;
}
ui->encryptionLabel->setText(QVariant(connectedNetworkData.encryption).toString());
if(connectedNetworkData.mac.isEmpty() == false) {
ui->encryptionLabel->setText(QVariant(connectedNetworkData.encryption).toString());
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
ui->macLabel->setText(connectedNetworkData.mac);
ui->macLabel->setText(connectedNetworkData.mac);
}
else {
// Shouldn't happen for 99%, but if anyway... its designed to be non blocking, so i cant really wait for this.
ui->encryptionLabel->setText("Rescan needed");
ui->signalLabel->setText("Rescan needed");
ui->macLabel->setText("Rescan needed");
}
}
void wifilogger::on_returnBtn_clicked()
{
updateLogsTimer.stop();
this->deleteLater();
}
@ -137,3 +150,13 @@ void wifilogger::updateLogs() {
ui->allLogsText->setText(allLogsText);
}
}
void wifilogger::on_refreshBtn_clicked()
{
if(currentPage == 0) {
setWifiInfoPage();
}
else {
updateLogs();
}
}

View file

@ -26,7 +26,6 @@ private:
* 2 is all logs
*/
int currentPage = 0;
QTimer updateLogsTimer;
QFile fancyLogs = QFile("/external_root/run/wifi_stats");
QFile allLogs = QFile("/external_root/run/wifi_logs");
@ -40,6 +39,7 @@ private slots:
void getWifiInformations();
void on_returnBtn_clicked();
void updateLogs();
void on_refreshBtn_clicked();
};
#endif // WIFILOGGER_H

View file

@ -20,7 +20,7 @@
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="page_0">
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -358,6 +358,23 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="refreshBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../eink.qrc">
<normaloff>:/resources/refresh.png</normaloff>:/resources/refresh.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">