Moved Paths helper functions to service class

This commit is contained in:
Nav
2022-12-26 21:47:09 +00:00
parent 4c25c85c36
commit 8fa7e82c56
36 changed files with 131 additions and 125 deletions

View File

@@ -36,13 +36,13 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
# a lot easier, as it removes the need to recompile for each tweak.
# CAUTION: Although convenient, this does add a limitation; the debug build can only be run on the same machine
# that compiled it. Or a machine that has the Bloom source located in the same place.
# See Paths::compiledResourcesPath() for more.
# See Services::PathService::compiledResourcesPath() for more.
add_compile_definitions(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE="${CMAKE_CURRENT_SOURCE_DIR}")
# BLOOM_HOME_DOMAIN_NAME_OVERRIDE can be used to override the domain name used in URLs to the Bloom website.
# I (Nav) use this in debug builds, so I can test local changes that involve the Bloom website as well as Bloom
# itself. Other users can comment out this override if they don't have a copy of the Bloom website running on their
# local machine. See Paths::homeDomainName() for more.
# local machine. See Services::PathService::homeDomainName() for more.
add_compile_definitions(BLOOM_HOME_DOMAIN_NAME_OVERRIDE="http://bloom.local")
# CMAKE_BUILD_RPATH needs to point to the local Qt installation, to use Gammaray during development.

View File

@@ -10,7 +10,7 @@
#include "src/Services/ProcessService.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
@@ -178,7 +178,7 @@ namespace Bloom
}
void Application::loadProjectSettings() {
const auto projectSettingsPath = Paths::projectSettingsPath();
const auto projectSettingsPath = Services::PathService::projectSettingsPath();
auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath));
if (jsonSettingsFile.exists()) {
@@ -209,12 +209,12 @@ namespace Bloom
return;
}
const auto projectSettingsPath = Paths::projectSettingsPath();
const auto projectSettingsPath = Services::PathService::projectSettingsPath();
auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath));
Logger::debug("Saving project settings to " + projectSettingsPath);
QDir().mkpath(QString::fromStdString(Paths::projectSettingsDirPath()));
QDir().mkpath(QString::fromStdString(Services::PathService::projectSettingsDirPath()));
try {
const auto jsonDocument = QJsonDocument(this->projectSettings->toJson());
@@ -236,11 +236,11 @@ namespace Bloom
}
void Application::loadProjectConfiguration() {
auto configFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
auto configFile = QFile(QString::fromStdString(Services::PathService::projectConfigPath()));
if (!configFile.exists()) {
// Try looking for the old bloom.json config file
configFile.setFileName(QString::fromStdString(Paths::projectDirPath()) + "/bloom.json");
configFile.setFileName(QString::fromStdString(Services::PathService::projectDirPath()) + "/bloom.json");
if (configFile.exists()) {
Logger::warning(
@@ -252,14 +252,14 @@ namespace Bloom
} else {
throw InvalidConfig(
"Bloom configuration file (bloom.yaml) not found. Working directory: " + Paths::projectDirPath()
"Bloom configuration file (bloom.yaml) not found. Working directory: " + Services::PathService::projectDirPath()
);
}
}
if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
throw InvalidConfig(
"Failed to open Bloom configuration file. Working directory: " + Paths::projectDirPath()
"Failed to open Bloom configuration file. Working directory: " + Services::PathService::projectDirPath()
);
}
@@ -312,12 +312,12 @@ namespace Bloom
Logger::silence();
// The file help.txt is included in Bloom's binary, as a resource. See the root-level CMakeLists.txt for more.
auto helpFile = QFile(QString::fromStdString(Paths::compiledResourcesPath() + "/resources/help.txt"));
auto helpFile = QFile(QString::fromStdString(Services::PathService::compiledResourcesPath() + "/resources/help.txt"));
if (!helpFile.open(QIODevice::ReadOnly)) {
// This should never happen - if it does, something has gone very wrong
throw Exception(
"Failed to open help file - please report this issue at " + Paths::homeDomainName()
"Failed to open help file - please report this issue at " + Services::PathService::homeDomainName()
+ "/report-issue"
);
}
@@ -336,7 +336,7 @@ namespace Bloom
std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n";
#endif
std::cout << Paths::homeDomainName() + "/\n";
std::cout << Services::PathService::homeDomainName() + "/\n";
std::cout << "Nav Mohammed\n";
return EXIT_SUCCESS;
}
@@ -357,7 +357,7 @@ namespace Bloom
}
int Application::initProject() {
auto configFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
auto configFile = QFile(QString::fromStdString(Services::PathService::projectConfigPath()));
if (configFile.exists()) {
throw Exception("Bloom configuration file (bloom.yaml) already exists in working directory.");
@@ -370,13 +370,13 @@ namespace Bloom
* We simply copy the template file into the user's working directory.
*/
auto templateConfigFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()+ "/resources/bloom.template.yaml")
QString::fromStdString(Services::PathService::compiledResourcesPath()+ "/resources/bloom.template.yaml")
);
if (!templateConfigFile.open(QIODevice::ReadOnly)) {
throw Exception(
"Failed to open template configuration file - please report this issue at "
+ Paths::homeDomainName() + "/report-issue"
+ Services::PathService::homeDomainName() + "/report-issue"
);
}

View File

@@ -6,11 +6,11 @@ target_sources(
# Services
${CMAKE_CURRENT_SOURCE_DIR}/Services/TargetControllerService.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Services/PathService.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Services/ProcessService.cpp
# Helpers & other
${CMAKE_CURRENT_SOURCE_DIR}/Logger/Logger.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Helpers/Paths.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Helpers/String.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Helpers/EpollInstance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Helpers/EventFdNotifier.cpp

View File

@@ -7,7 +7,7 @@
#include "src/Application.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/String.hpp"
#include "src/Logger/Logger.hpp"
@@ -32,7 +32,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
debugSession.connection.writePacket(ResponsePacket(String::toHex(
std::string(
"Bloom v" + Application::VERSION.toString() + "\n"
+ Paths::homeDomainName() + "\n"
+ Services::PathService::homeDomainName() + "\n"
+ "Nav Mohammed\n"
)
)));

View File

@@ -9,7 +9,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "src/Application.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/String.hpp"
#include "src/Logger/Logger.hpp"
@@ -46,7 +46,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
return;
}
const auto svdOutputFilePath = Paths::projectDirPath() + "/" + targetDescriptor.name + ".svd";
const auto svdOutputFilePath = Services::PathService::projectDirPath() + "/" + targetDescriptor.name + ".svd";
auto outputFile = QFile(QString::fromStdString(svdOutputFilePath));
if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
@@ -102,7 +102,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
deviceElement.setAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema-instance");
deviceElement.setAttribute(
"xs:noNamespaceSchemaLocation",
QString::fromStdString(Paths::homeDomainName() + "/assets/svd-schema.xsd")
QString::fromStdString(Services::PathService::homeDomainName() + "/assets/svd-schema.xsd")
);
deviceElement.appendChild(createElement("vendor", QString::fromStdString(targetDescriptor.vendorName)));

View File

@@ -6,7 +6,7 @@
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/String.hpp"
#include "src/Logger/Logger.hpp"
@@ -35,13 +35,13 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
*/
auto helpFile = QFile(
QString::fromStdString(
Paths::compiledResourcesPath() + "/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt"
Services::PathService::compiledResourcesPath() + "/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt"
)
);
if (!helpFile.open(QIODevice::ReadOnly)) {
throw Exception(
"Failed to open GDB monitor info help file - please report this issue at " + Paths::homeDomainName()
"Failed to open GDB monitor info help file - please report this issue at " + Services::PathService::homeDomainName()
+ "/report-issue"
);
}

View File

@@ -3,9 +3,9 @@
#include <thread>
#include <cmath>
#include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/String.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
#include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp"
@@ -272,7 +272,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
throw DebugWirePhysicalInterfaceError(
"Failed to activate the debugWire physical interface - check target connection. "
"If the target was recently programmed via ISP, try cycling the target power. See "
+ Paths::homeDomainName() + "/docs/debugging-avr-debugwire for more information."
+ Services::PathService::homeDomainName() + "/docs/debugging-avr-debugwire for more information."
);
}

View File

@@ -85,6 +85,7 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.cpp
# Memory region manager window
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.cpp
@@ -110,6 +111,7 @@ qt_add_resources(
"./UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui"
"./UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/UiFiles/SnapshotManager.ui"
"./UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/UiFiles/CreateSnapshotWindow.ui"
"./UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/UiFiles/SnapshotViewer.ui"
"./UserInterfaces/InsightWindow/Images/bloom-icon.svg"
"./UserInterfaces/InsightWindow/Images/RAM.svg"
"./UserInterfaces/InsightWindow/Images/refresh.svg"

View File

@@ -9,7 +9,7 @@
#include <QUrlQuery>
#include <QJsonDocument>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Logger/Logger.hpp"
#include "UserInterfaces/InsightWindow/BloomProxyStyle.hpp"
@@ -39,7 +39,11 @@ namespace Bloom
(
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true),
#ifndef BLOOM_DEBUG_BUILD
<<<<<<< HEAD
QCoreApplication::addLibraryPath(QString::fromStdString(Paths::applicationDirPath() + "/../plugins")),
=======
QCoreApplication::addLibraryPath(QString::fromStdString(Services::PathService::applicationDirPath() + "/plugins")),
>>>>>>> 0fea8bc1 (Moved Paths helper functions to service class)
#endif
QApplication(this->qtApplicationArgc, this->qtApplicationArgv.data())
)
@@ -107,7 +111,7 @@ namespace Bloom
auto globalStylesheet = QFile(
QString::fromStdString(
Paths::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss"
Services::PathService::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss"
)
);
@@ -125,46 +129,46 @@ namespace Bloom
// Load Ubuntu fonts
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-B.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-B.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-BI.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-BI.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-C.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-C.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-L.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-L.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-LI.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-LI.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-M.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-M.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-MI.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-MI.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-B.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-B.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-BI.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-BI.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-R.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-R.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-RI.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-RI.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-R.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-R.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-RI.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-RI.ttf")
);
QFontDatabase::addApplicationFont(
QString::fromStdString(Paths::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-Th.ttf")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-Th.ttf")
);
/*
@@ -238,7 +242,7 @@ namespace Bloom
const auto currentVersionNumber = Application::VERSION;
auto* networkAccessManager = new QNetworkAccessManager(this);
auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Paths::homeDomainName() + "/latest-version"));
auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/latest-version"));
queryVersionEndpointUrl.setScheme("http");
queryVersionEndpointUrl.setQuery(QUrlQuery({
{"currentVersionNumber", QString::fromStdString(currentVersionNumber.toString())}
@@ -255,7 +259,7 @@ namespace Bloom
if (latestVersionNumber > currentVersionNumber) {
Logger::warning(
"Bloom v" + latestVersionNumber.toString()
+ " is available to download - upgrade via " + Paths::homeDomainName()
+ " is available to download - upgrade via " + Services::PathService::homeDomainName()
);
}
}

View File

@@ -9,7 +9,7 @@
#include <QTimer>
#include "src/Helpers/Thread.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/ProjectConfig.hpp"
#include "src/ProjectSettings.hpp"

View File

@@ -4,7 +4,7 @@
#include <QDir>
#include <QJsonDocument>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Logger/Logger.hpp"
@@ -83,7 +83,7 @@ namespace Bloom
std::move(this->excludedRegions)
);
const auto snapshotDirPath = QString::fromStdString(Paths::projectSettingsDirPath())
const auto snapshotDirPath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(snapshot.memoryType);
QDir().mkpath(snapshotDirPath);

View File

@@ -5,7 +5,7 @@
#include <QStringList>
#include <QJsonDocument>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Logger/Logger.hpp"
@@ -23,7 +23,7 @@ namespace Bloom
}
std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots(Targets::TargetMemoryType memoryType) {
auto snapshotDir = QDir(QString::fromStdString(Paths::projectSettingsDirPath())
auto snapshotDir = QDir(QString::fromStdString(Services::PathService::projectSettingsDirPath())
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(memoryType));
if (!snapshotDir.exists()) {

View File

@@ -5,7 +5,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Application.hpp"
namespace Bloom
@@ -14,12 +14,12 @@ namespace Bloom
AboutWindow::AboutWindow(QWidget* parent): QObject(parent) {
auto aboutWindowUiFile = QFile(QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
)
);
auto aboutWindowStylesheet = QFile(QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
)
);

View File

@@ -12,7 +12,7 @@
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Targets/TargetMemory.hpp"
@@ -60,12 +60,12 @@ namespace Bloom
}
auto mainWindowUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui"
)
);
auto mainWindowStylesheet = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss"
)
);
@@ -86,7 +86,7 @@ namespace Bloom
mainWindowStylesheet.close();
QApplication::setWindowIcon(QIcon(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Images/bloom-icon.svg"
)
));
@@ -937,7 +937,7 @@ namespace Bloom
}
void InsightWindow::openReportIssuesUrl() {
auto url = QUrl(QString::fromStdString(Paths::homeDomainName() + "/report-issue"));
auto url = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/report-issue"));
/*
* The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page.
*
@@ -963,7 +963,7 @@ namespace Bloom
void InsightWindow::openGettingStartedUrl() {
QDesktopServices::openUrl(
QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/getting-started"))
QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/getting-started"))
);
}

View File

@@ -4,7 +4,7 @@
#include <QFile>
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -23,13 +23,13 @@ namespace Bloom::Widgets
this->setWindowTitle(windowTitle);
auto dialogueUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui"
)
);
auto dialogueStylesheet = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss"
)
);

View File

@@ -5,7 +5,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
#include "src/Insight/InsightSignals.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -31,7 +31,7 @@ namespace Bloom::Widgets
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
auto widgetUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget"
+ "/UiFiles/HexViewerWidget.ui"
)

View File

@@ -2,7 +2,7 @@
#include <QFile>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
@@ -16,7 +16,7 @@ namespace Bloom::Widgets
: memoryRegion(region), RegionItem(region, memoryDescriptor, parent)
{
auto formUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
+ "/MemoryRegionManager/UiFiles/ExcludedMemoryRegionForm.ui"
)

View File

@@ -2,7 +2,7 @@
#include <QFile>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
@@ -18,7 +18,7 @@ namespace Bloom::Widgets
: memoryRegion(region), RegionItem(region, memoryDescriptor, parent)
{
auto formUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
+ "/MemoryRegionManager/UiFiles/FocusedMemoryRegionForm.ui"
)

View File

@@ -7,7 +7,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -33,14 +33,14 @@ namespace Bloom::Widgets
);
auto windowUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
+ "/MemoryRegionManager/UiFiles/MemoryRegionManagerWindow.ui"
)
);
auto windowStylesheet = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
+ "/MemoryRegionManager/Stylesheets/MemoryRegionManagerWindow.qss"
)
@@ -406,7 +406,7 @@ namespace Bloom::Widgets
void MemoryRegionManagerWindow::openHelpPage() {
QDesktopServices::openUrl(
QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/manage-memory-regions"))
QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/manage-memory-regions"))
);
}
}

View File

@@ -8,7 +8,7 @@
#include "src/Insight/InsightSignals.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -32,7 +32,7 @@ namespace Bloom::Widgets
);
auto windowUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
+ "/SnapshotManager/CreateSnapshotWindow/UiFiles/CreateSnapshotWindow.ui"
)

View File

@@ -9,7 +9,7 @@
#include "src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp"
#include "src/Insight/InsightWorker/InsightWorker.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Logger/Logger.hpp"
@@ -34,7 +34,7 @@ namespace Bloom::Widgets
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
auto widgetUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
+ "/SnapshotManager/UiFiles/SnapshotManager.ui"
)

View File

@@ -12,7 +12,7 @@
#include "src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp"
#include "src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Logger/Logger.hpp"
@@ -46,13 +46,13 @@ namespace Bloom::Widgets
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
auto uiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/UiFiles/TargetMemoryInspectionPane.ui"
)
);
auto stylesheetFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Stylesheets/TargetMemoryInspectionPane.qss"
)
);

View File

@@ -11,7 +11,7 @@
#include "src/Insight/InsightSignals.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/DateTime.hpp"
#include "src/Exceptions/Exception.hpp"
@@ -37,7 +37,7 @@ namespace Bloom::Widgets
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
auto widgetUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget"
+ "/UiFiles/RegisterHistoryWidget.ui"
)

View File

@@ -10,7 +10,7 @@
#include "src/Insight/InsightWorker/InsightWorker.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp"
@@ -40,14 +40,14 @@ namespace Bloom::Widgets
this->setWindowTitle("Inspect Register");
auto windowUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/"
"TargetRegisterInspectorWindow.ui"
)
);
auto windowStylesheet = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Stylesheets/"
"TargetRegisterInspectorWindow.qss"
)
@@ -378,7 +378,7 @@ namespace Bloom::Widgets
void TargetRegisterInspectorWindow::openHelpPage() {
QDesktopServices::openUrl(
QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/register-inspection"))
QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/register-inspection"))
);
}
}

View File

@@ -6,7 +6,7 @@
#include "RegisterWidget.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
namespace Bloom::Widgets
{
@@ -31,7 +31,7 @@ namespace Bloom::Widgets
this->arrowIcon->setObjectName("arrow-icon");
auto static arrowIconPath = QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/arrow.svg"
);
this->arrowIcon->setSvgFilePath(arrowIconPath);
@@ -40,7 +40,7 @@ namespace Bloom::Widgets
this->registerGroupIcon->setObjectName("register-group-icon");
auto static registerIconPath = QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/register-group.svg"
);
this->registerGroupIcon->setSvgFilePath(registerIconPath);

View File

@@ -5,7 +5,7 @@
#include <QMenu>
#include <QStyle>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Insight/InsightSignals.hpp"
#include "src/Insight/InsightWorker/InsightWorker.hpp"
@@ -35,7 +35,7 @@ namespace Bloom::Widgets
this->registerIcon->setObjectName("register-icon");
auto static registerIconPath = QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/register.svg"
);
this->registerIcon->setSvgFilePath(registerIconPath);

View File

@@ -9,7 +9,7 @@
#include "RegisterGroupWidget.hpp"
#include "RegisterWidget.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp"
@@ -34,7 +34,7 @@ namespace Bloom::Widgets
this->setObjectName("target-registers-side-pane");
auto targetRegistersPaneUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
QString::fromStdString(Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/"
"TargetRegistersSidePane.ui"
)

View File

@@ -6,7 +6,7 @@
#include <QEvent>
#include <QFile>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
namespace Bloom::Widgets::InsightTargetWidgets::Dip
{
@@ -19,7 +19,7 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip
: TargetPackageWidget(targetVariant, parent)
{
auto stylesheetFile = QFile(QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/"
"DualInlinePackage.qss"
)

View File

@@ -7,7 +7,7 @@
#include <QFile>
#include <QLine>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "PinWidget.hpp"
#include "BodyWidget.hpp"
@@ -22,7 +22,7 @@ namespace Bloom::Widgets::InsightTargetWidgets::Qfp
assert((targetVariant.pinDescriptorsByNumber.size() % 4) == 0);
auto stylesheetFile = QFile(QString::fromStdString(
Paths::compiledResourcesPath()
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/Stylesheets/QuadFlatPackage.qss"
)
);

View File

@@ -1,4 +1,4 @@
#include "Paths.hpp"
#include "PathService.hpp"
#include <unistd.h>
#include <array>
@@ -7,9 +7,9 @@
#include "src/Exceptions/Exception.hpp"
namespace Bloom
namespace Bloom::Services
{
std::string Paths::applicationDirPath() {
std::string PathService::applicationDirPath() {
auto pathCharArray = std::array<char, PATH_MAX>();
if (readlink("/proc/self/exe", pathCharArray.data(), PATH_MAX) < 0) {

View File

@@ -3,9 +3,9 @@
#include <string>
#include <filesystem>
namespace Bloom
namespace Bloom::Services
{
class Paths
class PathService
{
public:
/**
@@ -21,7 +21,7 @@ namespace Bloom
* @return
*/
static std::string resourcesDirPath() {
return Paths::applicationDirPath() + "/../resources/";
return PathService::applicationDirPath() + "/../resources/";
}
/**
@@ -39,7 +39,7 @@ namespace Bloom
* @return
*/
static std::string projectConfigPath() {
return Paths::projectDirPath() + "/bloom.yaml";
return PathService::projectDirPath() + "/bloom.yaml";
}
/**
@@ -48,7 +48,7 @@ namespace Bloom
* @return
*/
static std::string projectSettingsDirPath() {
return Paths::projectDirPath() + "/.bloom";
return PathService::projectDirPath() + "/.bloom";
}
/**
@@ -57,7 +57,7 @@ namespace Bloom
* @return
*/
static std::string projectSettingsPath() {
return Paths::projectSettingsDirPath() + "/settings.json";
return PathService::projectSettingsDirPath() + "/settings.json";
}
/**

View File

@@ -443,7 +443,7 @@ namespace Bloom::TargetController
=======
void TargetControllerComponent::checkUdevRules() {
auto bloomRulesPath = std::string("/etc/udev/rules.d/99-bloom.rules");
auto latestBloomRulesPath = Paths::resourcesDirPath() + "/UDevRules/99-bloom.rules";
auto latestBloomRulesPath = Services::PathService::resourcesDirPath() + "/UDevRules/99-bloom.rules";
if (!std::filesystem::exists(bloomRulesPath)) {
Logger::warning("Bloom udev rules missing - attempting installation");
@@ -453,7 +453,7 @@ namespace Bloom::TargetController
Logger::error("Bloom udev rules missing - cannot install udev rules without root privileges.\n"
"Running Bloom once with root privileges will allow it to automatically install the udev rules. "
"Alternatively, instructions on manually installing the udev rules can be found "
"here: " + Paths::homeDomainName() + "/docs/getting-started\nBloom may fail to connect to some "
"here: " + Services::PathService::homeDomainName() + "/docs/getting-started\nBloom may fail to connect to some "
"debug tools until this is resolved.");
return;
}

View File

@@ -7,7 +7,7 @@
#include <algorithm>
#include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
#include "Exceptions/DebugWirePhysicalInterfaceError.hpp"
@@ -67,9 +67,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
+ physicalInterfaceNames.at(this->targetConfig->physicalInterface) + "). Target activation "
"will likely fail. The target supports the following physical interfaces: \n"
+ supportedPhysicalInterfaceList + "\n\nFor physical interface configuration values, see "
+ Paths::homeDomainName() + "/docs/configuration/avr8-physical-interfaces. \n\nIf this "
+ Services::PathService::homeDomainName() + "/docs/configuration/avr8-physical-interfaces. \n\nIf this "
"information is incorrect, please report this to Bloom developers via "
+ Paths::homeDomainName() + "/report-issue.\n"
+ Services::PathService::homeDomainName() + "/report-issue.\n"
);
}
@@ -78,7 +78,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
throw InvalidConfig(
"The JTAG physical interface cannot be used with an ambiguous target name"
" - please specify the exact name of the target in your configuration file. "
"See " + Paths::homeDomainName() + "/docs/supported-targets"
"See " + Services::PathService::homeDomainName() + "/docs/supported-targets"
);
}
@@ -86,7 +86,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
throw InvalidConfig(
"The UPDI physical interface cannot be used with an ambiguous target name"
" - please specify the exact name of the target in your configuration file. "
"See " + Paths::homeDomainName() + "/docs/supported-targets"
"See " + Services::PathService::homeDomainName() + "/docs/supported-targets"
);
}
}
@@ -163,7 +163,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
throw TargetOperationFailure(
"Failed to activate debugWire physical interface - check target connection and DWEN fuse "
"bit. Bloom can manage the DWEN fuse bit automatically. For instructions on enabling this "
"function, see " + Paths::homeDomainName() + "/docs/debugging-avr-debugwire"
"function, see " + Services::PathService::homeDomainName() + "/docs/debugging-avr-debugwire"
);
}
@@ -763,7 +763,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
if (this->avrIspInterface == nullptr) {
throw Exception(
"Debug tool or driver does not provide access to an ISP interface - please confirm that the "
"debug tool supports ISP and then report this issue via " + Paths::homeDomainName()
"debug tool supports ISP and then report this issue via " + Services::PathService::homeDomainName()
+ "/report-issue"
);
}
@@ -778,7 +778,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
if (!this->supportedPhysicalInterfaces.contains(PhysicalInterface::DEBUG_WIRE)) {
throw Exception(
"Target does not support debugWire physical interface - check target configuration or "
"report this issue via " + Paths::homeDomainName() + "/report-issue"
"report this issue via " + Services::PathService::homeDomainName() + "/report-issue"
);
}
@@ -842,7 +842,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
"Updating the DWEN fuse bit is a potentially dangerous operation. Bloom is provided \"AS IS\", "
"without warranty of any kind. You are using Bloom at your own risk. In no event shall the copyright "
"owner or contributors be liable for any damage caused as a result of using Bloom. For more details, "
"see the Bloom license at " + Paths::homeDomainName() + "/license"
"see the Bloom license at " + Services::PathService::homeDomainName() + "/license"
);
try {
@@ -882,7 +882,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
*/
throw Exception(
"Invalid SPIEN fuse bit value - suspected inaccuracies in TDF data. Please report this to "
"Bloom developers as a matter of urgency, via " + Paths::homeDomainName() + "/report-issue"
"Bloom developers as a matter of urgency, via " + Services::PathService::homeDomainName() + "/report-issue"
);
}

View File

@@ -1,7 +1,7 @@
#include "Avr8TargetConfig.hpp"
#include "src/Helpers/String.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
namespace Bloom::Targets::Microchip::Avr::Avr8Bit
@@ -25,7 +25,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
if (physicalInterfaceIt == Avr8TargetConfig::debugPhysicalInterfacesByConfigName.end()) {
throw InvalidConfig(
"Invalid physical interface provided (\"" + physicalInterfaceName + "\") for AVR8 target. "
"See " + Paths::homeDomainName() + "/docs/configuration/avr8-physical-interfaces for valid physical "
"See " + Services::PathService::homeDomainName() + "/docs/configuration/avr8-physical-interfaces for valid physical "
"interface configuration values."
);
}

View File

@@ -4,7 +4,7 @@
#include <QJsonArray>
#include <QJsonObject>
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
@@ -73,7 +73,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
continue;
}
const auto descriptionFilePath = QString::fromStdString(Paths::applicationDirPath()) + "/"
const auto descriptionFilePath = QString::fromStdString(Services::PathService::applicationDirPath()) + "/"
+ mappingObject.find("targetDescriptionFilePath")->toString();
Logger::debug("Loading AVR8 target description file: " + descriptionFilePath.toStdString());
@@ -99,7 +99,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
QJsonObject TargetDescriptionFile::getTargetDescriptionMapping() {
auto mappingFile = QFile(
QString::fromStdString(Paths::resourcesDirPath() + "/TargetDescriptionFiles/AVR/Mapping.json")
QString::fromStdString(Services::PathService::resourcesDirPath() + "/TargetDescriptionFiles/AVR/Mapping.json")
);
if (!mappingFile.exists()) {

View File

@@ -5,7 +5,7 @@
#include "Exceptions/TargetDescriptionParsingFailureException.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Services/PathService.hpp"
namespace Bloom::Targets::TargetDescription
{
@@ -26,7 +26,7 @@ namespace Bloom::Targets::TargetDescription
auto xml = QDomDocument();
if (!xml.setContent(file.readAll())) {
throw Exception("Failed to parse target description file - please report this error "
"to Bloom developers via " + Paths::homeDomainName() + "/report-issue");
"to Bloom developers via " + Services::PathService::homeDomainName() + "/report-issue");
}
this->init(xml);