From 38120d555f45fb36c3d7de5b429f8a5e00ffa1e7 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Wed, 15 Jan 2020 09:22:33 +0100 Subject: mobile-widgets/qml: secure subsurfaceTheme.initial* move initialWidth/initialHeight out of subsurfaceTheme to placeHolder, this secures no change in behaviour. Signed-off-by: jan Iversen --- mobile-widgets/qml/main.qml | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'mobile-widgets') diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index e4bb1e8ef..e002062c8 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -590,6 +590,23 @@ if you have network connectivity and want to sync your data to cloud storage."), manager.appendTextToLog("Done setting up sizes") } + QtObject { + id: placeHolder + + property int initialWidth: rootItem.width + property int initialHeight: rootItem.height + + 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") + } + } + QtObject { id: subsurfaceTheme @@ -612,28 +629,16 @@ if you have network connectivity and want to sync your data to cloud storage."), property color contrastAccentColor: ThemeNew.contrastAccentColor property color lightDrawerColor: ThemeNew.lightDrawerColor - property int initialWidth: rootItem.width - property int initialHeight: rootItem.height - - 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") - } } onWidthChanged: { manager.appendTextToLog("Window width changed to " + width + " orientation " + Screen.primaryOrientation) - if (subsurfaceTheme.initialWidth !== undefined) { - if (width !== subsurfaceTheme.initialWidth && rootItem.firstChange) { + if (placeHolder.initialWidth !== undefined) { + if (width !== placeHolder.initialWidth && rootItem.firstChange) { rootItem.firstChange = false rootItem.lastOrientation = Screen.primaryOrientation - subsurfaceTheme.initialWidth = width - subsurfaceTheme.initialHeight = height + placeHolder.initialWidth = width + placeHolder.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) { @@ -642,10 +647,10 @@ if you have network connectivity and want to sync your data to cloud storage."), setupUnits() } else { manager.appendTextToLog("size change without rotation to " + width + " x " + height) - if (width > subsurfaceTheme.initialWidth) { - manager.appendTextToLog("resetting to initial width " + subsurfaceTheme.initialWidth + " and height " + subsurfaceTheme.initialHeight) - rootItem.width = subsurfaceTheme.initialWidth - rootItem.height = subsurfaceTheme.initialHeight + if (width > placeHolder.initialWidth) { + manager.appendTextToLog("resetting to initial width " + placeHolder.initialWidth + " and height " + placeHolder.initialHeight) + rootItem.width = placeHolder.initialWidth + rootItem.height = placeHolder.initialHeight } } } else { -- cgit v1.2.3-70-g09d2