mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 15:47:22 -08:00
Added general-purpose dialog; added soft reset option
This commit is contained in:
parent
d04c6ebc12
commit
55978a75fa
9 changed files with 387 additions and 80 deletions
62
generaldialog.cpp
Normal file
62
generaldialog.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
#include "generaldialog.h"
|
||||
#include "ui_generaldialog.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
generalDialog::generalDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::generalDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Preventing outside interaction
|
||||
this->setModal(true);
|
||||
|
||||
// Stylesheet, style & misc.
|
||||
QFile stylesheetFile(":/resources/eink.qss");
|
||||
stylesheetFile.open(QFile::ReadOnly);
|
||||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
stylesheetFile.close();
|
||||
|
||||
ui->okBtn->setProperty("type", "borderless");
|
||||
ui->cancelBtn->setProperty("type", "borderless");
|
||||
|
||||
ui->okBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||
ui->cancelBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||
ui->bodyLabel->setStyleSheet("font-size: 9pt");
|
||||
|
||||
if(checkconfig("/inkbox/resetDialog") == true) {
|
||||
resetDialog = true;
|
||||
ui->okBtn->setText("Proceed");
|
||||
ui->cancelBtn->setText("Go back");
|
||||
ui->bodyLabel->setText("This will erase any books you have on the device. Settings will be reset.");
|
||||
ui->headerLabel->setText("Warning");
|
||||
this->adjustSize();
|
||||
string_writeconfig("/inkbox/resetDialog", "false");
|
||||
}
|
||||
else {
|
||||
// We shouldn't be there ;)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
generalDialog::~generalDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void generalDialog::on_cancelBtn_clicked()
|
||||
{
|
||||
if(resetDialog == true) {
|
||||
generalDialog::close();
|
||||
}
|
||||
}
|
||||
|
||||
void generalDialog::on_okBtn_clicked()
|
||||
{
|
||||
if(resetDialog == true) {
|
||||
// Reset the device ... some code to come
|
||||
;
|
||||
}
|
||||
}
|
53
generaldialog.h
Normal file
53
generaldialog.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef GENERALDIALOG_H
|
||||
#define GENERALDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Ui {
|
||||
class generalDialog;
|
||||
}
|
||||
|
||||
class generalDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit generalDialog(QWidget *parent = nullptr);
|
||||
~generalDialog();
|
||||
bool resetDialog = false;
|
||||
bool checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
string contentstr = content.toStdString();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
};
|
||||
void string_writeconfig(string file, string config_option) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void on_cancelBtn_clicked();
|
||||
|
||||
void on_okBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::generalDialog *ui;
|
||||
};
|
||||
|
||||
#endif // GENERALDIALOG_H
|
130
generaldialog.ui
Normal file
130
generaldialog.ui
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>generalDialog</class>
|
||||
<widget class="QDialog" name="generalDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="cancelBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Inter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="okBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Inter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="bodyLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Inter</family>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Body</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="headerLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Inter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Header</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -13,6 +13,7 @@ SOURCES += \
|
|||
apps.cpp \
|
||||
brightnessdialog.cpp \
|
||||
calendarapp.cpp \
|
||||
generaldialog.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
quit.cpp \
|
||||
|
@ -26,6 +27,7 @@ HEADERS += \
|
|||
apps.h \
|
||||
brightnessdialog.h \
|
||||
calendarapp.h \
|
||||
generaldialog.h \
|
||||
mainwindow.h \
|
||||
quit.h \
|
||||
reader.h \
|
||||
|
@ -38,6 +40,7 @@ FORMS += \
|
|||
apps.ui \
|
||||
brightnessdialog.ui \
|
||||
calendarapp.ui \
|
||||
generaldialog.ui \
|
||||
mainwindow.ui \
|
||||
quit.ui \
|
||||
reader.ui \
|
||||
|
|
|
@ -462,10 +462,10 @@ void MainWindow::on_pushButton_clicked()
|
|||
|
||||
void MainWindow::on_searchBtn_clicked()
|
||||
{
|
||||
// Testing
|
||||
/*usbmsWindow = new usbms_splash();
|
||||
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
usbmsWindow->showFullScreen();*/
|
||||
/*// Testing
|
||||
generalDialogWindow = new generalDialog();
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();*/
|
||||
}
|
||||
|
||||
void MainWindow::on_quitBtn_clicked()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "alert.h"
|
||||
#include "usbms_splash.h"
|
||||
#include "brightnessdialog.h"
|
||||
#include "generaldialog.h"
|
||||
#include <iostream>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
@ -162,5 +163,6 @@ private:
|
|||
alert *alertWindow;
|
||||
usbms_splash *usbmsWindow;
|
||||
brightnessDialog *brightnessDialogWindow;
|
||||
generalDialog *generalDialogWindow;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
13
settings.cpp
13
settings.cpp
|
@ -26,12 +26,14 @@ settings::settings(QWidget *parent) :
|
|||
ui->requestLeaseBtn->setProperty("type", "borderless");
|
||||
ui->usbmsBtn->setProperty("type", "borderless");
|
||||
ui->updateBtn->setProperty("type", "borderless");
|
||||
ui->resetBtn->setProperty("type", "borderless");
|
||||
ui->previousBtn->setProperty("type", "borderless");
|
||||
ui->nextBtn->setProperty("type", "borderless");
|
||||
ui->aboutBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->requestLeaseBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->usbmsBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->updateBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->resetBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->comboBox->setStyleSheet("font-size: 9pt");
|
||||
|
||||
ui->previousBtn->setText("");
|
||||
|
@ -490,3 +492,14 @@ void settings::on_comboBox_currentIndexChanged(const QString &arg1)
|
|||
string_writeconfig(".config/04-book/refresh", "-1");
|
||||
}
|
||||
}
|
||||
|
||||
void settings::on_resetBtn_clicked()
|
||||
{
|
||||
// We write to a temporary file to show a "Reset" prompt
|
||||
string_writeconfig("/inkbox/resetDialog", "true");
|
||||
|
||||
// We show the dialog
|
||||
generalDialogWindow = new generalDialog();
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <fstream>
|
||||
|
||||
#include <usbms_splash.h>
|
||||
#include "generaldialog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -97,9 +98,12 @@ private slots:
|
|||
|
||||
void on_comboBox_currentIndexChanged(const QString &arg1);
|
||||
|
||||
void on_resetBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::settings *ui;
|
||||
usbms_splash *usbmsWindow;
|
||||
generalDialog *generalDialogWindow;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
|
192
settings.ui
192
settings.ui
|
@ -413,82 +413,6 @@
|
|||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="4" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="updateBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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 row="0" column="0">
|
||||
<widget class="QLabel" name="updateLabel">
|
||||
<property name="text">
|
||||
<string>Update InkBox</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="darkModeCheckBox">
|
||||
<property name="text">
|
||||
<string>Enable night mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line_9">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="softwareLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Software</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<property name="bottomMargin">
|
||||
|
@ -541,7 +465,73 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="softwareLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Software</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="darkModeCheckBox">
|
||||
<property name="text">
|
||||
<string>Enable night mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="updateBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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 row="0" column="0">
|
||||
<widget class="QLabel" name="updateLabel">
|
||||
<property name="text">
|
||||
<string>Update InkBox</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -554,6 +544,56 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line_9">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_12">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Reset this device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<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 row="0" column="2">
|
||||
<widget class="QPushButton" name="resetBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in a new issue