diff --git a/reader.cpp b/reader.cpp index 7b2d882..150b9ee 100644 --- a/reader.cpp +++ b/reader.cpp @@ -306,7 +306,15 @@ reader::reader(QWidget *parent) : dialog->setStyleSheet(stylesheetFile.readAll()); stylesheetFile.close(); book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath()); - QDir::setCurrent("/mnt/onboard/.adds/inkbox"); + + if(book_file != "") { + QDir::setCurrent("/mnt/onboard/.adds/inkbox"); + } + else { + // User clicked "Cancel" button + QDir::setCurrent("/mnt/onboard/.adds/inkbox"); + quit_restart(); + } } else { QDir::setCurrent("/mnt/onboard"); @@ -318,7 +326,15 @@ reader::reader(QWidget *parent) : dialog->setStyleSheet(stylesheetFile.readAll()); stylesheetFile.close(); book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath()); - QDir::setCurrent("/mnt/onboard/.adds/inkbox"); + + if(book_file != "") { + QDir::setCurrent("/mnt/onboard/.adds/inkbox"); + } + else { + // User clicked "Cancel" button + QDir::setCurrent("/mnt/onboard/.adds/inkbox"); + quit_restart(); + } } } @@ -547,9 +563,7 @@ void reader::on_homeBtn_clicked() string_writeconfig("/tmp/inkboxReading", "false"); // Relaunching process - QProcess process; - process.startDetached("inkbox", QStringList()); - qApp->quit(); + quit_restart(); } void reader::on_fontChooser_currentIndexChanged(const QString &arg1) @@ -820,3 +834,10 @@ void reader::writeconfig_pagenumber() { string split_total_str = to_string(split_total); string_writeconfig("/tmp/inkboxPageNumber", split_total_str); } + +void reader::quit_restart() { + // Restarting InkBox + QProcess process; + process.startDetached("inkbox", QStringList()); + qApp->quit(); +} diff --git a/reader.h b/reader.h index 2aaaaec..a337505 100644 --- a/reader.h +++ b/reader.h @@ -251,6 +251,7 @@ private slots: void on_saveWordBtn_clicked(); void on_sizeSlider_valueChanged(int value); void writeconfig_pagenumber(); + void quit_restart(); private: Ui::reader *ui;