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()); dialog->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close(); stylesheetFile.close();
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath()); 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 { else {
QDir::setCurrent("/mnt/onboard"); QDir::setCurrent("/mnt/onboard");
@ -318,7 +326,15 @@ reader::reader(QWidget *parent) :
dialog->setStyleSheet(stylesheetFile.readAll()); dialog->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close(); stylesheetFile.close();
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath()); 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"); string_writeconfig("/tmp/inkboxReading", "false");
// Relaunching process // Relaunching process
QProcess process; quit_restart();
process.startDetached("inkbox", QStringList());
qApp->quit();
} }
void reader::on_fontChooser_currentIndexChanged(const QString &arg1) 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 split_total_str = to_string(split_total);
string_writeconfig("/tmp/inkboxPageNumber", split_total_str); 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_saveWordBtn_clicked();
void on_sizeSlider_valueChanged(int value); void on_sizeSlider_valueChanged(int value);
void writeconfig_pagenumber(); void writeconfig_pagenumber();
void quit_restart();
private: private:
Ui::reader *ui; Ui::reader *ui;