mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Vacuum-cleaner; centralized all functions in one header file. I'm sorry.
This commit is contained in:
parent
940f2aa374
commit
f46e9f3f28
19 changed files with 174 additions and 387 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "alert.h"
|
||||
#include "ui_alert.h"
|
||||
#include "functions.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QScreen>
|
||||
|
|
26
alert.h
26
alert.h
|
@ -2,10 +2,6 @@
|
|||
#define ALERT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace Ui {
|
||||
class alert;
|
||||
|
@ -20,32 +16,10 @@ class alert : public QWidget
|
|||
public:
|
||||
explicit alert(QWidget *parent = nullptr);
|
||||
~alert();
|
||||
void string_writeconfig(string file, string config_option) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
bool checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
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();
|
||||
};
|
||||
|
||||
private slots:
|
||||
void on_continueBtn_clicked();
|
||||
|
||||
void on_resetBtn_clicked();
|
||||
|
||||
void on_continue2Btn_clicked();
|
||||
|
||||
private:
|
||||
|
|
3
apps.h
3
apps.h
|
@ -20,11 +20,8 @@ public:
|
|||
private slots:
|
||||
void on_scribbleLaunchBtn_clicked();
|
||||
void exitSlot();
|
||||
|
||||
void on_lightmapsLaunchBtn_clicked();
|
||||
|
||||
void on_savedWordsLaunchBtn_clicked();
|
||||
|
||||
void on_calendarLaunchBtn_clicked();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "brightnessdialog.h"
|
||||
#include "ui_brightnessdialog.h"
|
||||
#include "functions.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
#define BRIGHTNESSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <QTextStream>
|
||||
#include <QFile>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -22,43 +18,12 @@ public:
|
|||
int oldValue;
|
||||
explicit brightnessDialog(QWidget *parent = nullptr);
|
||||
~brightnessDialog();
|
||||
void brightness_writeconfig(int value) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(".config/03-brightness/config");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
void string_checkconfig_ro(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
int get_brightness() {
|
||||
QFile brightness("/var/run/brightness");
|
||||
brightness.open(QIODevice::ReadOnly);
|
||||
QString valuestr = brightness.readAll();
|
||||
int value = valuestr.toInt();
|
||||
brightness.close();
|
||||
return value;
|
||||
}
|
||||
void set_brightness(int value) {
|
||||
ofstream fhandler;
|
||||
fhandler.open("/var/run/brightness");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void on_quitBtn_clicked();
|
||||
|
||||
void on_horizontalSlider_valueChanged(int value);
|
||||
|
||||
void on_incBtn_clicked();
|
||||
|
||||
void on_decBtn_clicked();
|
||||
|
||||
void on_okBtn_clicked();
|
||||
|
||||
private:
|
||||
|
|
158
functions.h
Normal file
158
functions.h
Normal file
|
@ -0,0 +1,158 @@
|
|||
#ifndef FUNCTIONS_H
|
||||
#define FUNCTIONS_H
|
||||
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <fstream>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <regex>
|
||||
|
||||
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
|
||||
namespace {
|
||||
QString checkconfig_str_val;
|
||||
QString batt_level;
|
||||
int batt_level_int;
|
||||
bool checked_box = false;
|
||||
bool checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
return 0;
|
||||
};
|
||||
bool checkconfig_rw(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
return 0;
|
||||
};
|
||||
int brightness_checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
int content_int = content.toInt();
|
||||
return content_int;
|
||||
config.close();
|
||||
return 0;
|
||||
};
|
||||
int get_brightness() {
|
||||
QFile brightness("/var/run/brightness");
|
||||
brightness.open(QIODevice::ReadOnly);
|
||||
QString valuestr = brightness.readAll();
|
||||
int value = valuestr.toInt();
|
||||
brightness.close();
|
||||
return value;
|
||||
return 0;
|
||||
}
|
||||
void set_brightness(int value) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open("/var/run/brightness");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
int int_checkconfig(QString file) {
|
||||
QFile int_config(file);
|
||||
int_config.open(QIODevice::ReadOnly);
|
||||
QString valuestr = int_config.readAll();
|
||||
int value = valuestr.toInt();
|
||||
int_config.close();
|
||||
return value;
|
||||
return 0;
|
||||
}
|
||||
int display_quote() {
|
||||
QDir::setCurrent(".config/05-quote");
|
||||
QString quote_prog ("sh");
|
||||
QStringList quote_args;
|
||||
quote_args << "quote.sh";
|
||||
QProcess *quote_proc = new QProcess();
|
||||
quote_proc->start(quote_prog, quote_args);
|
||||
quote_proc->waitForFinished();
|
||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
||||
|
||||
int quote_value = int_checkconfig(".config/05-quote/quote");
|
||||
return quote_value;
|
||||
return 0;
|
||||
}
|
||||
void string_writeconfig(std::string file, std::string config_option) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
void string_checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
void string_checkconfig_ro(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
void brightness_writeconfig(int value) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open(".config/03-brightness/config");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
void get_battery_level() {
|
||||
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
|
||||
batt_level_file.open(QIODevice::ReadOnly);
|
||||
batt_level = batt_level_file.readAll();
|
||||
batt_level = batt_level.trimmed();
|
||||
batt_level_int = batt_level.toInt();
|
||||
batt_level = batt_level.append("%");
|
||||
batt_level_file.close();
|
||||
}
|
||||
void writeconfig(std::string file, std::string config) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config << std::boolalpha << checked_box << endl;
|
||||
fhandler.close();
|
||||
}
|
||||
bool checkconfig_match(QString file, std::string pattern) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
|
||||
// Thanks to https://stackoverflow.com/questions/22516463/how-do-i-find-a-complete-word-not-part-of-it-in-a-string-in-c
|
||||
std::regex r("\\b" + pattern + "\\b");
|
||||
std::smatch m;
|
||||
|
||||
if(std::regex_search(contentstr, m, r)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
#endif // FUNCTIONS_H
|
|
@ -1,5 +1,6 @@
|
|||
#include "generaldialog.h"
|
||||
#include "ui_generaldialog.h"
|
||||
#include "functions.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define GENERALDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -21,26 +18,6 @@ public:
|
|||
~generalDialog();
|
||||
bool resetDialog = false;
|
||||
bool updateDialog = 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();
|
||||
|
|
|
@ -4,6 +4,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|||
|
||||
CONFIG += c++11
|
||||
|
||||
QMAKE_CXXFLAGS += -Wno-unused-function
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
@ -27,6 +29,7 @@ HEADERS += \
|
|||
apps.h \
|
||||
brightnessdialog.h \
|
||||
calendarapp.h \
|
||||
functions.h \
|
||||
generaldialog.h \
|
||||
mainwindow.h \
|
||||
quit.h \
|
||||
|
|
10
main.cpp
10
main.cpp
|
@ -16,6 +16,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "alert.h"
|
||||
#include "generaldialog.h"
|
||||
#include "functions.h"
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
@ -25,14 +26,9 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
checkconfig("test");
|
||||
// Checking if there has been an ALERT flag set up, and if there is, show a big warning
|
||||
QFile config("/external_root/boot/flags/ALERT");
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
string contentstr = content.toStdString();
|
||||
config.close();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
if(checkconfig("/external_root/boot/flags/ALERT") == true) {
|
||||
QApplication a(argc, argv);
|
||||
alert w;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ui_settings.h"
|
||||
#include "apps.h"
|
||||
#include "ui_apps.h"
|
||||
#include "functions.h"
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
|
|
120
mainwindow.h
120
mainwindow.h
|
@ -10,9 +10,6 @@
|
|||
#include "usbms_splash.h"
|
||||
#include "brightnessdialog.h"
|
||||
#include "generaldialog.h"
|
||||
#include <iostream>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
using namespace std;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -26,128 +23,11 @@ class MainWindow : public QMainWindow
|
|||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
bool checked_box = false;
|
||||
bool existing_recent_books = false;
|
||||
bool reboot_after_update = false;
|
||||
int batt_level_int;
|
||||
bool updateDialog = false;
|
||||
int timerTime = 0;
|
||||
QString checkconfig_str_val;
|
||||
QString relative_path;
|
||||
QString batt_level;
|
||||
bool checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
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();
|
||||
};
|
||||
bool checkconfig_rw(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 writeconfig(string file, string config) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config << boolalpha << checked_box << endl;
|
||||
fhandler.close();
|
||||
}
|
||||
void get_battery_level() {
|
||||
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
|
||||
batt_level_file.open(QIODevice::ReadOnly);
|
||||
batt_level = batt_level_file.readAll();
|
||||
batt_level = batt_level.trimmed();
|
||||
batt_level_int = batt_level.toInt();
|
||||
batt_level = batt_level.append("%");
|
||||
batt_level_file.close();
|
||||
}
|
||||
int brightness_checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
int content_int = content.toInt();
|
||||
return content_int;
|
||||
config.close();
|
||||
};
|
||||
int get_brightness() {
|
||||
QFile brightness("/var/run/brightness");
|
||||
brightness.open(QIODevice::ReadOnly);
|
||||
QString valuestr = brightness.readAll();
|
||||
int value = valuestr.toInt();
|
||||
brightness.close();
|
||||
return value;
|
||||
}
|
||||
void set_brightness(int value) {
|
||||
ofstream fhandler;
|
||||
fhandler.open("/var/run/brightness");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
void brightness_writeconfig(int value) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(".config/03-brightness/config");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
int int_checkconfig(QString file) {
|
||||
QFile int_config(file);
|
||||
int_config.open(QIODevice::ReadOnly);
|
||||
QString valuestr = int_config.readAll();
|
||||
int value = valuestr.toInt();
|
||||
int_config.close();
|
||||
return value;
|
||||
}
|
||||
void string_checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
void string_checkconfig_ro(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
void string_writeconfig(string file, string config_option) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
int display_quote() {
|
||||
QDir::setCurrent(".config/05-quote");
|
||||
QString quote_prog ("sh");
|
||||
QStringList quote_args;
|
||||
quote_args << "quote.sh";
|
||||
QProcess *quote_proc = new QProcess();
|
||||
quote_proc->start(quote_prog, quote_args);
|
||||
quote_proc->waitForFinished();
|
||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
||||
|
||||
int quote_value = int_checkconfig(".config/05-quote/quote");
|
||||
return quote_value;
|
||||
}
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
|
|
1
quit.cpp
1
quit.cpp
|
@ -1,5 +1,6 @@
|
|||
#include "quit.h"
|
||||
#include "ui_quit.h"
|
||||
#include "functions.h"
|
||||
#include <QProcess>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
|
12
quit.h
12
quit.h
|
@ -2,8 +2,6 @@
|
|||
#define QUIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -18,22 +16,12 @@ class quit : public QWidget
|
|||
public:
|
||||
explicit quit(QWidget *parent = nullptr);
|
||||
~quit();
|
||||
void string_writeconfig(string file, string config_option) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
void on_backBtn_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "reader.h"
|
||||
#include "ui_reader.h"
|
||||
#include "functions.h"
|
||||
#include <QProcess>
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
|
@ -11,6 +12,7 @@
|
|||
#include <QSize>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QFontDatabase>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
102
reader.h
102
reader.h
|
@ -1,6 +1,8 @@
|
|||
#ifndef READER_H
|
||||
#define READER_H
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
@ -8,12 +10,6 @@
|
|||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QList>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <QMessageBox>
|
||||
#include <regex>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -30,7 +26,6 @@ public:
|
|||
int split_files_number;
|
||||
int page_number;
|
||||
int dictionary_position = 1;
|
||||
int batt_level_int;
|
||||
int pagesTurned = 0;
|
||||
|
||||
// -1 : Never refresh | 0 : Refresh every page | 1 : Refresh every 1 page. And so on...
|
||||
|
@ -50,10 +45,7 @@ public:
|
|||
QString book_4;
|
||||
QString ittext;
|
||||
QString book_file;
|
||||
QString batt_level;
|
||||
bool batt_status;
|
||||
QString percent = "%";
|
||||
QString checkconfig_str_val;
|
||||
QString selected_text;
|
||||
QString word;
|
||||
QString words; // Saved words
|
||||
|
@ -67,20 +59,6 @@ public:
|
|||
QList<QString> content;
|
||||
explicit reader(QWidget *parent = nullptr);
|
||||
~reader();
|
||||
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();
|
||||
};
|
||||
int setup_book(QString book, int i, bool run_parser) {
|
||||
// Parse ebook
|
||||
QString mount_prog ("sh");
|
||||
|
@ -163,29 +141,6 @@ public:
|
|||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
||||
}
|
||||
}
|
||||
int get_brightness() {
|
||||
QFile brightness("/var/run/brightness");
|
||||
brightness.open(QIODevice::ReadOnly);
|
||||
QString valuestr = brightness.readAll();
|
||||
int value = valuestr.toInt();
|
||||
brightness.close();
|
||||
return value;
|
||||
}
|
||||
int int_checkconfig(QString file) {
|
||||
QFile int_config(file);
|
||||
int_config.open(QIODevice::ReadOnly);
|
||||
QString valuestr = int_config.readAll();
|
||||
int value = valuestr.toInt();
|
||||
int_config.close();
|
||||
return value;
|
||||
}
|
||||
void string_checkconfig_ro(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
void checkwords() {
|
||||
QFile words_list(".config/06-words/config");
|
||||
words_list.open(QIODevice::ReadWrite);
|
||||
|
@ -193,44 +148,6 @@ public:
|
|||
words = in.readAll();
|
||||
words_list.close();
|
||||
}
|
||||
void set_brightness(int value) {
|
||||
ofstream fhandler;
|
||||
fhandler.open("/var/run/brightness");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
void brightness_writeconfig(int value) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(".config/03-brightness/config");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
void string_checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
bool checkconfig_match(QString file, string pattern) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
string contentstr = content.toStdString();
|
||||
|
||||
// Thanks to https://stackoverflow.com/questions/22516463/how-do-i-find-a-complete-word-not-part-of-it-in-a-string-in-c
|
||||
std::regex r("\\b" + pattern + "\\b");
|
||||
std::smatch m;
|
||||
|
||||
if(std::regex_search(contentstr, m, r)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
};
|
||||
bool epub_file_match(QString file) {
|
||||
QString fileExt = file.right(4);
|
||||
|
||||
|
@ -241,21 +158,6 @@ public:
|
|||
return false;
|
||||
}
|
||||
};
|
||||
void string_writeconfig(string file, string config_option) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
void get_battery_level() {
|
||||
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
|
||||
batt_level_file.open(QIODevice::ReadOnly);
|
||||
batt_level = batt_level_file.readAll();
|
||||
batt_level = batt_level.trimmed();
|
||||
batt_level_int = batt_level.toInt();
|
||||
batt_level = batt_level.append("%");
|
||||
batt_level_file.close();
|
||||
}
|
||||
void dictionary_lookup(string word, QString first_letter, int position) {
|
||||
ofstream fhandler;
|
||||
fhandler.open("/inkbox/dictionary/word");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_settings.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "functions.h"
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
|
|
59
settings.h
59
settings.h
|
@ -2,9 +2,6 @@
|
|||
#define SETTINGS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <fstream>
|
||||
|
||||
#include <usbms_splash.h>
|
||||
#include "generaldialog.h"
|
||||
|
@ -21,53 +18,11 @@ class settings : public QWidget
|
|||
|
||||
public:
|
||||
int settings_page = 1;
|
||||
bool checked_box = false;
|
||||
bool launch_sh = false;
|
||||
bool not_user_change = true;
|
||||
QString checkconfig_str_val;
|
||||
|
||||
explicit settings(QWidget *parent = nullptr);
|
||||
~settings();
|
||||
bool checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
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 writeconfig(string file, string config) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config << boolalpha << checked_box << endl;
|
||||
fhandler.close();
|
||||
}
|
||||
void string_writeconfig(string file, string config_option) {
|
||||
ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
void string_checkconfig(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
void string_checkconfig_ro(QString file) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void exitSlot();
|
||||
|
@ -75,33 +30,19 @@ private slots:
|
|||
void on_aboutBtn_clicked();
|
||||
void on_okBtn_clicked();
|
||||
void on_clockCheckBox_toggled(bool checked);
|
||||
|
||||
void on_quoteCheckBox_toggled(bool checked);
|
||||
|
||||
void on_requestLeaseBtn_clicked();
|
||||
|
||||
void on_usbmsBtn_clicked();
|
||||
|
||||
void on_previousBtn_clicked();
|
||||
|
||||
void on_nextBtn_clicked();
|
||||
|
||||
void on_wordsNumber_valueChanged(int arg1);
|
||||
|
||||
void on_updateBtn_clicked();
|
||||
|
||||
void on_darkModeCheckBox_toggled(bool checked);
|
||||
|
||||
void on_uiScalingSlider_valueChanged(int value);
|
||||
|
||||
void on_menuBarCheckBox_toggled(bool checked);
|
||||
|
||||
void on_comboBox_currentIndexChanged(const QString &arg1);
|
||||
|
||||
void on_resetBtn_clicked();
|
||||
|
||||
void on_setPasscodeBtn_clicked();
|
||||
|
||||
void on_enableLockscreenCheckBox_toggled(bool checked);
|
||||
|
||||
private:
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
#define USBMS_SPLASH_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace Ui {
|
||||
class usbms_splash;
|
||||
|
|
Loading…
Reference in a new issue