From f40c6187fbf96c011b0ccf46ece8ba689264fffc Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Thu, 30 Jul 2020 12:30:23 +0100 Subject: [PATCH] Launcher: omit some setup for in-sim mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately this doesn’t fix the weirdness reported in: https://sourceforge.net/p/flightgear/codetickets/2180/ .. but will keep trying. --- src/GUI/LauncherMainWindow.cxx | 75 ++++++++++++++++++---------------- src/GUI/LauncherMainWindow.hxx | 2 +- src/GUI/QtLauncher.cxx | 4 +- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/GUI/LauncherMainWindow.cxx b/src/GUI/LauncherMainWindow.cxx index 924a22cf4..f0a6971ae 100755 --- a/src/GUI/LauncherMainWindow.cxx +++ b/src/GUI/LauncherMainWindow.cxx @@ -30,60 +30,59 @@ ////////////////////////////////////////////////////////////////////////////// -LauncherMainWindow::LauncherMainWindow() : - QQuickView() +LauncherMainWindow::LauncherMainWindow(bool inSimMode) : QQuickView() { setTitle("FlightGear " FLIGHTGEAR_VERSION); m_controller = new LauncherController(this, this); m_controller->initQML(); + if (!inSimMode) { #if defined(Q_OS_MAC) - QMenuBar* mb = new QMenuBar(); + QMenuBar* mb = new QMenuBar(); - QMenu* fileMenu = mb->addMenu(tr("File")); - QAction* openAction = new QAction(tr("Open saved configuration...")); - openAction->setMenuRole(QAction::NoRole); - connect(openAction, &QAction::triggered, - m_controller, &LauncherController::openConfig); + QMenu* fileMenu = mb->addMenu(tr("File")); + QAction* openAction = new QAction(tr("Open saved configuration...")); + openAction->setMenuRole(QAction::NoRole); + connect(openAction, &QAction::triggered, + m_controller, &LauncherController::openConfig); - QAction* saveAction = new QAction(tr("Save configuration as...")); - saveAction->setMenuRole(QAction::NoRole); - connect(saveAction, &QAction::triggered, - m_controller, &LauncherController::saveConfigAs); + QAction* saveAction = new QAction(tr("Save configuration as...")); + saveAction->setMenuRole(QAction::NoRole); + connect(saveAction, &QAction::triggered, + m_controller, &LauncherController::saveConfigAs); - fileMenu->addAction(openAction); - fileMenu->addAction(saveAction); + fileMenu->addAction(openAction); + fileMenu->addAction(saveAction); - QMenu* toolsMenu = mb->addMenu(tr("Tools")); - QAction* restoreDefaultsAction = new QAction(tr("Restore defaults...")); - restoreDefaultsAction->setMenuRole(QAction::NoRole); - connect(restoreDefaultsAction, &QAction::triggered, - m_controller, &LauncherController::requestRestoreDefaults); + QMenu* toolsMenu = mb->addMenu(tr("Tools")); + QAction* restoreDefaultsAction = new QAction(tr("Restore defaults...")); + restoreDefaultsAction->setMenuRole(QAction::NoRole); + connect(restoreDefaultsAction, &QAction::triggered, + m_controller, &LauncherController::requestRestoreDefaults); - QAction* changeDataAction = new QAction(tr("Select data files location...")); - changeDataAction->setMenuRole(QAction::NoRole); - connect(changeDataAction, &QAction::triggered, - m_controller, &LauncherController::requestChangeDataPath); + QAction* changeDataAction = new QAction(tr("Select data files location...")); + changeDataAction->setMenuRole(QAction::NoRole); + connect(changeDataAction, &QAction::triggered, + m_controller, &LauncherController::requestChangeDataPath); - QAction* viewCommandLineAction = new QAction(tr("View command-line")); - connect(viewCommandLineAction, &QAction::triggered, - m_controller, &LauncherController::viewCommandLine); + QAction* viewCommandLineAction = new QAction(tr("View command-line")); + connect(viewCommandLineAction, &QAction::triggered, + m_controller, &LauncherController::viewCommandLine); - toolsMenu->addAction(restoreDefaultsAction); - toolsMenu->addAction(changeDataAction); - toolsMenu->addAction(viewCommandLineAction); + toolsMenu->addAction(restoreDefaultsAction); + toolsMenu->addAction(changeDataAction); + toolsMenu->addAction(viewCommandLineAction); #endif - QAction* qa = new QAction(this); - qa->setMenuRole(QAction::QuitRole); // will be addeed accordingly - qa->setShortcut(QKeySequence("Ctrl+Q")); - connect(qa, &QAction::triggered, m_controller, &LauncherController::quit); + QAction* qa = new QAction(this); + qa->setMenuRole(QAction::QuitRole); // will be addeed accordingly + qa->setShortcut(QKeySequence("Ctrl+Q")); + connect(qa, &QAction::triggered, m_controller, &LauncherController::quit); + } m_controller->initialRestoreSettings(); - auto addOnsCtl = new AddOnsController(this, m_controller->config()); - //////////// #if defined(Q_OS_WIN) const QString osName("win"); @@ -98,11 +97,15 @@ LauncherMainWindow::LauncherMainWindow() : QQmlContext* ctx = rootContext(); ctx->setContextProperty("_launcher", m_controller); - ctx->setContextProperty("_addOns", addOnsCtl); ctx->setContextProperty("_config", m_controller->config()); ctx->setContextProperty("_location", m_controller->location()); ctx->setContextProperty("_osName", osName); + if (!inSimMode) { + auto addOnsCtl = new AddOnsController(this, m_controller->config()); + ctx->setContextProperty("_addOns", addOnsCtl); + } + #if defined(ENABLE_COMPOSITOR) ctx->setContextProperty("_haveCompositor", true); #else diff --git a/src/GUI/LauncherMainWindow.hxx b/src/GUI/LauncherMainWindow.hxx index b3cccad54..b8c8289ad 100644 --- a/src/GUI/LauncherMainWindow.hxx +++ b/src/GUI/LauncherMainWindow.hxx @@ -40,7 +40,7 @@ class LauncherMainWindow : public QQuickView { Q_OBJECT public: - LauncherMainWindow(); + LauncherMainWindow(bool inSimMode); virtual ~LauncherMainWindow(); bool execInApp(); diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index aa451883b..d99bf44af 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -481,7 +481,7 @@ bool runLauncherDialog() // try to initialise various Cocoa structures. flightgear::WindowBuilder::setPoseAsStandaloneApp(false); - LauncherMainWindow dlg; + LauncherMainWindow dlg(false); if (options->isOptionSet("enable-fullscreen")) { dlg.showFullScreen(); } else { @@ -502,7 +502,7 @@ bool runLauncherDialog() bool runInAppLauncherDialog() { - LauncherMainWindow dlg; + LauncherMainWindow dlg(true); bool accepted = dlg.execInApp(); if (!accepted) { return false;