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:
+15
-1
@@ -6,6 +6,7 @@
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/scheduling/TaskScheduler.h"
|
||||
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "component/view/MainView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
#include "data/StorageCache.h"
|
||||
@@ -31,9 +32,11 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
|
||||
void Application::loadSettings()
|
||||
{
|
||||
ApplicationSettings::getInstance()->load("data/ApplicationSettings.xml");
|
||||
GraphViewStyle::loadStyleSettings();
|
||||
}
|
||||
|
||||
Application::Application()
|
||||
: m_isInitialParse(true)
|
||||
{
|
||||
TaskScheduler::getInstance()->startSchedulerLoopThreaded();
|
||||
MessageQueue::getInstance()->setSendMessagesAsTasks(true);
|
||||
@@ -96,11 +99,13 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
m_project->logStats();
|
||||
|
||||
if (message->errorCount > 0)
|
||||
if (!m_isInitialParse || message->errorCount > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_isInitialParse = false;
|
||||
|
||||
Id mainId = m_storageCache->getIdForNodeWithName("main");
|
||||
|
||||
if (!mainId)
|
||||
@@ -126,17 +131,26 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
||||
|
||||
void Application::handleMessage(MessageLoadProject* message)
|
||||
{
|
||||
m_isInitialParse = true;
|
||||
loadProject(message->projectSettingsFilePath);
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageLoadSource* message)
|
||||
{
|
||||
m_isInitialParse = true;
|
||||
loadSource(message->sourceDirectoryPath);
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
if (message->uiOnly)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
return;
|
||||
}
|
||||
|
||||
reloadProject();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ private:
|
||||
|
||||
std::shared_ptr<MainView> m_mainView;
|
||||
std::shared_ptr<ComponentManager> m_componentManager;
|
||||
|
||||
bool m_isInitialParse;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_H
|
||||
|
||||
@@ -267,15 +267,16 @@ add_files(
|
||||
utility/messaging/type/MessageInterruptTasks.h
|
||||
utility/messaging/type/MessageLoadProject.h
|
||||
utility/messaging/type/MessageLoadSource.h
|
||||
utility/messaging/type/MessageRedo.h
|
||||
utility/messaging/type/MessageRefresh.h
|
||||
utility/messaging/type/MessageSaveProject.h
|
||||
utility/messaging/type/MessageSearch.h
|
||||
utility/messaging/type/MessageSearchAutocomplete.h
|
||||
utility/messaging/type/MessageShowFile.h
|
||||
utility/messaging/type/MessageStatus.h
|
||||
utility/messaging/type/MessageRedo.h
|
||||
utility/messaging/type/MessageUndo.h
|
||||
utility/messaging/type/MessageWindowFocus.h
|
||||
utility/messaging/type/MessageZoom.h
|
||||
|
||||
utility/messaging/Message.h
|
||||
utility/messaging/MessageBase.h
|
||||
|
||||
@@ -25,7 +25,7 @@ const uint CodeController::s_lineRadius = 2;
|
||||
|
||||
void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
if (message->isIgnorable())
|
||||
if (message->isEdge && message->isIgnorable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "component/controller/FeatureController.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
#include "data/access/StorageAccess.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
FeatureController::FeatureController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
@@ -85,3 +87,12 @@ void FeatureController::handleMessage(MessageSearch* message)
|
||||
m.undoRedoType = message->undoRedoType;
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageZoom* message)
|
||||
{
|
||||
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
|
||||
settings->setFontSize(std::max(settings->getFontSize() + (message->zoomIn ? 1 : -1), 5));
|
||||
settings->save();
|
||||
|
||||
MessageRefresh(true).dispatch();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "utility/messaging/type/MessageActivateNode.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocation.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
@@ -19,6 +20,7 @@ class FeatureController
|
||||
, public MessageListener<MessageActivateNode>
|
||||
, public MessageListener<MessageActivateTokenLocation>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageZoom>
|
||||
{
|
||||
public:
|
||||
FeatureController(StorageAccess* storageAccess);
|
||||
@@ -30,6 +32,7 @@ private:
|
||||
virtual void handleMessage(MessageActivateNode* message);
|
||||
virtual void handleMessage(MessageActivateTokenLocation* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageZoom* message);
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
@@ -712,7 +712,7 @@ void GraphController::layoutNestingRecursive(DummyNode& node) const
|
||||
}
|
||||
|
||||
subNode.position.x = margins.left + x;
|
||||
subNode.position.y = margins.top + y;
|
||||
subNode.position.y = margins.top + margins.charHeight + y;
|
||||
|
||||
if (layoutHorizontal)
|
||||
{
|
||||
@@ -747,7 +747,7 @@ void GraphController::layoutNestingRecursive(DummyNode& node) const
|
||||
}
|
||||
|
||||
node.size.x = margins.left + width + margins.right;
|
||||
node.size.y = margins.top + y + height + margins.bottom;
|
||||
node.size.y = margins.top + margins.charHeight + y + height + margins.bottom;
|
||||
|
||||
for (DummyNode& subNode : node.subNodes)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "component/controller/RefreshController.h"
|
||||
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
#include "component/view/RefreshView.h"
|
||||
|
||||
RefreshController::RefreshController()
|
||||
@@ -16,11 +18,6 @@ void RefreshController::handleMessage(MessageAutoRefreshChanged* message)
|
||||
m_autoRefreshEnabled = message->enabled;
|
||||
}
|
||||
|
||||
void RefreshController::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
getView()->refreshView();
|
||||
}
|
||||
|
||||
void RefreshController::handleMessage(MessageWindowFocus* message)
|
||||
{
|
||||
if (m_autoRefreshEnabled)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "component/controller/Controller.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageAutoRefreshChanged.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
|
||||
class RefreshView;
|
||||
@@ -12,7 +11,6 @@ class RefreshView;
|
||||
class RefreshController
|
||||
: public Controller
|
||||
, public MessageListener<MessageAutoRefreshChanged>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageWindowFocus>
|
||||
{
|
||||
public:
|
||||
@@ -21,7 +19,6 @@ public:
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageAutoRefreshChanged* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageWindowFocus* message);
|
||||
|
||||
RefreshView* getView();
|
||||
|
||||
@@ -99,6 +99,34 @@ void UndoRedoController::handleMessage(MessageRedo* message)
|
||||
}
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
if (!m_lastCommand.message)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_lastCommand.order > 0)
|
||||
{
|
||||
replayCommands(false);
|
||||
}
|
||||
|
||||
std::shared_ptr<MessageBase> msg = m_lastCommand.message;
|
||||
|
||||
if (m_undo.size())
|
||||
{
|
||||
m_lastCommand = m_undo.back();
|
||||
m_undo.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastCommand.message.reset();
|
||||
}
|
||||
|
||||
msg->undoRedoType = MessageBase::UNDOTYPE_REDO;
|
||||
msg->dispatch();
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageSearch* message)
|
||||
{
|
||||
if (m_lastCommand.message && m_lastCommand.message->getType() == message->getType() &&
|
||||
@@ -112,6 +140,11 @@ void UndoRedoController::handleMessage(MessageSearch* message)
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageUndo* message)
|
||||
{
|
||||
replayCommands(true);
|
||||
}
|
||||
|
||||
void UndoRedoController::replayCommands(bool removeLast)
|
||||
{
|
||||
if (!m_undo.empty())
|
||||
{
|
||||
@@ -131,8 +164,17 @@ void UndoRedoController::handleMessage(MessageUndo* message)
|
||||
}
|
||||
|
||||
m = m_undo.back().message;
|
||||
m_undo.pop_back();
|
||||
m->undoRedoType = MessageBase::UNDOTYPE_UNDO;
|
||||
|
||||
if (removeLast)
|
||||
{
|
||||
m_undo.pop_back();
|
||||
m->undoRedoType = MessageBase::UNDOTYPE_UNDO;
|
||||
}
|
||||
else
|
||||
{
|
||||
m->undoRedoType = MessageBase::UNDOTYPE_IGNORE;
|
||||
}
|
||||
|
||||
m->dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageLoadSource.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
|
||||
@@ -32,6 +33,7 @@ class UndoRedoController
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageLoadSource>
|
||||
, public MessageListener<MessageRedo>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageUndo>
|
||||
{
|
||||
@@ -59,9 +61,12 @@ private:
|
||||
virtual void handleMessage(MessageLoadProject* message);
|
||||
virtual void handleMessage(MessageLoadSource* message);
|
||||
virtual void handleMessage(MessageRedo* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageUndo* message);
|
||||
|
||||
void replayCommands(bool removeLast);
|
||||
|
||||
void processCommand(const Command& command);
|
||||
void processNormalCommand(const Command& command);
|
||||
void processRedoCommand(const Command& command);
|
||||
|
||||
@@ -14,6 +14,7 @@ GraphViewStyle::NodeMargins::NodeMargins()
|
||||
, spacingY(0)
|
||||
, minWidth(0)
|
||||
, charWidth(0.0f)
|
||||
, charHeight(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,6 +57,15 @@ void GraphViewStyle::setImpl(std::shared_ptr<GraphViewStyleImpl> impl)
|
||||
s_impl = impl;
|
||||
}
|
||||
|
||||
void GraphViewStyle::loadStyleSettings()
|
||||
{
|
||||
s_fontSize = ApplicationSettings::getInstance()->getFontSize();
|
||||
s_fontName = ApplicationSettings::getInstance()->getFontName();
|
||||
|
||||
s_charWidths.clear();
|
||||
s_charHeights.clear();
|
||||
}
|
||||
|
||||
float GraphViewStyle::getCharWidthForNodeType(Node::NodeType type)
|
||||
{
|
||||
std::map<Node::NodeType, float>::const_iterator it = s_charWidths.find(type);
|
||||
@@ -70,13 +80,27 @@ float GraphViewStyle::getCharWidthForNodeType(Node::NodeType type)
|
||||
return charWidth;
|
||||
}
|
||||
|
||||
float GraphViewStyle::getCharHeightForNodeType(Node::NodeType type)
|
||||
{
|
||||
std::map<Node::NodeType, float>::const_iterator it = s_charHeights.find(type);
|
||||
|
||||
if (it != s_charHeights.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
float charHeight = getImpl()->getCharHeightForNodeType(type);
|
||||
s_charHeights.emplace(type, charHeight);
|
||||
return charHeight;
|
||||
}
|
||||
|
||||
size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Node::NODE_UNDEFINED:
|
||||
case Node::NODE_NAMESPACE:
|
||||
return 12;
|
||||
return s_fontSize - 2;
|
||||
|
||||
case Node::NODE_UNDEFINED_TYPE:
|
||||
case Node::NODE_STRUCT:
|
||||
@@ -85,7 +109,7 @@ size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type)
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
case Node::NODE_FILE:
|
||||
return 14;
|
||||
return s_fontSize;
|
||||
|
||||
case Node::NODE_UNDEFINED_FUNCTION:
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
@@ -94,23 +118,23 @@ size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type)
|
||||
case Node::NODE_GLOBAL_VARIABLE:
|
||||
case Node::NODE_FIELD:
|
||||
case Node::NODE_ENUM_CONSTANT:
|
||||
return 11;
|
||||
return s_fontSize - 3;
|
||||
}
|
||||
}
|
||||
|
||||
size_t GraphViewStyle::getFontSizeOfAccessNode()
|
||||
{
|
||||
return 11;
|
||||
return s_fontSize - 3;
|
||||
}
|
||||
|
||||
size_t GraphViewStyle::getFontSizeOfExpandToggleNode()
|
||||
{
|
||||
return 9;
|
||||
return s_fontSize - 5;
|
||||
}
|
||||
|
||||
std::string GraphViewStyle::getFontNameForNodeType(Node::NodeType type)
|
||||
{
|
||||
return "Source Code Pro";
|
||||
return s_fontName;
|
||||
}
|
||||
|
||||
std::string GraphViewStyle::getFontNameOfAccessNode()
|
||||
@@ -134,7 +158,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
case Node::NODE_UNDEFINED:
|
||||
case Node::NODE_NAMESPACE:
|
||||
margins.left = margins.right = 15;
|
||||
margins.top = 28;
|
||||
margins.top = 10;
|
||||
margins.bottom = 15;
|
||||
break;
|
||||
|
||||
@@ -148,33 +172,30 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
if (hasChildren)
|
||||
{
|
||||
margins.left = margins.right = 10;
|
||||
margins.top = 33;
|
||||
margins.top = 15;
|
||||
margins.bottom = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
margins.left = margins.right = 8;
|
||||
margins.top = margins.bottom = 17;
|
||||
margins.top = margins.bottom = 8;
|
||||
}
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_FUNCTION:
|
||||
case Node::NODE_FUNCTION:
|
||||
case Node::NODE_METHOD:
|
||||
margins.left = margins.right = 5;
|
||||
margins.top = margins.bottom = 10;
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
case Node::NODE_GLOBAL_VARIABLE:
|
||||
case Node::NODE_FIELD:
|
||||
case Node::NODE_ENUM_CONSTANT:
|
||||
margins.left = margins.right = 5;
|
||||
margins.top = margins.bottom = 10;
|
||||
margins.top = margins.bottom = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
margins.charWidth = getCharWidthForNodeType(type);
|
||||
margins.charHeight = getCharHeightForNodeType(type);
|
||||
|
||||
return margins;
|
||||
}
|
||||
@@ -211,8 +232,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode()
|
||||
{
|
||||
NodeMargins margins;
|
||||
|
||||
margins.left = margins.right = margins.top = margins.bottom = 11;
|
||||
margins.minWidth = 0;
|
||||
margins.left = margins.right = margins.top = margins.bottom = 7;
|
||||
margins.minWidth = margins.charHeight = getFontSizeOfExpandToggleNode();
|
||||
|
||||
return margins;
|
||||
}
|
||||
@@ -364,7 +385,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
|
||||
style.color = "#FFFFFF";
|
||||
style.borderColor = "#00000000";
|
||||
|
||||
style.cornerRadius = 12;
|
||||
style.cornerRadius = 100;
|
||||
|
||||
style.fontName = getFontNameOfExpandToggleNode();
|
||||
style.fontSize = getFontSizeOfExpandToggleNode();
|
||||
@@ -466,4 +487,9 @@ size_t GraphViewStyle::s_gridCellSize = 5;
|
||||
size_t GraphViewStyle::s_gridCellPadding = 10;
|
||||
|
||||
std::map<Node::NodeType, float> GraphViewStyle::s_charWidths;
|
||||
std::map<Node::NodeType, float> GraphViewStyle::s_charHeights;
|
||||
|
||||
std::shared_ptr<GraphViewStyleImpl> GraphViewStyle::s_impl;
|
||||
|
||||
int GraphViewStyle::s_fontSize;
|
||||
std::string GraphViewStyle::s_fontName;
|
||||
|
||||
@@ -29,7 +29,9 @@ public:
|
||||
int spacingY;
|
||||
|
||||
int minWidth;
|
||||
|
||||
float charWidth;
|
||||
float charHeight;
|
||||
};
|
||||
|
||||
struct NodeStyle
|
||||
@@ -81,7 +83,10 @@ public:
|
||||
static std::shared_ptr<GraphViewStyleImpl> getImpl();
|
||||
static void setImpl(std::shared_ptr<GraphViewStyleImpl> impl);
|
||||
|
||||
static void loadStyleSettings();
|
||||
|
||||
static float getCharWidthForNodeType(Node::NodeType type);
|
||||
static float getCharHeightForNodeType(Node::NodeType type);
|
||||
|
||||
static size_t getFontSizeForNodeType(Node::NodeType type);
|
||||
static size_t getFontSizeOfAccessNode();
|
||||
@@ -110,7 +115,12 @@ public:
|
||||
|
||||
private:
|
||||
static std::map<Node::NodeType, float> s_charWidths;
|
||||
static std::map<Node::NodeType, float> s_charHeights;
|
||||
|
||||
static std::shared_ptr<GraphViewStyleImpl> s_impl;
|
||||
|
||||
static int s_fontSize;
|
||||
static std::string s_fontName;
|
||||
};
|
||||
|
||||
#endif // GRAPH_VIEW_STYLE_H
|
||||
|
||||
@@ -7,6 +7,7 @@ class GraphViewStyleImpl
|
||||
{
|
||||
public:
|
||||
virtual float getCharWidthForNodeType(Node::NodeType type) = 0;
|
||||
virtual float getCharHeightForNodeType(Node::NodeType type) = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPH_VIEW_STYLE_IMPL_H
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
class MessageRefresh: public Message<MessageRefresh>
|
||||
{
|
||||
public:
|
||||
MessageRefresh()
|
||||
MessageRefresh(bool uiOnly = false)
|
||||
: uiOnly(uiOnly)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,6 +15,8 @@ public:
|
||||
{
|
||||
return "MessageRefresh";
|
||||
}
|
||||
|
||||
const bool uiOnly;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_REFRESH_H
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_ZOOM_H
|
||||
#define MESSAGE_ZOOM_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageZoom
|
||||
: public Message<MessageZoom>
|
||||
{
|
||||
public:
|
||||
MessageZoom(bool zoomIn)
|
||||
: zoomIn(zoomIn)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageZoom";
|
||||
}
|
||||
|
||||
const bool zoomIn;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ZOOM_H
|
||||
Reference in New Issue
Block a user