From 8b37ca2524a2d42c1c3197e9728c6d21ebfe139e Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 1 Sep 2020 14:19:40 -0400 Subject: [PATCH] Add a persistent zoom setting to settings.json The zoom keybinds now modify this setting directly. The `uiScale` property in themes now default to using this zoom setting, since just removing it would need of annoying changes through theme files and QML code, and is best left to until the future theming overhaul update. --- TODO.md | 1 - src/backend/user_files.py | 2 ++ src/gui/UI.qml | 15 ++++++++++++--- src/themes/Glass.qpl | 2 +- src/themes/Midnight.qpl | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 7d96db20..b660b620 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ - handle invalid access token - If an account is gone from the user's config, discard UI state last page - room A-Z sorting -- move uiScale to settings.json - up/down doesn't work in the middle of a @word for which autocompletion isn't open because no matches - filter > enter > room list is always scrolled to top diff --git a/src/backend/user_files.py b/src/backend/user_files.py index cbedd705..3e5a2d28 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -285,6 +285,8 @@ class UISettings(JSONDataFile): "ownMessagesOnLeftAboveWidth": 895, "theme": "Midnight.qpl", "writeAliases": {}, + "zoom": 1.0, + "media": { "autoLoad": True, "autoPlay": False, diff --git a/src/gui/UI.qml b/src/gui/UI.qml index c839f2ff..c838f2a8 100644 --- a/src/gui/UI.qml +++ b/src/gui/UI.qml @@ -64,17 +64,26 @@ Item { HShortcut { sequences: window.settings.keys.zoomIn - onActivated: theme.uiScale += 0.1 + onActivated: { + window.settings.zoom += 0.1 + window.settingsChanged() + } } HShortcut { sequences: window.settings.keys.zoomOut - onActivated: theme.uiScale = Math.max(0.1, theme.uiScale - 0.1) + onActivated: { + window.settings.zoom = Math.max(0.1, window.settings.zoom - 0.1) + window.settingsChanged() + } } HShortcut { sequences: window.settings.keys.zoomReset - onActivated: theme.uiScale = 1 + onActivated: { + window.settings.zoom = 1 + window.settingsChanged() + } } HShortcut { diff --git a/src/themes/Glass.qpl b/src/themes/Glass.qpl index b27c842b..6c04bf42 100644 --- a/src/themes/Glass.qpl +++ b/src/themes/Glass.qpl @@ -2,7 +2,7 @@ // Base variables -real uiScale: 1.0 +real uiScale: window.settings.zoom int minimumSupportedWidth: 240 * uiScale int minimumSupportedHeight: 120 * uiScale diff --git a/src/themes/Midnight.qpl b/src/themes/Midnight.qpl index ce6a17c8..795aab99 100644 --- a/src/themes/Midnight.qpl +++ b/src/themes/Midnight.qpl @@ -2,7 +2,7 @@ // Base variables -real uiScale: 1.0 +real uiScale: window.settings.zoom int minimumSupportedWidth: 240 * uiScale int minimumSupportedHeight: 120 * uiScale