mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-27 16:17:21 -08:00
Added ePUB boundaries (don't get out of page range)
This commit is contained in:
parent
d734c182da
commit
db12e81896
1 changed files with 26 additions and 13 deletions
39
reader.cpp
39
reader.cpp
|
@ -815,13 +815,18 @@ void reader::on_nextBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mupdf::epubPageNumber = mupdf::epubPageNumber + 1;
|
if(mupdf::epubPageNumber + 1 > totalPagesInt) {
|
||||||
setup_book(book_file, mupdf::epubPageNumber, true);
|
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
||||||
ui->text->setText("");
|
}
|
||||||
ui->text->setText(epubPageContent);
|
else {
|
||||||
|
mupdf::epubPageNumber = mupdf::epubPageNumber + 1;
|
||||||
|
setup_book(book_file, mupdf::epubPageNumber, true);
|
||||||
|
ui->text->setText("");
|
||||||
|
ui->text->setText(epubPageContent);
|
||||||
|
|
||||||
pagesTurned = pagesTurned + 1;
|
pagesTurned = pagesTurned + 1;
|
||||||
writeconfig_pagenumber();
|
writeconfig_pagenumber();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
alignText(textAlignment);
|
alignText(textAlignment);
|
||||||
setupPageWidget();
|
setupPageWidget();
|
||||||
|
@ -847,14 +852,19 @@ void reader::on_previousBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mupdf::epubPageNumber = mupdf::epubPageNumber - 1;
|
if(mupdf::epubPageNumber - 1 <= 0) {
|
||||||
setup_book(book_file, mupdf::epubPageNumber, true);
|
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
|
||||||
ui->text->setText("");
|
}
|
||||||
ui->text->setText(epubPageContent);
|
else {
|
||||||
|
mupdf::epubPageNumber = mupdf::epubPageNumber - 1;
|
||||||
|
setup_book(book_file, mupdf::epubPageNumber, true);
|
||||||
|
ui->text->setText("");
|
||||||
|
ui->text->setText(epubPageContent);
|
||||||
|
|
||||||
// We always increment pagesTurned regardless whether we press the Previous or Next button
|
// We always increment pagesTurned regardless whether we press the Previous or Next button
|
||||||
pagesTurned = pagesTurned + 1;
|
pagesTurned = pagesTurned + 1;
|
||||||
writeconfig_pagenumber();
|
writeconfig_pagenumber();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
alignText(textAlignment);
|
alignText(textAlignment);
|
||||||
setupPageWidget();
|
setupPageWidget();
|
||||||
|
@ -1369,6 +1379,9 @@ void reader::convertMuPdfVars() {
|
||||||
mupdf::fontSize_qstr = QString::number(mupdf::fontSize);
|
mupdf::fontSize_qstr = QString::number(mupdf::fontSize);
|
||||||
mupdf::width_qstr = QString::number(mupdf::width);
|
mupdf::width_qstr = QString::number(mupdf::width);
|
||||||
mupdf::height_qstr = QString::number(mupdf::height);
|
mupdf::height_qstr = QString::number(mupdf::height);
|
||||||
|
if(mupdf::epubPageNumber <= 0) {
|
||||||
|
mupdf::epubPageNumber = 1;
|
||||||
|
}
|
||||||
mupdf::epubPageNumber_qstr = QString::number(mupdf::epubPageNumber);
|
mupdf::epubPageNumber_qstr = QString::number(mupdf::epubPageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue