From d27167f18a6ba757ee614b828ba95911c53d9c65 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 30 Jul 2017 10:20:48 +0300 Subject: [PATCH] Add function to set custom mm and dp scale factor --- src/controls/sizing.cpp | 23 +++++++++++++++++++++++ src/controls/sizing.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/controls/sizing.cpp b/src/controls/sizing.cpp index 4b2c8c3..09cff96 100644 --- a/src/controls/sizing.cpp +++ b/src/controls/sizing.cpp @@ -105,3 +105,26 @@ float Sizing::dp(float value) { return value*m_dp_factor; } + + +void Sizing::setMmScaleFactor(float value) +{ + if(value != 0) + { + qDebug() << "Set custom mm scale factor"; + + m_p_width = value; + setMmScaleFactor(); + } +} + + +void Sizing::setDpScaleFactor(float value) +{ + if(value != 0) + { + qDebug() << "Set custom dp scale factor"; + + m_dp_factor = value; + } +} diff --git a/src/controls/sizing.h b/src/controls/sizing.h index 57fc8c1..5fe7ac1 100644 --- a/src/controls/sizing.h +++ b/src/controls/sizing.h @@ -37,6 +37,9 @@ class Sizing : public QObject Q_INVOKABLE float mm(float value); Q_INVOKABLE float dp(float value); + Q_INVOKABLE void setMmScaleFactor(float value); + Q_INVOKABLE void setDpScaleFactor(float value); + private: bool m_valid;