Added shutdownOnClose Insight config param, to trigger a shutdown when the user closes the main Insight window.

This commit is contained in:
Nav
2023-07-14 18:39:27 +01:00
parent edcf62e67d
commit bc4939e48f
9 changed files with 56 additions and 1 deletions

View File

@@ -170,6 +170,10 @@ namespace Bloom
applicationEventListener->registerCallbackForEventType<Events::InsightActivationRequested>(
std::bind(&Application::onInsightActivationRequest, this, std::placeholders::_1)
);
applicationEventListener->registerCallbackForEventType<Events::InsightMainWindowClosed>(
std::bind(&Application::onInsightMainWindowClosed, this, std::placeholders::_1)
);
#endif
this->startTargetController();
this->startDebugServer();
@@ -586,6 +590,12 @@ namespace Bloom
this->activateInsight();
}
void Application::onInsightMainWindowClosed(const Events::InsightMainWindowClosed& event) {
if (this->insightConfig->shutdownOnClose) {
this->triggerShutdown();
}
}
#endif
void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) {

View File

@@ -282,6 +282,13 @@ namespace Bloom
* Handles requests to start the Insight GUI.
*/
void onInsightActivationRequest(const Events::InsightActivationRequested&);
/**
* Performs any post-insight-closed actions.
*
* @param event
*/
void onInsightMainWindowClosed(const Events::InsightMainWindowClosed& event);
#endif
/**

View File

@@ -31,6 +31,7 @@ namespace Bloom::Events
PROGRAMMING_MODE_ENABLED,
PROGRAMMING_MODE_DISABLED,
INSIGHT_ACTIVATION_REQUESTED,
INSIGHT_MAIN_WINDOW_CLOSED,
};
class Event

View File

@@ -21,6 +21,7 @@
#ifndef EXCLUDE_INSIGHT
#include "InsightActivationRequested.hpp"
#include "InsightMainWindowClosed.hpp"
#endif
namespace Bloom::Events

View File

@@ -0,0 +1,23 @@
#pragma once
#include <string>
#include "Event.hpp"
namespace Bloom::Events
{
class InsightMainWindowClosed: public Event
{
public:
static constexpr EventType type = EventType::INSIGHT_MAIN_WINDOW_CLOSED;
static const inline std::string name = "InsightMainWindowClosed";
[[nodiscard]] EventType getType() const override {
return InsightMainWindowClosed::type;
}
[[nodiscard]] std::string getName() const override {
return InsightMainWindowClosed::name;
}
};
}

View File

@@ -6,6 +6,7 @@
#include "src/Services/PathService.hpp"
#include "src/Logger/Logger.hpp"
#include "src/EventManager/EventManager.hpp"
#include "UserInterfaces/InsightWindow/BloomProxyStyle.hpp"
#include "src/Application.hpp"
@@ -204,6 +205,7 @@ namespace Bloom
void Insight::onInsightWindowDestroyed() {
this->mainWindow = nullptr;
EventManager::triggerEvent(std::make_shared<Events::InsightMainWindowClosed>());
}
void Insight::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) {

View File

@@ -13,7 +13,6 @@
#include "src/ProjectConfig.hpp"
#include "src/ProjectSettings.hpp"
#include "src/EventManager/EventManager.hpp"
#include "src/EventManager/EventListener.hpp"
#include "src/EventManager/Events/Events.hpp"

View File

@@ -80,6 +80,10 @@ namespace Bloom
if (insightNode["activateOnStartup"]) {
this->activateOnStartup = insightNode["activateOnStartup"].as<bool>(this->activateOnStartup);
}
if (insightNode["shutdownOnClose"]) {
this->shutdownOnClose = insightNode["shutdownOnClose"].as<bool>(this->shutdownOnClose);
}
}
EnvironmentConfig::EnvironmentConfig(std::string name, const YAML::Node& environmentNode)

View File

@@ -126,8 +126,16 @@ namespace Bloom
struct InsightConfig
{
/**
* If true, the Insight GUI will be activated immediately at startup.
*/
bool activateOnStartup = false;
/**
* If true, Bloom will shutdown when the user closes the Insight GUI.
*/
bool shutdownOnClose = false;
InsightConfig() = default;
/**