From fb1c4c0de75b4672e5bd318cec72357effed0544 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Sat, 22 Oct 2022 14:16:15 +0200 Subject: [PATCH] Using Screen.devicePixelRatio as image depth. Fixes bluriness of images on HDPI screens and disabling it on those who don't need it. --- .../qml/eu/ad5001/LogarithmPlotter/History/History.qml | 2 ++ .../eu/ad5001/LogarithmPlotter/ObjectLists/ObjectRow.qml | 5 +++-- .../qml/eu/ad5001/LogarithmPlotter/Setting/Icon.qml | 7 ++++--- .../qml/eu/ad5001/LogarithmPlotter/js/history/common.js | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/History.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/History.qml index e6caf9d..bdbc768 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/History.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/History.qml @@ -18,6 +18,7 @@ import QtQuick 2.12 import QtQml 2.12 +import QtQuick.Window 2.12 import "../js/objects.js" as Objects import "../js/historylib.js" as HistoryLib import "../js/history/common.js" as HistoryCommon @@ -215,5 +216,6 @@ Item { Component.onCompleted: { HistoryLib.history = historyObj HistoryCommon.themeTextColor = sysPalette.windowText + HistoryCommon.imageDepth = Screen.devicePixelRatio } } diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/ObjectRow.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/ObjectRow.qml index 11ce7aa..ca02fe9 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/ObjectRow.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/ObjectRow.qml @@ -19,6 +19,7 @@ import QtQuick 2.12 import QtQuick.Dialogs 1.3 as D import QtQuick.Controls 2.12 +import QtQuick.Window 2.12 import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import "../js/objects.js" as Objects import "../js/historylib.js" as HistoryLib @@ -100,8 +101,8 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left visible: LatexJS.enabled - property double depth: 2 - property var ltxInfo: visible ? Latex.render(obj.getLatexString(), depth*parent.font.pixelSize+4, parent.color).split(",") : ["","0","0"] + property double depth: Screen.devicePixelRatio + property var ltxInfo: visible ? Latex.render(obj.getLatexString(), depth*(parent.font.pixelSize+2), parent.color).split(",") : ["","0","0"] source: visible ? ltxInfo[0] : "" width: parseInt(ltxInfo[1])/depth height: parseInt(ltxInfo[2])/depth diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/Icon.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/Icon.qml index 7df012c..7cf3b31 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/Icon.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/Icon.qml @@ -15,7 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -import QtQuick 2.7 +import QtQuick 2.12 +import QtQuick.Window 2.12 import QtGraphicalEffects 1.0 /*! @@ -48,8 +49,8 @@ Item { width: parent.width //smooth: true visible: false - sourceSize.width: width*2 - sourceSize.height: width*2 + sourceSize.width: width*Screen.devicePixelRatio + sourceSize.height: width*Screen.devicePixelRatio } ColorOverlay { anchors.fill: img diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/common.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/common.js index 92811d9..0cdf6a7 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/common.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/common.js @@ -98,7 +98,7 @@ class Action { renderLatexAsHtml(latexString) { if(!Latex.enabled) throw new Error("Cannot render an item as LaTeX when LaTeX is disabled.") - let latexInfo = Latex.Renderer.render(latexString, imageDepth*fontSize+4, themeTextColor).split(",") + let latexInfo = Latex.Renderer.render(latexString, imageDepth*(fontSize+2), themeTextColor).split(",") return `` }