mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
fb26f6b0fa
commit
c90050f449
1 changed files with 22 additions and 3 deletions
|
@ -34,6 +34,7 @@ Kirigami.ApplicationWindow {
|
||||||
property alias defaultCylinderIndex: settingsWindow.defaultCylinderIndex
|
property alias defaultCylinderIndex: settingsWindow.defaultCylinderIndex
|
||||||
property bool filterToggle: false
|
property bool filterToggle: false
|
||||||
property string filterPattern: ""
|
property string filterPattern: ""
|
||||||
|
property bool firstChange: true
|
||||||
|
|
||||||
onNotificationTextChanged: {
|
onNotificationTextChanged: {
|
||||||
if (notificationText != "") {
|
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
|
// set the initial UI scaling as in the the preferences
|
||||||
fontMetrics.font.pointSize = subsurfaceTheme.basePointSize * PrefDisplay.mobile_scale;
|
fontMetrics.font.pointSize = subsurfaceTheme.basePointSize * PrefDisplay.mobile_scale;
|
||||||
|
console.log("Done setting up sizes")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
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 contrastAccentColor: "#FF5722" // used for delete button
|
||||||
property color lightDrawerColor: "#FFFFFF"
|
property color lightDrawerColor: "#FFFFFF"
|
||||||
property color darkDrawerColor: "#424242"
|
property color darkDrawerColor: "#424242"
|
||||||
|
property int initialWidth: rootItem.width
|
||||||
Component.onCompleted: {
|
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
|
// this needs to pick the theme from persistent preference settings
|
||||||
var theme = PrefDisplay.theme
|
var theme = PrefDisplay.theme
|
||||||
if (theme == "Blue")
|
if (theme == "Blue")
|
||||||
|
@ -567,8 +577,17 @@ if you have network connectivity and want to sync your data to cloud storage."),
|
||||||
|
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
console.log("Window width changed to " + width)
|
console.log("Window width changed to " + width)
|
||||||
// we need to recalculate our base units
|
if (subsurfaceTheme.initialWidth !== undefined) {
|
||||||
setupUnits()
|
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 {
|
pageStack.initialPage: DiveList {
|
||||||
|
|
Loading…
Add table
Reference in a new issue