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,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();
}

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;