[PATCH 06/11] Theme tweaks

Sebastian Kügler sebas at kde.org
Fri Nov 6 13:53:26 PST 2015


- gridUnits is dynamic again, using FontMetrics now
- Add a page to display some sizing-relevant details, so we can debug
  dpi problems a bit better on Android

Signed-off-by: Sebastian Kügler <sebas at kde.org>
---
 qt-mobile/ThemeTest.qml        | 15 +++++++++++++++
 qt-mobile/main.qml             | 12 ++++++++++++
 qt-mobile/mobile-resources.qrc |  5 +++--
 qt-mobile/theme/Units.qml      | 10 +++++-----
 4 files changed, 35 insertions(+), 7 deletions(-)
 create mode 100644 qt-mobile/ThemeTest.qml

diff --git a/qt-mobile/ThemeTest.qml b/qt-mobile/ThemeTest.qml
new file mode 100644
index 0000000..55c15ed
--- /dev/null
+++ b/qt-mobile/ThemeTest.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.5
+import QtQuick.Layouts 1.1
+
+ColumnLayout {
+	id: themetest
+
+	Text {
+		text: "units.gridUnit is: " + units.gridUnit
+	}
+
+	Text {
+		text: "units.devicePixelRatio: " + units.devicePixelRatio
+
+	}
+}
diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml
index f45ab9b..f754765 100644
--- a/qt-mobile/main.qml
+++ b/qt-mobile/main.qml
@@ -72,6 +72,13 @@ ApplicationWindow {
 				stackView.push(logWindow)
 			}
 		}
+
+		MenuItem {
+			text: "Theme Information"
+			onTriggered: {
+				stackView.push(themetest)
+			}
+		}
 	}
 
 	StackView {
@@ -201,6 +208,11 @@ ApplicationWindow {
 		visible: false
 	}
 
+	ThemeTest {
+		id: themetest
+		visible: false
+	}
+
 	Component.onCompleted: {
 		print("units.gridUnit is: " + units.gridUnit);
 	}
diff --git a/qt-mobile/mobile-resources.qrc b/qt-mobile/mobile-resources.qrc
index a5875bf..c09dca5 100644
--- a/qt-mobile/mobile-resources.qrc
+++ b/qt-mobile/mobile-resources.qrc
@@ -7,8 +7,9 @@
         <file>DiveDetails.qml</file>
         <file>DownloadFromDiveComputer.qml</file>
         <file>Log.qml</file>
-        <file>TopBar.qml</file>
-        <file alias="subsurface-mobile-icon.png">../icons/subsurface-mobile-icon.png</file>
+		<file>TopBar.qml</file>
+		<file>ThemeTest.qml</file>
+		<file alias="subsurface-mobile-icon.png">../icons/subsurface-mobile-icon.png</file>
     </qresource>
     <qresource prefix="/qml/theme">
         <file alias="Theme.qml">theme/Theme.qml</file>
diff --git a/qt-mobile/theme/Units.qml b/qt-mobile/theme/Units.qml
index 9efec31..1d0899f 100644
--- a/qt-mobile/theme/Units.qml
+++ b/qt-mobile/theme/Units.qml
@@ -31,7 +31,7 @@ QtObject {
      * Given the screen has an accurate DPI settings, it corresponds to a width of
      * the capital letter M
      */
-    property int gridUnit: 20
+    property int gridUnit: fontMetrics.height
 
     /**
      * units.iconSizes provides access to platform-dependent icon sizing
@@ -95,8 +95,8 @@ QtObject {
      */
     property int shortDuration: 150
 
-//     property QtObject fontMetrics: FontMetrics {
-//         //id: textSpacer
-//         //text: "M"
-//     }
+    property QtObject fontMetrics: FontMetrics {
+        //id: textSpacer
+        //text: "M"
+    }
 }
-- 
2.6.2



More information about the subsurface mailing list