From 8ba205419048a039a8dbc84c87dfa4c6b2cb1252 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Tue, 28 Jun 2016 13:03:58 +0200 Subject: [PATCH] feat(chat): add settings to alter the chat view's base font Defaults to GUI style font according to previous behavior. --- src/persistence/settings.cpp | 25 +++++++++++++++++++++++++ src/persistence/settings.h | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/src/persistence/settings.cpp b/src/persistence/settings.cpp index 594fadc8a..efa86342f 100644 --- a/src/persistence/settings.cpp +++ b/src/persistence/settings.cpp @@ -24,6 +24,7 @@ #include "src/core/corestructs.h" #include "src/core/core.h" #include "src/widget/gui.h" +#include "src/widget/style.h" #include "src/persistence/profilelocker.h" #include "src/persistence/settingsserializer.h" #include "src/nexus.h" @@ -224,6 +225,12 @@ void Settings::loadGlobal() } s.endGroup(); + s.beginGroup("Chat"); + { + chatMessageFont = s.value("chatMessageFont", Style::getFont(Style::Big)).value(); + } + s.endGroup(); + s.beginGroup("State"); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray(); @@ -454,6 +461,12 @@ void Settings::saveGlobal() s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled); s.endGroup(); + s.beginGroup("Chat"); + { + s.setValue("chatMessageFont", chatMessageFont); + } + s.endGroup(); + s.beginGroup("State"); s.setValue("windowGeometry", windowGeometry); s.setValue("windowState", windowState); @@ -1134,6 +1147,18 @@ void Settings::setGlobalAutoAcceptDir(const QString& newValue) globalAutoAcceptDir = newValue; } +const QFont& Settings::getChatMessageFont() const +{ + QMutexLocker locker(&bigLock); + return chatMessageFont; +} + +void Settings::setChatMessageFont(const QFont& font) +{ + QMutexLocker locker(&bigLock); + chatMessageFont = font; +} + void Settings::setWidgetData(const QString& uniqueName, const QByteArray& data) { QMutexLocker locker{&bigLock}; diff --git a/src/persistence/settings.h b/src/persistence/settings.h index 15af3ae08..6a3fd429a 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -21,6 +21,7 @@ #ifndef SETTINGS_HPP #define SETTINGS_HPP +#include #include #include #include @@ -224,6 +225,9 @@ public: void setGlobalAutoAcceptDir(const QString& dir); // ChatView + const QFont& getChatMessageFont() const; + void setChatMessageFont(const QFont& font); + int getFirstColumnHandlePos() const; void setFirstColumnHandlePos(const int pos); @@ -415,6 +419,7 @@ private: bool showSystemTray; // ChatView + QFont chatMessageFont; MarkdownType markdownPreference; int firstColumnHandlePos; int secondColumnHandlePosFromRight;