From f74d1a67a5f8c3524c73982a4dfba7d1e2fda4f1 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Thu, 2 Sep 2021 09:10:39 +0300 Subject: [PATCH] fix(@desktop): various UI scaling fixes --- src/app/utilsView/view.nim | 9 +++ src/nim_status_client.nim | 4 +- .../Profile/Sections/AppearanceContainer.qml | 68 ++++++++++++++++++- vendor/DOtherSide | 2 +- 4 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/app/utilsView/view.nim b/src/app/utilsView/view.nim index 37007c8e21..9524b39093 100644 --- a/src/app/utilsView/view.nim +++ b/src/app/utilsView/view.nim @@ -189,3 +189,12 @@ QtObject: read = getNewVersion notify = newVersionChanged + proc readTextFile*(self: UtilsView, filepath: string): string {.slot.} = + return readFile(filepath) + + proc writeTextFile*(self: UtilsView, filepath: string, text: string): bool {.slot.} = + try: + writeFile(filepath, text) + return true + except: + return false \ No newline at end of file diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index 0f05cebaa6..8a8798d41f 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -49,7 +49,8 @@ proc mainProc() = status.tasks.marathon.registerWorker(mailserverWorker) status.initNode() - enableHDPI() + let uiScaleFilePath = joinPath(DATADIR, "ui-scale") + enableHDPI(uiScaleFilePath) initializeOpenGL() let app = newQGuiApplication() @@ -95,6 +96,7 @@ proc mainProc() = defer: engine.delete() engine.addImportPath("qrc:/./StatusQ/src") engine.setNetworkAccessManagerFactory(networkAccessFactory) + engine.setRootContextProperty("uiScaleFilePath", newQVariant(uiScaleFilePath)) # Register events objects let dockShowAppEvent = newStatusDockShowAppEventObject(engine) diff --git a/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml b/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml index 821def2a53..dcb98cb9bf 100644 --- a/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml @@ -172,6 +172,72 @@ ScrollView { } } + StyledText { + id: labelZoom + anchors.top: fontSizeSliderLegend.bottom + anchors.topMargin: Style.current.xlPadding + anchors.left: parent.left + font.pixelSize: 15 + text: qsTr("Change Zoom (requires restart)") + } + + StatusSlider { + id: zoomSlider + anchors.top: labelZoom.bottom + anchors.topMargin: Style.current.padding + width: parent.width + minimumValue: 50 + maximumValue: 200 + stepSize: 50 + value: parseFloat(utilsModel.readTextFile(uiScaleFilePath)) * 100 + onValueChanged: { + utilsModel.writeTextFile(uiScaleFilePath, value / 100.0) + } + } + + RowLayout { + id: zoomSliderLegend + anchors.top: zoomSlider.bottom + anchors.topMargin: Style.current.padding + anchors.left: parent.left + anchors.right: parent.right + spacing: 0 + + StyledText { + font.pixelSize: 15 + text: "50%" + } + + Item { + Layout.fillWidth: true + } + + StyledText { + font.pixelSize: 15 + Layout.leftMargin: width / 2 + text: "100%" + } + + Item { + Layout.fillWidth: true + } + + StyledText { + font.pixelSize: 15 + Layout.leftMargin: width / 2 + text: "150%" + } + + Item { + Layout.fillWidth: true + } + + StyledText { + font.pixelSize: 15 + text: "200%" + } + } + // StatusSectionHeadline { // id: sectionHeadlineChatMode // //% "Chat mode" @@ -225,7 +291,7 @@ ScrollView { //% "Appearance" text: qsTrId("appearance") // anchors.top: chatModeSection.bottom - anchors.top: fontSizeSliderLegend.bottom + anchors.top: zoomSliderLegend.bottom anchors.topMargin: Style.current.padding*3 anchors.left: parent.left anchors.right: parent.right diff --git a/vendor/DOtherSide b/vendor/DOtherSide index c18777749a..595e151080 160000 --- a/vendor/DOtherSide +++ b/vendor/DOtherSide @@ -1 +1 @@ -Subproject commit c18777749a2574d743ca2b7e5abc654152154f00 +Subproject commit 595e151080b999bbe6f2bc366b87917994f2b444