From 42a25f7bb50d7d7c89b47b0b5fda524f47de42c8 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Fri, 7 Apr 2017 11:32:30 +0300 Subject: [PATCH 01/15] [Sizing] add simple sizing class --- rpm/qtquickcontrols-nemo.spec | 2 +- src/controls/controls.pro | 6 ++- .../qquicknemocontrolsextensionplugin.cpp | 7 +++ src/controls/sizing.cpp | 45 +++++++++++++++++++ src/controls/sizing.h | 27 +++++++++++ 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 src/controls/sizing.cpp create mode 100644 src/controls/sizing.h diff --git a/rpm/qtquickcontrols-nemo.spec b/rpm/qtquickcontrols-nemo.spec index 5278d5e..7771900 100644 --- a/rpm/qtquickcontrols-nemo.spec +++ b/rpm/qtquickcontrols-nemo.spec @@ -1,6 +1,6 @@ Name: qt5-qtquickcontrols-nemo Summary: Nemomobile Qt Quick Controls -Version: 5.1.3 +Version: 5.2.0 Release: nemo1 Group: Qt/Qt License: LGPLv2.1 with exception or GPLv3 diff --git a/src/controls/controls.pro b/src/controls/controls.pro index b020258..28f7444 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -34,7 +34,8 @@ HEADERS += \ qquickfilteringmousearea.h \ nemoimageprovider.h \ themedaemon/mlocalthemedaemonclient.h \ - themedaemon/mabstractthemedaemonclient.h + themedaemon/mabstractthemedaemonclient.h \ + sizing.h SOURCES += \ qquicknemocontrolsextensionplugin.cpp \ @@ -44,7 +45,8 @@ SOURCES += \ qquickfilteringmousearea.cpp \ nemoimageprovider.cpp \ themedaemon/mlocalthemedaemonclient.cpp \ - themedaemon/mabstractthemedaemonclient.cpp + themedaemon/mabstractthemedaemonclient.cpp \ + sizing.cpp target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH diff --git a/src/controls/qquicknemocontrolsextensionplugin.cpp b/src/controls/qquicknemocontrolsextensionplugin.cpp index bde3841..8dee1a0 100644 --- a/src/controls/qquicknemocontrolsextensionplugin.cpp +++ b/src/controls/qquicknemocontrolsextensionplugin.cpp @@ -25,6 +25,7 @@ #include "nemopage.h" #include "qquickfilteringmousearea.h" #include "nemoimageprovider.h" +#include "sizing.h" QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) : QQmlExtensionPlugin(parent) @@ -48,7 +49,13 @@ void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri) void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri) { + Sizing *sizing = new Sizing(); + QQmlExtensionPlugin::initializeEngine(engine,uri); + QQmlContext* context = engine->rootContext(); + + context->setContextProperty("mm",sizing->getScaleFactor()); + engine->addImageProvider(QLatin1String("theme"), new NemoImageProvider); } diff --git a/src/controls/sizing.cpp b/src/controls/sizing.cpp new file mode 100644 index 0000000..f430f26 --- /dev/null +++ b/src/controls/sizing.cpp @@ -0,0 +1,45 @@ +#include "sizing.h" + +#include +#include +#include + +Sizing::Sizing(QObject *parent) : QObject(parent) +{ + m_valid = false; + m_scale_factor = 10; + + m_p_height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt(); + m_p_width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt(); + + QScreen *screen = QGuiApplication::primaryScreen(); + + m_height = screen->size().height(); + m_width = screen->size().width(); + + if(m_p_height > 0 && m_p_width >0){ + m_valid = true; + scaleFactor(); + }else{ + if(m_p_height == 0){ + qWarning("QT_QPA_EGLFS_PHYSICAL_HEIGHT is not set!"); + } + + if(m_p_width == 0){ + qWarning("QT_QPA_EGLFS_PHYSICAL_WIDTH is not set!"); + } + + qWarning("Device sizing don`t work"); + } +} + +void Sizing::scaleFactor() +{ + if(m_p_width != 0){ + m_scale_factor = m_width/m_p_width; + } + + qDebug() << "Scale factor is " << m_scale_factor; +} + + diff --git a/src/controls/sizing.h b/src/controls/sizing.h new file mode 100644 index 0000000..5bbbaca --- /dev/null +++ b/src/controls/sizing.h @@ -0,0 +1,27 @@ +#ifndef SIZING_H +#define SIZING_H + +#include + +class Sizing : public QObject +{ + Q_OBJECT +public: + explicit Sizing(QObject *parent = 0); + bool isValid(){return m_valid;} + int getScaleFactor(){return m_scale_factor;} + +private: + bool m_valid; + + int m_p_width; + int m_p_height; + int m_width; + int m_height; + + int m_scale_factor; + + void scaleFactor(); +}; + +#endif // SIZING_H From 415dc3a300c4d27b4fd0b3514bbead5a15cc403b Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Fri, 7 Apr 2017 13:31:30 +0300 Subject: [PATCH 02/15] [Styles] Add scale to styles --- src/controls/ButtonRow.qml | 10 +++++----- src/styles/ButtonStyle.qml | 4 ++-- src/styles/CheckBoxStyle.qml | 16 ++++++++-------- src/styles/GrooveStyle.qml | 4 ++-- src/styles/MenuBarStyle.qml | 4 ++-- src/styles/SliderStyle.qml | 14 +++++++------- src/styles/TextFieldStyle.qml | 6 +++--- src/styles/ToolBarStyle.qml | 4 ++-- src/styles/ToolButtonStyle.qml | 6 +++--- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/controls/ButtonRow.qml b/src/controls/ButtonRow.qml index b020f5f..1cb8a05 100644 --- a/src/controls/ButtonRow.qml +++ b/src/controls/ButtonRow.qml @@ -36,7 +36,7 @@ Rectangle { id: main width: childrenRect.width color: "#313131" - height: 40 + height: 4*mm property ListModel model: ListModel {} property bool enabled: true property int currentIndex: -1 @@ -51,10 +51,10 @@ Rectangle { Rectangle{ id: selecter x: rowElement.children[main.currentIndex].x || 0 - y: -5 + y: -0.5*mm width: rowElement.children[main.currentIndex].width || 0 - height: 50 + height: 5*mm color: "#0091e5" visible: main.currentIndex > -1 @@ -74,10 +74,10 @@ Rectangle { model: main.model delegate: Rectangle { id: rowItem - height: 50 + height: 5*mm width: text.width+(text.width/name.length*2) - y: -5 + y: -0.5*mm color: "transparent" MouseArea { diff --git a/src/styles/ButtonStyle.qml b/src/styles/ButtonStyle.qml index 5f11cf6..8662a21 100644 --- a/src/styles/ButtonStyle.qml +++ b/src/styles/ButtonStyle.qml @@ -30,8 +30,8 @@ ButtonStyle { // The background of the button. background: Rectangle { - implicitWidth: 240 - implicitHeight: 50 + implicitWidth: 24*mm + implicitHeight: 5*mm clip: true color: control.primary ? Theme.primaryButton.background : Theme.button.background diff --git a/src/styles/CheckBoxStyle.qml b/src/styles/CheckBoxStyle.qml index eb6694d..ff7d57c 100644 --- a/src/styles/CheckBoxStyle.qml +++ b/src/styles/CheckBoxStyle.qml @@ -39,21 +39,21 @@ CheckBoxStyle { indicator: Rectangle { id: background color: "transparent" - implicitWidth: 72 - implicitHeight: 32 + implicitWidth: 7.2*mm + implicitHeight: 3.2*mm Rectangle { id: back1 - implicitWidth: 72 - implicitHeight: 28 + implicitWidth: 7.2*mm + implicitHeight: 2.8*mm color: Theme.checkbox.back1 anchors.centerIn: parent } Rectangle { id: back2 - implicitWidth: 72 - implicitHeight: 28 + implicitWidth: 7.2*mm + implicitHeight: 2.8*mm color: Theme.checkbox.back2 anchors.centerIn: parent } @@ -80,7 +80,7 @@ CheckBoxStyle { Component.onCompleted: { back1.opacity = control.checked ? 1 : 0 back2.opacity = control.checked ? 0 : 1 - ball.x = control.checked ? 32 : 0 + ball.x = control.checked ? 3.2*mm : 0 } SequentialAnimation { @@ -89,7 +89,7 @@ CheckBoxStyle { NumberAnimation { target: ball property: "x" - to: 32 + to: 3.2*mm duration: 120 } NumberAnimation { diff --git a/src/styles/GrooveStyle.qml b/src/styles/GrooveStyle.qml index 577b98d..f64137a 100644 --- a/src/styles/GrooveStyle.qml +++ b/src/styles/GrooveStyle.qml @@ -22,8 +22,8 @@ import QtQuick.Controls.Styles.Nemo 1.0 Component { Rectangle { - implicitHeight: 16 - implicitWidth: 440 + implicitHeight: 1.6*mm + implicitWidth: 44*mm color: Theme.groove.background Rectangle { antialiasing: true diff --git a/src/styles/MenuBarStyle.qml b/src/styles/MenuBarStyle.qml index 4effd6e..5eb3e30 100644 --- a/src/styles/MenuBarStyle.qml +++ b/src/styles/MenuBarStyle.qml @@ -59,8 +59,8 @@ Style { } property Component menuItem: Rectangle { - width: text.width + 12 - height: text.height + 4 + width: text.width + 1.2*mm + height: text.height + 0.4*mm color: sunken ? "#49d" :__backgroundColor SystemPalette { id: syspal } diff --git a/src/styles/SliderStyle.qml b/src/styles/SliderStyle.qml index ffdb1fb..3745009 100644 --- a/src/styles/SliderStyle.qml +++ b/src/styles/SliderStyle.qml @@ -29,9 +29,9 @@ SliderStyle{ color: "black" border.color: "#0091e5" border.width: 2 - implicitWidth: 34 - implicitHeight: 34 - radius: 16 + implicitWidth: 3.4*mm + implicitHeight: 3.4*mm + radius: 1.6*mm visible: control.enabled Text{ @@ -46,8 +46,8 @@ SliderStyle{ groove: Rectangle{ id: grove - implicitHeight: 16 - implicitWidth: 440 + implicitHeight: 1.6*mm + implicitWidth: 44*mm color: "#313131" z: 1 Rectangle{ @@ -72,9 +72,9 @@ SliderStyle{ verticalCenter: dataLine.verticalCenter } source: "images/slider-handle-left.svg" - height: 34 + height: 3.4*mm visible: control.enabled - width: (styleData.handlePosition > 80) ? 80 : styleData.handlePosition + width: (styleData.handlePosition > 8*mm) ? 8*mm : styleData.handlePosition sourceSize.width: width sourceSize.height: height } diff --git a/src/styles/TextFieldStyle.qml b/src/styles/TextFieldStyle.qml index 5d641be..3f8b846 100644 --- a/src/styles/TextFieldStyle.qml +++ b/src/styles/TextFieldStyle.qml @@ -25,11 +25,11 @@ TextFieldStyle { selectedTextColor: Theme.textField.selectedTextColor selectionColor: Theme.textField.selectionColor textColor: Theme.textField.selectedTextColor - font.pointSize: 14 + font.pointSize: 1.4*mm font.family: Theme.textField.font background: Item { - anchors.leftMargin: 16 - anchors.rightMargin: 16 + anchors.leftMargin: 1.6*mm + anchors.rightMargin: 1.6*mm opacity: control.enabled ? 1 : 0.6 Image { anchors.fill: parent diff --git a/src/styles/ToolBarStyle.qml b/src/styles/ToolBarStyle.qml index 8ae7108..ac59026 100644 --- a/src/styles/ToolBarStyle.qml +++ b/src/styles/ToolBarStyle.qml @@ -28,8 +28,8 @@ Style { padding.bottom: 3 property Component panel: Item { - implicitHeight: 75 - implicitWidth: 400 + implicitHeight: 7.5*mm + implicitWidth: 40*mm Rectangle { anchors.fill: parent color: Theme.toolBar.background diff --git a/src/styles/ToolButtonStyle.qml b/src/styles/ToolButtonStyle.qml index bc44037..12fb055 100644 --- a/src/styles/ToolButtonStyle.qml +++ b/src/styles/ToolButtonStyle.qml @@ -31,8 +31,8 @@ Style { id: styleitem //TODO: Maybe we want to add a descriptive text at the bottom of the icon? - implicitWidth: 50 - implicitHeight: 50 + implicitWidth: 5*mm + implicitHeight: 5*mm opacity: control.pressed ? 0.5 : 1 @@ -47,7 +47,7 @@ Style { id: icon anchors.fill: parent fillMode: Image.PreserveAspectFit - anchors.margins: 8 + anchors.margins: 0.8*mm source: control.iconSource } } From c4206d08497741e2d9ae47fa2608c4fff5920318 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Fri, 7 Apr 2017 20:45:24 +0300 Subject: [PATCH 03/15] [Sizing] add density independence pixel sizes --- src/controls/ButtonRow.qml | 10 +-- .../qquicknemocontrolsextensionplugin.cpp | 3 +- src/controls/sizing.cpp | 74 +++++++++++++++++-- src/controls/sizing.h | 36 ++++++++- src/styles/ButtonStyle.qml | 4 +- src/styles/CheckBoxStyle.qml | 17 ++--- src/styles/GrooveStyle.qml | 4 +- src/styles/MenuBarStyle.qml | 4 +- src/styles/SliderStyle.qml | 14 ++-- src/styles/TextFieldStyle.qml | 6 +- src/styles/ToolBarStyle.qml | 4 +- src/styles/ToolButtonStyle.qml | 6 +- 12 files changed, 135 insertions(+), 47 deletions(-) diff --git a/src/controls/ButtonRow.qml b/src/controls/ButtonRow.qml index 1cb8a05..6e50bf7 100644 --- a/src/controls/ButtonRow.qml +++ b/src/controls/ButtonRow.qml @@ -36,7 +36,7 @@ Rectangle { id: main width: childrenRect.width color: "#313131" - height: 4*mm + height: size.dp(40) property ListModel model: ListModel {} property bool enabled: true property int currentIndex: -1 @@ -51,10 +51,10 @@ Rectangle { Rectangle{ id: selecter x: rowElement.children[main.currentIndex].x || 0 - y: -0.5*mm + y: size.dp(-5) width: rowElement.children[main.currentIndex].width || 0 - height: 5*mm + height: size.dp(50) color: "#0091e5" visible: main.currentIndex > -1 @@ -74,10 +74,10 @@ Rectangle { model: main.model delegate: Rectangle { id: rowItem - height: 5*mm + height: size.dp(50) width: text.width+(text.width/name.length*2) - y: -0.5*mm + y: size.dp(-5) color: "transparent" MouseArea { diff --git a/src/controls/qquicknemocontrolsextensionplugin.cpp b/src/controls/qquicknemocontrolsextensionplugin.cpp index 8dee1a0..06cd56c 100644 --- a/src/controls/qquicknemocontrolsextensionplugin.cpp +++ b/src/controls/qquicknemocontrolsextensionplugin.cpp @@ -53,8 +53,7 @@ void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, con QQmlExtensionPlugin::initializeEngine(engine,uri); QQmlContext* context = engine->rootContext(); - - context->setContextProperty("mm",sizing->getScaleFactor()); + context->setContextProperty("size",sizing); engine->addImageProvider(QLatin1String("theme"), new NemoImageProvider); } diff --git a/src/controls/sizing.cpp b/src/controls/sizing.cpp index f430f26..f3a95a0 100644 --- a/src/controls/sizing.cpp +++ b/src/controls/sizing.cpp @@ -7,7 +7,10 @@ Sizing::Sizing(QObject *parent) : QObject(parent) { m_valid = false; - m_scale_factor = 10; + m_mm_factor = 10; + m_dp_factor = 1; + + m_densitie = mdpi; m_p_height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt(); m_p_width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt(); @@ -17,9 +20,32 @@ Sizing::Sizing(QObject *parent) : QObject(parent) m_height = screen->size().height(); m_width = screen->size().width(); + m_dpi = screen->physicalDotsPerInch(); + + qDebug() << "DPI is " << m_dpi; + + if(m_dpi < 140){ + m_densitie = ldpi; + }else if(m_dpi >= 140 && m_dpi < 200){ + //~160dpi + m_densitie = mdpi; + }else if(m_dpi >= 200 && m_dpi < 280){ + //~240dpi + m_densitie = hdpi; + }else if(m_dpi >= 280 && m_dpi < 400){ + //~320dpi + m_densitie = xhdpi; + }else if(m_dpi >= 400 && m_dpi < 560){ + //~480dpi + m_densitie = xxhdpi; + }else{ + m_densitie = xxxhdpi; + } + if(m_p_height > 0 && m_p_width >0){ m_valid = true; - scaleFactor(); + setMmScaleFactor(); + setDpScaleFactor(); }else{ if(m_p_height == 0){ qWarning("QT_QPA_EGLFS_PHYSICAL_HEIGHT is not set!"); @@ -28,18 +54,52 @@ Sizing::Sizing(QObject *parent) : QObject(parent) if(m_p_width == 0){ qWarning("QT_QPA_EGLFS_PHYSICAL_WIDTH is not set!"); } - - qWarning("Device sizing don`t work"); + qWarning("Device mm sizing don`t work"); } } -void Sizing::scaleFactor() +void Sizing::setMmScaleFactor() { if(m_p_width != 0){ - m_scale_factor = m_width/m_p_width; + m_mm_factor = m_width/m_p_width; } - qDebug() << "Scale factor is " << m_scale_factor; + qDebug() << "MM scale factor is " << m_mm_factor; } +void Sizing::setDpScaleFactor() +{ + switch (m_densitie) { + case ldpi: + m_dp_factor = 0.75; + break; + case mdpi: + m_dp_factor = 1; + break; + case hdpi: + m_dp_factor = 1.5; + break; + case xhdpi: + m_dp_factor = 2; + break; + case xxhdpi: + m_dp_factor = 3; + break; + case xxxhdpi: + m_dp_factor = 4; + break; + default: + m_dp_factor = 1; + break; + } +} +float Sizing::mm(float value) +{ + return value*m_mm_factor; +} + +float Sizing::dp(float value) +{ + return value*m_dp_factor; +} diff --git a/src/controls/sizing.h b/src/controls/sizing.h index 5bbbaca..eb1e9d8 100644 --- a/src/controls/sizing.h +++ b/src/controls/sizing.h @@ -3,25 +3,55 @@ #include +#ifndef Q_ENUM +#define Q_ENUM(x) Q_ENUMS(x) +#endif + class Sizing : public QObject { Q_OBJECT public: explicit Sizing(QObject *parent = 0); + + enum Densitie{ + ldpi, + mdpi, + hdpi, + xhdpi, + xxhdpi, + xxxhdpi + }; + Q_ENUM(Densities) + bool isValid(){return m_valid;} - int getScaleFactor(){return m_scale_factor;} + + float getMmScaleFactor(){return m_mm_factor;} + float getDpScaleFactor(){return m_dp_factor;} + + Densitie getDensitie(); + + Q_INVOKABLE float mm(float value); + Q_INVOKABLE float dp(float value); private: bool m_valid; int m_p_width; int m_p_height; + int m_width; int m_height; - int m_scale_factor; + float m_mm_factor; + float m_dp_factor; + + qreal m_dpi; + + Densitie m_densitie; + + void setMmScaleFactor(); + void setDpScaleFactor(); - void scaleFactor(); }; #endif // SIZING_H diff --git a/src/styles/ButtonStyle.qml b/src/styles/ButtonStyle.qml index 8662a21..284e198 100644 --- a/src/styles/ButtonStyle.qml +++ b/src/styles/ButtonStyle.qml @@ -30,8 +30,8 @@ ButtonStyle { // The background of the button. background: Rectangle { - implicitWidth: 24*mm - implicitHeight: 5*mm + implicitWidth: size.dp(240) + implicitHeight: size.dp(50) clip: true color: control.primary ? Theme.primaryButton.background : Theme.button.background diff --git a/src/styles/CheckBoxStyle.qml b/src/styles/CheckBoxStyle.qml index ff7d57c..b18a1e7 100644 --- a/src/styles/CheckBoxStyle.qml +++ b/src/styles/CheckBoxStyle.qml @@ -39,21 +39,21 @@ CheckBoxStyle { indicator: Rectangle { id: background color: "transparent" - implicitWidth: 7.2*mm - implicitHeight: 3.2*mm + implicitWidth: size.dp(72) + implicitHeight: size.dp(32) Rectangle { id: back1 - implicitWidth: 7.2*mm - implicitHeight: 2.8*mm + implicitWidth: size.dp(72) + implicitHeight: size.dp(28) color: Theme.checkbox.back1 anchors.centerIn: parent } Rectangle { id: back2 - implicitWidth: 7.2*mm - implicitHeight: 2.8*mm + implicitWidth: size.dp(72) + implicitHeight: size.dp(28) color: Theme.checkbox.back2 anchors.centerIn: parent } @@ -73,14 +73,13 @@ CheckBoxStyle { } else { anim2.restart() } - } } Component.onCompleted: { back1.opacity = control.checked ? 1 : 0 back2.opacity = control.checked ? 0 : 1 - ball.x = control.checked ? 3.2*mm : 0 + ball.x = control.checked ? size.dp(32) : 0 } SequentialAnimation { @@ -89,7 +88,7 @@ CheckBoxStyle { NumberAnimation { target: ball property: "x" - to: 3.2*mm + to: size.dp(32) duration: 120 } NumberAnimation { diff --git a/src/styles/GrooveStyle.qml b/src/styles/GrooveStyle.qml index f64137a..846ee6f 100644 --- a/src/styles/GrooveStyle.qml +++ b/src/styles/GrooveStyle.qml @@ -22,8 +22,8 @@ import QtQuick.Controls.Styles.Nemo 1.0 Component { Rectangle { - implicitHeight: 1.6*mm - implicitWidth: 44*mm + implicitHeight: size.dp(16) + implicitWidth: size.dp(440) color: Theme.groove.background Rectangle { antialiasing: true diff --git a/src/styles/MenuBarStyle.qml b/src/styles/MenuBarStyle.qml index 5eb3e30..4effd6e 100644 --- a/src/styles/MenuBarStyle.qml +++ b/src/styles/MenuBarStyle.qml @@ -59,8 +59,8 @@ Style { } property Component menuItem: Rectangle { - width: text.width + 1.2*mm - height: text.height + 0.4*mm + width: text.width + 12 + height: text.height + 4 color: sunken ? "#49d" :__backgroundColor SystemPalette { id: syspal } diff --git a/src/styles/SliderStyle.qml b/src/styles/SliderStyle.qml index 3745009..f223417 100644 --- a/src/styles/SliderStyle.qml +++ b/src/styles/SliderStyle.qml @@ -29,9 +29,9 @@ SliderStyle{ color: "black" border.color: "#0091e5" border.width: 2 - implicitWidth: 3.4*mm - implicitHeight: 3.4*mm - radius: 1.6*mm + implicitWidth: size.dp(34) + implicitHeight: size.dp(34) + radius: size.dp(16) visible: control.enabled Text{ @@ -46,8 +46,8 @@ SliderStyle{ groove: Rectangle{ id: grove - implicitHeight: 1.6*mm - implicitWidth: 44*mm + implicitHeight: size.dp(16) + implicitWidth: size.dp(440) color: "#313131" z: 1 Rectangle{ @@ -72,9 +72,9 @@ SliderStyle{ verticalCenter: dataLine.verticalCenter } source: "images/slider-handle-left.svg" - height: 3.4*mm + height: size.dp(34) visible: control.enabled - width: (styleData.handlePosition > 8*mm) ? 8*mm : styleData.handlePosition + width: (styleData.handlePosition > size.dp(80)) ? size.dp(80) : styleData.handlePosition sourceSize.width: width sourceSize.height: height } diff --git a/src/styles/TextFieldStyle.qml b/src/styles/TextFieldStyle.qml index 3f8b846..fff49ec 100644 --- a/src/styles/TextFieldStyle.qml +++ b/src/styles/TextFieldStyle.qml @@ -25,11 +25,11 @@ TextFieldStyle { selectedTextColor: Theme.textField.selectedTextColor selectionColor: Theme.textField.selectionColor textColor: Theme.textField.selectedTextColor - font.pointSize: 1.4*mm + font.pointSize: size.dp(14) font.family: Theme.textField.font background: Item { - anchors.leftMargin: 1.6*mm - anchors.rightMargin: 1.6*mm + anchors.leftMargin: size.dp(16) + anchors.rightMargin: size.dp(16) opacity: control.enabled ? 1 : 0.6 Image { anchors.fill: parent diff --git a/src/styles/ToolBarStyle.qml b/src/styles/ToolBarStyle.qml index ac59026..a5023b8 100644 --- a/src/styles/ToolBarStyle.qml +++ b/src/styles/ToolBarStyle.qml @@ -28,8 +28,8 @@ Style { padding.bottom: 3 property Component panel: Item { - implicitHeight: 7.5*mm - implicitWidth: 40*mm + implicitHeight: size.dp(75) + implicitWidth: size.dp(40) Rectangle { anchors.fill: parent color: Theme.toolBar.background diff --git a/src/styles/ToolButtonStyle.qml b/src/styles/ToolButtonStyle.qml index 12fb055..c8999e2 100644 --- a/src/styles/ToolButtonStyle.qml +++ b/src/styles/ToolButtonStyle.qml @@ -31,8 +31,8 @@ Style { id: styleitem //TODO: Maybe we want to add a descriptive text at the bottom of the icon? - implicitWidth: 5*mm - implicitHeight: 5*mm + implicitWidth: size.dp(50) + implicitHeight: size.dp(50) opacity: control.pressed ? 0.5 : 1 @@ -47,7 +47,7 @@ Style { id: icon anchors.fill: parent fillMode: Image.PreserveAspectFit - anchors.margins: 0.8*mm + anchors.margins: size.dp(8) source: control.iconSource } } From 48057b7abbb3b37de81cc7b6fe22a45da7db453e Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sat, 8 Apr 2017 06:49:33 +0300 Subject: [PATCH 04/15] [CheckBoxStyle] fix size of chechbox switcher --- src/styles/CheckBoxStyle.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/styles/CheckBoxStyle.qml b/src/styles/CheckBoxStyle.qml index b18a1e7..167ae0c 100644 --- a/src/styles/CheckBoxStyle.qml +++ b/src/styles/CheckBoxStyle.qml @@ -61,6 +61,8 @@ CheckBoxStyle { Image { id: ball + width: size.dp(32) + height: size.dp(32) source: "images/switch-ball.png" anchors.verticalCenter: parent.verticalCenter } From 0788338b1161ba84c78c501e206a9d6d5a92f061 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sat, 8 Apr 2017 07:02:45 +0300 Subject: [PATCH 05/15] [TextField] fix issue #4 --- examples/touch/content/TextInputPage.qml | 22 +++++++++++----------- src/styles/TextFieldStyle.qml | 3 +++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/touch/content/TextInputPage.qml b/examples/touch/content/TextInputPage.qml index f9c3c94..6417b22 100644 --- a/examples/touch/content/TextInputPage.qml +++ b/examples/touch/content/TextInputPage.qml @@ -65,36 +65,36 @@ Page { headerTools: HeaderToolsLayout { showBackButton: true; title: "Text input" } Column { - spacing: 40 + spacing: size.dp(40) anchors.centerIn: parent TextField { - anchors.margins: 20 + anchors.margins: size.dp(20) text: "Text input" //style: touchStyle } TextField { - anchors.margins: 20 + anchors.margins: size.dp(20) text: "Readonly Text input" //style: touchStyle readOnly: true } TextField { - anchors.margins: 20 + anchors.margins: size.dp(20) text: "Disabled textfield" enabled: false } TextField { - anchors.margins: 20 + anchors.margins: size.dp(20) text: "Text input" style: touchStyle } TextField { - anchors.margins: 20 + anchors.margins: size.dp(20) text: "Readonly Text input" style: touchStyle readOnly: true @@ -107,14 +107,14 @@ Page { TextFieldStyle { textColor: "white" - font.pixelSize: 28 + font.pixelSize: size.dp(28) background: Item { - implicitHeight: 50 - implicitWidth: 320 + implicitHeight: size.dp(50) + implicitWidth: size.dp(320) BorderImage { source: "../images/textinput.png" - border.left: 8 - border.right: 8 + border.left: size.dp(8) + border.right: size.dp(8) anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right diff --git a/src/styles/TextFieldStyle.qml b/src/styles/TextFieldStyle.qml index fff49ec..5df3e0a 100644 --- a/src/styles/TextFieldStyle.qml +++ b/src/styles/TextFieldStyle.qml @@ -27,9 +27,12 @@ TextFieldStyle { textColor: Theme.textField.selectedTextColor font.pointSize: size.dp(14) font.family: Theme.textField.font + background: Item { anchors.leftMargin: size.dp(16) anchors.rightMargin: size.dp(16) + implicitHeight: size.dp(50) + implicitWidth: size.dp(320) opacity: control.enabled ? 1 : 0.6 Image { anchors.fill: parent From 4cb4baf35db0fe76bd0803d46448346fa3134ce8 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sat, 8 Apr 2017 07:10:10 +0300 Subject: [PATCH 06/15] [Tabs] fix issue #3 --- examples/touch/content/TabBarPage.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/touch/content/TabBarPage.qml b/examples/touch/content/TabBarPage.qml index 73a4aa7..5427c4d 100644 --- a/examples/touch/content/TabBarPage.qml +++ b/examples/touch/content/TabBarPage.qml @@ -74,23 +74,23 @@ Page { frame: Item { } tab: Item { implicitWidth: control.width/control.count - implicitHeight: 50 + implicitHeight: size.dp(50) BorderImage { anchors.fill: parent - border.bottom: 8 - border.top: 8 + border.bottom: size.dp(8) + border.top: size.dp(8) source: styleData.selected ? "../images/tab_selected.png":"../images/tabs_standard.png" Text { anchors.centerIn: parent color: "white" text: styleData.title.toUpperCase() - font.pixelSize: 16 + font.pixelSize: size.dp(16) } Rectangle { visible: index > 0 anchors.top: parent.top anchors.bottom: parent.bottom - anchors.margins: 10 + anchors.margins: size.dp(10) width:1 color: "#3a3a3a" } From e0c708ff203ed4e143972a58a7ca84f7779cd91e Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sat, 8 Apr 2017 07:17:03 +0300 Subject: [PATCH 07/15] [Header] add scale fix issue #1 --- src/controls/Header.qml | 4 ++-- src/controls/HeaderToolsLayout.qml | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/controls/Header.qml b/src/controls/Header.qml index d25eb62..85b4c2f 100644 --- a/src/controls/Header.qml +++ b/src/controls/Header.qml @@ -62,7 +62,7 @@ Item { PropertyChanges { target: toolBarRect width: parent.width - height: 75 + height: size.dp(75) } }, State { @@ -91,7 +91,7 @@ Item { } PropertyChanges { target: toolBarRect - width: 75 + width: size.dp(75) height: parent.height } } diff --git a/src/controls/HeaderToolsLayout.qml b/src/controls/HeaderToolsLayout.qml index c40e017..6c2d53c 100644 --- a/src/controls/HeaderToolsLayout.qml +++ b/src/controls/HeaderToolsLayout.qml @@ -25,13 +25,13 @@ Item { Rectangle { id: backButton - width: opacity ? 60 : 0 - anchors.leftMargin: 20 + width: opacity ? size.dp(60) : 0 + anchors.leftMargin: size.dp(20) //check if Stack.view has already been initialized as well anchors.verticalCenter: parent.verticalCenter antialiasing: true height: width - radius: 4 + radius: size.dp(4) color: backmouse.pressed ? "#222" : "transparent" rotation: isUiPortrait ? 0 : 90 @@ -46,7 +46,7 @@ Item { MouseArea { id: backmouse anchors.fill: parent - anchors.margins: -10 + anchors.margins: size.dp(-10) onClicked: header && header.stackView && header.stackView.pop() } } @@ -56,16 +56,16 @@ Item { anchors.right: toolButtonsContainer.left anchors.left: backButton.visible ? backButton.right : parent.left anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 20 - anchors.rightMargin: 20 + anchors.leftMargin: size.dp(20) + anchors.rightMargin: size.dp(20) clip: true font.family: Theme.fontFamily color: Theme.label.color - font.pointSize: 24 + font.pointSize: size.dp(24) font.weight: Font.Bold LinearGradient { anchors.right: parent.right - width: 50 + width: size.dp(50) height: parent.paintedHeight visible: titleTxt.paintedWidth > titleTxt.width start: Qt.point(0,0) @@ -79,9 +79,9 @@ Item { Item { id: toolButtonsContainer anchors.right: dots.visible ? dots.left : parent.right - anchors.rightMargin: 20 + anchors.rightMargin: size.dp(20) anchors.verticalCenter: parent.verticalCenter - width: tools ? (50 * Math.min(maxNumberOfToolButtons, tools.length)) : 0 + width: tools ? (size.dp(50) * Math.min(maxNumberOfToolButtons, tools.length)) : 0 property int maxNumberOfToolButtons: 3 @@ -107,7 +107,7 @@ Item { Image { id: dots anchors.right: parent.right - anchors.rightMargin: 20 + anchors.rightMargin: size.dp(20) anchors.verticalCenter: parent.verticalCenter visible: drawerLevels && drawerLevels.length > 1 source: "../Styles/Nemo/images/dots-vertical.png" From c2d7f34a83b1ab10cb5937c031b0811b46999825 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:23:04 +0300 Subject: [PATCH 08/15] [Sizing] Fix dp scaling --- src/controls/sizing.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/controls/sizing.cpp b/src/controls/sizing.cpp index f3a95a0..095a31f 100644 --- a/src/controls/sizing.cpp +++ b/src/controls/sizing.cpp @@ -71,27 +71,29 @@ void Sizing::setDpScaleFactor() { switch (m_densitie) { case ldpi: - m_dp_factor = 0.75; + m_dp_factor = 0.5; break; case mdpi: - m_dp_factor = 1; + m_dp_factor = 0.6; break; case hdpi: - m_dp_factor = 1.5; + m_dp_factor = 1; break; case xhdpi: - m_dp_factor = 2; + m_dp_factor = 1.3; break; case xxhdpi: - m_dp_factor = 3; + m_dp_factor = 2; break; case xxxhdpi: - m_dp_factor = 4; + m_dp_factor = 2.5; break; default: - m_dp_factor = 1; + m_dp_factor = 1.3; break; } + + qDebug() << "DP scale factor is " << m_dp_factor; } float Sizing::mm(float value) From 2809324194d0315074843ef1abc0ae0afd8fc3e7 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:23:28 +0300 Subject: [PATCH 09/15] [CheckBox] fix checker size --- src/styles/CheckBoxStyle.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/CheckBoxStyle.qml b/src/styles/CheckBoxStyle.qml index 167ae0c..0a8bead 100644 --- a/src/styles/CheckBoxStyle.qml +++ b/src/styles/CheckBoxStyle.qml @@ -61,7 +61,7 @@ CheckBoxStyle { Image { id: ball - width: size.dp(32) + width: size.dp(40) height: size.dp(32) source: "images/switch-ball.png" anchors.verticalCenter: parent.verticalCenter From affcc596d51ecebaa9565a9ef3ac13f3b153d26e Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:42:20 +0300 Subject: [PATCH 10/15] [ButtonRow] fix size --- src/controls/ButtonRow.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/controls/ButtonRow.qml b/src/controls/ButtonRow.qml index 6e50bf7..c317224 100644 --- a/src/controls/ButtonRow.qml +++ b/src/controls/ButtonRow.qml @@ -74,11 +74,9 @@ Rectangle { model: main.model delegate: Rectangle { id: rowItem - height: size.dp(50) + height: size.dp(40) width: text.width+(text.width/name.length*2) - y: size.dp(-5) - color: "transparent" MouseArea { width: parent.width @@ -93,6 +91,7 @@ Rectangle { Label { id: text text: name + height: parent.heigh anchors.horizontalCenter: parent.horizontalCenter From b08594ec33b7d052078dfd81773eeae6100c28ec Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:44:19 +0300 Subject: [PATCH 11/15] [ListViewItemWithAction] add scaling --- src/controls/ListViewItemWithActions.qml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/controls/ListViewItemWithActions.qml b/src/controls/ListViewItemWithActions.qml index b5bafdc..db51ef5 100644 --- a/src/controls/ListViewItemWithActions.qml +++ b/src/controls/ListViewItemWithActions.qml @@ -66,13 +66,13 @@ Item { Image{ id: itemIcon - height: parent.height-10 + height: parent.height-size.dp(10) width: height anchors{ left: parent.left - leftMargin: 20 + leftMargin: size.dp(20) top: parent.top - topMargin: 5 + topMargin: size.dp(5) } sourceSize.width: width @@ -84,13 +84,13 @@ Item { Rectangle{ id: dataArea - width: parent.width-itemIcon.width-arrowItem.width-60 + width: parent.width-itemIcon.width-arrowItem.width-size.dp(60) height: labelItem.height+(description != "" ? descriptionItem.height : 0)+(subdescription != "" ? subDescriptionItem.height : 0) clip: true anchors{ left:itemIcon.right - leftMargin: 20 + leftMargin: size.dp(20) verticalCenter: itemIcon.verticalCenter } color: "transparent" @@ -103,7 +103,7 @@ Item { left: parent.left right: parent.right } - font.pixelSize: 30 + font.pixelSize: size.dp(30) clip: true } @@ -116,7 +116,7 @@ Item { right: parent.right top: labelItem.bottom } - font.pixelSize: 18 + font.pixelSize: size.dp(18) clip: true visible: description != "" } @@ -130,13 +130,13 @@ Item { right: parent.right top: descriptionItem.bottom } - font.pixelSize: 18 + font.pixelSize: size.dp(18) clip: true visible: subdescription != "" } Item{ - width: 15 + width: size.dp(15) height: parent.height anchors{ top: parent.top @@ -146,7 +146,7 @@ Item { LinearGradient{ anchors.fill: parent start: Qt.point(0, 0) - end: Qt.point(15, 0) + end: Qt.point(size.dp(15), 0) gradient: Gradient { GradientStop { position: 0.0; color: "transparent" } GradientStop { position: 1.0; color: "black" } @@ -157,12 +157,12 @@ Item { Image { id: arrowItem - height: parent.height-10 + height: parent.height-size.dp(10) width: height anchors{ right: parent.right - rightMargin: 20 + rightMargin: size.dp(20) verticalCenter: parent.verticalCenter } From 9906bc68f428c28dbb4a2c9c40ef1ab3cdb6efea Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:47:42 +0300 Subject: [PATCH 12/15] [ListView] add scaling --- src/controls/ListView.qml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/controls/ListView.qml b/src/controls/ListView.qml index 9a7e75c..9453249 100644 --- a/src/controls/ListView.qml +++ b/src/controls/ListView.qml @@ -15,18 +15,18 @@ ListView { id: sectionHeading Rectangle { width: listView.width - height: 44 + height: size.dp(44) color: "black" Text { id: sectionText text: section font.capitalization: Font.AllUppercase - font.pixelSize: 20 + font.pixelSize: size.dp(20) color: "white" anchors{ left: parent.left - leftMargin: 10 + leftMargin: size.dp(10) verticalCenter: parent.verticalCenter } } @@ -35,10 +35,10 @@ ListView { id: line height: 1 color: "white" - width: listView.width-sectionText.width-30 + width: listView.width-sectionText.width-size.dp(30) anchors{ left: sectionText.right - leftMargin: 10 + leftMargin: size.dp(10) verticalCenter: sectionText.verticalCenter } } @@ -48,7 +48,7 @@ ListView { Item{ id: bottom width: parent.width - height: 30 + height: size.dp(30) anchors.bottom: parent.bottom visible: listView.contentHeight > listView.height @@ -56,7 +56,7 @@ ListView { LinearGradient{ anchors.fill: parent start: Qt.point(0, 0) - end: Qt.point(0, 30) + end: Qt.point(0, size.dp(30)) gradient: Gradient { GradientStop { position: 0.0; color: "transparent" } GradientStop { position: 1.0; color: "black" } @@ -70,13 +70,13 @@ ListView { visible: (listView.showDecorator && listView.contentHeight > listView.height) color: "#0091e5" - width: 5 + width: size.dp(5) height: listView.height*listView.height/listView.contentHeight y: (listView.height)/listView.contentHeight*listView.contentY anchors{ right: listView.right - rightMargin: 4 + rightMargin: size.dp(4) } } } From 5b1fee8d5ffb620bc7f2b91f95bd7e205209e123 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:50:12 +0300 Subject: [PATCH 13/15] [GlacierRoller] add scaling --- src/controls/GlacierRoller.qml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controls/GlacierRoller.qml b/src/controls/GlacierRoller.qml index 793d52a..f4afed2 100644 --- a/src/controls/GlacierRoller.qml +++ b/src/controls/GlacierRoller.qml @@ -21,7 +21,7 @@ Item { id: label visible: label.text != "" font.capitalization: Font.AllUppercase - font.pixelSize: 14 + font.pixelSize: size.dp(14) color: "white" anchors{ @@ -51,19 +51,19 @@ Item { PathView{ id: view - property int itemHeight: 40 + property int itemHeight: size.dp(40) property bool showRow: false interactive: activated - width: parent.width-60 - height: 40 + width: parent.width-size.dp(60) + height: size.dp(40) clip: true anchors{ top: label.top - topMargin: 20 + topMargin: size.dp(20) left: label.left - leftMargin: 30 + leftMargin: size.dp(30) } pathItemCount: height/itemHeight From 1971d150b4d9d1859e53d59989534fbddfd4e7d5 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Sun, 9 Apr 2017 10:50:31 +0300 Subject: [PATCH 14/15] [Label] add scaling --- src/controls/Label.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/Label.qml b/src/controls/Label.qml index c76aa55..f163e90 100644 --- a/src/controls/Label.qml +++ b/src/controls/Label.qml @@ -35,5 +35,5 @@ Text { renderType: Text.NativeRendering font.family: Theme.fontFamily color: Theme.label.color - font.pointSize: Theme.label.pointSize + font.pointSize: size.dp(Theme.label.pointSize) } From e96571cfa1bf8d43ce9548c177ad41a421f3e0b1 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 10 Apr 2017 13:14:25 +0300 Subject: [PATCH 15/15] [Packaking] fix qt 5.6 build --- src/controls/sizing.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controls/sizing.h b/src/controls/sizing.h index eb1e9d8..57fc8c1 100644 --- a/src/controls/sizing.h +++ b/src/controls/sizing.h @@ -3,10 +3,11 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(5,6,0) #ifndef Q_ENUM #define Q_ENUM(x) Q_ENUMS(x) #endif - +#endif class Sizing : public QObject { Q_OBJECT @@ -21,8 +22,11 @@ class Sizing : public QObject xxhdpi, xxxhdpi }; +#if QT_VERSION < QT_VERSION_CHECK(5,6,0) Q_ENUM(Densities) - +#else + Q_ENUMS(Densities) +#endif bool isValid(){return m_valid;} float getMmScaleFactor(){return m_mm_factor;}