Various fixes; Reader: scrap old brightness progress bar

This commit is contained in:
Nicolas Mailloux 2023-06-12 12:19:49 -04:00
parent 72322a7fe5
commit c07d2d7aaf
6 changed files with 103 additions and 270 deletions

View file

@ -274,7 +274,7 @@ MainWindow::MainWindow(QWidget *parent)
// Global reading settings
string_checkconfig(".config/16-global_reading_settings/config");
if(checkconfig_str_val == "") {
checked_box = true;
checked_box = false;
writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings=");
}
@ -579,8 +579,15 @@ void MainWindow::on_homeBtn_clicked()
void MainWindow::resetWindow(bool resetStackedWidget) {
// Reset layout
bool authorQuote = false;
if(resetStackedWidget == true) {
ui->homeStackedWidget->setCurrentIndex(2);
if(checkconfig(".config/05-quote/config") == false) {
authorQuote = true;
ui->homeStackedWidget->setCurrentIndex(0);
}
else {
ui->homeStackedWidget->setCurrentIndex(2);
}
ui->stackedWidget->setCurrentIndex(0);
}
@ -616,7 +623,7 @@ void MainWindow::resetWindow(bool resetStackedWidget) {
if(global::mainwindow::tabSwitcher::repaint == true) {
this->repaint();
}
if(resetStackedWidget == true) {
if(resetStackedWidget == true && authorQuote == false) {
setupHomePageWidget();
}
}
@ -950,7 +957,6 @@ void MainWindow::on_libraryButton_clicked()
log("Launching Online Library", className);
if(testPing() == 0 or global::deviceID == "emu\n") {
// 'Do you want to sync?' dialog
log("Showing 'Sync required' dialog", className);
bool willSync = false;
QString syncEpochQStr = readFile("/external_root/opt/storage/gutenberg/last_sync");
if(!syncEpochQStr.isEmpty()) {
@ -966,6 +972,7 @@ void MainWindow::on_libraryButton_clicked()
}
if(willSync == true) {
log("Showing 'Sync required' dialog", className);
global::library::librarySyncDialog = true;
generalDialogWindow = new generalDialog(this);
QObject::connect(generalDialogWindow, &generalDialog::syncOnlineLibrary, this, &MainWindow::launchOnlineLibrary);

View file

@ -36,7 +36,6 @@
<font>
<family>Inter</family>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -96,7 +95,6 @@
<font>
<family>Inter</family>
<pointsize>11</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
@ -129,7 +127,6 @@
<font>
<family>Inter</family>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -232,7 +229,6 @@
<font>
<family>Inter</family>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -310,7 +306,6 @@
<font>
<family>Chivo</family>
<pointsize>11</pointsize>
<weight>50</weight>
<italic>true</italic>
<bold>false</bold>
</font>
@ -467,7 +462,6 @@
<font>
<family>Inter</family>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -485,7 +479,6 @@ Library
<font>
<family>Inter</family>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -536,7 +529,6 @@ Reader
<font>
<family>Inter</family>
<pointsize>10</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -570,7 +562,6 @@ Search
<font>
<family>Inter</family>
<pointsize>10</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -604,7 +595,6 @@ Settings
<font>
<family>Inter</family>
<pointsize>10</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
@ -644,7 +634,6 @@ Apps
<font>
<family>Inter</family>
<pointsize>10</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>

View file

@ -47,7 +47,6 @@ reader::reader(QWidget *parent) :
global::reader::currentViewportText = "";
ui->setupUi(this);
ui->brightnessStatus->setFont(QFont("u001"));
ui->fontLabel->setFont(QFont("u001"));
ui->sizeLabel->setFont(QFont("u001"));
ui->sizeValueLabel->setFont(QFont("Inter"));
@ -63,10 +62,8 @@ reader::reader(QWidget *parent) :
ui->previousBtn->setProperty("type", "borderless");
ui->nextBtn->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->brightnessBtn->setProperty("type", "borderless");
ui->alignLeftBtn->setProperty("type", "borderless");
ui->alignRightBtn->setProperty("type", "borderless");
ui->alignCenterBtn->setProperty("type", "borderless");
@ -101,14 +98,10 @@ reader::reader(QWidget *parent) :
ui->previousDefinitionBtn->setIcon(QIcon(":/resources/chevron-left.png"));
ui->nextDefinitionBtn->setText("");
ui->nextDefinitionBtn->setIcon(QIcon(":/resources/chevron-right.png"));
ui->brightnessDecBtn->setText("");
ui->brightnessDecBtn->setIcon(QIcon(":/resources/minus.png"));
ui->brightnessIncBtn->setText("");
ui->brightnessIncBtn->setIcon(QIcon(":/resources/plus.png"));
ui->homeBtn->setText("");
ui->homeBtn->setIcon(QIcon(":/resources/home.png"));
ui->aboutBtn->setText("");
ui->aboutBtn->setIcon(QIcon(":/resources/info.png"));
ui->brightnessBtn->setText("");
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
ui->searchBtn->setText("");
ui->searchBtn->setIcon(QIcon(":/resources/search.png"));
ui->increaseScaleBtn->setText("");
@ -309,7 +302,7 @@ reader::reader(QWidget *parent) :
ui->lineSpacingValueLabel->setStyleSheet("font-size: 9pt; font-weight: bold");
ui->marginsValueLabel->setStyleSheet("font-size: 9pt; font-weight: bold");
ui->homeBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->aboutBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->brightnessBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->fontChooser->setStyleSheet("font-size: 9pt");
ui->gotoBtn->setStyleSheet("font-size: 9pt; padding: 9px; font-weight: bold; background: lightGrey");
ui->pageNumberLabel->setFont(QFont("Source Serif Pro"));
@ -317,7 +310,7 @@ reader::reader(QWidget *parent) :
// Hiding the menubar + definition widget + brightness widget + buttons bar widget
ui->menuWidget->setVisible(false);
ui->brightnessWidget->setVisible(false);
ui->brightnessBtn->setVisible(false);
ui->menuBarWidget->setVisible(false);
ui->buttonsBarWidget->setVisible(false);
ui->pdfScaleWidget->setVisible(false);
@ -340,20 +333,6 @@ reader::reader(QWidget *parent) :
showTopbarWidget = true;
ui->bookInfoLabel->setFont(crimson);
// Getting brightness level
int brightness_value;
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
brightness_value = get_brightness();
}
else if(global::isN613 == true) {
setDefaultWorkDir();
brightness_value = brightness_checkconfig(".config/03-brightness/config");
}
else {
brightness_value = get_brightness();
}
ui->brightnessStatus->setValue(brightness_value);
// Defining pixmaps
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
@ -1180,69 +1159,6 @@ void reader::on_optionsBtn_clicked()
}
}
void reader::on_brightnessDecBtn_clicked()
{
int bval;
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
bval = get_brightness();
}
else if(global::isN613 == true) {
setDefaultWorkDir();
bval = brightness_checkconfig(".config/03-brightness/config");
}
else {
bval = get_brightness();
}
int set_bval = bval - 1;
if(set_bval < 0) {
set_bval = 0;
}
pre_set_brightness(set_bval);
brightness_writeconfig(set_bval);
ui->brightnessStatus->setValue(set_bval);
}
void reader::on_brightnessIncBtn_clicked()
{
int bval;
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
bval = get_brightness();
}
else if(global::isN613 == true) {
setDefaultWorkDir();
bval = brightness_checkconfig(".config/03-brightness/config");
}
else {
bval = get_brightness();
}
int set_bval = bval + 1;
if(set_bval > 100) {
set_bval = 100;
}
pre_set_brightness(set_bval);
brightness_writeconfig(set_bval);
ui->brightnessStatus->setValue(set_bval);
}
void reader::on_aboutBtn_clicked()
{
log("Showing About message box", className);
if(checkconfig("/opt/inkbox_genuine") == true) {
QString aboutmsg = "InkBox is an open-source, Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive.";
aboutmsg.prepend("<font face='u001'>");
string_checkconfig_ro("/external_root/opt/isa/version");
aboutmsg.append("<br><br>InkBox ");
aboutmsg.append(checkconfig_str_val);
aboutmsg.append("</font>");
QMessageBox::information(this, tr("Information"), aboutmsg);
}
else {
QMessageBox::information(this, tr("About"), tr("InkBox is an open-source Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive."));
}
}
void reader::on_homeBtn_clicked()
{
log("Returning to Home screen", className);
@ -1486,7 +1402,7 @@ void reader::menubar_show() {
;
}
else {
ui->brightnessWidget->setVisible(true);
ui->brightnessBtn->setVisible(true);
}
menubar_shown = true;
@ -1495,11 +1411,11 @@ void reader::menubar_show() {
void reader::menubar_hide() {
log("Hiding menu bar", className);
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
ui->brightnessWidget->setVisible(false);
ui->brightnessBtn->setVisible(true);
}
else {
// Safety measure
ui->brightnessWidget->setVisible(false);
ui->brightnessBtn->setVisible(false);
}
if(is_pdf == false && is_image == false) {
@ -2356,3 +2272,11 @@ void reader::on_marginsSlider_valueChanged(int value)
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
ui->marginsValueLabel->setText(QString::number(value + 1));
}
void reader::on_brightnessBtn_clicked()
{
log("Showing Brightness Dialog", className);
brightnessDialogWindow = new brightnessDialog();
brightnessDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
brightnessDialogWindow->show();
}

View file

@ -8,6 +8,7 @@
#include "quit.h"
#include "textdialog.h"
#include "highlightslistdialog.h"
#include "brightnessdialog.h"
#include <QWidget>
#include <QGraphicsScene>
@ -126,9 +127,6 @@ private slots:
void on_nextBtn_clicked();
void on_previousBtn_clicked();
void on_optionsBtn_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();
@ -170,6 +168,7 @@ private slots:
void setMargins(int margins, bool write = true);
void on_lineSpacingSlider_valueChanged(int value);
void on_marginsSlider_valueChanged(int value);
void on_brightnessBtn_clicked();
signals:
void openBookFile(QString book, bool relativePath);
@ -183,6 +182,7 @@ private:
textDialog * textDialogWindow;
highlightsListDialog * highlightsListDialogWindow;
QGraphicsScene * graphicsScene;
brightnessDialog * brightnessDialogWindow;
};
#endif // READER_H

View file

@ -35,7 +35,6 @@
<widget class="QPushButton" name="previousBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -68,7 +67,6 @@
<widget class="QPushButton" name="optionsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -81,7 +79,6 @@
<widget class="QPushButton" name="nextBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -160,7 +157,6 @@
<widget class="QLabel" name="wordSearchLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -230,7 +226,6 @@
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -527,50 +522,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="11">
<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="2">
<widget class="QPushButton" name="aboutBtn">
<property name="text">
<string> About </string>
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QLabel" name="batteryIconLabel">
<property name="text">
<string>Battery Icon</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nightModeBtn">
<property name="text">
<string>Night mode</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_15">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="8">
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -584,29 +535,8 @@
</property>
</spacer>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="quitBtn">
<property name="text">
<string>Quit</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="QPushButton" name="searchBtn">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="Line" name="line_17">
<item row="0" column="10">
<widget class="Line" name="line_19">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -628,8 +558,20 @@
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="Line" name="line_19">
<item row="0" column="11">
<widget class="QLabel" name="batteryLabel">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Battery</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_15">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -638,6 +580,58 @@
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QLabel" name="batteryIconLabel">
<property name="text">
<string>Battery Icon</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nightModeBtn">
<property name="text">
<string>Night mode</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="quitBtn">
<property name="text">
<string>Quit</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="5">
<widget class="Line" name="line_17">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="searchBtn">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="brightnessBtn">
<property name="text">
<string>Brightness</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -717,7 +711,6 @@
<widget class="QLabel" name="timeLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -768,7 +761,6 @@
<widget class="QLabel" name="inkboxLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -815,90 +807,6 @@
<widget class="QWidget" name="page_5"/>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="brightnessWidget">
<property name="lineWidth">
<number>0</number>
</property>
<widget class="QWidget" name="page_12">
<layout class="QVBoxLayout" name="verticalLayout_6">
<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_6">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QPushButton" name="brightnessDecBtn">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="brightnessIncBtn">
<property name="text">
<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="1">
<widget class="QProgressBar" name="brightnessStatus">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<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>
</widget>
<widget class="QWidget" name="page_13"/>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="pdfScaleWidget">
<widget class="QWidget" name="page_15">

View file

@ -366,6 +366,11 @@ settings::settings(QWidget *parent) :
ui->autoCheckUpdatesBox->click();
}
// 'Export highlights' button
if(!QFile::exists(global::localLibrary::highlightsDatabasePath) or readFile(global::localLibrary::highlightsDatabasePath).isEmpty()) {
ui->exportHighlightsBtn->setEnabled(false);
}
if(readFile(".config/12-lockscreen/background") == "blank") {
ui->lockscreenBackgroundComboBox->setCurrentIndex(0);
}