summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-05 20:23:46 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-13 11:32:27 -0700
commitb9861a0059e558ed148d21539c155296325bc803 (patch)
tree7afb0070319e2647ed33e05fce21d50369f41d43
parente047e971908ff74707fb561e8e1a51b36d847bff (diff)
downloadsubsurface-b9861a0059e558ed148d21539c155296325bc803.tar.gz
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 <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qml/main.qml13
1 files 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