From c90050f4494e1a051a628b19d02d6ef39a0d4327 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 23 Sep 2019 13:57:22 -0700 Subject: Mobile: recalculate base units only for first real change Different Android devices seem to have different patterns of throwing incorrect width information at us. This seems like a really bad hack, but for the ones I've seen so far this should give us the right width information. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/main.qml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 0a60f4d03..51d591721 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -34,6 +34,7 @@ Kirigami.ApplicationWindow { property alias defaultCylinderIndex: settingsWindow.defaultCylinderIndex property bool filterToggle: false property string filterPattern: "" + property bool firstChange: true onNotificationTextChanged: { if (notificationText != "") { @@ -487,6 +488,7 @@ if you have network connectivity and want to sync your data to cloud storage."), // set the initial UI scaling as in the the preferences fontMetrics.font.pointSize = subsurfaceTheme.basePointSize * PrefDisplay.mobile_scale; + console.log("Done setting up sizes") } QtObject { @@ -552,8 +554,16 @@ if you have network connectivity and want to sync your data to cloud storage."), property color contrastAccentColor: "#FF5722" // used for delete button property color lightDrawerColor: "#FFFFFF" property color darkDrawerColor: "#424242" + property int initialWidth: rootItem.width Component.onCompleted: { - setupUnits() + // break the binding + initialWidth = initialWidth * 1 + console.log("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 + console.log("Already adjusted size, ignoring this") + // this needs to pick the theme from persistent preference settings var theme = PrefDisplay.theme if (theme == "Blue") @@ -567,8 +577,17 @@ if you have network connectivity and want to sync your data to cloud storage."), onWidthChanged: { console.log("Window width changed to " + width) - // we need to recalculate our base units - setupUnits() + if (subsurfaceTheme.initialWidth !== undefined) { + if (width !== subsurfaceTheme.initialWidth && rootItem.firstChange) { + rootItem.firstChange = false; + console.log("first real change, so recalculating units") + setupUnits() + } else { + console.log("not recalculating base unit") + } + } else { + console.log("width changed before initial width initialized, ignoring") + } } pageStack.initialPage: DiveList { -- cgit v1.2.3-70-g09d2