Don't launch Reader framework on Cancel in QFileDialog

This commit is contained in:
Nicolas Mailloux 2021-04-08 07:47:27 -04:00
parent b0b9cc3adf
commit d948375d03
2 changed files with 27 additions and 5 deletions

View file

@ -306,8 +306,16 @@ reader::reader(QWidget *parent) :
dialog->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
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");
QFileDialog *dialog = new QFileDialog(this);
@ -318,8 +326,16 @@ reader::reader(QWidget *parent) :
dialog->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
if(book_file != "") {
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
}
else {
// User clicked "Cancel" button
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
quit_restart();
}
}
}
// Checking if we're waking from sleep; if so, do nothing there because the book should have already been parsed
@ -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();
}

View file

@ -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;