From eb410aee550f9e186fe3e4b89e15bcd59c34602f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 6 Feb 2020 13:26:39 -0800 Subject: mobile UI: redo the screen size magic This still is way to fragile. Ordering of object completion doesn't appear consistent. Hopefully bringing the properties all into one (now reasonably named) object will help. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/main.qml | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index cdb1a1bad..d0e1ab9bf 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -32,8 +32,6 @@ Kirigami.ApplicationWindow { property alias defaultCylinderIndex: settingsWindow.defaultCylinderIndex property bool filterToggle: false property string filterPattern: "" - property bool firstChange: true - property int lastOrientation: undefined property int colWidth: undefined onNotificationTextChanged: { @@ -593,42 +591,41 @@ if you have network connectivity and want to sync your data to cloud storage."), } QtObject { - id: placeHolder + id: screenSizeObject property int initialWidth: rootItem.width property int initialHeight: rootItem.height + property bool firstChange: true + property int lastOrientation: undefined Component.onCompleted: { // break the binding initialWidth = initialWidth * 1 - manager.appendTextToLog("SubsufaceTheme constructor completed, initial width " + initialWidth) - if (rootItem.firstChange) // only run the setup if we haven't seen a change, yet - setupUnits() // but don't count this as a change (after all, it's not) - else - manager.appendTextToLog("Already adjusted size, ignoring this") + manager.appendTextToLog("screenSizeObject constructor completed, initial width " + initialWidth) + setupUnits() } } onWidthChanged: { manager.appendTextToLog("Window width changed to " + width + " orientation " + Screen.primaryOrientation) - if (placeHolder.initialWidth !== undefined) { - if (width !== placeHolder.initialWidth && rootItem.firstChange) { - rootItem.firstChange = false - rootItem.lastOrientation = Screen.primaryOrientation - placeHolder.initialWidth = width - placeHolder.initialHeight = height + if (screenSizeObject.initialWidth !== undefined) { + if (width !== screenSizeObject.initialWidth && screenSizeObject.firstChange) { + screenSizeObject.firstChange = false + screenSizeObject.lastOrientation = Screen.primaryOrientation + screenSizeObject.initialWidth = width + screenSizeObject.initialHeight = height manager.appendTextToLog("first real change, so recalculating units and recording size as " + width + " x " + height) setupUnits() - } else if (rootItem.lastOrientation !== undefined && rootItem.lastOrientation !== Screen.primaryOrientation) { + } else if (screenSizeObject.lastOrientation !== undefined && screenSizeObject.lastOrientation !== Screen.primaryOrientation) { manager.appendTextToLog("Screen rotated, no action necessary") - rootItem.lastOrientation = Screen.primaryOrientation + screenSizeObject.lastOrientation = Screen.primaryOrientation setupUnits() } else { manager.appendTextToLog("size change without rotation to " + width + " x " + height) - if (width > placeHolder.initialWidth) { - manager.appendTextToLog("resetting to initial width " + placeHolder.initialWidth + " and height " + placeHolder.initialHeight) - rootItem.width = placeHolder.initialWidth - rootItem.height = placeHolder.initialHeight + if ((Qt.platform.os === "android" || Qt.platform.os === "ios") && width > screenSizeObject.initialWidth) { + manager.appendTextToLog("resetting to initial width " + screenSizeObject.initialWidth + " and height " + screenSizeObject.initialHeight) + rootItem.width = screenSizeObject.initialWidth + rootItem.height = screenSizeObject.initialHeight } } } else { -- cgit v1.2.3-70-g09d2