diff --git a/src/swiftlauncher/main.cpp b/src/swiftlauncher/main.cpp index fad459a89..7738bb16a 100644 --- a/src/swiftlauncher/main.cpp +++ b/src/swiftlauncher/main.cpp @@ -40,11 +40,13 @@ int main(int argc, char *argv[]) } //! [SwiftApplicationDemo] - // Dialog to decide external or internal core CSwiftLauncher launcher; - CGuiApplication::registerAsRunning(); // needed because launcher's exec is called (normally application exec) - if (launcher.exec() == QDialog::Rejected) { return EXIT_SUCCESS; } - launcher.close(); + const int res = CGuiApplication::exec(); + if (res != EXIT_SUCCESS || !launcher.shouldStartAppDetached()) + { + return res; + } + const bool s = launcher.startDetached(); return s ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index f5bf7f200..fc8a7fa92 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -50,7 +50,7 @@ using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation::Data; using namespace BlackMisc::Simulation::FsCommon; -CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QDialog(parent, CEnableForFramelessWindow::modeToWindowFlags(CEnableForFramelessWindow::WindowNormal)), +CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QMainWindow(parent, CEnableForFramelessWindow::modeToWindowFlags(CEnableForFramelessWindow::WindowNormal)), CEnableForFramelessWindow(CEnableForFramelessWindow::WindowFrameless, true, "framelessMainWindow", this), CCentralMultiSimulatorModelSetCachesAware(), CIdentifiable(this), @@ -116,6 +116,8 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QDialog(parent, CEnableForFram this->requestMacMicrophoneAccess(); this->installerMode(); }); + + this->show(); } void CSwiftLauncher::installerMode() @@ -204,18 +206,18 @@ CoreModes::CoreMode CSwiftLauncher::getCoreMode() const void CSwiftLauncher::mousePressEvent(QMouseEvent *event) { - if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); } + if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); } } void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event) { - if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); } + if (!handleMouseMoveEvent(event)) { QMainWindow::mouseMoveEvent(event); } } void CSwiftLauncher::mouseReleaseEvent(QMouseEvent *event) { m_framelessDragPosition = QPoint(); - QDialog::mouseReleaseEvent(event); + QMainWindow::mouseReleaseEvent(event); } void CSwiftLauncher::updateInfoAvailable() @@ -443,7 +445,7 @@ void CSwiftLauncher::startButtonPressed() } else { - this->accept(); + close(); } } } @@ -459,7 +461,7 @@ void CSwiftLauncher::startButtonPressed() } else { - this->accept(); + close(); } } } @@ -612,6 +614,11 @@ void CSwiftLauncher::showSimulatorConfigDirs() m_textEditDialog->show(); } +bool CSwiftLauncher::shouldStartAppDetached() const +{ + return !m_executable.isEmpty(); +} + void CSwiftLauncher::requestMacMicrophoneAccess() { // needed to be able to start core/GUI which need MIC access diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index 5a884aea0..cef35ce33 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -21,7 +21,7 @@ # include "blackmisc/macos/microphoneaccess.h" #endif -#include +#include #include #include #include @@ -41,10 +41,9 @@ namespace BlackGui::Components * \note Besides the fact the launcher makes it easy to start our applications it also pre-fetches some * cache files, hence reducing load times in the subsequent applications. Therefor starting via the launcher * is preferable, but not mandatory. - * \fixme it was better if launcher was a QMainWindow, because we have to deal with main widgets QDialog and QMainWindow because of launcher */ class CSwiftLauncher : - public QDialog, + public QMainWindow, public BlackGui::CEnableForFramelessWindow, public BlackGui::IMainWindowAccess, public BlackMisc::Simulation::Data::CCentralMultiSimulatorModelSetCachesAware, @@ -82,6 +81,9 @@ public: //! \remark simplifies debugging bool startDetached(); + //! Check if an app is set that should be started detached + bool shouldStartAppDetached() const; + protected: //! Mouse events for frameless window //! @{ diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui index a742b407b..cc895956b 100644 --- a/src/swiftlauncher/swiftlauncher.ui +++ b/src/swiftlauncher/swiftlauncher.ui @@ -1,7 +1,7 @@ CSwiftLauncher - + 0 @@ -19,812 +19,793 @@ swift launcher - - - 4 + + + QFrame::StyledPanel - - 3 + + QFrame::Raised - - 3 + + 0 - - 3 - - - 3 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - + + + 0 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 20 + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 20 + + + 0 + + + 0 + + + 0 + + + + + header info goes here - - 0 + + + + + + 4 - - 0 + + 6 - - 0 - - - - - header info goes here - - - - - - + + + + 0 + 0 + 467 + 356 + + + + About + + + + + + + + + + + 0 + 0 + 467 + 356 + + + + &Window type + + + + + + Frameless + + + + + + + Normal window + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + :/launcher/icons/swiftFrameless125x203.png + + + + + + + + + + :/launcher/icons/swiftNormal125x206.png + + + + + + + + + 0 + 0 + 450 + 365 + + + + &Core mode + + + 4 - - 6 + + 4 - - - - 0 - 0 - 467 - 356 - - - - About - - - - - - - - - - - 0 - 0 - 467 - 356 - - - - &Window type - - - - - - Frameless - - - - - - - Normal window - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - :/launcher/icons/swiftFrameless125x203.png - - - - - - - - - - :/launcher/icons/swiftNormal125x206.png - - - - - - - - - 0 - 0 - 450 - 365 - - - - &Core mode - - - - 4 - - - 4 - - - 4 - - - 4 - - - 4 - - - - - standalone - - - true - - - bg_CoreMode - - - - - - - GUI and core (distributed) - - - bg_CoreMode - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Audio distributed - - - - - - disable core audio (AFV) - - - - - - - disable GUI audio (AFV) - - - - - - - - - - Standalone audio - - - - - - disable audio (AFV) - - - - - - - - - - - - - :/launcher/icons/swiftNormal61x100.png - - - - - - - - - - :/launcher/icons/swiftGUIandCore115x85.png - - - - - - - DBus (core to GUI) - - - - 4 - - - 2 - - - 2 - - - 2 - - - 4 - - - - - - 0 - 90 - - - - QFrame::Panel - - - QFrame::Raised - - - - - - - - - - - - 0 - 0 - 467 - 356 - - - - Check for &updates - - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Software - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - 0 - 120 - - - - - - - - - - - Data - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - border: 0px; padding: 2px; - - - true - - - - - 0 - 0 - 451 - 160 - - - - - 3 - - - 3 - - - 3 - - - 3 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - - 0 - 0 - 467 - 356 - - - - &Tools - - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - P3D/FSX - - - - - - P3D config dirs. - - - - - - - FSX config dirs. - - - - - - - - - - Log - - - - - - log - - - - - - - log directory - - - - - - - dump files - - - - - - - - - - Windows - - - - - - clear registry - - - - - - - - - - - - - - - 0 - 165 - + + 4 - - 0 + + 4 - - - - 0 - 0 - 467 - 134 - - - - Start application - - - - 3 + + 4 + + + + + standalone - - 3 + + true - - 3 + + bg_CoreMode + + + + + + + GUI and core (distributed) - - 3 + + bg_CoreMode + + + + + + + Qt::Vertical - - 1 + + + 20 + 40 + - - - - start swift GUI - - - swift GUI - - - - :/own/icons/own/swift3D/sw3DBlue-256.png:/own/icons/own/swift3D/sw3DBlue-256.png - - - - 64 - 64 - - - - - - - - start swift core - - - swift core - - - - :/own/icons/own/swift3D/sw3DOrange-256.png:/own/icons/own/swift3D/sw3DOrange-256.png - - - - 64 - 64 - - - - - - - - start swift data (the mapping tool) - - - mapping tool - - - - :/own/icons/own/swift3D/sw3DGreen-256.png:/own/icons/own/swift3D/sw3DGreen-256.png - - - - 64 - 64 - - - - - - - - ... - - - - :/misc/icons/misc/toolWizard128.png:/misc/icons/misc/toolWizard128.png - - - - 48 - 48 - - - - - - - - open browser for swift database - - - goto swift database - - - - :/own/icons/own/swift3D/sw3DGreen-256.png:/own/icons/own/swift3D/sw3DGreen-256.png - - - - 48 - 48 - - - - - - - - GUI - - - - - - - core - - - - - - - mapping tool - - - - - - - config - - - - - - - goto DB - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - reset window - - - - - - - - - - - - - - - - 3 + + + + + + Audio distributed + + + + + + disable core audio (AFV) + + + + + + + disable GUI audio (AFV) + + + + + + + + + + Standalone audio + + + + + + disable audio (AFV) + + + + + + + + + + + + + :/launcher/icons/swiftNormal61x100.png + + + + + + + + + + :/launcher/icons/swiftGUIandCore115x85.png + + + + + + + DBus (core to GUI) + + + + 4 + + + 2 + + + 2 + + + 2 + + + 4 + + + + + + 0 + 90 + + + + QFrame::Panel + + + QFrame::Raised + + + + + + + + + + + + 0 + 0 + 467 + 356 + + + + Check for &updates + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + Software + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 0 + 120 + + + + + + + + + + + Data + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + border: 0px; padding: 2px; + + + true + + + + + 0 + 0 + 451 + 160 + + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + + + 0 + 0 + 467 + 356 + + + + &Tools + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + P3D/FSX + + + + + + P3D config dirs. + + + + + + + FSX config dirs. + + + + + + + + + + Log + + + + + + log + + + + + + + log directory + + + + + + + dump files + + + + + + + + + + Windows + + + + + + clear registry + + + + + + + + + + + + + + + 0 + 165 + + + + 0 + + + + + 0 + 0 + 467 + 134 + + + + Start application + + + + 3 + + + 3 + + + 3 + + + 3 + + + 1 + + + + + start swift GUI + + + swift GUI + + + + :/own/icons/own/swift3D/sw3DBlue-256.png:/own/icons/own/swift3D/sw3DBlue-256.png + + + + 64 + 64 + + + + + + + + start swift core + + + swift core + + + + :/own/icons/own/swift3D/sw3DOrange-256.png:/own/icons/own/swift3D/sw3DOrange-256.png + + + + 64 + 64 + + + + + + + + start swift data (the mapping tool) + + + mapping tool + + + + :/own/icons/own/swift3D/sw3DGreen-256.png:/own/icons/own/swift3D/sw3DGreen-256.png + + + + 64 + 64 + + + + + + + + ... + + + + :/misc/icons/misc/toolWizard128.png:/misc/icons/misc/toolWizard128.png + + + + 48 + 48 + + + + + + + + open browser for swift database + + + goto swift database + + + + :/own/icons/own/swift3D/sw3DGreen-256.png:/own/icons/own/swift3D/sw3DGreen-256.png + + + + 48 + 48 + + + + + + + + GUI + + + + + + + core + + + + + + + mapping tool + + + + + + + config + + + + + + + goto DB + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + reset window + + + + + + + + + + + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + QFrame::StyledPanel - - 3 + + QFrame::Raised - - 3 + + + + + + back to main - - 3 + + + :/diagona/icons/diagona/icons/arrow-180.png:/diagona/icons/diagona/icons/arrow-180.png - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - back to main - - - - :/diagona/icons/diagona/icons/arrow-180.png:/diagona/icons/diagona/icons/arrow-180.png - - - Ctrl+M - - - - - - - - + + Ctrl+M + + + + + +