2015-09-06 20:20:00 +02:00
|
|
|
#include "./initiate.h"
|
|
|
|
#include "./mainwindow.h"
|
2016-01-14 23:53:28 +01:00
|
|
|
#include "./renamefilesdialog.h"
|
2015-09-01 20:20:15 +02:00
|
|
|
|
2015-09-06 20:20:00 +02:00
|
|
|
#include "../application/settings.h"
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2016-04-24 21:07:36 +02:00
|
|
|
#include "resources/config.h"
|
2019-06-16 15:55:55 +02:00
|
|
|
#include "resources/qtconfig.h"
|
2015-12-05 22:55:05 +01:00
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
#include <qtutilities/resources/importplugin.h>
|
2015-09-01 20:20:15 +02:00
|
|
|
#include <qtutilities/resources/qtconfigarguments.h>
|
2015-04-22 19:33:53 +02:00
|
|
|
#include <qtutilities/resources/resources.h>
|
2016-08-14 22:49:47 +02:00
|
|
|
#include <qtutilities/settingsdialog/qtsettings.h>
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
#include <QApplication>
|
2023-02-18 18:46:27 +01:00
|
|
|
#include <QMessageBox>
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2017-02-11 02:39:20 +01:00
|
|
|
ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES
|
|
|
|
|
2019-06-10 22:49:46 +02:00
|
|
|
using namespace CppUtilities;
|
2015-09-01 20:20:15 +02:00
|
|
|
|
2015-04-22 19:33:53 +02:00
|
|
|
namespace QtGui {
|
|
|
|
|
2023-02-18 18:46:27 +01:00
|
|
|
static void showSettingsError(const QString &settingsError)
|
|
|
|
{
|
|
|
|
if (!settingsError.isEmpty()) {
|
|
|
|
QMessageBox::critical(nullptr, QCoreApplication::applicationName(), settingsError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void saveSettings()
|
|
|
|
{
|
|
|
|
Settings::save();
|
|
|
|
showSettingsError(Settings::values().error);
|
|
|
|
}
|
|
|
|
|
2016-01-14 23:53:28 +01:00
|
|
|
int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &path, bool launchRenamingUtility)
|
2015-04-22 19:33:53 +02:00
|
|
|
{
|
2015-08-25 19:09:26 +02:00
|
|
|
SET_QT_APPLICATION_INFO;
|
2019-09-14 19:44:34 +02:00
|
|
|
QApplication application(argc, argv);
|
2016-08-14 22:49:47 +02:00
|
|
|
Settings::restore();
|
2019-09-14 19:44:34 +02:00
|
|
|
|
2016-08-14 22:49:47 +02:00
|
|
|
// apply settings specified via command line args after the settings chosen in the GUI to give the CLI options precedence
|
2023-02-18 18:46:27 +01:00
|
|
|
auto &settings = Settings::values();
|
2023-03-26 21:48:25 +02:00
|
|
|
settings.qt.disableNotices();
|
2023-02-18 18:46:27 +01:00
|
|
|
settings.qt.apply();
|
|
|
|
qtConfigArgs.applySettings(settings.qt.hasCustomFont());
|
2019-09-14 19:44:34 +02:00
|
|
|
|
2015-09-01 20:20:15 +02:00
|
|
|
LOAD_QT_TRANSLATIONS;
|
2019-09-14 19:44:34 +02:00
|
|
|
|
2023-02-18 18:46:27 +01:00
|
|
|
showSettingsError(settings.error);
|
|
|
|
QObject::connect(&application, &QCoreApplication::aboutToQuit, &saveSettings);
|
2019-09-14 19:44:34 +02:00
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
if (launchRenamingUtility) {
|
2019-09-14 19:44:34 +02:00
|
|
|
RenameFilesDialog window;
|
2020-03-09 15:56:48 +01:00
|
|
|
window.setAttribute(Qt::WA_QuitOnClose);
|
2019-09-14 19:44:34 +02:00
|
|
|
window.show();
|
|
|
|
return application.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow window;
|
|
|
|
window.show();
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
window.startParsing(path);
|
2015-07-27 23:26:51 +02:00
|
|
|
}
|
2019-09-14 19:44:34 +02:00
|
|
|
return application.exec();
|
2015-04-22 19:33:53 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
} // namespace QtGui
|