mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Toast messages; Wi-Fi dialog improvements
This commit is contained in:
parent
a532d00f48
commit
5793607d2b
13 changed files with 371 additions and 17 deletions
|
@ -67,6 +67,10 @@ namespace global {
|
||||||
inline QString keyboardText;
|
inline QString keyboardText;
|
||||||
inline QString keypadText;
|
inline QString keypadText;
|
||||||
}
|
}
|
||||||
|
namespace toast {
|
||||||
|
inline QString message;
|
||||||
|
inline bool wifiToast;
|
||||||
|
}
|
||||||
inline QString systemInfoText;
|
inline QString systemInfoText;
|
||||||
inline bool forbidOpenSearchDialog;
|
inline bool forbidOpenSearchDialog;
|
||||||
inline bool isN705;
|
inline bool isN705;
|
||||||
|
|
|
@ -27,6 +27,7 @@ SOURCES += \
|
||||||
settings.cpp \
|
settings.cpp \
|
||||||
settingschooser.cpp \
|
settingschooser.cpp \
|
||||||
textwidget.cpp \
|
textwidget.cpp \
|
||||||
|
toast.cpp \
|
||||||
usbms_splash.cpp \
|
usbms_splash.cpp \
|
||||||
virtualkeyboard.cpp \
|
virtualkeyboard.cpp \
|
||||||
virtualkeypad.cpp \
|
virtualkeypad.cpp \
|
||||||
|
@ -49,6 +50,7 @@ HEADERS += \
|
||||||
settings.h \
|
settings.h \
|
||||||
settingschooser.h \
|
settingschooser.h \
|
||||||
textwidget.h \
|
textwidget.h \
|
||||||
|
toast.h \
|
||||||
usbms_splash.h \
|
usbms_splash.h \
|
||||||
virtualkeyboard.h \
|
virtualkeyboard.h \
|
||||||
virtualkeypad.h \
|
virtualkeypad.h \
|
||||||
|
@ -70,6 +72,7 @@ FORMS += \
|
||||||
settings.ui \
|
settings.ui \
|
||||||
settingschooser.ui \
|
settingschooser.ui \
|
||||||
textwidget.ui \
|
textwidget.ui \
|
||||||
|
toast.ui \
|
||||||
usbms_splash.ui \
|
usbms_splash.ui \
|
||||||
virtualkeyboard.ui \
|
virtualkeyboard.ui \
|
||||||
virtualkeypad.ui \
|
virtualkeypad.ui \
|
||||||
|
|
|
@ -74,8 +74,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
brightnessIconHeight = sH / 24;
|
brightnessIconHeight = sH / 24;
|
||||||
homeIconWidth = sW / 18;
|
homeIconWidth = sW / 18;
|
||||||
homeIconHeight = sW / 18;
|
homeIconHeight = sW / 18;
|
||||||
wifiIconWidth = sW / 20;
|
wifiIconWidth = sW / 20.5;
|
||||||
wifiIconHeight = sH / 20;
|
wifiIconHeight = sH / 20.5;
|
||||||
}
|
}
|
||||||
else if(checkconfig_str_val == "n905\n") {
|
else if(checkconfig_str_val == "n905\n") {
|
||||||
stdIconWidth = sW / 14;
|
stdIconWidth = sW / 14;
|
||||||
|
@ -84,8 +84,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
brightnessIconHeight = sH / 26;
|
brightnessIconHeight = sH / 26;
|
||||||
homeIconWidth = sW / 20;
|
homeIconWidth = sW / 20;
|
||||||
homeIconHeight = sW / 20;
|
homeIconHeight = sW / 20;
|
||||||
wifiIconWidth = sW / 22;
|
wifiIconWidth = sW / 22.5;
|
||||||
wifiIconHeight = sH / 22;
|
wifiIconHeight = sH / 22.5;
|
||||||
}
|
}
|
||||||
else if(checkconfig_str_val == "n613\n") {
|
else if(checkconfig_str_val == "n613\n") {
|
||||||
stdIconWidth = sW / 12.5;
|
stdIconWidth = sW / 12.5;
|
||||||
|
@ -94,8 +94,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
brightnessIconHeight = sH / 24.5;
|
brightnessIconHeight = sH / 24.5;
|
||||||
homeIconWidth = sW / 18.5;
|
homeIconWidth = sW / 18.5;
|
||||||
homeIconHeight = sW / 18.5;
|
homeIconHeight = sW / 18.5;
|
||||||
wifiIconWidth = sW / 20.5;
|
wifiIconWidth = sW / 21;
|
||||||
wifiIconHeight = sH / 20.5;
|
wifiIconHeight = sH / 21;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stdIconWidth = sW / 14;
|
stdIconWidth = sW / 14;
|
||||||
|
@ -104,8 +104,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
brightnessIconHeight = sH / 26;
|
brightnessIconHeight = sH / 26;
|
||||||
homeIconWidth = sW / 20;
|
homeIconWidth = sW / 20;
|
||||||
homeIconHeight = sW / 20;
|
homeIconHeight = sW / 20;
|
||||||
wifiIconWidth = sW / 22;
|
wifiIconWidth = sW / 22.5;
|
||||||
wifiIconHeight = sH / 22;
|
wifiIconHeight = sH / 22.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting icons up
|
// Setting icons up
|
||||||
|
@ -346,6 +346,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// An USB cable is connected!
|
// An USB cable is connected!
|
||||||
|
setBatteryIcon();
|
||||||
openUsbmsDialog();
|
openUsbmsDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,3 +908,25 @@ void MainWindow::setWifiIcon() {
|
||||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::openWifiDialog() {
|
||||||
|
global::toast::wifiToast = true;
|
||||||
|
showToast("Searching for networks");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_wifiBtn_clicked()
|
||||||
|
{
|
||||||
|
openWifiDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
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)));
|
||||||
|
toastWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::hello(int testNumber) {
|
||||||
|
qDebug() << "Hello" << testNumber;
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "koboxappsdialog.h"
|
#include "koboxappsdialog.h"
|
||||||
#include "textwidget.h"
|
#include "textwidget.h"
|
||||||
#include "virtualkeypad.h"
|
#include "virtualkeypad.h"
|
||||||
|
#include "toast.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -53,9 +54,9 @@ public:
|
||||||
void resetWindow(bool resetStackedWidget);
|
void resetWindow(bool resetStackedWidget);
|
||||||
void resetIcons();
|
void resetIcons();
|
||||||
void setBatteryIcon();
|
void setBatteryIcon();
|
||||||
void updateWifiIcon(int mode);
|
|
||||||
int testPing();
|
int testPing();
|
||||||
bool checkWifiState();
|
bool checkWifiState();
|
||||||
|
void showToast(QString messageToDisplay);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -71,11 +72,15 @@ private slots:
|
||||||
void on_book4Btn_clicked();
|
void on_book4Btn_clicked();
|
||||||
void on_brightnessBtn_clicked();
|
void on_brightnessBtn_clicked();
|
||||||
void openUpdateDialog();
|
void openUpdateDialog();
|
||||||
|
void openWifiDialog();
|
||||||
void setInitialBrightness();
|
void setInitialBrightness();
|
||||||
void on_homeBtn_clicked();
|
void on_homeBtn_clicked();
|
||||||
void refreshScreen();
|
void refreshScreen();
|
||||||
void setupSearchDialog();
|
void setupSearchDialog();
|
||||||
void setWifiIcon();
|
void setWifiIcon();
|
||||||
|
void on_wifiBtn_clicked();
|
||||||
|
void updateWifiIcon(int mode);
|
||||||
|
void hello(int testNumber);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
@ -91,6 +96,7 @@ private:
|
||||||
koboxAppsDialog *koboxAppsDialogWindow;
|
koboxAppsDialog *koboxAppsDialogWindow;
|
||||||
textwidget *textwidgetWindow;
|
textwidget *textwidgetWindow;
|
||||||
virtualkeypad *keypadWidget;
|
virtualkeypad *keypadWidget;
|
||||||
|
toast *toastWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
19
reader.cpp
19
reader.cpp
|
@ -819,7 +819,7 @@ void reader::on_nextBtn_clicked()
|
||||||
{
|
{
|
||||||
if(is_epub != true) {
|
if(is_epub != true) {
|
||||||
if(split_total - 1 == 1 or split_total - 1 == 0) {
|
if(split_total - 1 == 1 or split_total - 1 == 0) {
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
showToast("You've reached the end of the document");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
split_total = split_total - 1;
|
split_total = split_total - 1;
|
||||||
|
@ -834,7 +834,7 @@ void reader::on_nextBtn_clicked()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(mupdf::epubPageNumber + 1 > totalPagesInt) {
|
if(mupdf::epubPageNumber + 1 > totalPagesInt) {
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
showToast("You've reached the end of the document");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mupdf::epubPageNumber = mupdf::epubPageNumber + 1;
|
mupdf::epubPageNumber = mupdf::epubPageNumber + 1;
|
||||||
|
@ -856,7 +856,7 @@ void reader::on_previousBtn_clicked()
|
||||||
if(is_epub != true) {
|
if(is_epub != true) {
|
||||||
// Making sure we won't encounter a "List index out of range" error ;)
|
// Making sure we won't encounter a "List index out of range" error ;)
|
||||||
if(split_total >= split_files_number - 1) {
|
if(split_total >= split_files_number - 1) {
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
|
showToast("No previous page");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
split_total = split_total + 1;
|
split_total = split_total + 1;
|
||||||
|
@ -871,7 +871,7 @@ void reader::on_previousBtn_clicked()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(mupdf::epubPageNumber - 1 <= 0) {
|
if(mupdf::epubPageNumber - 1 <= 0) {
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
|
showToast("No previous page");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mupdf::epubPageNumber = mupdf::epubPageNumber - 1;
|
mupdf::epubPageNumber = mupdf::epubPageNumber - 1;
|
||||||
|
@ -1567,7 +1567,7 @@ void reader::on_gotoBtn_clicked()
|
||||||
void reader::gotoPage(int pageNumber) {
|
void reader::gotoPage(int pageNumber) {
|
||||||
if(is_epub == true) {
|
if(is_epub == true) {
|
||||||
if(pageNumber > totalPagesInt or pageNumber < 1) {
|
if(pageNumber > totalPagesInt or pageNumber < 1) {
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("Request is beyond the page range."));
|
showToast("Request is beyond page range");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mupdf::epubPageNumber = pageNumber;
|
mupdf::epubPageNumber = pageNumber;
|
||||||
|
@ -1581,7 +1581,7 @@ void reader::gotoPage(int pageNumber) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(split_files_number - pageNumber < 2 or split_files_number - pageNumber > split_files_number - 1) {
|
if(split_files_number - pageNumber < 2 or split_files_number - pageNumber > split_files_number - 1) {
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
showToast("You've reached the end of the document");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
split_total = split_files_number - pageNumber;
|
split_total = split_files_number - pageNumber;
|
||||||
|
@ -1693,3 +1693,10 @@ void reader::setIbarraFont() {
|
||||||
void reader::searchRefreshScreen() {
|
void reader::searchRefreshScreen() {
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reader::showToast(QString messageToDisplay) {
|
||||||
|
global::toast::message = messageToDisplay;
|
||||||
|
toastWindow = new toast(this);
|
||||||
|
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
toastWindow->show();
|
||||||
|
}
|
||||||
|
|
3
reader.h
3
reader.h
|
@ -4,6 +4,7 @@
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "alert.h"
|
#include "alert.h"
|
||||||
#include "generaldialog.h"
|
#include "generaldialog.h"
|
||||||
|
#include "toast.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ public:
|
||||||
void setBitterFont();
|
void setBitterFont();
|
||||||
void setCrimsonProFont();
|
void setCrimsonProFont();
|
||||||
void setIbarraFont();
|
void setIbarraFont();
|
||||||
|
void showToast(QString messageToDisplay);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_nextBtn_clicked();
|
void on_nextBtn_clicked();
|
||||||
|
@ -135,6 +137,7 @@ private:
|
||||||
Ui::reader *ui;
|
Ui::reader *ui;
|
||||||
alert *alertWindow;
|
alert *alertWindow;
|
||||||
generalDialog *generalDialogWindow;
|
generalDialog *generalDialogWindow;
|
||||||
|
toast *toastWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // READER_H
|
#endif // READER_H
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 6.3 KiB |
63
toast.cpp
Normal file
63
toast.cpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#include "toast.h"
|
||||||
|
#include "ui_toast.h"
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
toast::toast(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::toast)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->messageLabel->setStyleSheet("padding: 35px");
|
||||||
|
ui->messageLabel->setText(global::toast::message);
|
||||||
|
this->adjustSize();
|
||||||
|
centerToast();
|
||||||
|
if(global::toast::wifiToast == true) {
|
||||||
|
global::toast::wifiToast = false;
|
||||||
|
wifiDialogWindow = new wifiDialog(this);
|
||||||
|
wifiDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(wifiDialogWindow, SIGNAL(wifiNetworksListReady(int)), SLOT(showWifiDialog(int)));
|
||||||
|
connect(wifiDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(exitSlot()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QTimer::singleShot(5000, this, SLOT(exitSlot()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toast::~toast()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void toast::showWifiDialog(int networksFound) {
|
||||||
|
if(networksFound == 1) {
|
||||||
|
emit updateWifiIconSig(2);
|
||||||
|
this->hide();
|
||||||
|
wifiDialogWindow->show();
|
||||||
|
wifiDialogWindow->adjustSize();
|
||||||
|
wifiDialogWindow->centerDialog();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->messageLabel->setText("No networks found");
|
||||||
|
QThread::sleep(5);
|
||||||
|
toast::close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void toast::centerToast() {
|
||||||
|
// 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 toast::exitSlot() {
|
||||||
|
toast::close();
|
||||||
|
}
|
33
toast.h
Normal file
33
toast.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef TOAST_H
|
||||||
|
#define TOAST_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "wifidialog.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class toast;
|
||||||
|
}
|
||||||
|
|
||||||
|
class toast : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit toast(QWidget *parent = nullptr);
|
||||||
|
~toast();
|
||||||
|
void centerToast();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::toast *ui;
|
||||||
|
wifiDialog *wifiDialogWindow;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void showWifiDialog(int networksFound);
|
||||||
|
void exitSlot();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void updateWifiIconSig(int mode);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOAST_H
|
53
toast.ui
Normal file
53
toast.ui
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>toast</class>
|
||||||
|
<widget class="QDialog" name="toast">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>63</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="messageLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Message</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -1,14 +1,92 @@
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QStringListModel>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
#include "wifidialog.h"
|
#include "wifidialog.h"
|
||||||
#include "ui_wifidialog.h"
|
#include "ui_wifidialog.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
wifiDialog::wifiDialog(QWidget *parent) :
|
wifiDialog::wifiDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::wifiDialog)
|
ui(new Ui::wifiDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
wifiListTimer = new QTimer(this);
|
||||||
|
|
||||||
|
// Stylesheet, style & misc.
|
||||||
|
QFile stylesheetFile(":/resources/eink.qss");
|
||||||
|
stylesheetFile.open(QFile::ReadOnly);
|
||||||
|
this->setStyleSheet(stylesheetFile.readAll());
|
||||||
|
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->setStyleSheet("font-size: 9pt");
|
||||||
|
|
||||||
|
checkWifiNetworks();
|
||||||
}
|
}
|
||||||
|
|
||||||
wifiDialog::~wifiDialog()
|
wifiDialog::~wifiDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
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();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
wifiListTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifiDialog::printWifiNetworks() {
|
||||||
|
string_checkconfig_ro("/run/wifi_networks_list");
|
||||||
|
if(checkconfig_str_val == "") {
|
||||||
|
emit wifiNetworksListReady(0);
|
||||||
|
wifiDialog::close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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::on_cancelBtn_clicked()
|
||||||
|
{
|
||||||
|
wifiDialog::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
10
wifidialog.h
10
wifidialog.h
|
@ -14,9 +14,19 @@ class wifiDialog : public QDialog
|
||||||
public:
|
public:
|
||||||
explicit wifiDialog(QWidget *parent = nullptr);
|
explicit wifiDialog(QWidget *parent = nullptr);
|
||||||
~wifiDialog();
|
~wifiDialog();
|
||||||
|
QString wifiNetworksList;
|
||||||
|
void checkWifiNetworks();
|
||||||
|
void printWifiNetworks();
|
||||||
|
void centerDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::wifiDialog *ui;
|
Ui::wifiDialog *ui;
|
||||||
|
QTimer * wifiListTimer;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void wifiNetworksListReady(int networksFound);
|
||||||
|
private slots:
|
||||||
|
void on_cancelBtn_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIFIDIALOG_H
|
#endif // WIFIDIALOG_H
|
||||||
|
|
|
@ -16,8 +16,79 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="page_2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QListView" name="networksListWidget">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QListWidget" name="networksListWidget"/>
|
<widget class="QLabel" name="mainLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Select a network</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="connectBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="cancelBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue