Added book status and page number/total pages bar

This commit is contained in:
Nicolas Mailloux 2021-07-04 22:35:06 -04:00
parent 61efc6ee45
commit d734c182da
3 changed files with 451 additions and 319 deletions

View file

@ -50,6 +50,7 @@ reader::reader(QWidget *parent) :
ui->previousDefinitionBtn->setProperty("type", "borderless");
ui->nextDefinitionBtn->setProperty("type", "borderless");
ui->nightModeBtn->setProperty("type", "borderless");
ui->gotoBtn->setProperty("type", "borderless");
// Icons
ui->alignLeftBtn->setText("");
@ -136,6 +137,8 @@ reader::reader(QWidget *parent) :
ui->homeBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->aboutBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->fontChooser->setStyleSheet("font-size: 9pt");
ui->gotoBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->pageNumberLabel->setFont(QFont("Source Serif Pro"));
// Hiding the menubar + definition widget + brightness widget
ui->hideOptionsBtn->hide();
@ -151,6 +154,7 @@ reader::reader(QWidget *parent) :
ui->menuWidget->setVisible(false);
ui->statusBarWidget->setVisible(false);
}
ui->pageWidget->hide();
// Topbar widget / book info
ui->topbarStackedWidget->setVisible(true);
@ -592,6 +596,12 @@ reader::reader(QWidget *parent) :
} );
t->start();
}
// Pages number info label
if(is_epub == true) {
getTotalEpubPagesNumber();
}
setupPageWidget();
}
reader::~reader()
@ -814,6 +824,7 @@ void reader::on_nextBtn_clicked()
writeconfig_pagenumber();
}
alignText(textAlignment);
setupPageWidget();
refreshScreen();
}
@ -846,6 +857,7 @@ void reader::on_previousBtn_clicked()
writeconfig_pagenumber();
}
alignText(textAlignment);
setupPageWidget();
refreshScreen();
}
@ -1119,6 +1131,7 @@ void reader::menubar_show() {
ui->menuWidget->setVisible(true);
ui->menuBarWidget->setVisible(true);
ui->statusBarWidget->setVisible(true);
ui->pageWidget->setVisible(true);
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
@ -1143,6 +1156,7 @@ void reader::menubar_hide() {
ui->hideOptionsBtn->hide();
ui->optionsBtn->show();
ui->menuBarWidget->setVisible(false);
ui->pageWidget->setVisible(false);
if(checkconfig(".config/11-menubar/sticky") == true) {
ui->statusBarWidget->setVisible(true);
}
@ -1457,3 +1471,50 @@ void reader::openUsbmsDialog() {
generalDialogWindow->show();
QApplication::processEvents();
}
QString reader::setPageNumberLabelContent() {
QString content;
if(is_epub == true) {
QString pageNumber;
QString totalPages;
pageNumberInt = mupdf::epubPageNumber;
pageNumber = QString::number(pageNumberInt);
totalPages = QString::number(totalPagesInt);
content.append(pageNumber);
content.append(" <i>of</i> ");
content.append(totalPages);
}
else {
QString pageNumber;
QString totalPages;
pageNumberInt = split_files_number - split_total;
totalPagesInt = split_files_number - 2;
pageNumber = QString::number(pageNumberInt);
totalPages = QString::number(totalPagesInt);
content.append(pageNumber);
content.append(" <i>of</i> ");
content.append(totalPages);
}
return content;
}
void reader::setupPageWidget() {
QString pageNumberInfoLabelContent = setPageNumberLabelContent();
ui->pageNumberLabel->setText(pageNumberInfoLabelContent);
ui->pageProgressBar->setMaximum(totalPagesInt);
ui->pageProgressBar->setMinimum(1);
ui->pageProgressBar->setValue(pageNumberInt);
}
void reader::getTotalEpubPagesNumber() {
QString epubProg ("sh");
QStringList epubArgs;
convertMuPdfVars();
epubArgs << "/mnt/onboard/.adds/inkbox/epub.sh" << mupdf::fontSize_qstr << mupdf::width_qstr << mupdf::height_qstr << mupdf::epubPageNumber_qstr << "get_pages_number";
QProcess *epubProc = new QProcess();
epubProc->start(epubProg, epubArgs);
epubProc->waitForFinished();
string_checkconfig_ro("/run/epub_total_pages_number");
totalPagesInt = checkconfig_str_val.toInt();
}

View file

@ -75,6 +75,8 @@ public:
QList<QString> content;
QString epubPageContent;
QString usbmsStatus;
int pageNumberInt;
int totalPagesInt;
int setup_book(QString book, int i, bool run_parser);
void checkwords();
@ -93,6 +95,9 @@ public:
void alignText(int alignment);
void delay(int seconds);
void openUsbmsDialog();
QString setPageNumberLabelContent();
void setupPageWidget();
void getTotalEpubPagesNumber();
private slots:
void on_nextBtn_clicked();

704
reader.ui
View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>490</width>
<height>726</height>
<height>750</height>
</rect>
</property>
<property name="windowTitle">
@ -16,285 +16,32 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="10" column="0">
<widget class="QStackedWidget" name="wordWidget">
<widget class="QWidget" name="page_8">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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>
<widget class="Line" name="line_12">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="3">
<spacer name="horizontalSpacer_4">
<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="QPushButton" name="saveWordBtn">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="infoCloseBtn">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="wordSearchLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Word search</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_14">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="Line" name="line_14">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="definitionLabel">
<property name="font">
<font>
<family>Source Serif Pro</family>
</font>
</property>
<property name="text">
<string>Definition</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="wordLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Word</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<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="0" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_4">
<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="4" column="0">
<layout class="QGridLayout" name="gridLayout_9">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer_7">
<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="1">
<widget class="QPushButton" name="previousDefinitionBtn">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item row="0" column="4">
<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="QLabel" name="definitionStatusLabel">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="nextDefinitionBtn">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" 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>
</layout>
</item>
<item>
<widget class="Line" name="line_13">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_9"/>
<item row="9" column="0">
<widget class="QTextEdit" name="text">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>50</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
<item row="8" column="0">
@ -895,6 +642,300 @@
</widget>
</item>
<item row="15" column="0">
<widget class="Line" name="line_2">
<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>
<item row="11" column="0">
<widget class="QStackedWidget" name="wordWidget">
<widget class="QWidget" name="page_8">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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>
<widget class="Line" name="line_12">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="3">
<spacer name="horizontalSpacer_4">
<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="QPushButton" name="saveWordBtn">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="infoCloseBtn">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="wordSearchLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Word search</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_14">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="Line" name="line_14">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="definitionLabel">
<property name="font">
<font>
<family>Source Serif Pro</family>
</font>
</property>
<property name="text">
<string>Definition</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="wordLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Word</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<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="0" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_4">
<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="4" column="0">
<layout class="QGridLayout" name="gridLayout_9">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer_7">
<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="1">
<widget class="QPushButton" name="previousDefinitionBtn">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item row="0" column="4">
<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="QLabel" name="definitionStatusLabel">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="nextDefinitionBtn">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" 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>
</layout>
</item>
<item>
<widget class="Line" name="line_13">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_9"/>
</widget>
</item>
<item row="16" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="4">
<widget class="Line" name="line_3">
@ -970,45 +1011,70 @@
</item>
</layout>
</item>
<item row="9" column="0">
<widget class="QTextEdit" name="text">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>50</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<item row="10" column="0">
<widget class="QStackedWidget" name="pageWidget">
<widget class="QWidget" name="page_10">
<layout class="QVBoxLayout" name="verticalLayout_5">
<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_15">
<item row="0" column="0">
<widget class="Line" name="line_16">
<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>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_18">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="pageNumberLabel">
<property name="text">
<string>x of x</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="gotoBtn">
<property name="text">
<string>Go to</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QProgressBar" name="pageProgressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_11"/>
</widget>
</item>
</layout>