ui: added universal font size setting and shortcuts for changing it
This change adds font size and font family to the ApplicationSettings to have a single point for manipulating them. The font size can also be changed via the menu or the zoomIn and zoomOut shortcuts on all platforms.
This commit is contained in:
@@ -26,6 +26,26 @@ bool ApplicationSettings::filterUndefinedNodesFromGraph() const
|
||||
return getValue<bool>("FilterUndefinedNodesFromGraph", false);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getFontName() const
|
||||
{
|
||||
return getValue<std::string>("application/font_name", "Source Code Pro");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setFontName(const std::string& fontName)
|
||||
{
|
||||
setValue<std::string>("application/font_name", fontName);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getFontSize() const
|
||||
{
|
||||
return getValue<int>("application/font_size", 14);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setFontSize(int fontSize)
|
||||
{
|
||||
setValue<int>("application/font_size", fontSize);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeTabWidth() const
|
||||
{
|
||||
return getValue<int>("code/TabWidth", 4);
|
||||
@@ -36,26 +56,6 @@ void ApplicationSettings::setCodeTabWidth(int codeTabWidth)
|
||||
setValue<int>("code/TabWidth", codeTabWidth);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getCodeFontName() const
|
||||
{
|
||||
return getValue<std::string>("code/FontName", "Courier");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setCodeFontName(const std::string& codeFontName)
|
||||
{
|
||||
setValue<std::string>("code/FontName", codeFontName);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeFontSize() const
|
||||
{
|
||||
return getValue<int>("code/FontSize", 12);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setCodeFontSize(int codeFontSize)
|
||||
{
|
||||
setValue<int>("code/FontSize", codeFontSize);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeSnippetSnapRange() const
|
||||
{
|
||||
return getValue<int>("code/snippet/snap_range", 4);
|
||||
|
||||
@@ -19,16 +19,17 @@ public:
|
||||
std::string getStartupProjectFilePath() const;
|
||||
bool filterUndefinedNodesFromGraph() const;
|
||||
|
||||
// application
|
||||
std::string getFontName() const;
|
||||
void setFontName(const std::string& fontName);
|
||||
|
||||
int getFontSize() const;
|
||||
void setFontSize(int fontSize);
|
||||
|
||||
// code
|
||||
int getCodeTabWidth() const;
|
||||
void setCodeTabWidth(int codeTabWidth);
|
||||
|
||||
std::string getCodeFontName() const;
|
||||
void setCodeFontName(const std::string& codeFontName);
|
||||
|
||||
int getCodeFontSize() const;
|
||||
void setCodeFontSize(int codeFontSize);
|
||||
|
||||
int getCodeSnippetSnapRange() const;
|
||||
void setCodeSnippetSnapRange(int range);
|
||||
|
||||
|
||||
@@ -14,16 +14,29 @@ bool Settings::load(const std::string& filePath)
|
||||
if (FileSystem::exists(filePath))
|
||||
{
|
||||
m_config = ConfigManager::createAndLoad(TextAccess::createFromFile(filePath));
|
||||
m_filePath = filePath;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_config = ConfigManager::createEmpty();
|
||||
clear();
|
||||
LOG_WARNING("File for Settings not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::save()
|
||||
{
|
||||
if (m_config.get() && m_filePath.size())
|
||||
{
|
||||
m_config->save(m_filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Settings were not saved.");
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::save(const std::string& filePath)
|
||||
{
|
||||
if (m_config)
|
||||
@@ -39,6 +52,7 @@ void Settings::save(const std::string& filePath)
|
||||
void Settings::clear()
|
||||
{
|
||||
m_config = ConfigManager::createEmpty();
|
||||
m_filePath.clear();
|
||||
}
|
||||
|
||||
Settings::Settings()
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
virtual ~Settings();
|
||||
|
||||
bool load(const std::string& filePath);
|
||||
void save();
|
||||
void save(const std::string& filePath);
|
||||
void clear();
|
||||
|
||||
@@ -32,6 +33,7 @@ protected:
|
||||
bool setValues(const std::string& key, std::vector<T> values);
|
||||
|
||||
private:
|
||||
std::string m_filePath;
|
||||
std::shared_ptr<ConfigManager> m_config;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user