logic: file paths
Changed relative file paths for resources to absolute paths to ensure functionality of shortcuts and file associations on windows platform
This commit is contained in:
@@ -274,9 +274,13 @@ add_files(
|
||||
utility/text/TextAccess.cpp
|
||||
utility/text/TextAccess.h
|
||||
|
||||
utility/AppPath.cpp
|
||||
utility/AppPath.h
|
||||
utility/ConfigManager.cpp
|
||||
utility/ConfigManager.h
|
||||
utility/Property.h
|
||||
utility/ResourcePaths.cpp
|
||||
utility/ResourcePaths.h
|
||||
utility/TimePoint.cpp
|
||||
utility/TimePoint.h
|
||||
utility/types.h
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "component/view/GraphViewStyleImpl.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
@@ -415,7 +417,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
|
||||
style.color = getNodeColor("bundle", isFocused);
|
||||
|
||||
addIcon(Node::NODE_ENUM, false, &style);
|
||||
style.iconPath = "data/gui/graph_view/images/bundle.png";
|
||||
style.iconPath = ResourcePaths::getGuiPath() + "graph_view/images/bundle.png";
|
||||
|
||||
return style;
|
||||
}
|
||||
@@ -562,16 +564,16 @@ void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* s
|
||||
switch (type)
|
||||
{
|
||||
case Node::NODE_ENUM:
|
||||
style->iconPath = "data/gui/graph_view/images/enum_1.png";
|
||||
style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/enum_1.png";
|
||||
break;
|
||||
case Node::NODE_TYPEDEF:
|
||||
style->iconPath = "data/gui/graph_view/images/typedef_2.png";
|
||||
style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/typedef_2.png";
|
||||
break;
|
||||
case Node::NODE_MACRO:
|
||||
style->iconPath = "data/gui/graph_view/images/macro_3.png";
|
||||
style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/macro_3.png";
|
||||
break;
|
||||
case Node::NODE_FILE:
|
||||
style->iconPath = "data/gui/graph_view/images/file.png";
|
||||
style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/file.png";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
std::shared_ptr<ApplicationSettings> ApplicationSettings::s_instance;
|
||||
|
||||
std::shared_ptr<ApplicationSettings> ApplicationSettings::getInstance()
|
||||
@@ -69,7 +71,7 @@ void ApplicationSettings::setFontSize(int fontSize)
|
||||
|
||||
std::string ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
return getValue<std::string>("application/color_scheme", "./data/color_schemes/bright.xml");
|
||||
return getValue<std::string>("application/color_scheme", ResourcePaths::getColorSchemesPath() + "bright.xml");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setColorSchemePath(const std::string& colorSchemePath)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "AppPath.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string AppPath::m_appPath = "";
|
||||
|
||||
std::string AppPath::getAppPath()
|
||||
{
|
||||
if (m_appPath.length() <= 0)
|
||||
{
|
||||
setupAppPath();
|
||||
}
|
||||
|
||||
return m_appPath;
|
||||
}
|
||||
|
||||
void AppPath::setupAppPath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HMODULE hModule = GetModuleHandleW(NULL);
|
||||
WCHAR path[MAX_PATH];
|
||||
GetModuleFileNameW(hModule, path, MAX_PATH);
|
||||
|
||||
std::wstring wPath(path);
|
||||
m_appPath = std::string(wPath.begin(), wPath.end());
|
||||
|
||||
size_t pos = m_appPath.find_last_of("/");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
pos = m_appPath.find_last_of("\\");
|
||||
}
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
m_appPath = m_appPath.substr(0, pos + 1);
|
||||
}
|
||||
#elif _WIN64
|
||||
HMODULE hModule = GetModuleHandleW(NULL);
|
||||
WCHAR path[MAX_PATH];
|
||||
GetModuleFileNameW(hModule, path, MAX_PATH);
|
||||
|
||||
std::wstring wPath(path);
|
||||
m_appPath = std::string(wPath.begin(), wPath.end());
|
||||
|
||||
size_t pos = m_appPath.find_last_of("/");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
pos = m_appPath.find_last_of("\\");
|
||||
}
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
m_appPath = m_appPath.substr(0, pos + 1);
|
||||
}
|
||||
#endif // WINDOWS
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef APP_PATH_H
|
||||
#define APP_PATH_H
|
||||
|
||||
#include <string>
|
||||
|
||||
// #include "src\lib_gui\includes.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#elif _WIN64
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#endif // WINDOWS
|
||||
|
||||
|
||||
class AppPath
|
||||
{
|
||||
public:
|
||||
static std::string getAppPath();
|
||||
|
||||
private:
|
||||
static void setupAppPath();
|
||||
|
||||
static std::string m_appPath;
|
||||
};
|
||||
|
||||
#endif // APP_PATH_H
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "ResourcePaths.h"
|
||||
|
||||
#include "AppPath.h"
|
||||
|
||||
std::string ResourcePaths::m_colorSchemesPath = AppPath::getAppPath() + "data/color_schemes/";
|
||||
std::string ResourcePaths::m_fontsPath = AppPath::getAppPath() + "data/fonts/";
|
||||
std::string ResourcePaths::m_guiPath = AppPath::getAppPath() + "data/gui/";
|
||||
|
||||
std::string ResourcePaths::getColorSchemesPath()
|
||||
{
|
||||
return m_colorSchemesPath;
|
||||
}
|
||||
|
||||
std::string ResourcePaths::getFontsPath()
|
||||
{
|
||||
return m_fontsPath;
|
||||
}
|
||||
|
||||
std::string ResourcePaths::getGuiPath()
|
||||
{
|
||||
return m_guiPath;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef RESOURCE_PATHS_H
|
||||
#define RESOURCE_PATHS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class ResourcePaths
|
||||
{
|
||||
public:
|
||||
static std::string getColorSchemesPath();
|
||||
static std::string getFontsPath();
|
||||
static std::string getGuiPath();
|
||||
|
||||
private:
|
||||
static std::string m_colorSchemesPath;
|
||||
static std::string m_fontsPath;
|
||||
static std::string m_guiPath;
|
||||
};
|
||||
|
||||
#endif // RESOURCE_PATHS_H
|
||||
Reference in New Issue
Block a user