Show scrollbar if needed in Reader framework

This commit is contained in:
Nicolas Mailloux 2021-06-27 13:28:41 -04:00
parent da62e98cde
commit fc4b9ba672
10 changed files with 276 additions and 233 deletions

View file

@ -127,11 +127,6 @@ void brightnessDialog::on_okBtn_clicked()
}
void brightnessDialog::pre_set_brightness(int brightnessValue) {
if(deviceChecked == false) {
checkDevice();
deviceChecked = true;
}
if(global::isN705 == true or global::isN905C == true) {
set_brightness(brightnessValue);
}

View file

@ -75,7 +75,6 @@ namespace {
int defaultEpubPageWidth;
int defaultEpubPageHeight;
bool checked_box = false;
bool deviceChecked = false;
bool checkconfig(QString file) {
QFile config(file);
config.open(QIODevice::ReadOnly);
@ -137,8 +136,8 @@ namespace {
void set_brightness_ntxio(int value) {
// Thanks to Kevin Short for this (GloLight)
int light;
if ((light = open("/dev/ntx_io", O_RDWR)) == -1) {
printf("Error opening ntx_io device");
if((light = open("/dev/ntx_io", O_RDWR)) == -1) {
fprintf(stderr, "Error opening ntx_io device\n");
}
ioctl(light, 241, value);
}
@ -250,6 +249,15 @@ namespace {
}
return 0;
}
void zeroBrightness() {
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val != "n613\n") {
set_brightness(0);
}
else {
set_brightness_ntxio(0);
}
}
void poweroff(bool splash) {
if(splash == true) {
QString prog ("/sbin/poweroff");
@ -371,9 +379,5 @@ namespace {
defaultEpubPageWidth = 450;
}
}
QString checkDevice() {
string_checkconfig_ro("/opt/inkbox_device");
return checkconfig_str_val;
}
}
#endif // FUNCTIONS_H

View file

@ -34,14 +34,26 @@ koboxSettings::koboxSettings(QWidget *parent) :
}
// DPI setting
QString dpiSetting;
string_checkconfig(".config/00-kobox/dpiSetting");
if(checkconfig_str_val == "") {
;
}
else {
int dpi_setting = checkconfig_str_val.toInt();
ui->spinBox->setValue(dpi_setting);
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
dpiSetting = "125";
}
else if(checkconfig_str_val == "n613\n") {
dpiSetting = "175";
}
else {
dpiSetting = "125";
}
std::string dpiSetting_str = dpiSetting.toStdString();
string_writeconfig(".config/00-kobox/dpiSetting", dpiSetting_str);
}
string_checkconfig(".config/00-kobox/dpiSetting");
int dpi_setting = checkconfig_str_val.toInt();
ui->spinBox->setValue(dpi_setting);
}
koboxSettings::~koboxSettings()

View file

@ -72,18 +72,18 @@ int main(int argc, char *argv[])
}
string_writeconfig("/inkbox/skip_opendialog", "true");
device = checkDevice();
if(device == "n705\n") {
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n") {
global::isN705 = true;
global::isN905C = false;
global::isN613 = false;
}
else if(device == "n905\n") {
else if(checkconfig_str_val == "n905\n") {
global::isN705 = false;
global::isN905C = true;
global::isN613 = false;
}
else if(device == "n613\n") {
else if(checkconfig_str_val == "n613\n") {
global::isN705 = false;
global::isN905C = false;
global::isN613 = true;
@ -111,18 +111,18 @@ int main(int argc, char *argv[])
w.setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
device = checkDevice();
if(device == "n705\n") {
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n") {
global::isN705 = true;
global::isN905C = false;
global::isN613 = false;
}
else if(device == "n905\n") {
else if(checkconfig_str_val == "n905\n") {
global::isN705 = false;
global::isN905C = true;
global::isN613 = false;
}
else if(device == "n613\n") {
else if(checkconfig_str_val == "n613\n") {
global::isN705 = false;
global::isN905C = false;
global::isN613 = true;

View file

@ -783,15 +783,15 @@ void MainWindow::setBatteryIcon() {
}
void MainWindow::pre_set_brightness(int brightnessValue) {
if(deviceChecked == false) {
checkDevice();
deviceChecked = true;
}
string_checkconfig_ro("/opt/inkbox_device");
if(device == "n705\n" or device == "n905\n") {
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
set_brightness(brightnessValue);
}
else {
else if(checkconfig_str_val == "n613\n") {
set_brightness_ntxio(brightnessValue);
}
else {
set_brightness(brightnessValue);
}
}

View file

@ -391,6 +391,16 @@ reader::reader(QWidget *parent) :
font_size = font_size.append("pt");
ui->text->setStyleSheet(font_size);
// If needed, show scroll bar when rendering engine isn't doing its job properly
if(checkconfig(".config/14-reader_scrollbar/config") == true) {
ui->text->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->text->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
}
else {
ui->text->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
// Wheeee!
if(is_epub != true) {
ui->text->setText(ittext);
@ -1392,10 +1402,7 @@ void reader::on_nightModeBtn_clicked()
}
void reader::pre_set_brightness(int brightnessValue) {
if(deviceChecked == false) {
string_checkconfig_ro("/opt/inkbox_device");
deviceChecked = true;
}
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
set_brightness(brightnessValue);

View file

@ -119,6 +119,11 @@ settings::settings(QWidget *parent) :
ui->pageSizeHeightSpinBox->setValue(defaultEpubPageHeight);
}
// QTextEdit scroll bar in Reader framework
if(checkconfig(".config/14-reader_scrollbar/config") == true) {
ui->readerScrollBarCheckBox->click();
}
// Sticky menubar
if(checkconfig(".config/11-menubar/sticky") == true) {
ui->menuBarCheckBox->click();
@ -726,3 +731,13 @@ void settings::on_pageSizeHeightSpinBox_valueChanged(int arg1)
string_writeconfig(".config/13-epub_page_size/height", value);
string_writeconfig(".config/13-epub_page_size/set", "true");
}
void settings::on_readerScrollBarCheckBox_toggled(bool checked)
{
if(checked == true) {
string_writeconfig(".config/14-reader_scrollbar/config", "true");
}
else {
string_writeconfig(".config/14-reader_scrollbar/config", "false");
}
}

View file

@ -49,6 +49,7 @@ private slots:
void on_showSystemInfoBtn_clicked();
void on_pageSizeWidthSpinBox_valueChanged(int arg1);
void on_pageSizeHeightSpinBox_valueChanged(int arg1);
void on_readerScrollBarCheckBox_toggled(bool checked);
private:
Ui::settings *ui;

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>477</width>
<height>607</height>
<height>647</height>
</rect>
</property>
<property name="windowTitle">
@ -190,56 +190,47 @@ OK
<property name="bottomMargin">
<number>0</number>
</property>
<item row="7" 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="16" 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="19" 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="17" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_15">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="usbmsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<item row="0" column="4">
<widget class="QLabel" name="pageSizeHeightLabel">
<property name="text">
<string>Go</string>
<string>Height:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="pageSizeWidthLabel">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="pageSizeWidthSpinBox">
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>700</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="epubPageSizeLabel">
<property name="text">
<string>ePUB page size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -251,17 +242,33 @@ OK
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Enter USB Mass Storage session</string>
<item row="0" column="5">
<widget class="QSpinBox" name="pageSizeHeightSpinBox">
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>700</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="18" column="0">
<widget class="QLabel" name="label_3">
<item row="8" 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="0" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<family>Chivo</family>
@ -269,25 +276,11 @@ OK
</font>
</property>
<property name="text">
<string>Networking</string>
<string>Reading</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Disable authors quotes</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="20" column="0">
<item row="21" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
@ -327,15 +320,8 @@ OK
</item>
</layout>
</item>
<item row="5" 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">
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Chivo</family>
@ -343,29 +329,99 @@ OK
</font>
</property>
<property name="text">
<string>Reading</string>
<string>Home</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<item row="18" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<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>
<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>
</layout>
</item>
<item row="11" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Clock: Show seconds</string>
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="text">
<string>Storage</string>
</property>
</widget>
<item row="1" 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>
<item row="1" column="0">
<widget class="QLabel" name="wordsNumberLabel">
<property name="text">
<string>Words number/page (plain text files)</string>
</property>
</widget>
</item>
<item row="1" 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>
</layout>
</item>
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_9">
@ -438,51 +494,18 @@ OK
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
<number>0</number>
<item row="17" column="0">
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<item row="1" 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>
<item row="1" column="0">
<widget class="QLabel" name="wordsNumberLabel">
<property name="text">
<string>Words number/page (plain text files)</string>
</property>
</widget>
</item>
<item row="1" 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>
</layout>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<item row="16" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<family>Chivo</family>
@ -490,7 +513,44 @@ OK
</font>
</property>
<property name="text">
<string>Home</string>
<string>Storage</string>
</property>
</widget>
</item>
<item row="20" 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="19" 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">
<widget class="QCheckBox" name="menuBarCheckBox">
<property name="text">
<string>Always show status bar</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<property name="text">
<string>Clock: Show seconds</string>
</property>
</widget>
</item>
@ -504,72 +564,19 @@ OK
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_15">
<property name="bottomMargin">
<number>0</number>
<item row="10" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Disable authors quotes</string>
</property>
<item row="0" column="4">
<widget class="QLabel" name="pageSizeHeightLabel">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="pageSizeWidthLabel">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="pageSizeWidthSpinBox">
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>700</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="epubPageSizeLabel">
<property name="text">
<string>ePUB page size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_11">
<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">
<widget class="QSpinBox" name="pageSizeHeightSpinBox">
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>700</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="readerScrollBarCheckBox">
<property name="text">
<string>Show scroll bar if needed</string>
</property>
</widget>
</item>
</layout>
</item>

View file

@ -64,6 +64,8 @@ usbms_splash::usbms_splash(QWidget *parent) :
void usbms_splash::usbms_launch()
{
zeroBrightness();
QString umount_prog ("umount");
QStringList umount_args;
if(global::usbms::koboxExportExtensions == true) {