Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "settings.h"
#include "apps.h"
#include "reader.h"
#include "quit.h"
#include "alert.h"
#include <iostream>
#include <QFile>
#include <QTextStream>
using namespace std;
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
bool checked_box = false;
bool existing_recent_books = false;
QString checkconfig_str_val;
QString relative_path;
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();
}
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:
void on_settingsBtn_clicked();
void on_appsBtn_clicked();
void on_pushButton_clicked();
void on_searchBtn_clicked();
void on_quitBtn_clicked();
void on_book1Btn_clicked();
void on_book2Btn_clicked();
void on_book3Btn_clicked();
void on_book4Btn_clicked();
private:
Ui::MainWindow *ui;
settings *settingsWindow;
apps *appsWindow;
reader *readerWindow;
quit *quitWindow;
alert *alertWindow;
};
#endif // MAINWINDOW_H