mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Use Drawer Sidebar instead of menu class to show the menu
This commit is contained in:
parent
c2b63a2313
commit
27593633fc
139
retroshare-qml-app/src/components/SideBar.qml
Normal file
139
retroshare-qml-app/src/components/SideBar.qml
Normal file
@ -0,0 +1,139 @@
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.0
|
||||
import "../URI.js" as UriJs
|
||||
import "../" //Needed for TokensManager and ClipboardWrapper singleton
|
||||
|
||||
Drawer
|
||||
{
|
||||
id: drawer
|
||||
height: parent.height
|
||||
width: Math.min(parent.width, parent.height) / 3 * 2
|
||||
dragMargin: 10
|
||||
|
||||
ListView
|
||||
{
|
||||
id: listView
|
||||
currentIndex: -1
|
||||
anchors.fill: parent
|
||||
height: parent.height
|
||||
|
||||
delegate: Item
|
||||
{
|
||||
property var itemHeight: 50
|
||||
|
||||
id: menuItem
|
||||
width: parent.width
|
||||
height: itemHeight
|
||||
|
||||
Connections
|
||||
{
|
||||
target: mainWindow
|
||||
onCoreReadyChanged:
|
||||
{
|
||||
if (model.showOnCoreReady)
|
||||
{
|
||||
setVisible(mainWindow.coreReady)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: model.title
|
||||
}
|
||||
|
||||
MouseArea
|
||||
{
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
onClicked:
|
||||
{
|
||||
if (listView.currentIndex != index)
|
||||
{
|
||||
listView.currentIndex = index
|
||||
menuList.actions[model.title]();
|
||||
// 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)
|
||||
{
|
||||
menuItem.visible = false
|
||||
menuItem.height = 0
|
||||
}
|
||||
}
|
||||
|
||||
function setVisible(b)
|
||||
{
|
||||
menuItem.visible = b
|
||||
if (!b)
|
||||
{
|
||||
menuItem.height = 0
|
||||
}
|
||||
else
|
||||
{
|
||||
menuItem.height = itemHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model: ListModel
|
||||
{
|
||||
id: menuList
|
||||
property var actions :
|
||||
{
|
||||
"Trusted Nodes": function()
|
||||
{
|
||||
stackView.push("qrc:/TrustedNodesView.qml");
|
||||
},
|
||||
"Search Contacts": function(){
|
||||
stackView.push("qrc:/Contacts.qml",
|
||||
{'searching': true} )
|
||||
|
||||
},
|
||||
"Paste Link": function()
|
||||
{
|
||||
UriJs.URI.withinString(
|
||||
ClipboardWrapper.getFromClipBoard(),
|
||||
handleIntentUri);
|
||||
},
|
||||
"Terminate Core": function()
|
||||
{
|
||||
rsApi.request("/control/shutdown");
|
||||
},
|
||||
}
|
||||
|
||||
ListElement
|
||||
{
|
||||
title: "Trusted Nodes"
|
||||
showOnCoreReady: true
|
||||
}
|
||||
ListElement
|
||||
{
|
||||
title: "Search Contacts"
|
||||
showOnCoreReady: true
|
||||
}
|
||||
ListElement
|
||||
{
|
||||
title: "Paste Link"
|
||||
showOnCoreReady: true
|
||||
}
|
||||
ListElement
|
||||
{
|
||||
title: "Terminate Core"
|
||||
showOnOsAndroid: false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import QtQuick.Controls 2.0
|
||||
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
||||
import "URI.js" as UriJs
|
||||
import "." //Needed for TokensManager and ClipboardWrapper singleton
|
||||
import "components/."
|
||||
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
@ -114,7 +116,7 @@ ApplicationWindow
|
||||
anchors.rightMargin: 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
onClicked: menu.open()
|
||||
onClicked: sideBar.open()
|
||||
|
||||
Image
|
||||
{
|
||||
@ -124,41 +126,8 @@ ApplicationWindow
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
id: menu
|
||||
y: parent.y + parent.height
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: qsTr("Trusted Nodes")
|
||||
//iconSource: "qrc:/icons/document-share.png"
|
||||
onTriggered: stackView.push("qrc:/TrustedNodesView.qml")
|
||||
enabled: mainWindow.coreReady
|
||||
}
|
||||
MenuItem
|
||||
{
|
||||
text: qsTr("Search Contacts")
|
||||
onTriggered:
|
||||
stackView.push("qrc:/Contacts.qml",
|
||||
{'searching': true} )
|
||||
enabled: mainWindow.coreReady
|
||||
}
|
||||
MenuItem
|
||||
{
|
||||
text: "Paste Link"
|
||||
onTriggered: UriJs.URI.withinString(
|
||||
ClipboardWrapper.getFromClipBoard(),
|
||||
handleIntentUri)
|
||||
|
||||
enabled: mainWindow.coreReady
|
||||
}
|
||||
MenuItem
|
||||
{
|
||||
text: "Terminate Core"
|
||||
onTriggered: rsApi.request("/control/shutdown")
|
||||
visible: !Q_OS_ANDROID
|
||||
}
|
||||
SideBar {
|
||||
id: sideBar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,5 +39,6 @@
|
||||
<file>components/ColorHash.qml</file>
|
||||
<file>styles/ChatStyle.qml</file>
|
||||
<file>components/AvatarOrColorHash.qml</file>
|
||||
<file>components/SideBar.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
Reference in New Issue
Block a user