fix(@desktop): various UI scaling fixes

This commit is contained in:
Andrei Smirnov 2021-09-02 09:10:39 +03:00 committed by Iuri Matias
parent 9dd35904ea
commit f74d1a67a5
4 changed files with 80 additions and 3 deletions

View File

@ -189,3 +189,12 @@ QtObject:
read = getNewVersion read = getNewVersion
notify = newVersionChanged 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

View File

@ -49,7 +49,8 @@ proc mainProc() =
status.tasks.marathon.registerWorker(mailserverWorker) status.tasks.marathon.registerWorker(mailserverWorker)
status.initNode() status.initNode()
enableHDPI() let uiScaleFilePath = joinPath(DATADIR, "ui-scale")
enableHDPI(uiScaleFilePath)
initializeOpenGL() initializeOpenGL()
let app = newQGuiApplication() let app = newQGuiApplication()
@ -95,6 +96,7 @@ proc mainProc() =
defer: engine.delete() defer: engine.delete()
engine.addImportPath("qrc:/./StatusQ/src") engine.addImportPath("qrc:/./StatusQ/src")
engine.setNetworkAccessManagerFactory(networkAccessFactory) engine.setNetworkAccessManagerFactory(networkAccessFactory)
engine.setRootContextProperty("uiScaleFilePath", newQVariant(uiScaleFilePath))
# Register events objects # Register events objects
let dockShowAppEvent = newStatusDockShowAppEventObject(engine) let dockShowAppEvent = newStatusDockShowAppEventObject(engine)

View File

@ -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 { // StatusSectionHeadline {
// id: sectionHeadlineChatMode // id: sectionHeadlineChatMode
// //% "Chat mode" // //% "Chat mode"
@ -225,7 +291,7 @@ ScrollView {
//% "Appearance" //% "Appearance"
text: qsTrId("appearance") text: qsTrId("appearance")
// anchors.top: chatModeSection.bottom // anchors.top: chatModeSection.bottom
anchors.top: fontSizeSliderLegend.bottom anchors.top: zoomSliderLegend.bottom
anchors.topMargin: Style.current.padding*3 anchors.topMargin: Style.current.padding*3
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit c18777749a2574d743ca2b7e5abc654152154f00 Subproject commit 595e151080b999bbe6f2bc366b87917994f2b444