Foundations laid for project settings and Insight porject settings
This commit is contained in:
@@ -67,6 +67,7 @@ add_executable(Bloom
|
|||||||
|
|
||||||
# Project & application configuration
|
# Project & application configuration
|
||||||
src/ProjectConfig.cpp
|
src/ProjectConfig.cpp
|
||||||
|
src/ProjectSettings.cpp
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
src/EventManager/EventListener.cpp
|
src/EventManager/EventListener.cpp
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ int Application::run(const std::vector<std::string>& arguments) {
|
|||||||
this->eventManager,
|
this->eventManager,
|
||||||
this->projectConfig.value(),
|
this->projectConfig.value(),
|
||||||
this->environmentConfig.value(),
|
this->environmentConfig.value(),
|
||||||
this->insightConfig.value()
|
this->insightConfig.value(),
|
||||||
|
this->projectSettings.value().insightSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -94,6 +95,7 @@ void Application::startup() {
|
|||||||
std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1)
|
std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this->loadProjectSettings();
|
||||||
this->loadProjectConfiguration();
|
this->loadProjectConfiguration();
|
||||||
Logger::configure(this->projectConfig.value());
|
Logger::configure(this->projectConfig.value());
|
||||||
|
|
||||||
@@ -153,6 +155,28 @@ void Application::shutdown() {
|
|||||||
Thread::setThreadState(ThreadState::STOPPED);
|
Thread::setThreadState(ThreadState::STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::loadProjectSettings() {
|
||||||
|
const auto projectSettingsPath = Paths::projectSettingsPath();
|
||||||
|
auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath));
|
||||||
|
|
||||||
|
if (jsonSettingsFile.exists()) {
|
||||||
|
auto jsonObject = QJsonDocument::fromJson(jsonSettingsFile.readAll()).object();
|
||||||
|
jsonSettingsFile.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
this->projectSettings = ProjectSettings(jsonObject);
|
||||||
|
return;
|
||||||
|
|
||||||
|
} catch (const std::exception& exception) {
|
||||||
|
Logger::error(
|
||||||
|
"Failed to load project settings from " + projectSettingsPath + " - " + exception.what()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->projectSettings = ProjectSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::loadProjectConfiguration() {
|
void Application::loadProjectConfiguration() {
|
||||||
auto jsonConfigFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
|
auto jsonConfigFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "src/Logger/Logger.hpp"
|
#include "src/Logger/Logger.hpp"
|
||||||
#include "src/ProjectConfig.hpp"
|
#include "src/ProjectConfig.hpp"
|
||||||
|
#include "src/ProjectSettings.hpp"
|
||||||
#include "src/VersionNumber.hpp"
|
#include "src/VersionNumber.hpp"
|
||||||
|
|
||||||
#include "src/EventManager/EventListener.hpp"
|
#include "src/EventManager/EventListener.hpp"
|
||||||
@@ -147,6 +148,11 @@ namespace Bloom
|
|||||||
std::optional<DebugServerConfig> debugServerConfig;
|
std::optional<DebugServerConfig> debugServerConfig;
|
||||||
std::optional<InsightConfig> insightConfig;
|
std::optional<InsightConfig> insightConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings extracted from the settings file in the user's project root.
|
||||||
|
*/
|
||||||
|
std::optional<ProjectSettings> projectSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The project environment selected by the user.
|
* The project environment selected by the user.
|
||||||
*
|
*
|
||||||
@@ -201,6 +207,12 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts or generates project settings.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void loadProjectSettings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the project config from the user's JSON config file and populates the following members:
|
* Extracts the project config from the user's JSON config file and populates the following members:
|
||||||
* - this->projectConfig
|
* - this->projectConfig
|
||||||
|
|||||||
@@ -41,6 +41,25 @@ namespace Bloom
|
|||||||
static std::string projectConfigPath() {
|
static std::string projectConfigPath() {
|
||||||
return std::filesystem::current_path().string() + "/bloom.json";
|
return std::filesystem::current_path().string() + "/bloom.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to the current project's settings directory.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static std::string projectSettingsDirPath() {
|
||||||
|
return std::filesystem::current_path().string() + "/.bloom";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to the current project's settings file.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static std::string projectSettingsPath() {
|
||||||
|
return std::filesystem::current_path().string() + "/.bloom/settings.json";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path to Bloom's compiled resources.
|
* Returns the path to Bloom's compiled resources.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "src/TargetController/TargetControllerConsole.hpp"
|
#include "src/TargetController/TargetControllerConsole.hpp"
|
||||||
#include "src/Helpers/Paths.hpp"
|
#include "src/Helpers/Paths.hpp"
|
||||||
#include "src/ProjectConfig.hpp"
|
#include "src/ProjectConfig.hpp"
|
||||||
|
#include "src/ProjectSettings.hpp"
|
||||||
|
|
||||||
#include "src/EventManager/EventManager.hpp"
|
#include "src/EventManager/EventManager.hpp"
|
||||||
#include "src/EventManager/EventListener.hpp"
|
#include "src/EventManager/EventListener.hpp"
|
||||||
@@ -41,12 +42,14 @@ namespace Bloom
|
|||||||
EventManager& eventManager,
|
EventManager& eventManager,
|
||||||
const ProjectConfig& projectConfig,
|
const ProjectConfig& projectConfig,
|
||||||
const EnvironmentConfig& environmentConfig,
|
const EnvironmentConfig& environmentConfig,
|
||||||
const InsightConfig& insightConfig
|
const InsightConfig& insightConfig,
|
||||||
|
const InsightProjectSettings& insightProjectSettings
|
||||||
):
|
):
|
||||||
eventManager(eventManager),
|
eventManager(eventManager),
|
||||||
projectConfig(projectConfig),
|
projectConfig(projectConfig),
|
||||||
environmentConfig(environmentConfig),
|
environmentConfig(environmentConfig),
|
||||||
insightConfig(insightConfig),
|
insightConfig(insightConfig),
|
||||||
|
insightProjectSettings(insightProjectSettings),
|
||||||
application(
|
application(
|
||||||
(
|
(
|
||||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, false),
|
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, false),
|
||||||
@@ -71,6 +74,8 @@ namespace Bloom
|
|||||||
EnvironmentConfig environmentConfig;
|
EnvironmentConfig environmentConfig;
|
||||||
InsightConfig insightConfig;
|
InsightConfig insightConfig;
|
||||||
|
|
||||||
|
InsightProjectSettings insightProjectSettings;
|
||||||
|
|
||||||
EventManager& eventManager;
|
EventManager& eventManager;
|
||||||
EventListenerPointer eventListener = std::make_shared<EventListener>("InsightEventListener");
|
EventListenerPointer eventListener = std::make_shared<EventListener>("InsightEventListener");
|
||||||
|
|
||||||
|
|||||||
9
src/ProjectSettings.cpp
Normal file
9
src/ProjectSettings.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "ProjectSettings.hpp"
|
||||||
|
|
||||||
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
|
using namespace Bloom;
|
||||||
|
|
||||||
|
ProjectSettings::ProjectSettings(const QJsonObject& jsonObject) {
|
||||||
|
|
||||||
|
}
|
||||||
31
src/ProjectSettings.hpp
Normal file
31
src/ProjectSettings.hpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp"
|
||||||
|
|
||||||
|
namespace Bloom
|
||||||
|
{
|
||||||
|
struct InsightProjectSettings
|
||||||
|
{
|
||||||
|
std::map<
|
||||||
|
Targets::TargetMemoryType,
|
||||||
|
Widgets::TargetMemoryInspectionPaneSettings
|
||||||
|
> memoryInspectionPaneSettingsByMemoryType;
|
||||||
|
|
||||||
|
InsightProjectSettings() = default;
|
||||||
|
InsightProjectSettings(const QJsonObject& jsonObject);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ProjectSettings
|
||||||
|
{
|
||||||
|
InsightProjectSettings insightSettings;
|
||||||
|
|
||||||
|
ProjectSettings() = default;
|
||||||
|
explicit ProjectSettings(const QJsonObject& jsonObject);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user