Added disable UI scaling option; laying down a path for remembering

position in book
This commit is contained in:
Nicolas Mailloux 2021-04-05 15:35:25 -04:00
parent 511594eeba
commit daaef3a72f
10 changed files with 375 additions and 212 deletions

View file

@ -24,9 +24,11 @@ generalDialog::generalDialog(QWidget *parent) :
ui->okBtn->setProperty("type", "borderless");
ui->cancelBtn->setProperty("type", "borderless");
ui->acceptBtn->setProperty("type", "borderless");
ui->okBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->cancelBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->acceptBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->bodyLabel->setStyleSheet("font-size: 9pt");
if(checkconfig("/inkbox/resetDialog") == true) {
@ -47,6 +49,14 @@ generalDialog::generalDialog(QWidget *parent) :
this->adjustSize();
string_writeconfig("/inkbox/updateDialog", "false");
}
if(checkconfig("/inkbox/settingsRebootDialog") == true) {
settingsRebootDialog = true;
ui->stackedWidget->setCurrentIndex(1);
ui->bodyLabel->setText("The settings you chose might require a complete reboot of the device for them to work properly.");
ui->headerLabel->setText("Information");
this->adjustSize();
string_writeconfig("/inkbox/settingsRebootDialog", "false");
}
else {
// We shouldn't be there ;)
;
@ -78,15 +88,26 @@ void generalDialog::on_cancelBtn_clicked()
void generalDialog::on_okBtn_clicked()
{
if(resetDialog == true) {
// Soft-reset the device
// We set a custom boot flag and reboot silently in Diagnostics
string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true");
string_writeconfig("/external_root/boot/flags/DO_SOFT_RESET", "true");
QString prog ("reboot");
QStringList args;
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
if(checkconfig("/opt/inkbox_genuine") == true) {
// Soft-reset the device
// We set a custom boot flag and reboot silently in Diagnostics
string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true");
string_writeconfig("/external_root/boot/flags/DO_SOFT_RESET", "true");
QString prog ("reboot");
QStringList args;
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
}
else {
// Restore default settings, we're not running on InkBox OS
QString prog ("sh");
QStringList args;
args << "reset-config.sh";
QProcess *proc = new QProcess();
proc->startDetached(prog, args);
qApp->quit();
}
}
if(updateDialog == true) {
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true");
@ -99,3 +120,12 @@ void generalDialog::on_okBtn_clicked()
proc->waitForFinished();
}
}
void generalDialog::on_acceptBtn_clicked()
{
// We don't have any other option ;p
generalDialog::close();
QProcess process;
process.startDetached("inkbox.sh", QStringList());
qApp->quit();
}

View file

@ -18,12 +18,15 @@ public:
~generalDialog();
bool resetDialog = false;
bool updateDialog = false;
bool settingsRebootDialog = false;
private slots:
void on_cancelBtn_clicked();
void on_okBtn_clicked();
void on_acceptBtn_clicked();
private:
Ui::generalDialog *ui;
};

View file

@ -29,61 +29,6 @@
</property>
</spacer>
</item>
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="cancelBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="okBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="bodyLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Body</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
@ -108,6 +53,121 @@
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="cancelBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="okBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QPushButton" name="acceptBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="bodyLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Body</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">

View file

@ -17,6 +17,7 @@
#include "alert.h"
#include "generaldialog.h"
#include "functions.h"
#include "reader.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
@ -32,7 +33,18 @@ int main(int argc, char *argv[])
alert w;
const QScreen* screen = qApp->primaryScreen();
w.setGeometry(QRect(QPoint(0,0), screen->geometry ().size()));
w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
w.show();
return a.exec();
}
// If we're waking from sleep and we have the lockscreen enabled, we'll "resume" the book from scratch
if(checkconfig("/tmp/suspendBook") == true) {
string_writeconfig("/inkbox/skip_opendialog", "true");
QApplication a(argc, argv);
reader w;
const QScreen* screen = qApp->primaryScreen();
w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
w.show();
return a.exec();
}

View file

@ -259,14 +259,12 @@ MainWindow::MainWindow(QWidget *parent)
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");
}
// Dark mode
if(checkconfig(".config/10-dark_mode/config") == true) {
string_writeconfig("/tmp/invertScreen", "y");
}
else {
string_writeconfig("/tmp/invertScreen", "n");
}
// Clock setting to show seconds

View file

@ -267,24 +267,30 @@ reader::reader(QWidget *parent) :
} );
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;
// We have to get the file's path
if(checkconfig("/tmp/suspendBook") == true) {
// Prevent from opening the Reader framework next time unless the condition is reset
string_writeconfig("/tmp/suspendBook", "false");
}
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 {
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 {

View file

@ -152,7 +152,7 @@ public:
bool epub_file_match(QString file) {
QString fileExt = file.right(4);
if(fileExt == "epub" or fileExt=="EPUB") {
if(fileExt == "epub" or fileExt == "EPUB") {
return true;
}
else {

View file

@ -57,6 +57,11 @@ settings::settings(QWidget *parent) :
ui->enableLockscreenCheckBox->hide();
ui->setPasscodeBtn->hide();
ui->setPasscodeLabel->hide();
ui->securityLabel->hide();
ui->line_2->hide();
ui->uiScaleNumberLabel->hide();
ui->uiScalingSlider->hide();
ui->uiScalingLabel->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) {
@ -149,6 +154,12 @@ settings::settings(QWidget *parent) :
ui->enableLockscreenCheckBox->click();
}
// DPI checkbox
if(checkconfig_rw(".config/09-dpi/config-enabled") == true) {
ui_not_user_change = true;
ui->enableUiScalingCheckBox->click();
}
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) {
@ -163,6 +174,8 @@ settings::settings(QWidget *parent) :
ui->label_3->hide();
ui->line_3->hide();
}
ui->securityLabel->show();
ui->line_2->show();
ui->enableLockscreenCheckBox->show();
ui->setPasscodeBtn->show();
ui->setPasscodeLabel->show();
@ -178,11 +191,6 @@ settings::settings(QWidget *parent) :
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()
@ -193,9 +201,18 @@ settings::~settings()
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();
if(ui_enable_changed == true) {
ui_enable_changed = false;
string_writeconfig("/inkbox/settingsRebootDialog", "true");
generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
generalDialogWindow->show();
}
else {
QProcess process;
process.startDetached("inkbox.sh", QStringList());
qApp->quit();
}
}
else {
QProcess process;
@ -535,3 +552,31 @@ void settings::on_enableLockscreenCheckBox_toggled(bool checked)
string_writeconfig(".config/12-lockscreen/config", "false");
}
}
void settings::on_enableUiScalingCheckBox_toggled(bool checked)
{
if(checked == true) {
// Writing default value
string_writeconfig(".config/09-dpi/config", "187");
string_writeconfig(".config/09-dpi/config-enabled", "true");
ui->uiScaleNumberLabel->show();
ui->uiScalingSlider->show();
ui->uiScalingLabel->show();
launch_sh = true;
if(ui_not_user_change == true) {
ui_enable_changed = false;
}
else {
ui_enable_changed = true;
}
}
else {
string_writeconfig(".config/09-dpi/config", "false");
string_writeconfig(".config/09-dpi/config-enabled", "false");
ui->uiScaleNumberLabel->hide();
ui->uiScalingSlider->hide();
ui->uiScalingLabel->hide();
launch_sh = true;
ui_enable_changed = true;
}
}

View file

@ -19,13 +19,14 @@ class settings : public QWidget
public:
int settings_page = 1;
bool launch_sh = false;
bool ui_enable_changed = false;
bool ui_not_user_change = false;
bool not_user_change = true;
explicit settings(QWidget *parent = nullptr);
~settings();
private slots:
void exitSlot();
void on_demoCheckBox_toggled(bool);
void on_aboutBtn_clicked();
void on_okBtn_clicked();
@ -44,6 +45,7 @@ private slots:
void on_resetBtn_clicked();
void on_setPasscodeBtn_clicked();
void on_enableLockscreenCheckBox_toggled(bool checked);
void on_enableUiScalingCheckBox_toggled(bool checked);
private:
Ui::settings *ui;

View file

@ -524,45 +524,33 @@ OK
</property>
<item>
<layout class="QGridLayout" name="gridLayout_10">
<item row="8" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="11" column="0">
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="uiScalingLabel">
<widget class="QLabel" name="label_8">
<property name="text">
<string>UI scaling factor</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>Reset this device</string>
</property>
</widget>
</item>
<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>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<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="uiScaleNumberLabel">
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<weight>75</weight>
@ -570,13 +558,39 @@ OK
</font>
</property>
<property name="text">
<string>1</string>
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="softwareLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>System</string>
</property>
</widget>
</item>
<item row="17" 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="16" column="0">
<layout class="QGridLayout" name="gridLayout_13">
<property name="bottomMargin">
<number>0</number>
@ -616,49 +630,20 @@ OK
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="softwareLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>System</string>
</property>
</widget>
</item>
<item row="12" 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="9" column="0">
<item row="10" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="securityLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
<item row="14" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Security</string>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -672,7 +657,66 @@ OK
</property>
</widget>
</item>
<item row="11" column="0">
<item row="15" column="0">
<widget class="QCheckBox" name="enableLockscreenCheckBox">
<property name="text">
<string>Enable lock screen and passcode</string>
</property>
</widget>
</item>
<item row="9" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" 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>
<item row="1" 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="1" 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>
</layout>
</item>
<item row="12" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="bottomMargin">
<number>0</number>
@ -718,60 +762,23 @@ OK
</item>
</layout>
</item>
<item row="10" column="0">
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
<number>0</number>
<item row="13" column="0">
<widget class="QLabel" name="securityLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Reset this device</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="text">
<string>Security</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="enableLockscreenCheckBox">
<item row="8" column="0">
<widget class="QCheckBox" name="enableUiScalingCheckBox">
<property name="text">
<string>Enable lock screen and passcode</string>
<string>Enable UI scaling</string>
</property>
</widget>
</item>