attempt to get the safeAreaMargins working on iPhoneX, not working

This commit is contained in:
Michael Zanetti 2018-07-02 23:03:31 +02:00
parent 2b67bec375
commit 8e21b17d4c
6 changed files with 21 additions and 8 deletions

View File

@ -63,7 +63,7 @@ void DeviceDiscovery::discoverDevicesResponse(const QVariantMap &params)
m_busy = false; m_busy = false;
emit busyChanged(); emit busyChanged();
qDebug() << "response received" << params; // qDebug() << "response received" << params;
QVariantList descriptors = params.value("params").toMap().value("deviceDescriptors").toList(); QVariantList descriptors = params.value("params").toMap().value("deviceDescriptors").toList();
foreach (const QVariant &descriptor, descriptors) { foreach (const QVariant &descriptor, descriptors) {
qDebug() << "descriptor" << descriptor; qDebug() << "descriptor" << descriptor;

View File

@ -150,7 +150,7 @@ void DeviceManager::getVendorsResponse(const QVariantMap &params)
void DeviceManager::getSupportedDevicesResponse(const QVariantMap &params) void DeviceManager::getSupportedDevicesResponse(const QVariantMap &params)
{ {
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")) { if (params.value("params").toMap().keys().contains("deviceClasses")) {
QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList(); QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList();
foreach (QVariant deviceClassVariant, deviceClassList) { foreach (QVariant deviceClassVariant, deviceClassList) {

View File

@ -80,6 +80,8 @@ int main(int argc, char *argv[])
StyleController styleController; StyleController styleController;
engine->rootContext()->setContextProperty("styleController", &styleController); engine->rootContext()->setContextProperty("styleController", &styleController);
engine->rootContext()->setContextProperty("systemProductType", QSysInfo::productType());
application.setWindowIcon(QIcon(QString(":/styles/%1/logo.svg").arg(styleController.currentStyle()))); application.setWindowIcon(QIcon(QString(":/styles/%1/logo.svg").arg(styleController.currentStyle())));
engine->load(QUrl(QLatin1String("qrc:/ui/Nymea.qml"))); engine->load(QUrl(QLatin1String("qrc:/ui/Nymea.qml")));

View File

@ -2,6 +2,7 @@ import QtQuick 2.8
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1 import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtQuick.Window 2.3
import Nymea 1.0 import Nymea 1.0
import "components" import "components"
import "delegates" import "delegates"
@ -52,11 +53,13 @@ Page {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
clip: true
SwipeView { SwipeView {
id: swipeView id: swipeView
clip: true
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: (systemProductType === "ios" && Screen.width === 812) ? 25 : 0
anchors.rightMargin: anchors.leftMargin
opacity: Engine.deviceManager.fetchingData ? 0 : 1 opacity: Engine.deviceManager.fetchingData ? 0 : 1
Behavior on opacity { NumberAnimation { duration: 300 } } Behavior on opacity { NumberAnimation { duration: 300 } }
@ -100,7 +103,7 @@ Page {
} }
DevicesPage { DevicesPage {
property string title: qsTr("My things"); property string title: qsTr("My things")
width: swipeView.width width: swipeView.width
height: swipeView.height height: swipeView.height
model: InterfacesSortModel { model: InterfacesSortModel {
@ -175,7 +178,11 @@ Page {
Material.elevation: 3 Material.elevation: 3
currentIndex: settings.currentMainViewIndex currentIndex: settings.currentMainViewIndex
position: TabBar.Footer 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. // 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 // 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. // 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 { MainPageTabButton {
property int pageIndex: 0 property int pageIndex: 0
onClicked: settings.currentMainViewIndex = pageIndex onClicked: settings.currentMainViewIndex = pageIndex
alignment: app.landscape ? Qt.Horizontal : Qt.Vertical
} }
} }
} }

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1 import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0
import QtQuick.Window 2.3
import Nymea 1.0 import Nymea 1.0
ApplicationWindow { ApplicationWindow {
@ -10,7 +11,7 @@ ApplicationWindow {
visible: true visible: true
width: 360 width: 360
height: 580 height: 580
visibility: ApplicationWindow.Maximized visibility: ApplicationWindow.AutomaticVisibility
font: Qt.application.font font: Qt.application.font
title: appName title: appName

View File

@ -6,8 +6,10 @@ import QtQuick.Layouts 1.3
TabButton { TabButton {
id: root id: root
property string iconSource property string iconSource
property var alignment: Qt.Vertical
contentItem: ColumnLayout { contentItem: GridLayout {
columns: root.alignment === Qt.Vertical ? 1 : 2
ColorIcon { ColorIcon {
Layout.preferredWidth: app.iconSize Layout.preferredWidth: app.iconSize
Layout.preferredHeight: app.iconSize Layout.preferredHeight: app.iconSize
@ -16,7 +18,7 @@ TabButton {
color: root.checked ? app.guhAccent : keyColor color: root.checked ? app.guhAccent : keyColor
} }
Label { Label {
Layout.fillWidth: true Layout.fillWidth: root.alignment === Qt.Vertical
text: root.text text: root.text
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
font.pixelSize: app.smallFont font.pixelSize: app.smallFont