PrimaryNavigation.qml
1 import QtQuick 2 import QtQuick.Controls as Controls 3 import QtQuick.Layouts 4 import org.kde.kirigami as Kirigami 5 6 Kirigami.GlobalDrawer { 7 id: primaryNavigation 8 9 property Kirigami.ApplicationWindow windowRef 10 11 function isMobile(width) { 12 return width < 800; 13 } 14 function onWindowSizeChanged(width) { 15 drawerOpen = !isMobile(width); 16 modal = isMobile(width); 17 } 18 19 collapseButtonVisible: false 20 drawerOpen: !isMobile() 21 edge: Qt.LeftEdge 22 height: parent.height 23 modal: isMobile() 24 25 actions: [ 26 Kirigami.Action { 27 icon.name: "go-home" 28 text: "Home" 29 30 onTriggered: console.log("Home triggered") 31 }, 32 Kirigami.Action { 33 expandible: true 34 icon.name: "bookmark" 35 text: "Audiobooks" 36 37 onTriggered: console.log("Audiobooks triggered") 38 }, 39 Kirigami.Action { 40 expandible: true 41 icon.name: "emblem-music-symbolic" 42 text: "Music" 43 44 children: [ 45 Kirigami.Action { 46 text: "Local Library" 47 48 onTriggered: console.log("Music Local Library triggered") 49 }, 50 Kirigami.Action { 51 text: "Radio" 52 53 onTriggered: console.log("Music Radio triggered") 54 } 55 ] 56 }, 57 Kirigami.Action { 58 expandible: true 59 icon.name: "application-rss+xml-symbolic" 60 text: "Podcasts" 61 62 children: [ 63 Kirigami.Action { 64 text: "Library" 65 66 onTriggered: console.log("Podcasts Library triggered") 67 }, 68 Kirigami.Action { 69 text: "Find new podcasts" 70 71 onTriggered: console.log("Podcasts Find new podcasts triggered") 72 } 73 ] 74 }, 75 Kirigami.Action { 76 expandible: true 77 icon.name: "music-playlist-symbolic" 78 text: "Playlists" 79 80 children: [ 81 Kirigami.Action { 82 text: "Library" 83 84 onTriggered: console.log("Playlists Library triggered") 85 } 86 ] 87 // TODO: Generate list of playlists 88 } 89 ] 90 header: Kirigami.SearchField { 91 id: searchEntry 92 93 placeholderText: qsTr("Search") 94 } 95 96 Component.onCompleted: { 97 if (Kirigami.Settings.isMobile) 98 return; 99 if (windowRef) 100 windowRef.onWidthChanged.connect(() => onWindowSizeChanged(windowRef.width)); 101 } 102 }