#include "settings/ApplicationSettings.h" #include "utility/ResourcePaths.h" #include "utility/utility.h" std::shared_ptr ApplicationSettings::s_instance; std::shared_ptr ApplicationSettings::getInstance() { if (!s_instance) { s_instance = std::shared_ptr(new ApplicationSettings()); } return s_instance; } ApplicationSettings::ApplicationSettings() { } ApplicationSettings::~ApplicationSettings() { } bool ApplicationSettings::operator==(const ApplicationSettings& other) const { return utility::isPermutation(getHeaderSearchPaths(), other.getHeaderSearchPaths()) && utility::isPermutation(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()); } int ApplicationSettings::getMaxRecentProjectsCount() const { return 7; } std::vector ApplicationSettings::getHeaderSearchPaths() const { return getPathValues("source/header_search_paths/header_search_path"); } std::vector ApplicationSettings::getHeaderSearchPathsExpanded() const { std::vector paths = getPathValues("source/header_search_paths/header_search_path"); expandPaths(paths); return paths; } bool ApplicationSettings::setHeaderSearchPaths(const std::vector& headerSearchPaths) { return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths); } std::vector ApplicationSettings::getFrameworkSearchPaths() const { return getPathValues("source/framework_search_paths/framework_search_path"); } std::vector ApplicationSettings::getFrameworkSearchPathsExpanded() const { std::vector paths = getPathValues("source/framework_search_paths/framework_search_path"); expandPaths(paths); return paths; } bool ApplicationSettings::setFrameworkSearchPaths(const std::vector& frameworkSearchPaths) { return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths); } std::vector ApplicationSettings::getCompilerFlags() const { std::vector defaultValues; return getValues("source/compiler_flags/compiler_flag", defaultValues); } std::string ApplicationSettings::getFontName() const { return getValue("application/font_name", "Source Code Pro"); } void ApplicationSettings::setFontName(const std::string& fontName) { setValue("application/font_name", fontName); } int ApplicationSettings::getFontSize() const { return getValue("application/font_size", 14); } void ApplicationSettings::setFontSize(int fontSize) { setValue("application/font_size", fontSize); } std::string ApplicationSettings::getColorSchemePath() const { std::string defaultPath = ResourcePaths::getColorSchemesPath() + "bright.xml"; std::string path = getValue("application/color_scheme", defaultPath); if (path != defaultPath && !FilePath(path).exists()) { return defaultPath; } return path; } void ApplicationSettings::setColorSchemePath(const std::string& colorSchemePath) { setValue("application/color_scheme", colorSchemePath); } int ApplicationSettings::getFontSizeMax() const { return getValue("application/font_size_max", 24); } void ApplicationSettings::setFontSizeMax(const int fontSizeMax) { setValue("application/font_size_max", fontSizeMax); } int ApplicationSettings::getFontSizeMin() const { return getValue("application/font_size_min", 4); } void ApplicationSettings::setFontSizeMin(const int fontSizeMin) { setValue("application/font_size_min", fontSizeMin); } int ApplicationSettings::getFontSizeStd() const { return getValue("application/font_size_std", 12); } void ApplicationSettings::setFontSizeStd(const int fontSizeStd) { setValue("application/font_size_std", fontSizeStd); } int ApplicationSettings::getIndexerThreadCount() const { return getValue("application/indexer_thread_count", 4); } void ApplicationSettings::setIndexerThreadCount(const int count) { setValue("application/indexer_thread_count", count); } int ApplicationSettings::getWindowBaseWidth() const { return getValue("application/window_base_width", 500); } int ApplicationSettings::getWindowBaseHeight() const { return getValue("application/window_base_height", 500); } int ApplicationSettings::getCodeTabWidth() const { return getValue("code/tab_width", 4); } void ApplicationSettings::setCodeTabWidth(int codeTabWidth) { setValue("code/tab_width", codeTabWidth); } int ApplicationSettings::getCodeSnippetSnapRange() const { return getValue("code/snippet/snap_range", 4); } void ApplicationSettings::setCodeSnippetSnapRange(int range) { setValue("code/snippet/snap_range", range); } int ApplicationSettings::getCodeSnippetExpandRange() const { return getValue("code/snippet/expand_range", 2); } void ApplicationSettings::setCodeSnippetExpandRange(int range) { setValue("code/snippet/expand_range", range); } std::vector ApplicationSettings::getRecentProjects() const { std::vector recentProjects; std::vector loadedRecentProjects = getPathValues("user/recent_projects/recent_project"); for (FilePath project: loadedRecentProjects) { recentProjects.push_back(project); } return recentProjects; } bool ApplicationSettings::setRecentProjects(const std::vector &recentProjects) { return setPathValues("user/recent_projects/recent_project", recentProjects); } int ApplicationSettings::getPluginPort() const { return getValue("network/plugin_port", 6666); } void ApplicationSettings::setPluginPort(const int pluginPort) { setValue("network/plugin_port", pluginPort); } int ApplicationSettings::getCoatiPort() const { return getValue("network/coati_port", 6667); } void ApplicationSettings::setCoatiPort(const int coatiPort) { setValue("network/coati_port", coatiPort); } int ApplicationSettings::getControlsMouseBackButton() const { return getValue("controls/mouse_back_button", 0x8); } int ApplicationSettings::getControlsMouseForwardButton() const { return getValue("controls/mouse_forward_button", 0x10); } std::string ApplicationSettings::getLicenseString() const { return getValue("user/license/license", ""); } std::string ApplicationSettings::getLicenseCheck() const { return getValue("user/license/check", ""); } void ApplicationSettings::setLicenseString(const std::string& licenseString) { setValue("user/license/license", licenseString); } void ApplicationSettings::setLicenseCheck(const std::string& hash) { setValue("user/license/check", hash); }