Qml app fix disappearing sidebar buttons

Cleaup the messy code of sidebar buttons, should fix button erratic
disappearance
This commit is contained in:
Gioacchino Mazzurco 2018-02-02 00:20:14 +01:00
parent 36e20db887
commit b662e6623b

View File

@ -74,7 +74,6 @@ Drawer
{ {
id: gxsText id: gxsText
text: (ChatCache.contactsCache.own)?ChatCache.contactsCache.own.gxs_id : "" text: (ChatCache.contactsCache.own)?ChatCache.contactsCache.own.gxs_id : ""
// height: contentHeight
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
width: header.width width: header.width
anchors.top: nickText.bottom anchors.top: nickText.bottom
@ -89,29 +88,17 @@ Drawer
} }
delegate: Item delegate: Item
{ {
property var styles: StyleSideBar.item property var styles: StyleSideBar.item
id: menuItem id: menuItem
width: parent.width width: parent.width
height: styles.height
Connections visible: model.showOnCoreReady ? mainWindow.coreReady : true
{ height: visible ? styles.height : 0
target: mainWindow Component.onCompleted:
onCoreReadyChanged: if (Q_OS_ANDROID && !model.showOnOsAndroid) visible = false
{
console.log("Drawer onCoreReadyChanged",
model.title,
model.showOnCoreReady,
mainWindow.coreReady)
if (model.showOnCoreReady)
menuItem.setVisible(mainWindow.coreReady)
}
}
ButtonText ButtonText
{ {
@ -142,28 +129,10 @@ Drawer
listView.currentIndex = index listView.currentIndex = index
menuList.actions[model.title](); menuList.actions[model.title]();
lastItem = stackView.currentItem lastItem = stackView.currentItem
// titleLabel.text = model.title
// stackView.replace(model.source)
} }
drawer.close() drawer.close()
} }
} }
visible: (model.showOnCoreReady)? setVisible(mainWindow.coreReady) : true
Component.onCompleted:
{
if (!model.showOnOsAndroid && Q_OS_ANDROID)
setVisible(false)
}
function setVisible(b)
{
menuItem.visible = b
if (!b) menuItem.height = 0
else menuItem.height = styles.height
return b;
}
} }
model: ListModel model: ListModel
@ -220,24 +189,28 @@ Drawer
{ {
title: "Contacts" title: "Contacts"
showOnCoreReady: true showOnCoreReady: true
showOnOsAndroid: true
icon: "/icons/search.svg" icon: "/icons/search.svg"
} }
ListElement ListElement
{ {
title: "Trusted Nodes" title: "Trusted Nodes"
showOnCoreReady: true showOnCoreReady: true
showOnOsAndroid: true
icon: "/icons/netgraph.svg" icon: "/icons/netgraph.svg"
} }
ListElement ListElement
{ {
title: "Paste Link" title: "Paste Link"
showOnCoreReady: true showOnCoreReady: true
showOnOsAndroid: true
icon: "/icons/add.svg" icon: "/icons/add.svg"
} }
ListElement ListElement
{ {
title: "Share identity" title: "Share identity"
showOnCoreReady: true showOnCoreReady: true
showOnOsAndroid: true
icon: "/icons/share.svg" icon: "/icons/share.svg"
} }
ListElement ListElement
@ -250,6 +223,7 @@ Drawer
ListElement ListElement
{ {
title: "Terminate Core" title: "Terminate Core"
showOnCoreReady: false
showOnOsAndroid: false showOnOsAndroid: false
icon: "/icons/exit.svg" icon: "/icons/exit.svg"
} }