Merge PR #90: Fix restoring of the tab in main page after reconnecting
This commit is contained in:
commit
ea801b3cee
@ -63,18 +63,18 @@ Page {
|
|||||||
opacity: engine.deviceManager.fetchingData ? 0 : 1
|
opacity: engine.deviceManager.fetchingData ? 0 : 1
|
||||||
Behavior on opacity { NumberAnimation { duration: 300 } }
|
Behavior on opacity { NumberAnimation { duration: 300 } }
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
settings.currentMainViewIndex = currentIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
print("MainPage Tab index: Component.completed: settings:", tabSettings.currentMainViewIndex)
|
||||||
if (engine.jsonRpcClient.ensureServerVersion(1.6)) {
|
if (engine.jsonRpcClient.ensureServerVersion(1.6)) {
|
||||||
swipeView.insertItem(0, favoritesViewComponent.createObject(swipeView))
|
swipeView.insertItem(0, favoritesViewComponent.createObject(swipeView))
|
||||||
}
|
}
|
||||||
if (settings.currentMainViewIndex > swipeView.count) {
|
if (tabSettings.currentMainViewIndex > swipeView.count) {
|
||||||
settings.currentMainViewIndex = swipeView.count - 1;
|
print("MainPage Tab index: setting config to", swipeView.count - 1, "(", tabSettings.currentMainViewIndex, swipeView.count, ")")
|
||||||
|
tabSettings.currentMainViewIndex = swipeView.count - 1;
|
||||||
}
|
}
|
||||||
swipeView.currentIndex = Qt.binding(function() { return settings.currentMainViewIndex; })
|
print("MainPage Tab index: setting tab to", tabSettings.currentMainViewIndex)
|
||||||
|
swipeView.currentIndex = Qt.binding(function() { return tabSettings.currentMainViewIndex; })
|
||||||
|
tabSettings.currentMainViewChanged = Qt.binding(function() { return swipeView.currentIndex; });
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
@ -177,7 +177,7 @@ Page {
|
|||||||
footer: TabBar {
|
footer: TabBar {
|
||||||
id: tabBar
|
id: tabBar
|
||||||
Material.elevation: 3
|
Material.elevation: 3
|
||||||
currentIndex: settings.currentMainViewIndex
|
// currentIndex: tabSettings.currentMainViewIndex
|
||||||
position: TabBar.Footer
|
position: TabBar.Footer
|
||||||
implicitHeight: 70 + (app.landscape ?
|
implicitHeight: 70 + (app.landscape ?
|
||||||
((systemProductType === "ios" && Screen.height === 375) ? -10 : -20) :
|
((systemProductType === "ios" && Screen.height === 375) ? -10 : -20) :
|
||||||
@ -196,14 +196,22 @@ Page {
|
|||||||
tabEntryComponent.createObject(tabBar, {text: qsTr("Scenes"), iconSource: "../images/slideshow.svg", pageIndex: pi++})
|
tabEntryComponent.createObject(tabBar, {text: qsTr("Scenes"), iconSource: "../images/slideshow.svg", pageIndex: pi++})
|
||||||
initTimer.start()
|
initTimer.start()
|
||||||
}
|
}
|
||||||
Timer { id: initTimer; interval: 1; repeat: false; onTriggered: tabBar.currentIndex = Qt.binding(function() {return settings.currentMainViewIndex;})}
|
Timer {
|
||||||
|
id: initTimer
|
||||||
|
interval: 1
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
print("MainPage Tab index: restoring tab index to:", tabSettings.currentMainViewIndex)
|
||||||
|
tabBar.currentIndex = Qt.binding(function() {return tabSettings.currentMainViewIndex;})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: tabEntryComponent
|
id: tabEntryComponent
|
||||||
MainPageTabButton {
|
MainPageTabButton {
|
||||||
property int pageIndex: 0
|
property int pageIndex: 0
|
||||||
// height: tabBar.height
|
// height: tabBar.height
|
||||||
onClicked: settings.currentMainViewIndex = pageIndex
|
onClicked: tabSettings.currentMainViewIndex = pageIndex
|
||||||
alignment: app.landscape ? Qt.Horizontal : Qt.Vertical
|
alignment: app.landscape ? Qt.Horizontal : Qt.Vertical
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,6 @@ ApplicationWindow {
|
|||||||
property bool darkTheme: false
|
property bool darkTheme: false
|
||||||
property string graphStyle: "bars"
|
property string graphStyle: "bars"
|
||||||
property string style: "light"
|
property string style: "light"
|
||||||
property int currentMainViewIndex: 0
|
|
||||||
property bool showHiddenOptions: false
|
property bool showHiddenOptions: false
|
||||||
property string cloudEnvironment: "community"
|
property string cloudEnvironment: "community"
|
||||||
property bool showConnectionTabs: false
|
property bool showConnectionTabs: false
|
||||||
|
|||||||
@ -71,6 +71,7 @@ Item {
|
|||||||
property var tabSettings: Settings {
|
property var tabSettings: Settings {
|
||||||
category: "tabSettings" + index
|
category: "tabSettings" + index
|
||||||
property string lastConnectedHost
|
property string lastConnectedHost
|
||||||
|
property int currentMainViewIndex: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine {
|
Engine {
|
||||||
|
|||||||
Reference in New Issue
Block a user