diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 04a73fb9e..751717019 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -207,7 +207,7 @@ namespace BlackCore if (a.contains("core")) { return CApplicationInfo::PilotClientCore; } if (a.contains("launcher")) { return CApplicationInfo::Laucher; } if (a.contains("gui")) { return CApplicationInfo::PilotClientGui; } - if (a.contains("core")) { return CApplicationInfo::PilotClientCore; } + if (a.contains("data") || a.contains("mapping")) { return CApplicationInfo::MappingTool; } return CApplicationInfo::Unknown; } diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 3aad6a590..56c992740 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -42,7 +42,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : this->init(); connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CSwiftLauncher::ps_loadSetup); connect(ui->tb_SwiftCore, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed); - connect(ui->tb_SwiftData, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed); + connect(ui->tb_SwiftMappingTool, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed); connect(ui->tb_SwiftGui, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed); connect(ui->tb_Database, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed); connect(ui->tb_BackToMain, &QToolButton::pressed, this, &CSwiftLauncher::ps_showMainPage); @@ -58,8 +58,14 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : // default from settings const QString dbus(this->m_dbusServerAddress.getThreadLocal()); this->setDefault(dbus); + + // periodically check + connect(&this->m_checkTimer, &QTimer::timeout, this, &CSwiftLauncher::ps_checkRunningApplications); + this->m_checkTimer.setInterval(5000); + this->m_checkTimer.start(); } + CSwiftLauncher::~CSwiftLauncher() { } @@ -344,14 +350,18 @@ void CSwiftLauncher::ps_startButtonPressed() this->accept(); } } - else if (sender == ui->tb_SwiftData) + else if (sender == ui->tb_SwiftMappingTool) { + ui->tb_SwiftMappingTool->setEnabled(false); + this->m_startMappingToolWaitCycles = 2; this->setSwiftDataExecutable(); this->accept(); } else if (sender == ui->tb_SwiftCore) { if (this->isStandaloneGuiSelected()) { ui->rb_SwiftCoreGuiAudio->setChecked(true); } + ui->tb_SwiftCore->setEnabled(false); + this->m_startCoreWaitCycles = 2; this->startSwiftCore(); } else if (sender == ui->tb_Database) @@ -418,3 +428,27 @@ void CSwiftLauncher::ps_showLogPage() { ui->sw_SwiftLauncher->setCurrentWidget(ui->pg_SwiftLauncherLog); } + +void CSwiftLauncher::ps_checkRunningApplications() +{ + const CApplicationInfoList runningApps = sGui->getRunningApplications(); + if (this->m_startCoreWaitCycles > 0) { this->m_startCoreWaitCycles--; } + else { ui->tb_SwiftCore->setEnabled(true); } + if (this->m_startMappingToolWaitCycles > 0) { this->m_startMappingToolWaitCycles--; } + else { ui->tb_SwiftMappingTool->setEnabled(true); } + + for (const CApplicationInfo &info : runningApps) + { + switch (info.application()) + { + case CApplicationInfo::PilotClientCore : + ui->tb_SwiftCore->setEnabled(false); + break; + case CApplicationInfo::MappingTool : + ui->tb_SwiftMappingTool->setEnabled(false); + break; + default: + break; + } + } +} diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index 9a85073f8..08875c179 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -20,6 +20,7 @@ #include "blackcore/coremodeenums.h" #include "blackcore/application/applicationsettings.h" #include +#include #include #include @@ -77,10 +78,13 @@ private slots: private: QScopedPointer ui; - BlackMisc::CData m_updateInfo { this, &CSwiftLauncher::ps_changedUpdateInfoCache }; //!< version cache + BlackMisc::CData m_updateInfo { this, &CSwiftLauncher::ps_changedUpdateInfoCache }; //!< version cache BlackMisc::CSetting m_dbusServerAddress { this }; //!< DBus address - QString m_executable; - QStringList m_executableArgs; + QString m_executable; + QStringList m_executableArgs; + QTimer m_checkTimer { this }; + int m_startCoreWaitCycles = 0; + int m_startMappingToolWaitCycles = 0; //! Get core mode BlackCore::CoreModes::CoreMode getCoreMode() const; @@ -166,6 +170,9 @@ private slots: //! Show the log page void ps_showLogPage(); + + //! Check if applicationas are already running + void ps_checkRunningApplications(); }; #endif // guard diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui index f0903e4e0..9379bfadc 100644 --- a/src/swiftlauncher/swiftlauncher.ui +++ b/src/swiftlauncher/swiftlauncher.ui @@ -78,7 +78,7 @@ - 0 + 4 6 @@ -708,7 +708,7 @@ p, li { white-space: pre-wrap; } - + start swift data (the mapping tool) @@ -837,8 +837,8 @@ p, li { white-space: pre-wrap; } - +