Reader framework bug fixes, preparing for v1.3

This commit is contained in:
Nicolas Mailloux 2021-04-06 12:01:04 -04:00
parent daaef3a72f
commit 11e7541759
2 changed files with 59 additions and 29 deletions

View file

@ -270,8 +270,10 @@ reader::reader(QWidget *parent) :
if(checkconfig("/inkbox/skip_opendialog") == true) { if(checkconfig("/inkbox/skip_opendialog") == true) {
// We have to get the file's path // We have to get the file's path
if(checkconfig("/tmp/suspendBook") == true) { if(checkconfig("/tmp/suspendBook") == true) {
wakeFromSleep = true;
// Prevent from opening the Reader framework next time unless the condition is reset // Prevent from opening the Reader framework next time unless the condition is reset
string_writeconfig("/tmp/suspendBook", "false"); string_writeconfig("/tmp/suspendBook", "false");
book_file = "/inkbox/book/book.txt";
} }
else { else {
string_checkconfig("/inkbox/book_number"); string_checkconfig("/inkbox/book_number");
@ -320,11 +322,22 @@ reader::reader(QWidget *parent) :
} }
} }
// Checking if we're waking from sleep; if so, do nothing there because the book should already have been parsed
if(wakeFromSleep != true) {
// Counting number of parsed files // Counting number of parsed files
split_total = setup_book(book_file, 0, true); split_total = setup_book(book_file, 0, true);
split_files_number = split_total; split_files_number = split_total;
split_total = split_total - 1; split_total = split_total - 1;
writeconfig_pagenumber();
}
else {
// Retrieve split_total from tmpfs
string_checkconfig("/tmp/inkboxPageNumber");
split_total = checkconfig_str_val.toInt();
setup_book(book_file, 0, true);
}
// Get text // Get text
QDir::setCurrent("/mnt/onboard/.adds/inkbox"); QDir::setCurrent("/mnt/onboard/.adds/inkbox");
setup_book(book_file, split_total, false); setup_book(book_file, split_total, false);
@ -370,6 +383,12 @@ reader::reader(QWidget *parent) :
// Wheeee! // Wheeee!
ui->text->setText(ittext); ui->text->setText(ittext);
// Clean up
string_writeconfig("/inkbox/remount", "true");
// Way to tell shell scripts that we're in the Reader framework
string_writeconfig("/tmp/inkboxReading", "true");
// Saving the book opened in the favorites list // Saving the book opened in the favorites list
string_checkconfig(".config/08-recent_books/1"); string_checkconfig(".config/08-recent_books/1");
book_1 = checkconfig_str_val; book_1 = checkconfig_str_val;
@ -411,6 +430,7 @@ void reader::on_nextBtn_clicked()
else { else {
parser_ran = true; parser_ran = true;
split_total = split_total - 1; split_total = split_total - 1;
setup_book(book_file, split_total, false); setup_book(book_file, split_total, false);
ui->text->setText(""); ui->text->setText("");
ui->text->setText(ittext); ui->text->setText(ittext);
@ -428,6 +448,7 @@ void reader::on_nextBtn_clicked()
pagesTurned = 0; pagesTurned = 0;
} }
} }
writeconfig_pagenumber();
} }
} }
@ -458,6 +479,7 @@ void reader::on_previousBtn_clicked()
pagesTurned = 0; pagesTurned = 0;
} }
} }
writeconfig_pagenumber();
} }
} }
@ -511,6 +533,10 @@ void reader::on_aboutBtn_clicked()
void reader::on_homeBtn_clicked() void reader::on_homeBtn_clicked()
{ {
// We're leaving reading mode
string_writeconfig("/tmp/inkboxReading", "false");
// Relaunching process
QProcess process; QProcess process;
process.startDetached("inkbox", QStringList()); process.startDetached("inkbox", QStringList());
qApp->quit(); qApp->quit();
@ -778,3 +804,9 @@ void reader::on_sizeSlider_valueChanged(int value)
} }
} }
} }
void reader::writeconfig_pagenumber() {
// Saving the page number in tmpfs
string split_total_str = to_string(split_total);
string_writeconfig("/tmp/inkboxPageNumber", split_total_str);
}

View file

@ -39,6 +39,8 @@ public:
bool parser_ran = false; bool parser_ran = false;
bool booktostr_ran = false; bool booktostr_ran = false;
bool neverRefresh = false; bool neverRefresh = false;
bool wakeFromSleep = false;
bool remount = true;
QString book_1; QString book_1;
QString book_2; QString book_2;
QString book_3; QString book_3;
@ -61,12 +63,24 @@ public:
~reader(); ~reader();
int setup_book(QString book, int i, bool run_parser) { int setup_book(QString book, int i, bool run_parser) {
// Parse ebook // Parse ebook
if(remount != false) {
QString mount_prog ("sh"); QString mount_prog ("sh");
QStringList mount_args; QStringList mount_args;
mount_args << "split.sh"; mount_args << "split.sh";
QProcess *mount_proc = new QProcess(); QProcess *mount_proc = new QProcess();
mount_proc->start(mount_prog, mount_args); mount_proc->start(mount_prog, mount_args);
mount_proc->waitForFinished(); mount_proc->waitForFinished();
remount = false;
}
else {
string_writeconfig("/inkbox/remount", "false");
QString mount_prog ("sh");
QStringList mount_args;
mount_args << "split.sh";
QProcess *mount_proc = new QProcess();
mount_proc->start(mount_prog, mount_args);
mount_proc->waitForFinished();
}
if(booktostr_ran != true) { if(booktostr_ran != true) {
if(epub_file_match(book) == true) { if(epub_file_match(book) == true) {
@ -108,7 +122,7 @@ public:
QProcess *parse_proc = new QProcess(); QProcess *parse_proc = new QProcess();
parse_proc->start(parse_prog, parse_args); parse_proc->start(parse_prog, parse_args);
parse_proc->waitForFinished(); parse_proc->waitForFinished();
parser_ran = false; parser_ran = true;
} }
else { else {
QString parse_prog ("python3"); QString parse_prog ("python3");
@ -117,7 +131,7 @@ public:
QProcess *parse_proc = new QProcess(); QProcess *parse_proc = new QProcess();
parse_proc->start(parse_prog, parse_args); parse_proc->start(parse_prog, parse_args);
parse_proc->waitForFinished(); parse_proc->waitForFinished();
parser_ran = false; parser_ran = true;
} }
} }
@ -219,40 +233,24 @@ public:
private slots: private slots:
void on_nextBtn_clicked(); void on_nextBtn_clicked();
void on_previousBtn_clicked(); void on_previousBtn_clicked();
void on_optionsBtn_clicked(); void on_optionsBtn_clicked();
void on_hideOptionsBtn_clicked(); void on_hideOptionsBtn_clicked();
void on_brightnessDecBtn_clicked(); void on_brightnessDecBtn_clicked();
void on_brightnessIncBtn_clicked(); void on_brightnessIncBtn_clicked();
void on_aboutBtn_clicked(); void on_aboutBtn_clicked();
void on_homeBtn_clicked(); void on_homeBtn_clicked();
void on_fontChooser_currentIndexChanged(const QString &arg1); void on_fontChooser_currentIndexChanged(const QString &arg1);
void on_alignLeftBtn_clicked(); void on_alignLeftBtn_clicked();
void on_alignCenterBtn_clicked(); void on_alignCenterBtn_clicked();
void on_alignRightBtn_clicked(); void on_alignRightBtn_clicked();
void on_alignJustifyBtn_clicked(); void on_alignJustifyBtn_clicked();
void on_infoCloseBtn_clicked(); void on_infoCloseBtn_clicked();
void on_previousDefinitionBtn_clicked(); void on_previousDefinitionBtn_clicked();
void on_nextDefinitionBtn_clicked(); void on_nextDefinitionBtn_clicked();
void on_saveWordBtn_clicked(); void on_saveWordBtn_clicked();
void on_sizeSlider_valueChanged(int value); void on_sizeSlider_valueChanged(int value);
void writeconfig_pagenumber();
private: private:
Ui::reader *ui; Ui::reader *ui;