Added refresh every x page setting

This commit is contained in:
Nicolas Mailloux 2021-03-30 08:24:13 -04:00
parent 007af67b23
commit 41cef1444a
6 changed files with 295 additions and 96 deletions

View file

@ -181,6 +181,27 @@ reader::reader(QWidget *parent) :
scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
}
// Checking if there is a page refresh setting set
string_checkconfig(".config/04-book/refresh");
if(checkconfig_str_val == "") {
// Writing the default, refresh every 3 pages
string_writeconfig(".config/04-book/refresh", "3");
string_checkconfig(".config/04-book/refresh");
}
else {
// A config option was set, continuing after the Else statement...
;
}
pageRefreshSetting = checkconfig_str_val.toInt();
// Checking if that config option was set to "Never refresh"...
if(pageRefreshSetting == -1) {
neverRefresh = true;
}
else {
// Safety measure
neverRefresh = false;
}
// Clock setting to show seconds + battery level
if(checkconfig(".config/02-clock/config") == true) {
QTimer *t = new QTimer(this);
@ -385,6 +406,20 @@ void reader::on_nextBtn_clicked()
setup_book(book_file, split_total, false);
ui->text->setText("");
ui->text->setText(ittext);
pagesTurned = pagesTurned + 1;
if(neverRefresh == true) {
// Do nothing; "Never refresh" was set
;
}
else {
if(pagesTurned >= pageRefreshSetting) {
// Refreshing the screen
this->repaint();
// Reset count
pagesTurned = 0;
}
}
}
}
@ -400,12 +435,28 @@ void reader::on_previousBtn_clicked()
setup_book(book_file, split_total, false);
ui->text->setText("");
ui->text->setText(ittext);
// We always increment pagesTurned regardless if we press the Previous or Next button
pagesTurned = pagesTurned + 1;
if(neverRefresh == true) {
// Do nothing; "Never refresh" was set
;
}
else {
if(pagesTurned >= pageRefreshSetting) {
// Refreshing the screen
this->repaint();
// Reset count
pagesTurned = 0;
}
}
}
}
void reader::on_optionsBtn_clicked()
{
menubar_show();
this->repaint();
}
void reader::on_hideOptionsBtn_clicked()

View file

@ -31,12 +31,19 @@ public:
int page_number;
int dictionary_position = 1;
int batt_level_int;
int pagesTurned = 0;
// -1 : Never refresh | 0 : Refresh every page | 1 : Refresh every 1 page. And so on...
// Refresh every 3 pages is the default
int pageRefreshSetting = 3;
bool menubar_shown = false;
bool selected_text_lock = false;
bool nextdefinition_lock = false;
bool is_epub = false;
bool parser_ran = false;
bool booktostr_ran = false;
bool neverRefresh = false;
QString book_1;
QString book_2;
QString book_3;

View file

@ -726,7 +726,7 @@
<widget class="QLabel" name="wordLabel">
<property name="font">
<font>
<family>Ubuntu</family>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>

View file

@ -32,6 +32,7 @@ settings::settings(QWidget *parent) :
ui->requestLeaseBtn->setStyleSheet("font-size: 9pt");
ui->usbmsBtn->setStyleSheet("font-size: 9pt");
ui->updateBtn->setStyleSheet("font-size: 9pt");
ui->comboBox->setStyleSheet("font-size: 9pt");
ui->previousBtn->setText("");
ui->previousBtn->setIcon(QIcon(":/resources/chevron-left.png"));
@ -96,6 +97,45 @@ settings::settings(QWidget *parent) :
}
}
// Refresh
string_checkconfig(".config/04-book/refresh");
if(checkconfig_str_val == "") {
// Set default option, 3
string_writeconfig(".config/04-book/refresh", "3");
string_checkconfig(".config/04-book/refresh");
ui->comboBox->setCurrentText("3 pages");
}
else {
int refreshInt = checkconfig_str_val.toInt();
if(refreshInt == -1) {
ui->comboBox->setCurrentText("Never refresh");
}
if(refreshInt == 0) {
ui->comboBox->setCurrentText("Every page");
}
if(refreshInt == 1) {
ui->comboBox->setCurrentText("1 page");
}
if(refreshInt == 2) {
ui->comboBox->setCurrentText("2 pages");
}
if(refreshInt == 3) {
ui->comboBox->setCurrentText("3 pages");
}
if(refreshInt == 4) {
ui->comboBox->setCurrentText("4 pages");
}
if(refreshInt == 5) {
ui->comboBox->setCurrentText("5 pages");
}
if(refreshInt == 6) {
ui->comboBox->setCurrentText("6 pages");
}
else {
qDebug() << "Refresh setting value out of range, skipping...";
}
}
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) {
@ -422,3 +462,31 @@ void settings::on_menuBarCheckBox_toggled(bool checked)
writeconfig(".config/11-menubar/sticky", "StickyMenuBar=");
}
}
void settings::on_comboBox_currentIndexChanged(const QString &arg1)
{
if(arg1 == "Every page") {
string_writeconfig(".config/04-book/refresh", "0");
}
if(arg1 == "1 page") {
string_writeconfig(".config/04-book/refresh", "1");
}
if(arg1 == "2 pages") {
string_writeconfig(".config/04-book/refresh", "2");
}
if(arg1 == "3 pages") {
string_writeconfig(".config/04-book/refresh", "3");
}
if(arg1 == "4 pages") {
string_writeconfig(".config/04-book/refresh", "4");
}
if(arg1 == "5 pages") {
string_writeconfig(".config/04-book/refresh", "5");
}
if(arg1 == "6 pages") {
string_writeconfig(".config/04-book/refresh", "6");
}
if(arg1 == "Never refresh") {
string_writeconfig(".config/04-book/refresh", "-1");
}
}

View file

@ -95,6 +95,8 @@ private slots:
void on_menuBarCheckBox_toggled(bool checked);
void on_comboBox_currentIndexChanged(const QString &arg1);
private:
Ui::settings *ui;
usbms_splash *usbmsWindow;

View file

@ -79,41 +79,15 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="9" 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="6" column="0">
<item row="7" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<property name="text">
<string>Clock: Show seconds</string>
</property>
</widget>
</item>
<item row="4" 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="5" column="0">
<widget class="Line" name="line_6">
<item row="15" column="0">
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -122,7 +96,7 @@
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="bottomMargin">
<number>0</number>
@ -162,6 +136,80 @@
</item>
</layout>
</item>
<item row="13" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<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>
<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>
</layout>
</item>
<item row="6" 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="1" 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="8" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Disable authors quotes</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="menuBarCheckBox">
<property name="text">
<string>Always show status bar</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
@ -175,36 +223,6 @@
</property>
</widget>
</item>
<item row="13" 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="14" 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="8" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
@ -249,6 +267,45 @@
</layout>
</item>
<item row="10" 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="5" 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="14" 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="11" column="0">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
@ -258,37 +315,27 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<item row="9" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable authors quotes</string>
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="1" 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="12" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_9">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="screenRefreshLabel">
<property name="text">
<string>Request DHCP lease</string>
<string>Screen refresh</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -301,27 +348,51 @@
</spacer>
</item>
<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 class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Every page</string>
</property>
</item>
<item>
<property name="text">
<string>1 page</string>
</property>
</item>
<item>
<property name="text">
<string>2 pages</string>
</property>
</item>
<item>
<property name="text">
<string>3 pages</string>
</property>
</item>
<item>
<property name="text">
<string>4 pages</string>
</property>
</item>
<item>
<property name="text">
<string>5 pages</string>
</property>
</item>
<item>
<property name="text">
<string>6 pages</string>
</property>
</item>
<item>
<property name="text">
<string>Never refresh</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="menuBarCheckBox">
<property name="text">
<string>Always show status bar</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>