From b9d97ddc5b33a374a3b67fb03549cafdd7c4c9cc Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 7 Dec 2020 15:17:09 +0100 Subject: [PATCH] Some fixes for regressions after the style changes --- androidservice/controlviews/Main.qml | 29 ++++++++++++++----- .../controlviews/devicecontrolapplication.cpp | 14 +++++++++ nymea-app/styles/light/Button.qml | 3 +- nymea-app/ui/devicepages/DeviceLogPage.qml | 3 +- .../ui/thingconfiguration/NewThingPage.qml | 3 +- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/androidservice/controlviews/Main.qml b/androidservice/controlviews/Main.qml index c87839d2..ff445f9f 100644 --- a/androidservice/controlviews/Main.qml +++ b/androidservice/controlviews/Main.qml @@ -10,24 +10,37 @@ ApplicationWindow { id: app visible: true visibility: ApplicationWindow.FullScreen - color: Material.background - - // Those variables must be present in the Style title: appName - Material.primary: primaryColor - Material.accent: accentColor - Material.foreground: foregroundColor + + Material.theme: NymeaUtils.isDark(Style.backgroundColor) ? Material.Dark : Material.Light + Material.background: Style.backgroundColor + Material.primary: Style.headerBackgroundColor + Material.accent: Style.accentColor + Material.foreground: Style.foregroundColor + + font.pixelSize: mediumFont + font.weight: Font.Normal + font.capitalization: Font.MixedCase + font.family: Style.fontFamily + + property string appName: "appBranding" in app ? app.appBranding : "nymea:app" + property string systemName: "coreBranding" in app ? app.coreBranding : "nymea" property int margins: 16 property int bigMargins: 20 + property int extraSmallFont: 10 property int smallFont: 13 property int mediumFont: 16 property int largeFont: 20 - property int iconSize: 30 + + property int smallIconSize: 16 + property int iconSize: 24 + property int largeIconSize: 40 + property int hugeIconSize: 64 + property int delegateHeight: 60 - property color backgroundColor: Material.background readonly property bool landscape: app.width > app.height diff --git a/androidservice/controlviews/devicecontrolapplication.cpp b/androidservice/controlviews/devicecontrolapplication.cpp index 06758a40..168abf8a 100644 --- a/androidservice/controlviews/devicecontrolapplication.cpp +++ b/androidservice/controlviews/devicecontrolapplication.cpp @@ -46,6 +46,20 @@ DeviceControlApplication::DeviceControlApplication(int argc, char *argv[]) : QAp qmlRegisterSingletonType("Nymea", 1, 0, "NfcHelper", NfcHelper::nfcHelperProvider); StyleController *styleController = new StyleController(this); + + QQmlFileSelector *styleSelector = new QQmlFileSelector(m_qmlEngine); + styleSelector->setExtraSelectors({styleController->currentStyle()}); + + foreach (const QFileInfo &fi, QDir(":/ui/fonts/").entryInfoList()) { + QFontDatabase::addApplicationFont(fi.absoluteFilePath()); + } + foreach (const QFileInfo &fi, QDir(":/styles/" + styleController->currentStyle() + "/fonts/").entryInfoList()) { + qDebug() << "Adding style font:" << fi.absoluteFilePath(); + QFontDatabase::addApplicationFont(fi.absoluteFilePath()); + } + + qmlRegisterSingletonType(QUrl("qrc:///styles/" + styleController->currentStyle() + "/Style.qml"), "Nymea", 1, 0, "Style" ); + m_qmlEngine->rootContext()->setContextProperty("styleController", styleController); m_qmlEngine->rootContext()->setContextProperty("engine", m_engine); m_qmlEngine->rootContext()->setContextProperty("_engine", m_engine); diff --git a/nymea-app/styles/light/Button.qml b/nymea-app/styles/light/Button.qml index f89cd009..508250dd 100644 --- a/nymea-app/styles/light/Button.qml +++ b/nymea-app/styles/light/Button.qml @@ -34,6 +34,7 @@ import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.2 import QtQuick.Controls.Material 2.2 import QtQuick.Controls.Material.impl 2.2 +import Nymea 1.0 T.Button { id: control @@ -64,7 +65,7 @@ T.Button { font.overline: control.font.overline font.pixelSize: app.smallFont font.weight: Font.Bold - color: app.primaryColor + color: Style.backgroundColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight diff --git a/nymea-app/ui/devicepages/DeviceLogPage.qml b/nymea-app/ui/devicepages/DeviceLogPage.qml index 0cbb75da..6c5d612d 100644 --- a/nymea-app/ui/devicepages/DeviceLogPage.qml +++ b/nymea-app/ui/devicepages/DeviceLogPage.qml @@ -83,8 +83,7 @@ Page { Material.elevation: 1 leftPadding: 0; rightPadding: 0; topPadding: 0; bottomPadding: 0 - contentItem: Rectangle { - color: app.primaryColor + contentItem: Item { clip: true RowLayout { anchors.fill: parent diff --git a/nymea-app/ui/thingconfiguration/NewThingPage.qml b/nymea-app/ui/thingconfiguration/NewThingPage.qml index 0872b4a6..fdeb3df1 100644 --- a/nymea-app/ui/thingconfiguration/NewThingPage.qml +++ b/nymea-app/ui/thingconfiguration/NewThingPage.qml @@ -56,8 +56,7 @@ Page { z: 1 leftPadding: 0; rightPadding: 0; topPadding: 0; bottomPadding: 0 - contentItem: Rectangle { - color: app.primaryColor + contentItem: Item { clip: true GridLayout { anchors.fill: parent