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->previousDefinitionBtn->setProperty("type", "borderless");
ui->nextDefinitionBtn->setProperty("type", "borderless"); ui->nextDefinitionBtn->setProperty("type", "borderless");
ui->nightModeBtn->setProperty("type", "borderless"); ui->nightModeBtn->setProperty("type", "borderless");
ui->gotoBtn->setProperty("type", "borderless");
// Icons // Icons
ui->alignLeftBtn->setText(""); ui->alignLeftBtn->setText("");
@ -136,6 +137,8 @@ reader::reader(QWidget *parent) :
ui->homeBtn->setStyleSheet("font-size: 9pt; padding: 5px"); ui->homeBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->aboutBtn->setStyleSheet("font-size: 9pt; padding: 5px"); ui->aboutBtn->setStyleSheet("font-size: 9pt; padding: 5px");
ui->fontChooser->setStyleSheet("font-size: 9pt"); 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 // Hiding the menubar + definition widget + brightness widget
ui->hideOptionsBtn->hide(); ui->hideOptionsBtn->hide();
@ -151,6 +154,7 @@ reader::reader(QWidget *parent) :
ui->menuWidget->setVisible(false); ui->menuWidget->setVisible(false);
ui->statusBarWidget->setVisible(false); ui->statusBarWidget->setVisible(false);
} }
ui->pageWidget->hide();
// Topbar widget / book info // Topbar widget / book info
ui->topbarStackedWidget->setVisible(true); ui->topbarStackedWidget->setVisible(true);
@ -592,6 +596,12 @@ reader::reader(QWidget *parent) :
} ); } );
t->start(); t->start();
} }
// Pages number info label
if(is_epub == true) {
getTotalEpubPagesNumber();
}
setupPageWidget();
} }
reader::~reader() reader::~reader()
@ -814,6 +824,7 @@ void reader::on_nextBtn_clicked()
writeconfig_pagenumber(); writeconfig_pagenumber();
} }
alignText(textAlignment); alignText(textAlignment);
setupPageWidget();
refreshScreen(); refreshScreen();
} }
@ -846,6 +857,7 @@ void reader::on_previousBtn_clicked()
writeconfig_pagenumber(); writeconfig_pagenumber();
} }
alignText(textAlignment); alignText(textAlignment);
setupPageWidget();
refreshScreen(); refreshScreen();
} }
@ -1119,6 +1131,7 @@ void reader::menubar_show() {
ui->menuWidget->setVisible(true); ui->menuWidget->setVisible(true);
ui->menuBarWidget->setVisible(true); ui->menuBarWidget->setVisible(true);
ui->statusBarWidget->setVisible(true); ui->statusBarWidget->setVisible(true);
ui->pageWidget->setVisible(true);
string_checkconfig_ro("/opt/inkbox_device"); string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
@ -1143,6 +1156,7 @@ void reader::menubar_hide() {
ui->hideOptionsBtn->hide(); ui->hideOptionsBtn->hide();
ui->optionsBtn->show(); ui->optionsBtn->show();
ui->menuBarWidget->setVisible(false); ui->menuBarWidget->setVisible(false);
ui->pageWidget->setVisible(false);
if(checkconfig(".config/11-menubar/sticky") == true) { if(checkconfig(".config/11-menubar/sticky") == true) {
ui->statusBarWidget->setVisible(true); ui->statusBarWidget->setVisible(true);
} }
@ -1457,3 +1471,50 @@ void reader::openUsbmsDialog() {
generalDialogWindow->show(); generalDialogWindow->show();
QApplication::processEvents(); 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; QList<QString> content;
QString epubPageContent; QString epubPageContent;
QString usbmsStatus; QString usbmsStatus;
int pageNumberInt;
int totalPagesInt;
int setup_book(QString book, int i, bool run_parser); int setup_book(QString book, int i, bool run_parser);
void checkwords(); void checkwords();
@ -93,6 +95,9 @@ public:
void alignText(int alignment); void alignText(int alignment);
void delay(int seconds); void delay(int seconds);
void openUsbmsDialog(); void openUsbmsDialog();
QString setPageNumberLabelContent();
void setupPageWidget();
void getTotalEpubPagesNumber();
private slots: private slots:
void on_nextBtn_clicked(); void on_nextBtn_clicked();

704
reader.ui
View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>490</width> <width>490</width>
<height>726</height> <height>750</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -16,285 +16,32 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="10" column="0"> <item row="9" column="0">
<widget class="QStackedWidget" name="wordWidget"> <widget class="QTextEdit" name="text">
<widget class="QWidget" name="page_8"> <property name="sizePolicy">
<layout class="QVBoxLayout" name="verticalLayout_4"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<property name="leftMargin"> <horstretch>50</horstretch>
<number>0</number> <verstretch>50</verstretch>
</property> </sizepolicy>
<property name="topMargin"> </property>
<number>0</number> <property name="locale">
</property> <locale language="English" country="UnitedStates"/>
<property name="rightMargin"> </property>
<number>0</number> <property name="frameShape">
</property> <enum>QFrame::NoFrame</enum>
<property name="bottomMargin"> </property>
<number>0</number> <property name="frameShadow">
</property> <enum>QFrame::Plain</enum>
<item> </property>
<widget class="Line" name="line_12"> <property name="lineWidth">
<property name="frameShadow"> <number>0</number>
<enum>QFrame::Plain</enum> </property>
</property> <property name="verticalScrollBarPolicy">
<property name="lineWidth"> <enum>Qt::ScrollBarAlwaysOff</enum>
<number>8</number> </property>
</property> <property name="horizontalScrollBarPolicy">
<property name="orientation"> <enum>Qt::ScrollBarAlwaysOff</enum>
<enum>Qt::Horizontal</enum> </property>
</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> </widget>
</item> </item>
<item row="8" column="0"> <item row="8" column="0">
@ -895,6 +642,300 @@
</widget> </widget>
</item> </item>
<item row="15" column="0"> <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"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="4"> <item row="0" column="4">
<widget class="Line" name="line_3"> <widget class="Line" name="line_3">
@ -970,45 +1011,70 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="9" column="0"> <item row="10" column="0">
<widget class="QTextEdit" name="text"> <widget class="QStackedWidget" name="pageWidget">
<property name="sizePolicy"> <widget class="QWidget" name="page_10">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <layout class="QVBoxLayout" name="verticalLayout_5">
<horstretch>50</horstretch> <property name="leftMargin">
<verstretch>50</verstretch> <number>0</number>
</sizepolicy> </property>
</property> <property name="topMargin">
<property name="locale"> <number>0</number>
<locale language="English" country="UnitedStates"/> </property>
</property> <property name="rightMargin">
<property name="frameShape"> <number>0</number>
<enum>QFrame::NoFrame</enum> </property>
</property> <property name="bottomMargin">
<property name="frameShadow"> <number>0</number>
<enum>QFrame::Plain</enum> </property>
</property> <item>
<property name="lineWidth"> <layout class="QGridLayout" name="gridLayout_15">
<number>0</number> <item row="0" column="0">
</property> <widget class="Line" name="line_16">
<property name="verticalScrollBarPolicy"> <property name="frameShadow">
<enum>Qt::ScrollBarAlwaysOff</enum> <enum>QFrame::Plain</enum>
</property> </property>
<property name="horizontalScrollBarPolicy"> <property name="lineWidth">
<enum>Qt::ScrollBarAlwaysOff</enum> <number>2</number>
</property> </property>
</widget> <property name="orientation">
</item> <enum>Qt::Horizontal</enum>
<item row="14" column="0"> </property>
<widget class="Line" name="line_2"> </widget>
<property name="frameShadow"> </item>
<enum>QFrame::Plain</enum> <item row="1" column="0">
</property> <layout class="QGridLayout" name="gridLayout_18">
<property name="lineWidth"> <property name="bottomMargin">
<number>2</number> <number>0</number>
</property> </property>
<property name="orientation"> <item row="0" column="0">
<enum>Qt::Horizontal</enum> <widget class="QLabel" name="pageNumberLabel">
</property> <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> </widget>
</item> </item>
</layout> </layout>