From fc4b9ba672b4a7a7ee9ad05346cec78b894278d8 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sun, 27 Jun 2021 13:28:41 -0400 Subject: [PATCH] Show scrollbar if needed in Reader framework --- brightnessdialog.cpp | 5 - functions.h | 18 +- koboxsettings.cpp | 22 ++- main.cpp | 16 +- mainwindow.cpp | 12 +- reader.cpp | 15 +- settings.cpp | 15 ++ settings.h | 1 + settings.ui | 403 ++++++++++++++++++++++--------------------- usbms_splash.cpp | 2 + 10 files changed, 276 insertions(+), 233 deletions(-) diff --git a/brightnessdialog.cpp b/brightnessdialog.cpp index 34b9ab1..905c28f 100644 --- a/brightnessdialog.cpp +++ b/brightnessdialog.cpp @@ -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); } diff --git a/functions.h b/functions.h index 264a640..9ea500d 100644 --- a/functions.h +++ b/functions.h @@ -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 diff --git a/koboxsettings.cpp b/koboxsettings.cpp index 4feca17..ba851ef 100644 --- a/koboxsettings.cpp +++ b/koboxsettings.cpp @@ -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() diff --git a/main.cpp b/main.cpp index 9fb4336..1e2aabc 100644 --- a/main.cpp +++ b/main.cpp @@ -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; diff --git a/mainwindow.cpp b/mainwindow.cpp index 269fd1d..f0aac09 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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); + } } diff --git a/reader.cpp b/reader.cpp index 4f81e49..36ced86 100644 --- a/reader.cpp +++ b/reader.cpp @@ -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); diff --git a/settings.cpp b/settings.cpp index 676a56d..906f017 100644 --- a/settings.cpp +++ b/settings.cpp @@ -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"); + } +} diff --git a/settings.h b/settings.h index 5eee262..1734124 100644 --- a/settings.h +++ b/settings.h @@ -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; diff --git a/settings.ui b/settings.ui index c67918c..7aa03ee 100644 --- a/settings.ui +++ b/settings.ui @@ -7,7 +7,7 @@ 0 0 477 - 607 + 647 @@ -190,56 +190,47 @@ OK 0 - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - + + 0 - - - - - 75 - true - - + + - Go + Height: + + + + + + + Width: + + + + + + + 300 + + + 700 + + + 25 + + + + + + + ePUB page size - + Qt::Horizontal @@ -251,17 +242,33 @@ OK - - - - Enter USB Mass Storage session + + + + 300 + + + 700 + + + 25 - - + + + + QFrame::Plain + + + Qt::Horizontal + + + + + Chivo @@ -269,25 +276,11 @@ OK - Networking + Reading - - - - Disable authors quotes - - - - - - - Disable "Welcome to InkBox" message - - - - + 0 @@ -327,15 +320,8 @@ OK - - - - Always show status bar - - - - - + + Chivo @@ -343,29 +329,99 @@ OK - Reading + Home - - + + + + 0 + + + + + + 75 + true + + + + Go + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Enter USB Mass Storage session + + + + + + + - Clock: Show seconds + Disable "Welcome to InkBox" message - - - - - Chivo - true - + + + + 0 - - Storage - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Words number/page (plain text files) + + + + + + + 20 + + + 300 + + + 20 + + + 20 + + + + @@ -438,51 +494,18 @@ OK - - - - 0 + + + + QFrame::Plain - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Words number/page (plain text files) - - - - - - - 20 - - - 300 - - - 20 - - - 20 - - - - + + Qt::Horizontal + + - - + + Chivo @@ -490,7 +513,44 @@ OK - Home + Storage + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + + Chivo + true + + + + Networking + + + + + + + Always show status bar + + + + + + + Clock: Show seconds @@ -504,72 +564,19 @@ OK - - - - 0 + + + + Disable authors quotes - - - - Height: - - - - - - - Width: - - - - - - - 300 - - - 700 - - - 25 - - - - - - - ePUB page size - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 300 - - - 700 - - - 25 - - - - + + + + + + Show scroll bar if needed + + diff --git a/usbms_splash.cpp b/usbms_splash.cpp index 891440d..ff77aad 100644 --- a/usbms_splash.cpp +++ b/usbms_splash.cpp @@ -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) {