diff --git a/src/backend/user_files.py b/src/backend/user_files.py index 5c5f0490..9c7f2188 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -238,6 +238,7 @@ class UISettings(JSONDataFile): "hideProfileChangeEvents": True, "hideMembershipEvents": False, "hideUnknownEvents": False, + "maxMessageCharactersPerLine": 65, "theme": "Midnight.qpl", "writeAliases": {}, "media": { diff --git a/src/gui/Pages/Chat/Timeline/EventContent.qml b/src/gui/Pages/Chat/Timeline/EventContent.qml index 368e71a4..c11418bc 100644 --- a/src/gui/Pages/Chat/Timeline/EventContent.qml +++ b/src/gui/Pages/Chat/Timeline/EventContent.qml @@ -62,8 +62,13 @@ HRowLayout { ) : 0 - // ~600px max with a 16px font - readonly property int maxMessageWidth: theme.fontSize.normal * 0.5 * 75 + readonly property int maxMessageWidth: + window.settings.maxMessageCharactersPerLine < 0 ? + -1 : + Math.ceil( + mainUI.fontMetrics.averageCharacterWidth * + window.settings.maxMessageCharactersPerLine + ) readonly property alias selectedText: contentLabel.selectedText diff --git a/src/gui/UI.qml b/src/gui/UI.qml index 7a12388e..9cde40fd 100644 --- a/src/gui/UI.qml +++ b/src/gui/UI.qml @@ -32,6 +32,7 @@ Item { readonly property alias mainPane: mainPane readonly property alias pageLoader: pageLoader readonly property alias pressAnimation: pressAnimation + readonly property alias fontMetrics: fontMetrics function reloadSettings() { @@ -82,6 +83,13 @@ Item { } } + FontMetrics { + id: fontMetrics + font.family: theme.fontFamily.sans + font.pixelSize: theme.fontSize.normal + font.pointSize: -1 + } + DebugConsole { id: debugConsole target: mainUI