diff --git a/src/constants.h b/src/constants.h index eb120d8..dd86445 100644 --- a/src/constants.h +++ b/src/constants.h @@ -58,6 +58,16 @@ const QLatin1String STARTUP_COMMAND_REPLAY_SPEED("replay-speed"); const QLatin1String STARTUP_COMMAND_WRITE_WHAZZUP("write-whazzup"); const QLatin1String STARTUP_COMMAND_WRITE_WHAZZUP_SPEED("write-whazzup-speed"); const QLatin1String STARTUP_COMMAND_REPLAY_GUI("replay-gui"); + +// "master" or "release/1.4" VERSION_NUMBER_TODO +const static QString HELP_BRANCH = "release/3.0"; + +#if defined(WINARCH64) +const QLatin1String SIMCONNECT_DLL_NAME("SimConnect_msfs_2020.dll"); +#else +const QLatin1String SIMCONNECT_DLL_NAME("SimConnect.dll"); +#endif + } // namespace lnc #endif // LITTLENAVCONNECT_CONSTANTS_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2cbe37b..69475f3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -39,6 +39,7 @@ #include "util/properties.h" #include "util/signalhandler.h" #include "util/version.h" +#include "win/activationcontext.h" #include #include @@ -47,6 +48,7 @@ #include #include #include +#include using atools::settings::Settings; using atools::fs::sc::SimConnectData; @@ -56,11 +58,8 @@ using atools::gui::Application; atools::gui::DataExchange *MainWindow::dataExchange = nullptr; -// "master" or "release/1.4" VERSION_NUMBER_TODO -const static QString HELP_BRANCH = "release/3.0"; - /* Important: keep slash at the end. Otherwise browser might not display the page properly */ -const static QString HELP_ONLINE_URL("https://www.littlenavmap.org/manuals/littlenavconnect/" + HELP_BRANCH + "/${LANG}/"); +const static QString HELP_ONLINE_URL("https://www.littlenavmap.org/manuals/littlenavconnect/" + lnc::HELP_BRANCH + "/${LANG}/"); const static QString HELP_OFFLINE_FILE("help/little-navconnect-user-manual-${LANG}.pdf"); @@ -69,6 +68,8 @@ MainWindow::MainWindow() { qDebug() << Q_FUNC_INFO; + activationContext = new atools::win::ActivationContext; + aboutMessage = QObject::tr("

is the Flight Simulator Network agent for Little Navmap.

" "

This software is licensed under " @@ -255,7 +256,13 @@ void MainWindow::deInit() ATOOLS_DELETE_LATER_LOG(dataReaderThread); } - ATOOLS_DELETE_LOG(fsxConnectHandler); + if(simConnectHandler != nullptr) + { + simConnectHandler->close(); + simConnectHandler->releaseSimConnect(); + } + + ATOOLS_DELETE_LOG(simConnectHandler); ATOOLS_DELETE_LOG(xpConnectHandler); qDebug() << Q_FUNC_INFO << "reset logging"; @@ -264,6 +271,7 @@ void MainWindow::deInit() ATOOLS_DELETE_LOG(helpHandler); ATOOLS_DELETE_LOG(simulatorActionGroup); ATOOLS_DELETE_LOG(ui); + ATOOLS_DELETE_LOG(activationContext); #if defined(Q_OS_LINUX) // Remove signal handler @@ -329,7 +337,7 @@ void MainWindow::showOfflineHelp() atools::fs::sc::ConnectHandler *MainWindow::handlerForSelection() { if(ui->actionConnectFsx->isChecked()) - return fsxConnectHandler; + return simConnectHandler; else return xpConnectHandler; } @@ -608,9 +616,9 @@ void MainWindow::mainWindowShownDelayed() << tr("Data Version %1. Reply Version %2.").arg(SimConnectData::getDataVersion()).arg(SimConnectReply::getReplyVersion()); // Build the handler classes which are an abstraction to SimConnect and the Little Xpconnect shared memory - fsxConnectHandler = new atools::fs::sc::SimConnectHandler(verbose); - fsxConnectHandler->loadSimConnect(QApplication::applicationDirPath() + - atools::SEP + "simconnect" + atools::SEP + "simconnect.manifest"); + simConnectHandler = new atools::fs::sc::SimConnectHandler(verbose); + + simConnectHandler->loadSimConnect(activationContext, lnc::SIMCONNECT_DLL_NAME); xpConnectHandler = new atools::fs::sc::XpConnectHandler(); #ifdef Q_OS_WIN32 @@ -619,15 +627,15 @@ void MainWindow::mainWindowShownDelayed() // Check the first time if SimConnect is available - if yes use FSX settings // Otherwise fall back to stored value or X-Plane - fsx = settings.getAndStoreValue(lnc::SETTINGS_OPTIONS_SIMULATOR_FSX, fsxConnectHandler->isLoaded()).toBool(); + fsx = settings.getAndStoreValue(lnc::SETTINGS_OPTIONS_SIMULATOR_FSX, simConnectHandler->isLoaded()).toBool(); - if(!fsxConnectHandler->isLoaded()) + if(!simConnectHandler->isLoaded()) // No SimConnect switch to X-Plane fsx = false; qDebug() << "FSX status" << fsx; - if(fsxConnectHandler->isLoaded()) + if(simConnectHandler->isLoaded()) { ui->toolBar->insertAction(ui->actionOptions, ui->actionConnectFsx); ui->toolBar->insertAction(ui->actionOptions, ui->actionConnectXplane); diff --git a/src/mainwindow.h b/src/mainwindow.h index f0cdcc4..6f4f290 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -27,6 +27,10 @@ class MainWindow; namespace atools { +namespace win { +class ActivationContext; +} + namespace util { class Properties; } @@ -148,11 +152,13 @@ class MainWindow : // Runs in background and fetches data from simulator - signals are sent to NavServerWorker threads atools::fs::sc::DataReaderThread *dataReaderThread = nullptr; - atools::fs::sc::SimConnectHandler *fsxConnectHandler = nullptr; + atools::fs::sc::SimConnectHandler *simConnectHandler = nullptr; atools::fs::sc::XpConnectHandler *xpConnectHandler = nullptr; QActionGroup *simulatorActionGroup = nullptr; atools::fs::sc::ConnectHandler *handlerForSelection(); + atools::win::ActivationContext *activationContext = nullptr; + atools::gui::HelpHandler *helpHandler = nullptr; bool firstStart = true; // Used to emit the first windowShown signal bool verbose = false;