Added default target variant option in project configuration
This commit is contained in:
@@ -42,6 +42,7 @@ int Application::run(const std::vector<std::string>& arguments) {
|
||||
if (this->insightConfig.insightEnabled) {
|
||||
this->insight.setApplicationConfig(this->applicationConfig);
|
||||
this->insight.setEnvironmentConfig(this->environmentConfig);
|
||||
this->insight.setInsightConfig(this->insightConfig);
|
||||
this->insight.run();
|
||||
Logger::debug("Insight closed");
|
||||
this->shutdown();
|
||||
|
||||
@@ -79,6 +79,11 @@ void TargetConfig::init(QJsonObject jsonObject) {
|
||||
}
|
||||
|
||||
this->name = jsonObject.find("name")->toString().toLower().toStdString();
|
||||
|
||||
if (jsonObject.contains("variantName")) {
|
||||
this->variantName = jsonObject.find("variantName").value().toString().toLower().toStdString();
|
||||
}
|
||||
|
||||
this->jsonObject = jsonObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace Bloom
|
||||
void init(QJsonObject jsonObject);
|
||||
|
||||
std::string name;
|
||||
|
||||
std::string variantName;
|
||||
|
||||
QJsonObject jsonObject;
|
||||
};
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void Insight::startup() {
|
||||
qRegisterMetaType<Bloom::Targets::TargetState>();
|
||||
qRegisterMetaType<std::map<int, Bloom::Targets::TargetPinState>>();
|
||||
|
||||
this->mainWindow.init(*(this->application), targetDescriptor);
|
||||
this->mainWindow.init(*(this->application), targetDescriptor, this->insightConfig, this->environmentConfig.targetConfig);
|
||||
this->mainWindow.show();
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Bloom
|
||||
private:
|
||||
ApplicationConfig applicationConfig;
|
||||
EnvironmentConfig environmentConfig;
|
||||
InsightConfig insightConfig;
|
||||
|
||||
EventManager& eventManager;
|
||||
EventListenerPointer eventListener = std::make_shared<EventListener>("InsightEventListener");
|
||||
@@ -54,6 +55,10 @@ namespace Bloom
|
||||
this->environmentConfig = environmentConfig;
|
||||
}
|
||||
|
||||
void setInsightConfig(const InsightConfig& insightConfig) {
|
||||
this->insightConfig = insightConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for Insight.
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,12 @@ using Targets::TargetVariant;
|
||||
using Targets::TargetPackage;
|
||||
|
||||
|
||||
void InsightWindow::init(QApplication& application, TargetDescriptor targetDescriptor) {
|
||||
void InsightWindow::init(
|
||||
QApplication& application,
|
||||
TargetDescriptor targetDescriptor,
|
||||
const InsightConfig& config,
|
||||
const TargetConfig& targetConfig
|
||||
) {
|
||||
this->targetDescriptor = targetDescriptor;
|
||||
|
||||
auto mainWindowUiFile = QFile(":/compiled/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui");
|
||||
@@ -106,7 +111,21 @@ void InsightWindow::init(QApplication& application, TargetDescriptor targetDescr
|
||||
Logger::debug("Number of target variants supported by Insight: " + std::to_string(supportedVariants.size()));
|
||||
|
||||
if (!supportedVariants.empty()) {
|
||||
this->selectVariant(&supportedVariants.front());
|
||||
auto selectedVariant = std::find_if(
|
||||
supportedVariants.begin(),
|
||||
supportedVariants.end(),
|
||||
[&targetConfig](const TargetVariant& variant) {
|
||||
auto variantName = QString::fromStdString(variant.name).toLower().toStdString();
|
||||
return !targetConfig.variantName.empty() && targetConfig.variantName == variantName;
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
* If ths user specified a valid variant name in their config file, use that as the default, otherwise just
|
||||
* use the first supported variant.
|
||||
*/
|
||||
this->selectVariant((selectedVariant != supportedVariants.end()) ? &(*selectedVariant)
|
||||
: &supportedVariants.front());
|
||||
|
||||
} else {
|
||||
if (this->targetDescriptor.variants.empty()) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include "AboutWindow.hpp"
|
||||
#include "src/ApplicationConfig.hpp"
|
||||
#include "TargetWidgets/TargetPackageWidget.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
@@ -71,7 +72,12 @@ namespace Bloom
|
||||
public:
|
||||
InsightWindow() = default;
|
||||
|
||||
void init(QApplication& application, Targets::TargetDescriptor targetDescriptor);
|
||||
void init(
|
||||
QApplication& application,
|
||||
Targets::TargetDescriptor targetDescriptor,
|
||||
const InsightConfig& config,
|
||||
const TargetConfig& targetConfig
|
||||
);
|
||||
|
||||
void show();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user