From 8e21b17d4ca8cb6f070a2ec0f1ff263330498147 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 2 Jul 2018 23:03:31 +0200 Subject: [PATCH] attempt to get the safeAreaMargins working on iPhoneX, not working --- libnymea-app-core/devicediscovery.cpp | 2 +- libnymea-app-core/devicemanager.cpp | 2 +- nymea-app/main.cpp | 2 ++ nymea-app/ui/MainPage.qml | 14 +++++++++++--- nymea-app/ui/Nymea.qml | 3 ++- nymea-app/ui/components/MainPageTabButton.qml | 6 ++++-- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/libnymea-app-core/devicediscovery.cpp b/libnymea-app-core/devicediscovery.cpp index c495572d..e24ee23e 100644 --- a/libnymea-app-core/devicediscovery.cpp +++ b/libnymea-app-core/devicediscovery.cpp @@ -63,7 +63,7 @@ void DeviceDiscovery::discoverDevicesResponse(const QVariantMap ¶ms) m_busy = false; emit busyChanged(); - qDebug() << "response received" << params; +// qDebug() << "response received" << params; QVariantList descriptors = params.value("params").toMap().value("deviceDescriptors").toList(); foreach (const QVariant &descriptor, descriptors) { qDebug() << "descriptor" << descriptor; diff --git a/libnymea-app-core/devicemanager.cpp b/libnymea-app-core/devicemanager.cpp index 62efb381..0539f39e 100644 --- a/libnymea-app-core/devicemanager.cpp +++ b/libnymea-app-core/devicemanager.cpp @@ -150,7 +150,7 @@ void DeviceManager::getVendorsResponse(const QVariantMap ¶ms) void DeviceManager::getSupportedDevicesResponse(const QVariantMap ¶ms) { - qDebug() << "DeviceClass received:" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson(QJsonDocument::Indented)); +// qDebug() << "DeviceClass received:" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson(QJsonDocument::Indented)); if (params.value("params").toMap().keys().contains("deviceClasses")) { QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList(); foreach (QVariant deviceClassVariant, deviceClassList) { diff --git a/nymea-app/main.cpp b/nymea-app/main.cpp index 033701ed..4bc3ece3 100644 --- a/nymea-app/main.cpp +++ b/nymea-app/main.cpp @@ -80,6 +80,8 @@ int main(int argc, char *argv[]) StyleController styleController; engine->rootContext()->setContextProperty("styleController", &styleController); + engine->rootContext()->setContextProperty("systemProductType", QSysInfo::productType()); + application.setWindowIcon(QIcon(QString(":/styles/%1/logo.svg").arg(styleController.currentStyle()))); engine->load(QUrl(QLatin1String("qrc:/ui/Nymea.qml"))); diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml index 23ee8bd6..ce06f023 100644 --- a/nymea-app/ui/MainPage.qml +++ b/nymea-app/ui/MainPage.qml @@ -2,6 +2,7 @@ import QtQuick 2.8 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.2 +import QtQuick.Window 2.3 import Nymea 1.0 import "components" import "delegates" @@ -52,11 +53,13 @@ Page { Item { Layout.fillWidth: true Layout.fillHeight: true + clip: true SwipeView { id: swipeView - clip: true anchors.fill: parent + anchors.leftMargin: (systemProductType === "ios" && Screen.width === 812) ? 25 : 0 + anchors.rightMargin: anchors.leftMargin opacity: Engine.deviceManager.fetchingData ? 0 : 1 Behavior on opacity { NumberAnimation { duration: 300 } } @@ -100,7 +103,7 @@ Page { } DevicesPage { - property string title: qsTr("My things"); + property string title: qsTr("My things") width: swipeView.width height: swipeView.height model: InterfacesSortModel { @@ -175,7 +178,11 @@ Page { Material.elevation: 3 currentIndex: settings.currentMainViewIndex position: TabBar.Footer - Layout.preferredHeight: 70 + Layout.preferredHeight: 70 + (app.landscape ? + ((systemProductType === "ios" && Screen.height === 375) ? -10 : -20) : + (systemProductType === "ios" && Screen.height === 812) ? 14 : 0) + + // FIXME: All this can go away when we require Controls 2.3 (Qt 5.10) or greater as TabBar got a major rework there. // Ideally we'd just list the 3 items and set visible to false if the server version isn't good enough but TabBar // has troubles dealing with that. For now, let's manually fill it and use a timer to initialize the currentIndex. @@ -195,6 +202,7 @@ Page { MainPageTabButton { property int pageIndex: 0 onClicked: settings.currentMainViewIndex = pageIndex + alignment: app.landscape ? Qt.Horizontal : Qt.Vertical } } } diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index 1db5a18d..a642c2f4 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.1 import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.2 import Qt.labs.settings 1.0 +import QtQuick.Window 2.3 import Nymea 1.0 ApplicationWindow { @@ -10,7 +11,7 @@ ApplicationWindow { visible: true width: 360 height: 580 - visibility: ApplicationWindow.Maximized + visibility: ApplicationWindow.AutomaticVisibility font: Qt.application.font title: appName diff --git a/nymea-app/ui/components/MainPageTabButton.qml b/nymea-app/ui/components/MainPageTabButton.qml index 3156c893..5a216242 100644 --- a/nymea-app/ui/components/MainPageTabButton.qml +++ b/nymea-app/ui/components/MainPageTabButton.qml @@ -6,8 +6,10 @@ import QtQuick.Layouts 1.3 TabButton { id: root property string iconSource + property var alignment: Qt.Vertical - contentItem: ColumnLayout { + contentItem: GridLayout { + columns: root.alignment === Qt.Vertical ? 1 : 2 ColorIcon { Layout.preferredWidth: app.iconSize Layout.preferredHeight: app.iconSize @@ -16,7 +18,7 @@ TabButton { color: root.checked ? app.guhAccent : keyColor } Label { - Layout.fillWidth: true + Layout.fillWidth: root.alignment === Qt.Vertical text: root.text horizontalAlignment: Text.AlignHCenter font.pixelSize: app.smallFont