Use aboutToQuit() signal for cleanup-code
As recommended by the Qt documentation
This commit is contained in:
parent
474d66b25c
commit
7f58124bf0
|
@ -23,27 +23,29 @@ namespace QtGui {
|
||||||
int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &path, bool launchRenamingUtility)
|
int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &path, bool launchRenamingUtility)
|
||||||
{
|
{
|
||||||
SET_QT_APPLICATION_INFO;
|
SET_QT_APPLICATION_INFO;
|
||||||
QApplication a(argc, argv);
|
QApplication application(argc, argv);
|
||||||
Settings::restore();
|
Settings::restore();
|
||||||
|
|
||||||
// apply settings specified via command line args after the settings chosen in the GUI to give the CLI options precedence
|
// apply settings specified via command line args after the settings chosen in the GUI to give the CLI options precedence
|
||||||
Settings::values().qt.apply();
|
Settings::values().qt.apply();
|
||||||
qtConfigArgs.applySettings(Settings::values().qt.hasCustomFont());
|
qtConfigArgs.applySettings(Settings::values().qt.hasCustomFont());
|
||||||
|
|
||||||
LOAD_QT_TRANSLATIONS;
|
LOAD_QT_TRANSLATIONS;
|
||||||
int res;
|
|
||||||
|
QObject::connect(&application, &QCoreApplication::aboutToQuit, &Settings::save);
|
||||||
|
|
||||||
if (launchRenamingUtility) {
|
if (launchRenamingUtility) {
|
||||||
RenameFilesDialog w;
|
RenameFilesDialog window;
|
||||||
w.show();
|
window.show();
|
||||||
res = a.exec();
|
return application.exec();
|
||||||
} else {
|
|
||||||
MainWindow w;
|
|
||||||
w.show();
|
|
||||||
if (!path.isEmpty()) {
|
|
||||||
w.startParsing(path);
|
|
||||||
}
|
|
||||||
res = a.exec();
|
|
||||||
}
|
}
|
||||||
Settings::save();
|
|
||||||
return res;
|
MainWindow window;
|
||||||
|
window.show();
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
window.startParsing(path);
|
||||||
|
}
|
||||||
|
return application.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QtGui
|
} // namespace QtGui
|
||||||
|
|
Loading…
Reference in New Issue