// last time modified by Arvo ES1JA on 20200127 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if QT_VERSION >= 0x050200 #include #include #endif #include "revision_utils.hpp" #include "MetaDataRegistry.hpp" #include "SettingsGroup.hpp" #include "TraceFile.hpp" #include "mainwindow.h" #include "commons.h" #include "lib/init_random_seed.h" namespace { struct RNGSetup { RNGSetup () { // one time seed of pseudo RNGs from current time auto seed = QDateTime::currentMSecsSinceEpoch (); qsrand (seed); // this is good for rand() as well } } seeding; // We can't use the GUI after QApplication::exit() is called so // uncaught exceptions can get lost on Windows systems where there // is no console terminal, so here we override // QApplication::notify() and wrap the base class call with a try // block to catch and display exceptions in a message box. class ExceptionCatchingApplication final : public QApplication { public: explicit ExceptionCatchingApplication (int& argc, char * * argv) : QApplication {argc, argv} { } bool notify (QObject * receiver, QEvent * e) override { try { return QApplication::notify (receiver, e); } catch (std::exception const& e) { MessageBox::critical_message (nullptr, translate ("main", "Fatal error"), e.what ()); throw; } catch (...) { MessageBox::critical_message (nullptr, translate ("main", "Unexpected fatal error")); throw; } } }; } int main(int argc, char *argv[]) { bool has_style = true; int result = 0; for (auto i = 0; i < argc; i++) if (std::string(argv[i]).find("-style") != std::string::npos ) has_style = false; init_random_seed (); register_types (); // make the Qt magic happen // Multiple instances: QSharedMemory mem_jtdxjt9; ExceptionCatchingApplication a(argc, argv); if (has_style) a.setStyle("Fusion"); try { setlocale (LC_NUMERIC, "C"); // ensure number forms are in // consistent format, do this after // instantiating QApplication so // that GUI has correct l18n // Override programs executable basename as application name. a.setApplicationName ("JTDX"); a.setApplicationVersion (version ()); // a.setApplicationVersion ("18.1.0.93_15"); bool multiple {false}; #if QT_VERSION >= 0x050200 QCommandLineParser parser; parser.setApplicationDescription ("\nFT8,JT65A,JT9 & T10 Weak Signal Communications Program."); auto help_option = parser.addHelpOption (); auto version_option = parser.addVersionOption (); // support for multiple instances running from a single installation QCommandLineOption style_option (QString {"style"} , a.translate ("main", "