InkBox v1.0 Release Commit

This commit is contained in:
Nicolas Mailloux 2021-03-25 08:00:19 -04:00
parent 898ec01e9c
commit f8ff9e0c37
68 changed files with 29925 additions and 0 deletions

65
alert.cpp Normal file
View file

@ -0,0 +1,65 @@
#include "alert.h"
#include "ui_alert.h"
#include <QPixmap>
#include <QScreen>
#include <QFile>
#include <QProcess>
alert::alert(QWidget *parent) :
QWidget(parent),
ui(new Ui::alert)
{
ui->setupUi(this);
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height();
// Defining what the "Alert" icon size will be
float stdIconWidth = sW / 1.7;
float stdIconHeight = sH / 1.7;
QPixmap pixmap(":/resources/alert.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->alertIconLabel->setPixmap(scaledPixmap);
// General stylesheet
QFile stylesheetFile(":/resources/eink_dark.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 16pt}");
ui->messageLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 9pt}");
ui->securityLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt}");
ui->continueBtn->setProperty("type", "borderless");
ui->resetBtn->setProperty("type", "borderless");
ui->continueBtn->setStyleSheet("padding: 20px");
ui->resetBtn->setStyleSheet("padding: 20px");
}
alert::~alert()
{
delete ui;
}
void alert::on_continueBtn_clicked()
{
// We continue anyway and re-set the ALERT flag
string_writeconfig("/external_root/boot/flags/ALERT", "false");
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
void alert::on_resetBtn_clicked()
{
// We set the DO_FACTORY_RESET flag and we restart the Kobo
string_writeconfig("/external_root/boot/flags/DO_FACTORY_RESET", "true");
string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true");
QString reboot_prog ("busybox");
QStringList reboot_args;
reboot_args << "reboot";
QProcess *reboot_proc = new QProcess();
reboot_proc->start(reboot_prog, reboot_args);
reboot_proc->waitForFinished();
}

37
alert.h Normal file
View file

@ -0,0 +1,37 @@
#ifndef ALERT_H
#define ALERT_H
#include <QWidget>
#include <iostream>
#include <fstream>
namespace Ui {
class alert;
}
using namespace std;
class alert : public QWidget
{
Q_OBJECT
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();
}
private slots:
void on_continueBtn_clicked();
void on_resetBtn_clicked();
private:
Ui::alert *ui;
};
#endif // ALERT_H

180
alert.ui Normal file
View file

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>alert</class>
<widget class="QWidget" name="alert">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>386</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" 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>
<item row="1" column="0">
<widget class="QLabel" name="warningLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Warning</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" 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="9" column="0">
<spacer name="verticalSpacer_5">
<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="3" column="0">
<widget class="QLabel" name="alertIconLabel">
<property name="text">
<string>Alert Icon</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<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>
<item row="0" column="0">
<widget class="QPushButton" name="continueBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Continue anyway</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_4">
<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="0" column="0">
<spacer name="verticalSpacer_3">
<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">
<widget class="QLabel" name="messageLabel">
<property name="text">
<string>This could mean that someone is trying to steal your data or gain root access to the device.
A factory reset is recommended.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="securityLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>The security policy was violated.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

64
apps.cpp Normal file
View file

@ -0,0 +1,64 @@
#include "apps.h"
#include "ui_apps.h"
#include <QFile>
#include <QProcess>
apps::apps(QWidget *parent) :
QWidget(parent),
ui(new Ui::apps)
{
ui->setupUi(this);
ui->backBtn->setProperty("type", "borderless");
ui->scribbleLaunchBtn->setProperty("type", "borderless");
ui->lightmapsLaunchBtn->setProperty("type", "borderless");
ui->calendarLaunchBtn->setProperty("type", "borderless");
ui->savedWordsLaunchBtn->setProperty("type", "borderless");
ui->scribbleLaunchBtn->setStyleSheet("background: lightGrey");
ui->lightmapsLaunchBtn->setStyleSheet("background: lightGrey");
ui->calendarLaunchBtn->setStyleSheet("background: lightGrey");
ui->savedWordsLaunchBtn->setStyleSheet("background: lightGrey");
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
QObject::connect(ui->backBtn, SIGNAL(clicked()), this, SLOT(exitSlot()));
}
apps::~apps()
{
delete ui;
}
void apps::exitSlot() {
apps::close();
}
void apps::on_scribbleLaunchBtn_clicked()
{
QProcess process;
process.startDetached("scribble", QStringList());
qApp->quit();
}
void apps::on_lightmapsLaunchBtn_clicked()
{
QProcess process;
process.startDetached("lightmaps", QStringList());
qApp->quit();
}
void apps::on_savedWordsLaunchBtn_clicked()
{
savedWordsWindow = new savedwords();
savedWordsWindow->setAttribute(Qt::WA_DeleteOnClose);
savedWordsWindow->showFullScreen();
}
void apps::on_calendarLaunchBtn_clicked()
{
calendarWindow = new calendarApp();
calendarWindow->setAttribute(Qt::WA_DeleteOnClose);
calendarWindow->showFullScreen();
}

36
apps.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef APPS_H
#define APPS_H
#include <QWidget>
#include <savedwords.h>
#include <calendarapp.h>
namespace Ui {
class apps;
}
class apps : public QWidget
{
Q_OBJECT
public:
explicit apps(QWidget *parent = nullptr);
~apps();
private slots:
void on_scribbleLaunchBtn_clicked();
void exitSlot();
void on_lightmapsLaunchBtn_clicked();
void on_savedWordsLaunchBtn_clicked();
void on_calendarLaunchBtn_clicked();
private:
Ui::apps *ui;
savedwords *savedWordsWindow;
calendarApp *calendarWindow;
};
#endif // APPS_H

201
apps.ui Normal file
View file

@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>apps</class>
<widget class="QWidget" name="apps">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QPushButton" name="backBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Back
</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Apps</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</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>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="calendarLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Calendar</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Light Maps</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="calendarLaunchBtn">
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="scribbleLaunchBtn">
<property name="font">
<font>
<family>Ubuntu</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="scribbleLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Scribble</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="lightmapsLaunchBtn">
<property name="font">
<font>
<family>Ubuntu</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Saved words</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="savedWordsLaunchBtn">
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

29
calendarapp.cpp Normal file
View file

@ -0,0 +1,29 @@
#include "calendarapp.h"
#include "ui_calendarapp.h"
#include <QFile>
calendarApp::calendarApp(QWidget *parent) :
QWidget(parent),
ui(new Ui::calendarApp)
{
ui->setupUi(this);
// Stylesheet
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->backBtn->setProperty("type", "borderless");
}
calendarApp::~calendarApp()
{
delete ui;
}
void calendarApp::on_backBtn_clicked()
{
calendarApp::close();
}

25
calendarapp.h Normal file
View file

@ -0,0 +1,25 @@
#ifndef CALENDARAPP_H
#define CALENDARAPP_H
#include <QWidget>
namespace Ui {
class calendarApp;
}
class calendarApp : public QWidget
{
Q_OBJECT
public:
explicit calendarApp(QWidget *parent = nullptr);
~calendarApp();
private slots:
void on_backBtn_clicked();
private:
Ui::calendarApp *ui;
};
#endif // CALENDARAPP_H

56
calendarapp.ui Normal file
View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>calendarApp</class>
<widget class="QWidget" name="calendarApp">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>505</width>
<height>392</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCalendarWidget" name="calendarWidget"/>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="backBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Back
</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

16
def.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef DEF_H
#define DEF_H
#include <QWidget>
class settingsRegistry : QWidget
{
public:
settingsRegistry();
private:
protected:
void closeEvent(QCloseEvent *event);
};
#endif // DEF_H

11616
dictionary/A/definitions Normal file

File diff suppressed because it is too large Load diff

11616
dictionary/A/index Normal file

File diff suppressed because it is too large Load diff

34
eink.qrc Normal file
View file

@ -0,0 +1,34 @@
<RCC>
<qresource prefix="/">
<file>resources/eink.qss</file>
<file>resources/checkbox-checked.png</file>
<file>resources/checkbox-unchecked.png</file>
<file>resources/align-center.png</file>
<file>resources/align-justify.png</file>
<file>resources/align-left.png</file>
<file>resources/align-right.png</file>
<file>resources/chesterton.jpg</file>
<file>resources/alcott.jpg</file>
<file>resources/davies.jpg</file>
<file>resources/king.jpg</file>
<file>resources/star.png</file>
<file>resources/starred_star.png</file>
<file>resources/close.png</file>
<file>resources/chevron-left.png</file>
<file>resources/chevron-right.png</file>
<file>resources/christie.png</file>
<file>resources/exit.png</file>
<file>resources/usbms.png</file>
<file>resources/settings.png</file>
<file>resources/search.png</file>
<file>resources/power.png</file>
<file>resources/book.png</file>
<file>resources/apps.png</file>
<file>resources/battery_half.png</file>
<file>resources/battery_full.png</file>
<file>resources/battery_empty.png</file>
<file>resources/battery_charging.png</file>
<file>resources/alert.png</file>
<file>resources/eink_dark.qss</file>
</qresource>
</RCC>

8
functions.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#endif // FUNCTIONS_H
void thing() {
}

51
inkbox.pro Normal file
View file

@ -0,0 +1,51 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# 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
SOURCES += \
alert.cpp \
apps.cpp \
calendarapp.cpp \
main.cpp \
mainwindow.cpp \
quit.cpp \
reader.cpp \
savedwords.cpp \
settings.cpp \
usbms_splash.cpp
HEADERS += \
alert.h \
apps.h \
calendarapp.h \
mainwindow.h \
quit.h \
reader.h \
savedwords.h \
settings.h \
usbms_splash.h
FORMS += \
alert.ui \
apps.ui \
calendarapp.ui \
mainwindow.ui \
quit.ui \
reader.ui \
savedwords.ui \
settings.ui \
usbms_splash.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
eink.qrc

36
main.cpp Normal file
View file

@ -0,0 +1,36 @@
#include "mainwindow.h"
#include "alert.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
int main(int argc, char *argv[])
{
// 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) {
QApplication a(argc, argv);
alert w;
w.show();
return a.exec();
}
else {
QApplication a(argc, argv);
MainWindow w;
QApplication::setStyle("windows");
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
w.setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
w.show();
return a.exec();
}
}

386
mainwindow.cpp Normal file
View file

@ -0,0 +1,386 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "settings.h"
#include "ui_settings.h"
#include "apps.h"
#include "ui_apps.h"
#include <QTime>
#include <QDateTime>
#include <QTimer>
#include <QMessageBox>
#include <QString>
#include <QFile>
#include <string>
#include <iostream>
#include <fstream>
#include <QTextStream>
#include <QPixmap>
#include <QScreen>
using namespace std;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->settingsBtn->setProperty("type", "borderless");
ui->appsBtn->setProperty("type", "borderless");
ui->quitBtn->setProperty("type", "borderless");
ui->searchBtn->setProperty("type", "borderless");
ui->pushButton->setProperty("type", "borderless");
ui->settingsBtn->setText("");
ui->appsBtn->setText("");
ui->pushButton->setText("");
ui->quitBtn->setText("");
ui->searchBtn->setText("");
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height();
// Defining what the default icon size will be
float stdIconWidth;
float stdIconHeight;
string_checkconfig("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n") {
stdIconWidth = sW / 12;
stdIconHeight = sH / 12;
}
else {
stdIconWidth = sW / 14;
stdIconHeight = sH / 14;
}
// Setting icons up
ui->pushButton->setIcon(QIcon(":/resources/book.png"));
ui->pushButton->setIconSize(QSize(stdIconWidth, stdIconHeight));
ui->searchBtn->setIcon(QIcon(":/resources/search.png"));
ui->searchBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
ui->settingsBtn->setIcon(QIcon(":/resources/settings.png"));
ui->settingsBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
ui->appsBtn->setIcon(QIcon(":/resources/apps.png"));
ui->appsBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
ui->quitBtn->setIcon(QIcon(":/resources/power.png"));
ui->quitBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
ui->book1Btn->setStyleSheet("font-size: 11pt; padding: 25px");
ui->book2Btn->setStyleSheet("font-size: 11pt; padding: 25px");
ui->book3Btn->setStyleSheet("font-size: 11pt; padding: 25px");
ui->book4Btn->setStyleSheet("font-size: 11pt; padding: 25px");
ui->book1Btn->hide();
ui->book2Btn->hide();
ui->book3Btn->hide();
ui->book4Btn->hide();
ui->recentBooksLabel->hide();
// Stylesheet
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
// Running rootfs changes script if it's there
// This is a BIG security flaw. Feel free to enable it, but it's not secure at all.
/*
if(checkconfig("/opt/inkbox_genuine") == true) {
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
QFile::copy("/mnt/onboard/onboard/.inkbox/rootfs.sh", "/external_root/rootfs.sh");
QString rootfs_prog ("chroot");
QStringList rootfs_args;
rootfs_args << "/external_root" << "/rootfs.sh";
QProcess *rootfs_proc = new QProcess();
rootfs_proc->start(rootfs_prog, rootfs_args);
rootfs_proc->waitForFinished();
QFile::remove("/mnt/onboard/onboard/.inkbox/rootfs.sh");
QFile::remove("/external_root/rootfs.sh");
}
}
else {
;
}
*/
// Custom settings
// Reading from the config files and tweaking the program according to the options set
// Safety mesure; /inkbox is a tmpfs
checked_box = false;
writeconfig("/inkbox/skip_opendialog", "SkipOpenDialog=");
// Demo setting, changes "Welcome to InkBox" label to "InkBox"
if(checkconfig(".config/01-demo/config") == true) {
ui->inkboxLabel->setText("InkBox");
}
// Dark mode: specfic to InkBox OS, but could be ported to Kobos running Nickel in the future
if(checkconfig("/opt/inkbox_genuine") == true) {
if(checkconfig(".config/10-dark_mode/config") == true) {
string_writeconfig("/tmp/invertScreen", "y");
}
else {
string_writeconfig("/tmp/invertScreen", "n");
}
}
// Clock setting to show seconds
if(checkconfig(".config/02-clock/config") == true) {
QTimer *t = new QTimer(this);
t->setInterval(500);
connect(t, &QTimer::timeout, [&]() {
QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd");
QString time = QTime::currentTime().toString("hh:mm:ss");
ui->timeLabel->setText(time);
ui->dateLabel->setText(date);
} );
t->start();
}
else {
QTimer *t = new QTimer(this);
t->setInterval(500);
connect(t, &QTimer::timeout, [&]() {
QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd");
QString time = QTime::currentTime().toString("hh:mm");
ui->timeLabel->setText(time);
ui->dateLabel->setText(date);
} );
t->start();
}
// We set the brightness level saved in the config file
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
set_brightness(brightness_value);
// Display quote if requested; otherwise, display recent books
string_checkconfig(".config/05-quote/config");
if(checkconfig_str_val == "") {
if(checkconfig("/opt/inkbox_genuine") == true) {
checked_box = true;
writeconfig(".config/05-quote/config", "DisableQuote=");
}
else {
checked_box = false;
writeconfig(".config/05-quote/config", "DisableQuote=");
}
}
if(checkconfig(".config/05-quote/config") == false) {
int quote_value = display_quote();
if(quote_value == 1) {
QPixmap pm(":/resources/chesterton.jpg");
ui->quotePictureLabel->setPixmap(pm);
ui->quotePictureLabel->setScaledContents(true);
ui->quoteLabel->setText("“A good novel tells us the truth about its hero; but a bad novel tells us the truth about its author.”\n― G.K. Chesterton");
}
if(quote_value == 2) {
QPixmap pm(":/resources/alcott.jpg");
ui->quotePictureLabel->setPixmap(pm);
ui->quotePictureLabel->setScaledContents(true);
ui->quoteLabel->setText("“I've got the key to my castle in the air, but whether I can unlock the door remains to be seen.”\n― Louisa May Alcott");
}
if(quote_value == 3) {
QPixmap pm(":/resources/king.jpg");
ui->quotePictureLabel->setPixmap(pm);
ui->quotePictureLabel->setScaledContents(true);
ui->quoteLabel->setText("“Quiet people have the loudest minds”\n― Stephen King");
}
if(quote_value == 4) {
QPixmap pm(":/resources/davies.jpg");
ui->quotePictureLabel->setPixmap(pm);
ui->quotePictureLabel->setScaledContents(true);
ui->quoteLabel->setText("“Authors like cats because they are such quiet, lovable, wise creatures, and cats like authors for the same reasons.”\n― Robertson Davies");
}
if(quote_value == 5) {
QPixmap pm(":/resources/christie.png");
ui->quotePictureLabel->setPixmap(pm);
ui->quotePictureLabel->setScaledContents(true);
ui->quoteLabel->setText("“One of the saddest things in life, is the things one remembers.”\n― Agatha Christie");
}
}
else {
ui->quoteLabel->hide();
ui->quotePictureLabel->hide();
ui->quoteHeadingLabel->setText("Books");
ui->book1Btn->show();
ui->book2Btn->show();
ui->book3Btn->show();
ui->book4Btn->show();
// Book 1
string_checkconfig(".config/08-recent_books/1");
if(checkconfig_str_val == "") {
ui->book1Btn->hide();
}
else {
relative_path = checkconfig_str_val.split("/").last();
relative_path.prepend(" ");
relative_path.append(" ");
ui->book1Btn->setText(relative_path);
existing_recent_books = true;
}
// Book 2
string_checkconfig(".config/08-recent_books/2");
if(checkconfig_str_val == "") {
ui->book2Btn->hide();
}
else {
relative_path = checkconfig_str_val.split("/").last();
relative_path.prepend(" ");
relative_path.append(" ");
ui->book2Btn->setText(relative_path);
existing_recent_books = true;
}
// Book 3
string_checkconfig(".config/08-recent_books/3");
if(checkconfig_str_val == "") {
ui->book3Btn->hide();
}
else {
relative_path = checkconfig_str_val.split("/").last();
relative_path.prepend(" ");
relative_path.append(" ");
ui->book3Btn->setText(relative_path);
existing_recent_books = true;
}
// Book 4
string_checkconfig(".config/08-recent_books/4");
if(checkconfig_str_val == "") {
ui->book4Btn->hide();
}
else {
relative_path = checkconfig_str_val.split("/").last();
relative_path.prepend(" ");
relative_path.append(" ");
ui->book4Btn->setText(relative_path);
existing_recent_books = true;
}
// Preventing from having the same label two times
if(ui->book2Btn->text() == ui->book1Btn->text()) {
ui->book2Btn->hide();
}
if(ui->book3Btn->text() == ui->book1Btn->text()) {
ui->book3Btn->hide();
}
if(ui->book4Btn->text() == ui->book1Btn->text()) {
ui->book4Btn->hide();
}
if(existing_recent_books == false) {
ui->recentBooksLabel->show();
}
else {
ui->recentBooksLabel->hide();
}
}
// Check if it's the first boot since an update and confirm that it installed successfully
if(checkconfig("/opt/inkbox_genuine") == true) {
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
string_checkconfig_ro("/external_root/opt/isa/version");
QString updatemsg = "InkBox update to v";
updatemsg = updatemsg.append(checkconfig_str_val);
updatemsg = updatemsg.remove(QRegExp("[\n]"));
updatemsg = updatemsg.append(" completed successfully.\n\nChangelog:\n");
string_checkconfig_ro("/external_root/opt/isa/changelog");
updatemsg = updatemsg.append(checkconfig_str_val);
QMessageBox::information(this, tr("Information"), updatemsg);
string_writeconfig("/external_root/opt/update/inkbox_updated", "false");
}
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_settingsBtn_clicked()
{
settingsWindow = new settings();
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
settingsWindow->showFullScreen();
}
void MainWindow::on_appsBtn_clicked()
{
appsWindow = new apps();
appsWindow->setAttribute(Qt::WA_DeleteOnClose);
appsWindow->showFullScreen();
}
void MainWindow::on_pushButton_clicked()
{
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
}
void MainWindow::on_searchBtn_clicked()
{
// Testing
/*alertWindow = new alert();
alertWindow->setAttribute(Qt::WA_DeleteOnClose);
alertWindow->showFullScreen();*/
}
void MainWindow::on_quitBtn_clicked()
{
quitWindow = new quit();
quitWindow->setAttribute(Qt::WA_DeleteOnClose);
quitWindow->showFullScreen();
}
void MainWindow::on_book1Btn_clicked()
{
checked_box = true;
writeconfig("/inkbox/skip_opendialog", "SkipOpenDialog=");
string_writeconfig("/inkbox/book_number", "1");
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
}
void MainWindow::on_book2Btn_clicked()
{
checked_box = true;
writeconfig("/inkbox/skip_opendialog", "SkipOpenDialog=");
string_writeconfig("/inkbox/book_number", "2");
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
}
void MainWindow::on_book3Btn_clicked()
{
checked_box = true;
writeconfig("/inkbox/skip_opendialog", "SkipOpenDialog=");
string_writeconfig("/inkbox/book_number", "3");
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
}
void MainWindow::on_book4Btn_clicked()
{
checked_box = true;
writeconfig("/inkbox/skip_opendialog", "SkipOpenDialog=");
string_writeconfig("/inkbox/book_number", "4");
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
}

148
mainwindow.h Normal file
View file

@ -0,0 +1,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

504
mainwindow.ui Normal file
View file

@ -0,0 +1,504 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>519</width>
<height>601</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<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 row="0" column="5">
<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 row="0" column="4">
<widget class="QLabel" name="label_2">
<property name="text">
<string>―</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="timeLabel">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="inkboxLabel">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Welcome to InkBox</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>―</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="dateLabel">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>date</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_6">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<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>
<widget class="QLabel" name="quoteHeadingLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Author's quote</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<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>
<widget class="QLabel" name="recentBooksLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Recently read books will appear here.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="book1Btn">
<property name="text">
<string>Book 1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="book2Btn">
<property name="text">
<string>Book 2</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="book3Btn">
<property name="text">
<string>Book 3</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="book4Btn">
<property name="text">
<string>Book 4</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="1">
<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="1" column="1">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="1">
<widget class="QLabel" name="quoteLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Quote</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="quotePictureLabel">
<property name="text">
<string>Picture</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<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>
<item row="1" column="3">
<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>
<item row="0" column="1">
<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>
<item>
<spacer name="verticalSpacer_4">
<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>
<widget class="Line" name="line_4">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Reader
</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="searchBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Search
</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="settingsBtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Settings
</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="appsBtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Apps
</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="quitBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Quit
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

78
quit.cpp Normal file
View file

@ -0,0 +1,78 @@
#include "quit.h"
#include "ui_quit.h"
#include <QProcess>
#include <QIcon>
#include <QPixmap>
#include <QFile>
#include <QDebug>
#include <QScreen>
quit::quit(QWidget *parent) :
QWidget(parent),
ui(new Ui::quit)
{
ui->setupUi(this);
ui->pushButton->setProperty("type", "borderless");
ui->pushButton_2->setProperty("type", "borderless");
ui->pushButton_3->setProperty("type", "borderless");
ui->pushButton_4->setProperty("type", "borderless");
ui->backBtn->setProperty("type", "borderless");
// Stylesheet
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height();
// Defining what the "Quit" icon size will be
float stdIconWidth = sW / 1.25;
float stdIconHeight = sH / 1.25;
QPixmap pixmap(":/resources/exit.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->label->setPixmap(scaledPixmap);
}
quit::~quit()
{
delete ui;
}
void quit::on_pushButton_clicked()
{
QString prog ("poweroff");
QStringList args;
QProcess *proc = new QProcess();
proc->start(prog, args);
}
void quit::on_pushButton_2_clicked()
{
QString prog ("reboot");
QStringList args;
QProcess *proc = new QProcess();
proc->start(prog, args);
}
void quit::on_pushButton_4_clicked()
{
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
void quit::on_backBtn_clicked()
{
quit::close();
}
void quit::on_pushButton_3_clicked()
{
// inotifywait waits for a MODIFY event, so we just do it instead of evtest and the power button
string_writeconfig("/external_root/tmp/power", "state changed");
}

43
quit.h Normal file
View file

@ -0,0 +1,43 @@
#ifndef QUIT_H
#define QUIT_H
#include <QWidget>
#include <fstream>
#include <iostream>
using namespace std;
namespace Ui {
class quit;
}
class quit : public QWidget
{
Q_OBJECT
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:
Ui::quit *ui;
};
#endif // QUIT_H

216
quit.ui Normal file
View file

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>quit</class>
<widget class="QWidget" name="quit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<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>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<spacer name="verticalSpacer_3">
<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="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Exit</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="1" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Suspend</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reboot</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Shutdown</string>
</property>
</widget>
</item>
<item row="2" column="2">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Restart InkBox</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Line" name="line_4">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</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>
<item>
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="backBtn">
<property name="text">
<string>Back</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

773
reader.cpp Normal file
View file

@ -0,0 +1,773 @@
#include "reader.h"
#include "ui_reader.h"
#include <QProcess>
#include <QFileDialog>
#include <QDir>
#include <QTimer>
#include <QTime>
#include <QMessageBox>
#include <QFont>
#include <QIcon>
#include <QSize>
#include <QDesktopWidget>
#include <QScreen>
using namespace std;
reader::reader(QWidget *parent) :
QWidget(parent),
ui(new Ui::reader)
{
ui->setupUi(this);
ui->previousBtn->setProperty("type", "borderless");
ui->nextBtn->setProperty("type", "borderless");
ui->hideOptionsBtn->setProperty("type", "borderless");
ui->optionsBtn->setProperty("type", "borderless");
ui->brightnessDecBtn->setProperty("type", "borderless");
ui->brightnessIncBtn->setProperty("type", "borderless");
ui->homeBtn->setProperty("type", "borderless");
ui->aboutBtn->setProperty("type", "borderless");
ui->alignLeftBtn->setProperty("type", "borderless");
ui->alignRightBtn->setProperty("type", "borderless");
ui->alignCenterBtn->setProperty("type", "borderless");
ui->alignLeftBtn->setProperty("type", "borderless");
ui->alignJustifyBtn->setProperty("type", "borderless");
ui->infoCloseBtn->setProperty("type", "borderless");
ui->saveWordBtn->setProperty("type", "borderless");
ui->previousDefinitionBtn->setProperty("type", "borderless");
ui->nextDefinitionBtn->setProperty("type", "borderless");
// Icons
ui->alignLeftBtn->setText("");
ui->alignLeftBtn->setIcon(QIcon(":/resources/align-left.png"));
ui->alignRightBtn->setText("");
ui->alignRightBtn->setIcon(QIcon(":/resources/align-right.png"));
ui->alignCenterBtn->setText("");
ui->alignCenterBtn->setIcon(QIcon(":/resources/align-center.png"));
ui->alignJustifyBtn->setText("");
ui->alignJustifyBtn->setIcon(QIcon(":/resources/align-justify.png"));
ui->infoCloseBtn->setText("");
ui->infoCloseBtn->setIcon(QIcon(":/resources/close.png"));
ui->saveWordBtn->setText("");
ui->saveWordBtn->setIcon(QIcon(":/resources/star.png"));
ui->previousDefinitionBtn->setText("");
ui->previousDefinitionBtn->setIcon(QIcon(":/resources/chevron-left.png"));
ui->nextDefinitionBtn->setText("");
ui->nextDefinitionBtn->setIcon(QIcon(":/resources/chevron-right.png"));
// Making text selectable
ui->text->setTextInteractionFlags(Qt::TextSelectableByMouse);
// Custom settings
// Font
string_checkconfig(".config/04-book/font");
if(checkconfig_str_val == "") {
;
}
else {
QFont config_font(checkconfig_str_val);
ui->text->setFont(config_font);
ui->fontChooser->setCurrentText(checkconfig_str_val);
}
// Alignment
string_checkconfig(".config/04-book/alignment");
if (checkconfig_str_val == "") {
;
}
else {
if(checkconfig_str_val == "Left") {
ui->text->setAlignment(Qt::AlignLeft);
}
if(checkconfig_str_val == "Center") {
ui->text->setAlignment(Qt::AlignHCenter);
}
if(checkconfig_str_val == "Right") {
ui->text->setAlignment(Qt::AlignRight);
}
if(checkconfig_str_val == "Justify") {
ui->text->setAlignment(Qt::AlignJustify);
}
}
// Stylesheet + misc.
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->sizeValueLabel->setStyleSheet("font-size: 9pt");
// Hiding the menubar + definition widget
ui->inkboxLabel->hide();
ui->hideOptionsBtn->hide();
ui->line_4->hide();
ui->line_5->hide();
ui->line_6->hide();
ui->line_7->hide();
ui->line_8->hide();
ui->line_9->hide();
ui->line_10->hide();
ui->line_11->hide();
ui->line_12->hide();
ui->line_13->hide();
ui->line_14->hide();
ui->timeLabel->hide();
ui->brightnessDecBtn->hide();
ui->brightnessIncBtn->hide();
ui->brightnessLabel->hide();
ui->brightnessStatus->hide();
ui->homeBtn->hide();
ui->aboutBtn->hide();
ui->batteryLabel->hide();
ui->batteryIconLabel->hide();
ui->fontChooser->hide();
ui->fontLabel->hide();
ui->styleLabel->hide();
ui->alignmentLabel->hide();
ui->alignJustifyBtn->hide();
ui->alignCenterBtn->hide();
ui->alignLeftBtn->hide();
ui->alignRightBtn->hide();
ui->sizeLabel->hide();
ui->sizeSlider->hide();
ui->sizeValueLabel->hide();
ui->infoCloseBtn->hide();
ui->saveWordBtn->hide();
ui->previousDefinitionBtn->hide();
ui->nextDefinitionBtn->hide();
ui->definitionLabel->hide();
ui->wordSearchLabel->hide();
ui->wordLabel->hide();
ui->definitionStatusLabel->hide();
// Getting brightness level
int brightness_value = get_brightness();
ui->brightnessStatus->setValue(brightness_value);
// Defining pixmaps
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height();
// Defining what the icons' size will be
if(checkconfig("/opt/inkbox_genuine") == true) {
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n") {
float stdIconWidth = sW / 16;
float stdIconHeight = sW / 16;
QPixmap chargingPixmap(":/resources/battery_charging.png");
scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap fullPixmap(":/resources/battery_full.png");
scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap halfPixmap(":/resources/battery_half.png");
scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap emptyPixmap(":/resources/battery_empty.png");
scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
}
else {
float stdIconWidth = sW / 19;
float stdIconHeight = sH / 19;
QPixmap chargingPixmap(":/resources/battery_charging.png");
scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap fullPixmap(":/resources/battery_full.png");
scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap halfPixmap(":/resources/battery_half.png");
scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap emptyPixmap(":/resources/battery_empty.png");
scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
}
}
else {
float stdIconWidth = sW / 19;
float stdIconHeight = sH / 19;
QPixmap chargingPixmap(":/resources/battery_charging.png");
scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap fullPixmap(":/resources/battery_full.png");
scaledFullPixmap = fullPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap halfPixmap(":/resources/battery_half.png");
scaledHalfPixmap = halfPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
QPixmap emptyPixmap(":/resources/battery_empty.png");
scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
}
// Clock setting to show seconds + battery level
if(checkconfig(".config/02-clock/config") == true) {
QTimer *t = new QTimer(this);
t->setInterval(500);
connect(t, &QTimer::timeout, [&]() {
QString time = QTime::currentTime().toString("hh:mm:ss");
get_battery_level();
ui->batteryLabel->setText(batt_level);
ui->timeLabel->setText(time);
} );
t->start();
}
else {
QTimer *t = new QTimer(this);
t->setInterval(500);
connect(t, &QTimer::timeout, [&]() {
QString time = QTime::currentTime().toString("hh:mm");
get_battery_level();
ui->batteryLabel->setText(batt_level);
ui->timeLabel->setText(time);
} );
t->start();
}
// Word selection & dictionary lookup feature
QString dictionary_position_str = QString::number(dictionary_position);
ui->definitionStatusLabel->setText(dictionary_position_str);
QTimer *select_t = new QTimer(this);
select_t->setInterval(100);
connect(select_t, &QTimer::timeout, [&]() {
selected_text = ui->text->selectedText();
if(ui->text->hasSelectedText() == true) {
if(selected_text_lock == false) {
selected_text_lock = true;
QStringList parts = selected_text.split(' ', QString::SkipEmptyParts);
for (int i = 0; i < parts.size(); ++i)
parts[i].replace(0, 1, parts[i][0].toUpper());
word = parts.join(" ");
letter = word.left(1);
selected_text_str = word.toStdString();
dictionary_lookup(selected_text_str, letter, dictionary_position);
ui->wordLabel->setText(word);
ui->definitionLabel->setText(definition);
if(checkconfig_match(".config/06-words/config", selected_text_str) == true) {
ui->saveWordBtn->setText("");
ui->saveWordBtn->setIcon(QIcon(":/resources/starred_star.png"));
}
else {
ui->saveWordBtn->setText("");
ui->saveWordBtn->setIcon(QIcon(":/resources/star.png"));
}
wordwidget_show();
}
else {
;
}
}
else {
;
}
} );
select_t->start();
// We have to get the file's path
if(checkconfig("/inkbox/skip_opendialog") == true) {
string_checkconfig("/inkbox/book_number");
if(checkconfig_str_val == "1") {
string_checkconfig(".config/08-recent_books/1");
book_file = checkconfig_str_val;
}
if(checkconfig_str_val == "2") {
string_checkconfig(".config/08-recent_books/2");
book_file = checkconfig_str_val;
}
if(checkconfig_str_val == "3") {
string_checkconfig(".config/08-recent_books/3");
book_file = checkconfig_str_val;
}
if(checkconfig_str_val == "4") {
string_checkconfig(".config/08-recent_books/4");
book_file = checkconfig_str_val;
}
}
else {
if(checkconfig("/opt/inkbox_genuine") == true) {
QDir::setCurrent("/mnt/onboard/onboard");
QFileDialog *dialog = new QFileDialog(this);
// https://forum.qt.io/topic/29471/solve-how-to-show-qfiledialog-at-center-position-screen/4
QDesktopWidget desk;
QRect screenres = desk.screenGeometry(0); dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
stylesheetFile.open(QFile::ReadOnly);
dialog->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
}
else {
QDir::setCurrent("/mnt/onboard");
QFileDialog *dialog = new QFileDialog(this);
// https://forum.qt.io/topic/29471/solve-how-to-show-qfiledialog-at-center-position-screen/4
QDesktopWidget desk;
QRect screenres = desk.screenGeometry(0); dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
stylesheetFile.open(QFile::ReadOnly);
dialog->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
}
}
// Counting number of parsed files
split_total = setup_book(book_file, 0, true);
split_total = split_total - 1;
split_files_number = setup_book(book_file, 0, true);
split_files_number = split_files_number / 2;
// Get text
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
setup_book(book_file, split_total, false);
// Display text
// Checking saved font size if any
string_checkconfig(".config/04-book/size");
if(checkconfig_str_val == "0") {
checkconfig_str_val = "6";
ui->sizeSlider->setValue(0);
ui->sizeValueLabel->setText("1");
}
if(checkconfig_str_val == "1") {
checkconfig_str_val = "10";
ui->sizeSlider->setValue(1);
ui->sizeValueLabel->setText("2");
}
if(checkconfig_str_val == "2") {
checkconfig_str_val = "14";
ui->sizeSlider->setValue(2);
ui->sizeValueLabel->setText("3");
}
if(checkconfig_str_val == "3") {
checkconfig_str_val = "18";
ui->sizeSlider->setValue(3);
ui->sizeValueLabel->setText("4");
}
if(checkconfig_str_val == "4") {
checkconfig_str_val = "22";
ui->sizeSlider->setValue(4);
ui->sizeValueLabel->setText("5");
}
if(checkconfig_str_val == "") {
checkconfig_str_val = "10";
ui->sizeSlider->setValue(1);
ui->sizeValueLabel->setText("2");
}
QString font_size = "font-size: ";
font_size = font_size.append(checkconfig_str_val);
font_size = font_size.append("pt");
ui->text->setStyleSheet(font_size);
// Wheeee!
ui->text->setText(ittext);
// Saving the book opened in the favorites list
string_checkconfig(".config/08-recent_books/1");
book_1 = checkconfig_str_val;
string str_book_1 = book_1.toStdString();
string_checkconfig(".config/08-recent_books/2");
book_2 = checkconfig_str_val;
string str_book_2 = book_2.toStdString();
string_checkconfig(".config/08-recent_books/3");
book_3 = checkconfig_str_val;
string str_book_3 = book_3.toStdString();
string_checkconfig(".config/08-recent_books/4");
book_4 = checkconfig_str_val;
string str_book_4 = book_4.toStdString();
string book_file_str = book_file.toStdString();
if(book_1 == book_file) {
;
}
else {
// Moves old items to the right and puts the new one at the left side
string_writeconfig(".config/08-recent_books/1", book_file_str);
string_writeconfig(".config/08-recent_books/2", str_book_1);
string_writeconfig(".config/08-recent_books/3", str_book_2);
string_writeconfig(".config/08-recent_books/4", str_book_3);
}
}
reader::~reader()
{
delete ui;
}
void reader::on_nextBtn_clicked()
{
if(split_total - 1 == 0) {
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
}
else {
split_total = split_total - 1;
setup_book(book_file, split_total, false);
ui->text->setText("");
ui->text->setText(ittext);
}
}
void reader::on_previousBtn_clicked()
{
// Making sure we won't encounter a "List index out of range" error ;)
if(split_total >= split_files_number) {
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
}
else {
split_total = split_total + 1;
setup_book(book_file, split_total, false);
ui->text->setText("");
ui->text->setText(ittext);
}
}
void reader::on_optionsBtn_clicked()
{
menubar_show();
}
void reader::on_hideOptionsBtn_clicked()
{
menubar_hide();
this->repaint();
}
void reader::on_brightnessDecBtn_clicked()
{
int bval = get_brightness();
int set_bval = bval - 1;
set_brightness(set_bval);
brightness_writeconfig(set_bval);
bval = get_brightness();
ui->brightnessStatus->setValue(bval);
}
void reader::on_brightnessIncBtn_clicked()
{
int bval = get_brightness();
int set_bval = bval + 1;
set_brightness(set_bval);
brightness_writeconfig(set_bval);
bval = get_brightness();
ui->brightnessStatus->setValue(bval);
}
void reader::on_aboutBtn_clicked()
{
if(checkconfig("/opt/inkbox_genuine") == true) {
QString aboutmsg = "InkBox is an open-source Qt-based eBook reader. It brings you the latest Qt features while being also fast and responsive.";
string_checkconfig_ro("/external_root/opt/isa/version");
aboutmsg.append("\n\nInkBox v");
aboutmsg.append(checkconfig_str_val);
QMessageBox::information(this, tr("Information"), aboutmsg);
}
else {
QMessageBox::information(this, tr("About"), tr("InkBox is an open-source Qt-based eBook reader. It brings you the latest Qt features while being also fast and responsive."));
}
}
void reader::on_homeBtn_clicked()
{
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
void reader::on_fontChooser_currentIndexChanged(const QString &arg1)
{
if(arg1 == "Roboto") {
QFont roboto("Roboto");
ui->text->setFont(roboto);
string_writeconfig(".config/04-book/font", "Roboto");
}
if(arg1 == "Inter") {
QFont inter("Inter");
ui->text->setFont(inter);
string_writeconfig(".config/04-book/font", "Inter");
}
if(arg1 == "Source Serif Pro") {
QFont sourceserif("Source Serif Pro");
ui->text->setFont(sourceserif);
string_writeconfig(".config/04-book/font", "Source Serif Pro");
}
if(arg1 == "Libre Baskerville") {
QFont librebaskerville("Libre Baskerville");
ui->text->setFont(librebaskerville);
string_writeconfig(".config/04-book/font", "Libre Baskerville");
}
if(arg1 == "Noto Mono") {
QFont notomono("Noto Mono");
ui->text->setFont(notomono);
string_writeconfig(".config/04-book/font", "Noto Mono");
}
if(arg1 == "Libertinus Serif") {
QFont libertinus("Libertinus Serif");
ui->text->setFont(libertinus);
string_writeconfig(".config/04-book/font", "Libertinus Serif");
}
}
void reader::on_alignLeftBtn_clicked()
{
ui->text->setAlignment(Qt::AlignLeft);
string_writeconfig(".config/04-book/alignment", "Left");
}
void reader::on_alignCenterBtn_clicked()
{
ui->text->setAlignment(Qt::AlignHCenter);
string_writeconfig(".config/04-book/alignment", "Center");
}
void reader::on_alignRightBtn_clicked()
{
ui->text->setAlignment(Qt::AlignRight);
string_writeconfig(".config/04-book/alignment", "Right");
}
void reader::on_alignJustifyBtn_clicked()
{
ui->text->setAlignment(Qt::AlignJustify);
string_writeconfig(".config/04-book/alignment", "Justify");
}
void reader::menubar_show() {
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
if(checkconfig_str_val == "Charging\n") {
ui->batteryIconLabel->setPixmap(scaledChargingPixmap);
}
else {
get_battery_level();
if(batt_level_int >= 75 && batt_level_int <= 100) {
ui->batteryIconLabel->setPixmap(scaledFullPixmap);
}
if(batt_level_int >= 25 && batt_level_int <= 74) {
ui->batteryIconLabel->setPixmap(scaledHalfPixmap);
}
if(batt_level_int >= 0 && batt_level_int <= 24) {
ui->batteryIconLabel->setPixmap(scaledEmptyPixmap);
}
}
ui->inkboxLabel->show();
ui->hideOptionsBtn->show();
ui->optionsBtn->hide();
ui->line_4->show();
ui->line_5->show();
ui->line_6->show();
ui->line_7->show();
ui->line_8->show();
ui->line_9->show();
ui->line_10->show();
ui->line_11->show();
ui->timeLabel->show();
ui->brightnessDecBtn->show();
ui->brightnessIncBtn->show();
ui->brightnessLabel->show();
ui->brightnessStatus->show();
ui->aboutBtn->show();
ui->homeBtn->show();
ui->batteryLabel->show();
ui->batteryIconLabel->show();
ui->fontChooser->show();
ui->fontLabel->show();
ui->styleLabel->show();
ui->alignmentLabel->show();
ui->alignJustifyBtn->show();
ui->alignCenterBtn->show();
ui->alignLeftBtn->show();
ui->alignRightBtn->show();
ui->sizeLabel->show();
ui->sizeSlider->show();
ui->sizeValueLabel->show();
menubar_shown = true;
}
void reader::menubar_hide() {
ui->inkboxLabel->hide();
ui->hideOptionsBtn->hide();
ui->line_4->hide();
ui->line_5->hide();
ui->line_6->hide();
ui->line_7->hide();
ui->line_8->hide();
ui->line_9->hide();
ui->line_10->hide();
ui->line_11->hide();
ui->optionsBtn->show();
ui->timeLabel->hide();
ui->brightnessDecBtn->hide();
ui->brightnessIncBtn->hide();
ui->brightnessLabel->hide();
ui->brightnessStatus->hide();
ui->aboutBtn->hide();
ui->homeBtn->hide();
ui->batteryLabel->hide();
ui->batteryIconLabel->hide();
ui->fontChooser->hide();
ui->fontLabel->hide();
ui->styleLabel->hide();
ui->alignmentLabel->hide();
ui->alignJustifyBtn->hide();
ui->alignCenterBtn->hide();
ui->alignLeftBtn->hide();
ui->alignRightBtn->hide();
ui->sizeLabel->hide();
ui->sizeSlider->hide();
ui->sizeValueLabel->hide();
menubar_shown = false;
}
void reader::wordwidget_show() {
if(menubar_shown == true) {
menubar_hide();
ui->optionsBtn->hide();
ui->hideOptionsBtn->hide();
ui->infoCloseBtn->show();
ui->saveWordBtn->show();
ui->previousDefinitionBtn->show();
ui->nextDefinitionBtn->show();
ui->definitionLabel->show();
ui->wordSearchLabel->show();
ui->wordLabel->show();
ui->definitionStatusLabel->show();
ui->line->hide();
ui->line_12->show();
ui->line_13->show();
ui->line_14->show();
}
else {
ui->optionsBtn->hide();
ui->hideOptionsBtn->hide();
ui->infoCloseBtn->show();
ui->saveWordBtn->show();
ui->definitionLabel->show();
ui->definitionStatusLabel->show();
ui->previousDefinitionBtn->show();
ui->nextDefinitionBtn->show();
ui->wordSearchLabel->show();
ui->wordLabel->show();
ui->line_13->show();
ui->line_12->show();
ui->line->hide();
ui->line_14->show();
}
}
void reader::wordwidget_hide() {
ui->infoCloseBtn->hide();
ui->saveWordBtn->hide();
ui->definitionLabel->hide();
ui->wordSearchLabel->hide();
ui->wordLabel->hide();
ui->line_12->hide();
ui->line_13->hide();
ui->line_14->hide();
ui->line->show();
ui->optionsBtn->show();
ui->previousDefinitionBtn->hide();
ui->nextDefinitionBtn->hide();
ui->definitionStatusLabel->hide();
selected_text_lock = false;
}
void reader::on_infoCloseBtn_clicked()
{
wordwidget_hide();
dictionary_position = 1;
QString dictionary_position_str = QString::number(dictionary_position);
ui->definitionStatusLabel->setText(dictionary_position_str);
}
void reader::on_previousDefinitionBtn_clicked()
{
dictionary_position = dictionary_position - 1;
if(dictionary_position <= 0) {
dictionary_position = 1;
}
else {
dictionary_lookup(selected_text_str, letter, dictionary_position);
ui->definitionLabel->setText(definition);
QString dictionary_position_str = QString::number(dictionary_position);
ui->definitionStatusLabel->setText(dictionary_position_str);
}
}
void reader::on_nextDefinitionBtn_clicked()
{
dictionary_position = dictionary_position + 1;
dictionary_lookup(selected_text_str, letter, dictionary_position);
if(nextdefinition_lock == true) {
dictionary_position = dictionary_position - 1;
}
else {
ui->definitionLabel->setText(definition);
QString dictionary_position_str = QString::number(dictionary_position);
ui->definitionStatusLabel->setText(dictionary_position_str);
}
}
void reader::on_saveWordBtn_clicked()
{
if(checkconfig_match(".config/06-words/config", selected_text_str) == true) {
checkwords();
word = word.append("\n");
words = words.replace(word, "");
string words_std_string = words.toStdString();
save_word(words_std_string, true);
ui->saveWordBtn->setText("");
ui->saveWordBtn->setIcon(QIcon(":/resources/star.png"));
}
else {
save_word(selected_text_str, false);
ui->saveWordBtn->setText("");
ui->saveWordBtn->setIcon(QIcon(":/resources/starred_star.png"));
}
}
void reader::on_sizeSlider_valueChanged(int value)
{
// Font size
string value_str = to_string(value);
string_writeconfig(".config/04-book/size", value_str);
// Future improvement?
if(checkconfig_match("/opt/inkbox_device", "n705\n") == true) {
if(value == 0) {
ui->text->setStyleSheet("font-size: 6pt");
ui->sizeValueLabel->setText("1");
}
if(value == 1) {
ui->text->setStyleSheet("font-size: 10pt");
ui->sizeValueLabel->setText("2");
}
if(value == 2) {
ui->text->setStyleSheet("font-size: 14pt");
ui->sizeValueLabel->setText("3");
}
if(value == 3) {
ui->text->setStyleSheet("font-size: 18pt");
ui->sizeValueLabel->setText("4");
}
if(value == 4) {
ui->text->setStyleSheet("font-size: 22pt");
ui->sizeValueLabel->setText("5");
}
}
else {
if(value == 0) {
ui->text->setStyleSheet("font-size: 6pt");
ui->sizeValueLabel->setText("1");
}
if(value == 1) {
ui->text->setStyleSheet("font-size: 10pt");
ui->sizeValueLabel->setText("2");
}
if(value == 2) {
ui->text->setStyleSheet("font-size: 14pt");
ui->sizeValueLabel->setText("3");
}
if(value == 3) {
ui->text->setStyleSheet("font-size: 18pt");
ui->sizeValueLabel->setText("4");
}
if(value == 4) {
ui->text->setStyleSheet("font-size: 22pt");
ui->sizeValueLabel->setText("5");
}
}
}

304
reader.h Normal file
View file

@ -0,0 +1,304 @@
#ifndef READER_H
#define READER_H
#include <QWidget>
#include <QProcess>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QDirIterator>
#include <QList>
#include <iostream>
#include <fstream>
#include <QMessageBox>
#include <regex>
using namespace std;
namespace Ui {
class reader;
}
class reader : public QWidget
{
Q_OBJECT
public:
int split_total;
int split_files_number;
int page_number;
int dictionary_position = 1;
int batt_level_int;
bool menubar_shown = false;
bool selected_text_lock = false;
bool nextdefinition_lock = false;
QString book_1;
QString book_2;
QString book_3;
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
QString letter;
string selected_text_str;
QString definition;
QPixmap scaledChargingPixmap;
QPixmap scaledHalfPixmap;
QPixmap scaledFullPixmap;
QPixmap scaledEmptyPixmap;
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
// TODO: Use BeautifulSoup with Python to parse ePUBs and display them... somehow (?
QString mount_prog ("sh");
QStringList mount_args;
mount_args << "split.sh";
QProcess *mount_proc = new QProcess();
mount_proc->start(mount_prog, mount_args);
mount_proc->waitForFinished();
// Copying book specified in the function call
QFile::copy(book, "/inkbox/book/book.txt");
// Checking if the user has defined an option for the number of words per page; if not, then setting the default.
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
string_checkconfig(".config/07-words_number/config");
if(checkconfig_str_val == "") {
string_writeconfig(".config/07-words_number/config", "100");
string_checkconfig(".config/07-words_number/config");
}
// Parsing file
QString parse_prog ("python3");
QStringList parse_args;
parse_args << "split.py" << checkconfig_str_val;
QProcess *parse_proc = new QProcess();
parse_proc->start(parse_prog, parse_args);
parse_proc->waitForFinished();
// Changing current working directory
QDir::setCurrent("/inkbox/book");
// Reading file
if(run_parser == true) {
QDirIterator it("/inkbox/book/split");
while (it.hasNext()) {
QFile f(it.next());
f.open(QIODevice::ReadOnly);
content << f.readAll();
f.close();
}
return content.size();
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
}
else {
ittext = content[i];
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();
qDebug() << value;
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);
QTextStream in (&words_list);
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();
};
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");
fhandler << word;
fhandler.close();
QDir::setCurrent("dictionary");
QDir::setCurrent(first_letter);
QString lookup_prog ("sh");
QStringList lookup_args;
QString position_str = QString::number(position);
lookup_args << "../scripts/lookup.sh" << position_str;
QProcess *lookup_proc = new QProcess();
lookup_proc->start(lookup_prog, lookup_args);
lookup_proc->waitForFinished();
QFile definition_file("/inkbox/dictionary/definition");
definition_file.open(QIODevice::ReadWrite);
QTextStream in (&definition_file);
definition = in.readAll();
definition = definition.remove(QRegExp("[\n]"));
if(definition == "No definition found.") {
nextdefinition_lock = true;
}
else {
nextdefinition_lock = false;
}
definition_file.close();
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
}
void save_word(string word, bool remove) {
if(remove == false) {
QFile words(".config/06-words/config");
words.open(QIODevice::ReadWrite);
QTextStream in (&words);
QString words_list = in.readAll();
string words_list_str = words_list.toStdString();
words.close();
ofstream fhandler;
fhandler.open(".config/06-words/config");
fhandler << words_list_str << word << "\n";
fhandler.close();
}
else {
ofstream fhandler;
fhandler.open(".config/06-words/config");
fhandler << word;
fhandler.close();
}
}
void menubar_show();
void menubar_hide();
void wordwidget_show();
void wordwidget_hide();
private slots:
void on_nextBtn_clicked();
void on_previousBtn_clicked();
void on_optionsBtn_clicked();
void on_hideOptionsBtn_clicked();
void on_brightnessDecBtn_clicked();
void on_brightnessIncBtn_clicked();
void on_aboutBtn_clicked();
void on_homeBtn_clicked();
void on_fontChooser_currentIndexChanged(const QString &arg1);
void on_alignLeftBtn_clicked();
void on_alignCenterBtn_clicked();
void on_alignRightBtn_clicked();
void on_alignJustifyBtn_clicked();
void on_infoCloseBtn_clicked();
void on_previousDefinitionBtn_clicked();
void on_nextDefinitionBtn_clicked();
void on_saveWordBtn_clicked();
void on_sizeSlider_valueChanged(int value);
private:
Ui::reader *ui;
};
#endif // READER_H

820
reader.ui Normal file
View file

@ -0,0 +1,820 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>reader</class>
<widget class="QWidget" name="reader">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>620</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="9" 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>
<item row="12" column="0">
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_14">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="Line" name="line_14">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="definitionLabel">
<property name="font">
<font>
<family>Source Serif Pro</family>
</font>
</property>
<property name="text">
<string>Definition</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="wordLabel">
<property name="font">
<font>
<family>Ubuntu</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Word</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_5">
<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">
<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>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_4">
<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="4" column="0">
<layout class="QGridLayout" name="gridLayout_9">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer_7">
<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="1">
<widget class="QPushButton" name="previousDefinitionBtn">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item row="0" column="4">
<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="QLabel" name="definitionStatusLabel">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="nextDefinitionBtn">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_3">
<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>
<item row="5" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="3">
<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 row="0" column="2">
<widget class="QPushButton" name="aboutBtn">
<property name="text">
<string> About </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="batteryLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Battery</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="homeBtn">
<property name="text">
<string> Home </string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="batteryIconLabel">
<property name="text">
<string>Battery Icon</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="Line" name="line_6">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QLabel" name="timeLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>time</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="inkboxLabel">
<property name="text">
<string>InkBox</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<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>
</layout>
</item>
<item row="10" column="0">
<widget class="Line" name="line_12">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="Line" name="line_4">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="11" column="0">
<layout class="QGridLayout" name="gridLayout_5">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1">
<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>
<item row="0" column="4">
<widget class="QPushButton" name="infoCloseBtn">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="wordSearchLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Word search</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="saveWordBtn">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="0" column="3">
<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 row="1" column="0">
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="Line" name="line_13">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="text">
<property name="font">
<font>
<family>Ubuntu</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Text</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" 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="15" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="4">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="previousBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="optionsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Options</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="nextBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="hideOptionsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Hide</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="styleLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Style</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_10">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="fontChooser">
<item>
<property name="text">
<string>Inter</string>
</property>
</item>
<item>
<property name="text">
<string>Source Serif Pro</string>
</property>
</item>
<item>
<property name="text">
<string>Libre Baskerville</string>
</property>
</item>
<item>
<property name="text">
<string>Libertinus Serif</string>
</property>
</item>
<item>
<property name="text">
<string>Noto Mono</string>
</property>
</item>
<item>
<property name="text">
<string>Roboto</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="fontLabel">
<property name="text">
<string>Font:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="alignmentLabel">
<property name="text">
<string>Alignment:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="4">
<widget class="QPushButton" name="alignRightBtn">
<property name="font">
<font>
<family>Ubuntu</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="alignLeftBtn">
<property name="font">
<font>
<family>Ubuntu</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Left</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="alignCenterBtn">
<property name="text">
<string>Center</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="alignJustifyBtn">
<property name="font">
<font>
<family>Ubuntu</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Justify</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="Line" name="line_10">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_9">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="Line" name="line_11">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="sizeLabel">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QSlider" name="sizeSlider">
<property name="maximum">
<number>4</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="sizeValueLabel">
<property name="text">
<string>Value</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="Line" name="line_8">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QProgressBar" name="brightnessStatus">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="brightnessDecBtn">
<property name="text">
<string>―</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="brightnessLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Brightness</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="brightnessIncBtn">
<property name="text">
<string> + </string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

36
resources.qrc Normal file
View file

@ -0,0 +1,36 @@
<RCC>
<qresource prefix="/">
<file>eink.qss</file>
<file>images/mangahostlogos/mangadex.png</file>
<file>images/mangahostlogos/mangapanda.png</file>
<file>images/icons/darker.png</file>
<file>images/icons/lighter.png</file>
<file>images/icons/moon.png</file>
<file>images/icons/sun.png</file>
<file>images/icons/favourite-star.png</file>
<file>images/icons/favourite-star-full.png</file>
<file>images/icons/backspace.png</file>
<file>images/mangahostlogos/jaiminisbox.png</file>
<file>images/icons/batterycharging.png</file>
<file>images/mangahostlogos/mangakakalot.png</file>
<file>images/icons/batteryempty.png</file>
<file>images/icons/batteryfull.png</file>
<file>images/mangahostlogos/mangahub.png</file>
<file>images/mangahostlogos/mangaowl.png</file>
<file>images/icons/keyboardicons.svg</file>
<file>images/icons/home.png</file>
<file>images/icons/wifi.png</file>
<file>images/icons/no-wifi.png</file>
<file>images/icons/menu.png</file>
<file>images/icons/checkbox-checked.png</file>
<file>images/icons/checkbox-unchecked.png</file>
<file>images/icons/error.png</file>
<file>images/icons/download.png</file>
<file>images/mangahostlogos/mangahere.png</file>
<file>images/mangahostlogos/mangatown.png</file>
<file>images/icons/ultimatemangareader.png</file>
<file>images/icons/file-error.png</file>
<file>images/mangahostlogos/mangago.png</file>
<file>images/mangahostlogos/mangaplus.png</file>
</qresource>
</RCC>

BIN
resources/alcott.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
resources/alert.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
resources/align-center.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
resources/align-justify.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
resources/align-left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
resources/align-right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
resources/apps.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
resources/battery_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
resources/battery_full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
resources/battery_half.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
resources/book.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
resources/chesterton.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

BIN
resources/chevron-left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
resources/chevron-right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
resources/christie.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 KiB

BIN
resources/christie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

BIN
resources/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
resources/davies.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

385
resources/eink.qss Normal file
View file

@ -0,0 +1,385 @@
QPushButton[type="borderless"]
{
background: white;
border: 0;
padding: 2px;
outline: none;
font-size: 10pt;
}
QPushButton[type="borderless"]:focus
{
border: 0;
}
QPushButton[type="borderless"]:pressed
{
background: black;
color: white;
border: none;
}
QPushButton[type="bw"]
{
background: white;
border: 0;
padding: 2px;
outline: none;
font-size: 10pt;
}
QPushButton[type="bw"]:focus
{
border: 0;
}
QPushButton[type="bw"]
{
background: black;
color: white;
border: none;
}
QLabel[type="mangainfolabel"]
{
font-weight: bold;
font-size: 10pt;
}
QLabel[type="mangainfocontent"]
{
font-size: 10pt;
}
QFrame#listViewSources
{
border: none;
font-size: 7pt;
outline: none;
}
QListView#listViewMangas
{
border: none;
padding: 8px;
font-size: 12pt;
}
QFrame#listViewChapters
{
border: none;
padding-top: 8px;
padding-bottom: 8px;
font-size: 12pt;
}
QFrame#topButtonsFrame
{
border-top: 1px solid black;
border-bottom: 1px solid black;
}
QFrame#frameButtons
{
border-top: 1px solid black;
}
QListView::item:selected#listViewSources
{
background: white;
color: black;
}
QListView::item:focused#listViewSources
{
background: white;
color: black;
}
QFrame#frameProgress
{
border: 1px solid black;
}
QLineEdit#lineEditFilter
{
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
font-size: 12pt;
}
QFrame#searchButtonFrame
{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border:1px solid black;
}
QPushButton#pushButtonFilterClear
{
font-size: 16pt;
}
QWidget
{
background-color: white;
selection-color: white;
selection-background-color: black;
font-size: 10pt;
}
QMenu
{
border: 1px solid black;
background-color:white;
}
QMenu::item::selected
{
border-bottom: 5px solid black;
}
QMenu::item
{
padding: 0px 25px 0px 20px;
border-bottom: 5px solid transparent;
}
QMenu::indicator
{
width: 20px;
height: 20px;
}
QMenu::indicator:exclusive:checked
{
image: url(:/images/icons/checkbox-checked.png);
}
QCheckBox::indicator
{
width: 20px;
height: 20px;
margin: 3px;
border: none;
}
QCheckBox::indicator:checked
{
image: url(:/resources/checkbox-checked.png);
}
QCheckBox::indicator:unchecked
{
image: url(:/resources/checkbox-unchecked.png);
}
QLineEdit, QSpinBox, QDoubleSpinBox
{
background-color:white;
border:1px solid black;
padding: 2px;
}
QLineEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus
{
border: 1px solid black;
padding: 1px;
}
QLineEdit:edit-focus, QSpinBox:edit-focus, QDoubleSpinBox:edit-focus
{
border: 3px solid black;
padding: 0px;
}
QTextEdit
{
background-color:transparent;
border:1px solid black;
padding: 1px;
}
QTextEdit:focus
{
border: 1px solid black;
padding: 1px;
}
QTextEdit:edit-focus
{
border: 3px solid black;
padding: 0px;
}
QComboBox
{
background-color:white;
border: 1.5px solid black;
border-radius:5px;
padding-top: 3px;
padding-right: 0px;
padding-bottom: 3px;
padding-left: 5px;
}
QComboBox:focus
{
border: 3px solid black;
padding-top: 1px;
padding-right: 0px;
padding-bottom: 1px;
padding-left: 3px;
}
QComboBox::drop-down
{
border-width:1px;
}
QComboBox::down-arrow {
image:url(:/down-arrow.png);
padding-top: 2px;
padding-right: 5px;
padding-bottom: 2px;
padding-left: 0px;
}
QComboBox::down-arrow:focus
{
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
QTreeView {
padding: 2px;
border: 1px solid black;
background: white;
outline: none;
font-size: 10pt;
}
QListView {
padding: 6px;
border: 1px solid black;
background: white;
outline: none;
font-size: 12pt;
}
QTreeView:focus, QTableView:focus {
padding: 1px;
border: 1px solid black;
}
QTreeView:edit-focus, QListView:edit-focus, QTableView:edit-focus {
padding: 0px;
border: 3px solid black;
}
QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings
{
border-image: none;
image: url(:/plus.png);
}
QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings
{
border-image: none;
image: url(:/minus.png);
}
QPushButton
{
background: white;
border: 3px solid black;
color: black;
padding: 2px;
outline: none;
font-size: 13pt;
}
QPushButton:focus {
border: 3px solid black;
padding: 2px;
}
QPushButton:pressed
{
background: black;
color: white;
padding: 2px;
}
QToolButton
{
background: transparent;
border: none;
color: black;
padding: 2px;
outline: none;
}
QToolButton:checked
{
border: none;
}
QToolButton:focus {
border: none;
padding: 2px;
}
QToolButton:pressed {
border: none;
padding: 2px;
}
QSlider::groove:horizontal {
border: 1.5px solid black;
border-radius: 0px;
height: 15px;
background: white;
margin: 0px 0;
}
QSlider::handle:horizontal {
background: black;
border: 1.5px solid black;
border-radius: 0px;
height: 15px;
width: 25px;
margin: 0px 0;
border-radius: 9px;
}
QSlider::handle:horizontal::focus {
background: black;
}
QScrollBar {
background: white;
border: 5px solid lightGrey;
}
QScrollBar:vertical {
width: 25px
}
QScrollBar:horizontal {
height: 25px
}
QScrollBar::handle {
background: black;
min-width: 25px;
min-height: 25px;
border: 5px;
}
QScrollBar::add-line {
width: 0px;
}
QScrollBar::sub-line {
width: 0px;
}
QDialog {
border: 5px solid black;
background: white;
}
QProgressBar {
border: 1.5px solid black;
text-align: center;
background: white;
color: rgb(160, 160, 160);
}
QProgressBar::chunk {
background: black;
color: white;
}

385
resources/eink_dark.qss Normal file
View file

@ -0,0 +1,385 @@
QPushButton[type="borderless"]
{
background: white;
border: 0;
padding: 2px;
outline: none;
font-size: 10pt;
}
QPushButton[type="borderless"]:focus
{
border: 0;
}
QPushButton[type="borderless"]:pressed
{
background: black;
color: white;
border: none;
}
QPushButton[type="bw"]
{
background: white;
border: 0;
padding: 2px;
outline: none;
font-size: 10pt;
}
QPushButton[type="bw"]:focus
{
border: 0;
}
QPushButton[type="bw"]
{
background: black;
color: white;
border: none;
}
QLabel[type="mangainfolabel"]
{
font-weight: bold;
font-size: 10pt;
}
QLabel[type="mangainfocontent"]
{
font-size: 10pt;
}
QFrame#listViewSources
{
border: none;
font-size: 7pt;
outline: none;
}
QListView#listViewMangas
{
border: none;
padding: 8px;
font-size: 12pt;
}
QFrame#listViewChapters
{
border: none;
padding-top: 8px;
padding-bottom: 8px;
font-size: 12pt;
}
QFrame#topButtonsFrame
{
border-top: 1px solid black;
border-bottom: 1px solid black;
}
QFrame#frameButtons
{
border-top: 1px solid black;
}
QListView::item:selected#listViewSources
{
background: white;
color: black;
}
QListView::item:focused#listViewSources
{
background: white;
color: black;
}
QFrame#frameProgress
{
border: 1px solid black;
}
QLineEdit#lineEditFilter
{
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
font-size: 12pt;
}
QFrame#searchButtonFrame
{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border:1px solid black;
}
QPushButton#pushButtonFilterClear
{
font-size: 16pt;
}
QWidget
{
background-color: black;
selection-color: black;
selection-background-color: white;
font-size: 10pt;
}
QMenu
{
border: 1px solid black;
background-color:white;
}
QMenu::item::selected
{
border-bottom: 5px solid black;
}
QMenu::item
{
padding: 0px 25px 0px 20px;
border-bottom: 5px solid transparent;
}
QMenu::indicator
{
width: 20px;
height: 20px;
}
QMenu::indicator:exclusive:checked
{
image: url(:/images/icons/checkbox-checked.png);
}
QCheckBox::indicator
{
width: 20px;
height: 20px;
margin: 3px;
border: none;
}
QCheckBox::indicator:checked
{
image: url(:/resources/checkbox-checked.png);
}
QCheckBox::indicator:unchecked
{
image: url(:/resources/checkbox-unchecked.png);
}
QLineEdit, QSpinBox, QDoubleSpinBox
{
background-color:white;
border:1px solid black;
padding: 2px;
}
QLineEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus
{
border: 1px solid black;
padding: 1px;
}
QLineEdit:edit-focus, QSpinBox:edit-focus, QDoubleSpinBox:edit-focus
{
border: 3px solid black;
padding: 0px;
}
QTextEdit
{
background-color:transparent;
border:1px solid black;
padding: 1px;
}
QTextEdit:focus
{
border: 1px solid black;
padding: 1px;
}
QTextEdit:edit-focus
{
border: 3px solid black;
padding: 0px;
}
QComboBox
{
background-color:white;
border: 1.5px solid black;
border-radius:5px;
padding-top: 3px;
padding-right: 0px;
padding-bottom: 3px;
padding-left: 5px;
}
QComboBox:focus
{
border: 3px solid black;
padding-top: 1px;
padding-right: 0px;
padding-bottom: 1px;
padding-left: 3px;
}
QComboBox::drop-down
{
border-width:1px;
}
QComboBox::down-arrow {
image:url(:/down-arrow.png);
padding-top: 2px;
padding-right: 5px;
padding-bottom: 2px;
padding-left: 0px;
}
QComboBox::down-arrow:focus
{
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
QTreeView {
padding: 2px;
border: 1px solid black;
background: white;
outline: none;
font-size: 10pt;
}
QListView {
padding: 6px;
border: 1px solid black;
background: white;
outline: none;
font-size: 12pt;
}
QTreeView:focus, QTableView:focus {
padding: 1px;
border: 1px solid black;
}
QTreeView:edit-focus, QListView:edit-focus, QTableView:edit-focus {
padding: 0px;
border: 3px solid black;
}
QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings
{
border-image: none;
image: url(:/plus.png);
}
QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings
{
border-image: none;
image: url(:/minus.png);
}
QPushButton
{
background: white;
border: 3px solid black;
color: black;
padding: 2px;
outline: none;
font-size: 13pt;
}
QPushButton:focus {
border: 3px solid black;
padding: 2px;
}
QPushButton:pressed
{
background: black;
color: white;
padding: 2px;
}
QToolButton
{
background: transparent;
border: none;
color: black;
padding: 2px;
outline: none;
}
QToolButton:checked
{
border: none;
}
QToolButton:focus {
border: none;
padding: 2px;
}
QToolButton:pressed {
border: none;
padding: 2px;
}
QSlider::groove:horizontal {
border: 1.5px solid black;
border-radius: 0px;
height: 15px;
background: white;
margin: 0px 0;
}
QSlider::handle:horizontal {
background: black;
border: 1.5px solid black;
border-radius: 0px;
height: 15px;
width: 25px;
margin: 0px 0;
border-radius: 9px;
}
QSlider::handle:horizontal::focus {
background: black;
}
QScrollBar {
background: white;
border: 5px solid lightGrey;
}
QScrollBar:vertical {
width: 25px
}
QScrollBar:horizontal {
height: 25px
}
QScrollBar::handle {
background: black;
min-width: 25px;
min-height: 25px;
border: 5px;
}
QScrollBar::add-line {
width: 0px;
}
QScrollBar::sub-line {
width: 0px;
}
QDialog {
border: 5px solid black;
background: white;
}
QProgressBar {
border: 1.5px solid black;
text-align: center;
background: white;
color: rgb(160, 160, 160);
}
QProgressBar::chunk {
background: black;
color: white;
}

BIN
resources/exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
resources/king.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
resources/power.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
resources/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
resources/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
resources/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
resources/starred_star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
resources/usbms.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

51
savedwords.cpp Normal file
View file

@ -0,0 +1,51 @@
#include "savedwords.h"
#include "ui_savedwords.h"
#include <QStringListModel>
#include <QFile>
#include <QProcess>
savedwords::savedwords(QWidget *parent) :
QWidget(parent),
ui(new Ui::savedwords)
{
ui->setupUi(this);
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->backBtn->setProperty("type", "borderless");
ui->clearBtn->setProperty("type", "borderless");
checkwords();
QStringListModel* model = new QStringListModel(this);
QStringList list = words.split("\n", QString::SkipEmptyParts);
model->setStringList(list);
ui->wordsList->setModel(model);
ui->wordsList->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
savedwords::~savedwords()
{
delete ui;
}
void savedwords::on_backBtn_clicked()
{
// Workaround for the random strange memory corruption error
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
void savedwords::on_clearBtn_clicked()
{
// Warning: possible memory leak here. Though, usually, when you press the "Clear" button and all clears up, you don't have to press it again ;)
save_word_init("");
checkwords();
QStringListModel* model = new QStringListModel(this);
QStringList list = words.split("\n", QString::SkipEmptyParts);
model->setStringList(list);
ui->wordsList->setModel(model);
ui->wordsList->setEditTriggers(QAbstractItemView::NoEditTriggers);
}

55
savedwords.h Normal file
View file

@ -0,0 +1,55 @@
#ifndef SAVEDWORDS_H
#define SAVEDWORDS_H
#include <QWidget>
#include <QFile>
#include <QTextStream>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
namespace Ui {
class savedwords;
}
class savedwords : public QWidget
{
Q_OBJECT
public:
explicit savedwords(QWidget *parent = nullptr);
~savedwords();
QString words;
void checkwords() {
QFile words_list(".config/06-words/config");
words_list.open(QIODevice::ReadWrite);
QTextStream in (&words_list);
words = in.readAll();
words_list.close();
}
void save_word_init(string word) {
QFile words(".config/06-words/config");
words.open(QIODevice::ReadWrite);
QTextStream in (&words);
QString words_list = in.readAll();
string words_list_str = words_list.toStdString();
words.close();
ofstream fhandler;
fhandler.open(".config/06-words/config");
fhandler << "";
fhandler.close();
}
private slots:
void on_backBtn_clicked();
void on_clearBtn_clicked();
private:
Ui::savedwords *ui;
};
#endif // SAVEDWORDS_H

94
savedwords.ui Normal file
View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>savedwords</class>
<widget class="QWidget" name="savedwords">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QListView" name="wordsList"/>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="backBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Back
</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="clearBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Clear list
</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="savedWordsLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Saved words</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

210
scribblearea.cpp Normal file
View file

@ -0,0 +1,210 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "scribblearea.h"
#include <QMouseEvent>
#include <QPainter>
#include <QDebug>
void ScribbleArea::keyPressEvent(QKeyEvent *event)
{
qDebug() << "Key pressed! " << event->key();
}
//! [0]
ScribbleArea::ScribbleArea(QWidget *parent)
: QWidget(parent)
{
setAttribute(Qt::WA_StaticContents);
this->setFocusPolicy(Qt::StrongFocus);
}
//! [0]
//! [1]
bool ScribbleArea::openImage(const QString &fileName)
//! [1] //! [2]
{
QImage loadedImage;
if (!loadedImage.load(fileName))
return false;
QSize newSize = loadedImage.size().expandedTo(size());
resizeImage(&loadedImage, newSize);
image = loadedImage;
modified = false;
update();
return true;
}
//! [2]
//! [3]
bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
//! [3] //! [4]
{
QImage visibleImage = image;
resizeImage(&visibleImage, size());
if (visibleImage.save(fileName, fileFormat)) {
modified = false;
return true;
}
return false;
}
//! [4]
//! [5]
void ScribbleArea::setPenColor(const QColor &newColor)
//! [5] //! [6]
{
myPenColor = newColor;
}
//! [6]
//! [7]
void ScribbleArea::setPenWidth(int newWidth)
//! [7] //! [8]
{
myPenWidth = newWidth;
}
//! [8]
//! [9]
void ScribbleArea::clearImage()
//! [9] //! [10]
{
image.fill(qRgb(255, 255, 255));
modified = true;
update();
}
//! [10]
//! [11]
void ScribbleArea::mousePressEvent(QMouseEvent *event)
//! [11] //! [12]
{
if (event->button() == Qt::LeftButton) {
lastPoint = event->pos();
scribbling = true;
}
}
void ScribbleArea::mouseMoveEvent(QMouseEvent *event)
{
if ((event->buttons() & Qt::LeftButton) && scribbling)
{
drawLineTo(event->pos());
}
}
void ScribbleArea::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton && scribbling) {
drawLineTo(event->pos());
scribbling = false;
}
}
//! [12] //! [13]
void ScribbleArea::paintEvent(QPaintEvent *event)
//! [13] //! [14]
{
QPainter painter(this);
QRect dirtyRect = event->rect();
painter.drawImage(dirtyRect, image, dirtyRect);
}
//! [14]
//! [15]
void ScribbleArea::resizeEvent(QResizeEvent *event)
//! [15] //! [16]
{
if (width() > image.width() || height() > image.height()) {
int newWidth = qMax(width() + 128, image.width());
int newHeight = qMax(height() + 128, image.height());
resizeImage(&image, QSize(newWidth, newHeight));
update();
}
QWidget::resizeEvent(event);
}
//! [16]
//! [17]
void ScribbleArea::drawLineTo(const QPoint &endPoint)
//! [17] //! [18]
{
QPainter painter(&image);
painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.drawLine(lastPoint, endPoint);
modified = true;
int rad = (myPenWidth / 2) + 2;
update(QRect(lastPoint, endPoint).normalized()
.adjusted(-rad, -rad, +rad, +rad));
lastPoint = endPoint;
}
//! [18]
//! [19]
void ScribbleArea::resizeImage(QImage *image, const QSize &newSize)
//! [19] //! [20]
{
if (image->size() == newSize)
return;
QImage newImage(newSize, QImage::Format_RGB32);
newImage.fill(qRgb(255, 255, 255));
QPainter painter(&newImage);
painter.drawImage(QPoint(0, 0), *image);
*image = newImage;
}
//! [20]

100
scribblearea.h Normal file
View file

@ -0,0 +1,100 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef SCRIBBLEAREA_H
#define SCRIBBLEAREA_H
#include <QColor>
#include <QImage>
#include <QPoint>
#include <QWidget>
//! [0]
class ScribbleArea : public QWidget
{
Q_OBJECT
public:
ScribbleArea(QWidget *parent = nullptr);
bool openImage(const QString &fileName);
bool saveImage(const QString &fileName, const char *fileFormat);
void setPenColor(const QColor &newColor);
void setPenWidth(int newWidth);
bool isModified() const { return modified; }
QColor penColor() const { return myPenColor; }
int penWidth() const { return myPenWidth; }
public slots:
void clearImage();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private:
void drawLineTo(const QPoint &endPoint);
void resizeImage(QImage *image, const QSize &newSize);
bool modified = false;
bool scribbling = false;
int myPenWidth = 1;
QColor myPenColor = Qt::blue;
QImage image;
QPoint lastPoint;
};
//! [0]
#endif

466
settings.cpp Normal file
View file

@ -0,0 +1,466 @@
#include "settings.h"
#include "ui_settings.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFile>
#include <QMessageBox>
#include <QSettings>
#include <QWidget>
#include <iostream>
#include <fstream>
#include <streambuf>
#include <string>
#include <QProcess>
#include <QTimer>
#include <QIcon>
using namespace std;
settings::settings(QWidget *parent) :
QWidget(parent),
ui(new Ui::settings)
{
ui->setupUi(this);
ui->okBtn->setProperty("type", "borderless");
ui->aboutBtn->setProperty("type", "borderless");
ui->requestLeaseBtn->setProperty("type", "borderless");
ui->usbmsBtn->setProperty("type", "borderless");
ui->updateBtn->setProperty("type", "borderless");
ui->previousBtn->setProperty("type", "borderless");
ui->nextBtn->setProperty("type", "borderless");
ui->requestLeaseBtn->setStyleSheet("font-size: 9pt");
ui->usbmsBtn->setStyleSheet("font-size: 9pt");
ui->updateBtn->setStyleSheet("font-size: 9pt");
ui->previousBtn->setText("");
ui->previousBtn->setIcon(QIcon(":/resources/chevron-left.png"));
ui->nextBtn->setText("");
ui->nextBtn->setIcon(QIcon(":/resources/chevron-right.png"));
ui->requestLeaseBtn->hide();
ui->usbmsBtn->hide();
ui->label_3->hide();
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->line_3->hide();
ui->line_7->hide();
ui->line_9->hide();
ui->softwareLabel->hide();
ui->updateBtn->hide();
ui->updateLabel->hide();
ui->darkModeCheckBox->hide();
ui->uiScalingLabel->hide();
ui->uiScalingSlider->hide();
ui->uiScaleNumberLabel->hide();
// Settings tweaking + enabling specific features whether it's running on the provided integrated OS or Kobo firmware
if(checkconfig(".config/01-demo/config") == true) {
ui->demoCheckBox->click();
}
if(checkconfig(".config/02-clock/config") == true) {
ui->clockCheckBox->click();
}
if(checkconfig(".config/05-quote/config") == true) {
ui->quoteCheckBox->click();
}
if(checkconfig(".config/10-dark_mode/config") == true) {
ui->darkModeCheckBox->click();
}
string_checkconfig(".config/07-words_number/config");
if(checkconfig_str_val == "") {
;
}
else {
int words_number = checkconfig_str_val.toInt();
ui->wordsNumber->setValue(words_number);
}
// Scaling
string_checkconfig(".config/09-dpi/config");
if(checkconfig_str_val == "") {
;
}
else {
int dpi_number = checkconfig_str_val.toInt();
if(dpi_number == 187) {
ui->uiScalingSlider->setValue(0);
}
if(dpi_number == 214) {
ui->uiScalingSlider->setValue(1);
}
if(dpi_number == 227) {
ui->uiScalingSlider->setValue(2);
}
}
if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device
if(checkconfig("/external_root/opt/root/rooted") == true) {
ui->requestLeaseBtn->show();
ui->label_4->show();
ui->label_3->show();
ui->line_3->show();
}
else {
ui->requestLeaseBtn->hide();
ui->label_4->hide();
ui->label_3->hide();
ui->line_3->hide();
}
ui->usbmsBtn->show();
ui->label_5->show();
ui->label_6->show();
ui->line_7->show();
ui->okBtn->setText("OK");
}
QFile stylesheetFile(":/resources/eink.qss");
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
QObject::connect(ui->okBtn, SIGNAL(clicked()), this, SLOT(exitSlot()));
}
void settings::exitSlot() {
settings::close();
}
settings::~settings()
{
delete ui;
}
void settings::on_okBtn_clicked() {
// Prevent potential unknown damage launching via shell script this could do
if(launch_sh == true) {
QProcess process;
process.startDetached("inkbox.sh", QStringList());
qApp->quit();
}
else {
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
}
void settings::on_aboutBtn_clicked()
{
if(checkconfig("/opt/inkbox_genuine") == true) {
QString aboutmsg = "InkBox is an open-source Qt-based eBook reader. It brings you the latest Qt features while being also fast and responsive.";
string_checkconfig_ro("/external_root/opt/isa/version");
aboutmsg.append("\n\nInkBox v");
aboutmsg.append(checkconfig_str_val);
QMessageBox::information(this, tr("Information"), aboutmsg);
}
else {
QMessageBox::information(this, tr("About"), tr("InkBox is an open-source Qt-based eBook reader. It brings you the latest Qt features while being also fast and responsive."));
}
}
void settings::on_demoCheckBox_toggled(bool checked)
{
// Write to config file
if(checked == true) {
checked_box = true;
writeconfig(".config/01-demo/config", "InkboxChangeLabel=");
}
else {
checked_box = false;
writeconfig(".config/01-demo/config", "InkboxChangeLabel=");
}
}
void settings::on_clockCheckBox_toggled(bool checked)
{
// Write to config file
if(checked == true) {
checked_box = true;
writeconfig(".config/02-clock/config", "ClockShowSeconds=");
}
else {
checked_box = false;
writeconfig(".config/02-clock/config", "ClockShowSeconds=");
}
}
void settings::on_quoteCheckBox_toggled(bool checked)
{
if(checked == true) {
checked_box = true;
writeconfig(".config/05-quote/config", "DisableQuote=");
}
else {
checked_box = false;
writeconfig(".config/05-quote/config", "DisableQuote=");
}
}
void settings::on_requestLeaseBtn_clicked()
{
QString prog ("chroot");
QStringList args;
args << "/external_root" << "/usr/sbin/dhclient";
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
}
void settings::on_usbmsBtn_clicked()
{
QString umount_prog ("umount");
QStringList umount_args;
umount_args << "/dev/loop0";
QProcess *umount_proc = new QProcess();
umount_proc->start(umount_prog, umount_args);
umount_proc->waitForFinished();
QString rmmod ("rmmod");
QStringList rmmod_args;
rmmod_args << "g_ether.ko";
QProcess *rmmod_proc = new QProcess();
rmmod_proc->start(rmmod, rmmod_args);
rmmod_proc->waitForFinished();
QString prog ("insmod");
QStringList args;
args << "/external_root/modules/arcotg_udc.ko";
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
QString prog_1 ("insmod");
QStringList args_1;
args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/onboard" << "removable=y" << "stall=0";
QProcess *proc_1 = new QProcess();
proc_1->start(prog_1, args_1);
proc_1->waitForFinished();
usbmsWindow = new usbms_splash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->showFullScreen();
QTimer *usbms_t = new QTimer(this);
usbms_t->setInterval(1000);
connect(usbms_t, &QTimer::timeout, [&]() {
QString prog ("mass_storage.sh");
QStringList args;
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
QFile modules("/tmp/usbevent");
modules.open(QIODevice::ReadWrite);
QTextStream in (&modules);
const QString content = in.readAll();
string contentstr = content.toStdString();
modules.close();
if(contentstr.find("1") != std::string::npos) {
QString reboot_prog ("busybox");
QStringList reboot_args;
reboot_args << "reboot";
QProcess *reboot_proc = new QProcess();
reboot_proc->start(reboot_prog, reboot_args);
reboot_proc->waitForFinished();
}
else {
;
}
} );
usbms_t->start();
}
// Please forgive me, I didn't know that QStackedWidget existed back then...
void settings::on_previousBtn_clicked()
{
settings_page = settings_page - 1;
if(settings_page == 1) {
ui->line_6->show();
ui->label_2->show();
ui->demoCheckBox->show();
ui->quoteCheckBox->show();
ui->line_8->show();
ui->label_7->show();
ui->wordsNumber->show();
ui->wordsNumberLabel->show();
ui->clockCheckBox->show();
ui->line_9->hide();
ui->softwareLabel->hide();
ui->updateBtn->hide();
ui->updateLabel->hide();
ui->darkModeCheckBox->hide();
ui->uiScalingLabel->hide();
ui->uiScalingSlider->hide();
ui->uiScaleNumberLabel->hide();
if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device
if(checkconfig("/external_root/opt/root/rooted") == true) {
ui->requestLeaseBtn->show();
ui->label_4->show();
ui->label_3->show();
ui->line_3->show();
}
else {
ui->requestLeaseBtn->hide();
ui->label_4->hide();
ui->label_3->hide();
ui->line_3->hide();
}
ui->label_5->show();
ui->label_6->show();
ui->line_7->show();
ui->usbmsBtn->show();
}
}
else {
if(settings_page == 2) {
ui->line_6->hide();
ui->label_2->hide();
ui->label_7->hide();
ui->line_8->hide();
ui->clockCheckBox->hide();
ui->demoCheckBox->hide();
ui->quoteCheckBox->hide();
if(checkconfig("/opt/inkbox_genuine") == true) {
ui->label_3->hide();
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->line_7->hide();
ui->line_3->hide();
ui->line_9->show();
ui->softwareLabel->show();
ui->darkModeCheckBox->show();
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
ui->updateBtn->show();
ui->updateLabel->show();
}
}
}
if(settings_page <= 0) {
// Prevent unwanted accesses
settings_page = settings_page + 1;
}
}
}
void settings::on_nextBtn_clicked()
{
settings_page = settings_page + 1;
if(settings_page == 2) {
ui->line_6->hide();
ui->label_2->hide();
ui->label_7->hide();
ui->line_8->hide();
ui->demoCheckBox->hide();
ui->quoteCheckBox->hide();
ui->clockCheckBox->hide();
ui->wordsNumber->hide();
ui->wordsNumberLabel->hide();
ui->line_9->show();
ui->softwareLabel->show();
ui->darkModeCheckBox->show();
ui->uiScalingLabel->show();
ui->uiScalingSlider->show();
ui->uiScaleNumberLabel->show();
if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device
if(checkconfig("/external_root/opt/root/rooted") == true) {
ui->requestLeaseBtn->show();
ui->label_4->show();
ui->label_3->show();
ui->line_3->show();
}
else {
ui->requestLeaseBtn->hide();
ui->label_4->hide();
ui->label_3->hide();
ui->line_3->hide();
}
ui->label_3->hide();
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->line_7->hide();
ui->line_3->hide();
ui->requestLeaseBtn->hide();
ui->usbmsBtn->hide();
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
ui->updateBtn->show();
ui->updateLabel->show();
}
}
}
if(settings_page >= 3) {
settings_page = settings_page - 1;
}
}
void settings::on_wordsNumber_valueChanged(int arg1)
{
QString number = QString::number(arg1);
string number_str = number.toStdString();
string_writeconfig(".config/07-words_number/config", number_str);
}
void settings::on_updateBtn_clicked()
{
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true");
string_writeconfig("/external_root/opt/update/will_update", "true");
string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true");
QString prog ("reboot");
QStringList args;
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
}
void settings::on_darkModeCheckBox_toggled(bool checked)
{
if(checked == true) {
string_writeconfig(".config/10-dark_mode/config", "true");
string_writeconfig("/tmp/invertScreen", "y");
}
else {
string_writeconfig(".config/10-dark_mode/config", "false");
string_writeconfig("/tmp/invertScreen", "n");
}
}
void settings::on_uiScalingSlider_valueChanged(int value)
{
if(value == 0) {
string_writeconfig(".config/09-dpi/config", "187");
}
if(value == 1) {
string_writeconfig(".config/09-dpi/config", "214");
}
if(value == 2) {
string_writeconfig(".config/09-dpi/config", "227");
}
// Making sense for the user
value = value + 1;
QString value_qstr = QString::number(value);
ui->uiScaleNumberLabel->setText(value_qstr);
if(not_user_change == true) {
launch_sh = false;
// If value is changed, it will launch inkbox.sh detached when "OK" is pressed.
not_user_change = false;
}
else {
// This is supposed to happen when the user clicks the slider, and not the software. Refer to setValue() methods for uiScalingSlider in main().
launch_sh = true;
}
}

101
settings.h Normal file
View file

@ -0,0 +1,101 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QWidget>
#include <QFile>
#include <QTextStream>
#include <fstream>
#include <usbms_splash.h>
using namespace std;
namespace Ui {
class settings;
}
class settings : public QWidget
{
Q_OBJECT
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();
void on_demoCheckBox_toggled(bool);
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);
private:
Ui::settings *ui;
usbms_splash *usbmsWindow;
};
#endif // SETTINGS_H

533
settings.ui Normal file
View file

@ -0,0 +1,533 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>settings</class>
<widget class="QWidget" name="settings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>650</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Reading</string>
</property>
</widget>
</item>
<item row="30" column="0">
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="Line" name="line_8">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Storage</string>
</property>
</widget>
</item>
<item row="29" 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>
<item row="18" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Disable authors quotes</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Home</string>
</property>
</widget>
</item>
<item row="32" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QPushButton" name="aboutBtn">
<property name="text">
<string>About InkBox</string>
</property>
</widget>
</item>
<item row="3" 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="17" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<property name="text">
<string>Clock: Show seconds</string>
</property>
</widget>
</item>
<item row="8" 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="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="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="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="19" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Networking</string>
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="22" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="requestLeaseBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Request</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Request DHCP lease</string>
</property>
</widget>
</item>
<item row="0" column="1">
<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>
</layout>
</item>
<item row="33" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="okBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
OK
</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_5">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>InkBox settings</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nextBtn">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="previousBtn">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item row="0" column="1">
<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>
<item row="0" column="3">
<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 row="16" column="0">
<widget class="Line" name="line_6">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="Line" name="line_4">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="wordsNumberLabel">
<property name="text">
<string>Words number per page</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="wordsNumber">
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="value">
<number>20</number>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_5">
<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 row="5" 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="25" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<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 row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Enter USB Mass Storage session</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="usbmsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Go</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QSlider" name="uiScalingSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="uiScalingLabel">
<property name="text">
<string>UI scaling factor</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="uiScaleNumberLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

23
usbms_splash.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "usbms_splash.h"
#include "ui_usbms_splash.h"
#include <QPixmap>
usbms_splash::usbms_splash(QWidget *parent) :
QWidget(parent),
ui(new Ui::usbms_splash)
{
ui->setupUi(this);
this->setStyleSheet("background-color:black;");
ui->label->setStyleSheet("QLabel { background-color : black; color : white; }");
ui->label_3->setStyleSheet("QLabel { background-color : black; color : white; font-size: 9pt}");
QPixmap pixmap(":/resources/usbms.png");
ui->label_2->setPixmap(pixmap);
}
usbms_splash::~usbms_splash()
{
delete ui;
}

22
usbms_splash.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef USBMS_SPLASH_H
#define USBMS_SPLASH_H
#include <QWidget>
namespace Ui {
class usbms_splash;
}
class usbms_splash : public QWidget
{
Q_OBJECT
public:
explicit usbms_splash(QWidget *parent = nullptr);
~usbms_splash();
private:
Ui::usbms_splash *ui;
};
#endif // USBMS_SPLASH_H

122
usbms_splash.ui Normal file
View file

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>usbms_splash</class>
<widget class="QWidget" name="usbms_splash">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<spacer name="verticalSpacer_3">
<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="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Don't forget to eject the device before unplugging the USB cable.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" 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>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>USB connected</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" 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="3" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>USB Icon</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_4">
<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>