From b9861a0059e558ed148d21539c155296325bc803 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 5 Oct 2019 20:23:46 -0700 Subject: Mobile: change handling of columns and column width The old calculation was clearly bogus, we'd also get zero columns here. Instead do a correct calculation of the number of columns and make the resulting column width a property of the rootItem so we can refer to it elsewhere. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/main.qml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index d478e29d5..02ea0fadd 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -33,6 +33,7 @@ Kirigami.ApplicationWindow { property string filterPattern: "" property bool firstChange: true property int lastOrientation: undefined + property int colWidth: undefined onNotificationTextChanged: { if (notificationText != "") { @@ -464,16 +465,16 @@ if you have network connectivity and want to sync your data to cloud storage."), function setupUnits() { // some screens are too narrow for Subsurface-mobile to render well // try to hack around that by making sure that we can fit at least 21 gridUnits in a row - var numColumns = Math.floor(rootItem.width/(Kirigami.Units.gridUnit * pageStack.defaultColumnWidth)) - var colWidth = numColumns > 1 ? Math.floor(rootItem.width / numColumns) : rootItem.width; + var numColumns = Math.floor(rootItem.width/pageStack.defaultColumnWidth) + rootItem.colWidth = numColumns > 1 ? Math.floor(rootItem.width / numColumns) : rootItem.width; var kirigamiGridUnit = Kirigami.Units.gridUnit - var widthInGridUnits = Math.floor(colWidth / kirigamiGridUnit) + var widthInGridUnits = Math.floor(rootItem.colWidth / kirigamiGridUnit) if (widthInGridUnits < 21) { - kirigamiGridUnit = Math.floor(colWidth / 21) - widthInGridUnits = Math.floor(colWidth / kirigamiGridUnit) + kirigamiGridUnit = Math.floor(rootItem.colWidth / 21) + widthInGridUnits = Math.floor(rootItem.colWidth / kirigamiGridUnit) } var factor = 1.0 - console.log("Column width " + colWidth + " root item width " + rootItem.width) + console.log(numColumns + " columns with column width of " + rootItem.colWidth) console.log("width in Grid Units " + widthInGridUnits + " original gridUnit " + Kirigami.Units.gridUnit + " now " + kirigamiGridUnit) if (Kirigami.Units.gridUnit !== kirigamiGridUnit) { factor = kirigamiGridUnit / Kirigami.Units.gridUnit -- cgit v1.2.3-70-g09d2