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