From 431b5e07fe6eaa1383b86a5ab16953897f642ebf Mon Sep 17 00:00:00 2001 From: Sebastian Kügler Date: Fri, 9 Oct 2015 01:57:10 +0200 Subject: QML-UI: basics for theming and hi-dpi support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Theme: For theming, we're just defining some colors centrally for now - Units: This object provides dpi-corrected sizing in the form of gridUnit. The idea is to base gridUnit on the rendered font size, so the ui scales with text size. As this interpolates font size and dpi, the sizing is rather responsive. These are the basics, now we can kill lots of hardcoded pixel values. Signed-off-by: Sebastian Kügler Signed-off-by: Dirk Hohndel --- qt-mobile/main.qml | 16 ++++++++++++++++ qt-mobile/mobile-resources.qrc | 4 ++++ qt-mobile/theme/Theme.qml | 7 +++++++ qt-mobile/theme/Units.qml | 5 +++++ 4 files changed, 32 insertions(+) create mode 100644 qt-mobile/theme/Theme.qml create mode 100644 qt-mobile/theme/Units.qml diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml index b249a333a..00ab008d3 100644 --- a/qt-mobile/main.qml +++ b/qt-mobile/main.qml @@ -6,6 +6,8 @@ import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import org.subsurfacedivelog.mobile 1.0 +import "qrc:/qml/theme" as Theme + ApplicationWindow { title: qsTr("Subsurface mobile") @@ -13,6 +15,14 @@ ApplicationWindow { property alias messageText: message.text visible: true + Theme.Units { + id: units + } + + Theme.Theme { + id: theme + } + Menu { id: prefsMenu title: "Menu" @@ -181,4 +191,10 @@ ApplicationWindow { id: logWindow visible: false } + + Component.onCompleted: { + print("main.qml laoded."); + print("gridUnit is: " + units.gridUnit); + print("hightlight : " + theme.highlightColor); + } } diff --git a/qt-mobile/mobile-resources.qrc b/qt-mobile/mobile-resources.qrc index cb31d7ea1..93cda6dc9 100644 --- a/qt-mobile/mobile-resources.qrc +++ b/qt-mobile/mobile-resources.qrc @@ -9,4 +9,8 @@ Log.qml TopBar.qml + + theme/Theme.qml + theme/Units.qml + diff --git a/qt-mobile/theme/Theme.qml b/qt-mobile/theme/Theme.qml new file mode 100644 index 000000000..5eed83fe8 --- /dev/null +++ b/qt-mobile/theme/Theme.qml @@ -0,0 +1,7 @@ +import QtQuick 2.3 + +QtObject { + property color textColor: "#333333" + property color backgroundColor: "#ececec" + property color highlightColor: "#91c4e1" +} \ No newline at end of file diff --git a/qt-mobile/theme/Units.qml b/qt-mobile/theme/Units.qml new file mode 100644 index 000000000..73ee3f8cf --- /dev/null +++ b/qt-mobile/theme/Units.qml @@ -0,0 +1,5 @@ +import QtQuick 2.3 + +QtObject { + property int gridUnit: 24 +} \ No newline at end of file -- cgit v1.2.3-70-g09d2