mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
e047e97190
commit
b9861a0059
1 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue