Added ePUB boundaries (don't get out of page range)

This commit is contained in:
Nicolas Mailloux 2021-07-04 22:52:00 -04:00
parent d734c182da
commit db12e81896

View file

@ -814,6 +814,10 @@ void reader::on_nextBtn_clicked()
writeconfig_pagenumber();
}
}
else {
if(mupdf::epubPageNumber + 1 > totalPagesInt) {
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
}
else {
mupdf::epubPageNumber = mupdf::epubPageNumber + 1;
setup_book(book_file, mupdf::epubPageNumber, true);
@ -823,6 +827,7 @@ void reader::on_nextBtn_clicked()
pagesTurned = pagesTurned + 1;
writeconfig_pagenumber();
}
}
alignText(textAlignment);
setupPageWidget();
refreshScreen();
@ -846,6 +851,10 @@ void reader::on_previousBtn_clicked()
writeconfig_pagenumber();
}
}
else {
if(mupdf::epubPageNumber - 1 <= 0) {
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
}
else {
mupdf::epubPageNumber = mupdf::epubPageNumber - 1;
setup_book(book_file, mupdf::epubPageNumber, true);
@ -856,6 +865,7 @@ void reader::on_previousBtn_clicked()
pagesTurned = pagesTurned + 1;
writeconfig_pagenumber();
}
}
alignText(textAlignment);
setupPageWidget();
refreshScreen();
@ -1369,6 +1379,9 @@ void reader::convertMuPdfVars() {
mupdf::fontSize_qstr = QString::number(mupdf::fontSize);
mupdf::width_qstr = QString::number(mupdf::width);
mupdf::height_qstr = QString::number(mupdf::height);
if(mupdf::epubPageNumber <= 0) {
mupdf::epubPageNumber = 1;
}
mupdf::epubPageNumber_qstr = QString::number(mupdf::epubPageNumber);
}