From 1c24ac1a945fe663e3e6267131025f0141259f97 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 28 Sep 2019 14:22:00 -0700 Subject: Mobile: don't allow width change without rotation We get incorrect changes to a new screen width that causes us to try draw to a much larger screen than we actually have. Ignore those changes. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/main.qml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 3390579fb..0b5288dfd 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -35,6 +35,7 @@ Kirigami.ApplicationWindow { property bool filterToggle: false property string filterPattern: "" property bool firstChange: true + property int lastOrientation: undefined onNotificationTextChanged: { if (notificationText != "") { @@ -555,6 +556,7 @@ if you have network connectivity and want to sync your data to cloud storage."), property color lightDrawerColor: "#FFFFFF" property color darkDrawerColor: "#424242" property int initialWidth: rootItem.width + property int initialHeight: rootItem.height Component.onCompleted: { // break the binding initialWidth = initialWidth * 1 @@ -576,14 +578,25 @@ if you have network connectivity and want to sync your data to cloud storage."), } onWidthChanged: { - console.log("Window width changed to " + width) + console.log("Window width changed to " + width + " orientation " + Screen.primaryOrientation) if (subsurfaceTheme.initialWidth !== undefined) { if (width !== subsurfaceTheme.initialWidth && rootItem.firstChange) { - rootItem.firstChange = false; - console.log("first real change, so recalculating units") + rootItem.firstChange = false + rootItem.lastOrientation = Screen.primaryOrientation + subsurfaceTheme.initialWidth = width + subsurfaceTheme.initialHeight = height + console.log("first real change, so recalculating units and recording size as " + width + " x " + height) setupUnits() + } else if (rootItem.lastOrientation !== undefined && rootItem.lastOrientation != Screen.primaryOrientation) { + console.log("Screen rotated, no action necessary") + rootItem.lastOrientation = Screen.primaryOrientation } else { - console.log("not recalculating base unit") + console.log("size change without rotation to " + width + " x " + height) + if (width > subsurfaceTheme.initialWidth) { + console.log("resetting to initial width " + subsurfaceTheme.initialWidth + " and height " + subsurfaceTheme.initialHeight) + rootItem.width = subsurfaceTheme.initialWidth + rootItem.height = subsurfaceTheme.initialHeight + } } } else { console.log("width changed before initial width initialized, ignoring") -- cgit v1.2.3-70-g09d2