Warning, /multimedia/audiotube/src/contents/ui/Sidebar.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 Mathis BrĂ¼chert <mbb@kaidan.im> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 0005 import QtQuick 2.15 0006 import QtQuick.Layouts 1.3 0007 import QtQuick.Controls 2.15 as Controls 0008 import org.kde.kirigami 2.20 as Kirigami 0009 import org.kde.ytmusic 1.0 0010 0011 Rectangle { 0012 property int sidebarWidth: 230 0013 property int sidebarWidthCollapsed: 60 0014 property bool collapsed: true 0015 0016 // workaround for label not being displayed before collapsed change 0017 Component.onCompleted: { 0018 collapsed = false 0019 } 0020 0021 id: sidebar 0022 width: sidebarWidth 0023 clip:true 0024 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0025 Kirigami.Theme.inherit: false 0026 color: "transparent" 0027 0028 Rectangle { 0029 anchors.fill: parent 0030 color: Kirigami.Theme.backgroundColor 0031 opacity: 0.8 0032 } 0033 0034 NumberAnimation on width{ 0035 id: collapse 0036 easing.type: Easing.OutCubic 0037 running: false 0038 from: sidebarWidth; to: sidebarWidthCollapsed 0039 } 0040 NumberAnimation on width{ 0041 id: show 0042 easing.type: Easing.OutCubic 0043 running: false 0044 from: sidebarWidthCollapsed; to: sidebarWidth 0045 //this is only a workaround to stop the text from disappearing 0046 onFinished:{ 0047 libraryButton.checked =!libraryButton.checked 0048 libraryButton.checked =!libraryButton.checked 0049 0050 favouritesButton.checked =!favouritesButton.checked 0051 favouritesButton.checked =!favouritesButton.checked 0052 0053 historyButton.checked =!historyButton.checked 0054 historyButton.checked =!historyButton.checked 0055 0056 searchButton.checked =!searchButton.checked 0057 searchButton.checked =!searchButton.checked 0058 0059 collapseButton.checked =!collapseButton.checked 0060 collapseButton.checked =false 0061 0062 aboutButton.checked = !aboutButton.checked 0063 aboutButton.checked = !aboutButton.checked 0064 0065 playlistsButton.checked = !playlistsButton.checked 0066 playlistsButton.checked = !playlistsButton.checked 0067 } 0068 } 0069 Kirigami.Separator { 0070 height: parent.height 0071 anchors.right: parent.right 0072 z:100 0073 } 0074 0075 ColumnLayout { 0076 anchors.fill: parent 0077 spacing: 0 0078 0079 Kirigami.Separator { 0080 Layout.fillWidth: true 0081 } 0082 0083 Controls.ScrollView { 0084 0085 id: scrollView 0086 Layout.fillWidth: true 0087 Layout.fillHeight: true 0088 0089 Controls.ScrollBar.vertical.policy: Controls.ScrollBar.AlwaysOff 0090 Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff 0091 contentWidth: -1 // disable horizontal scroll 0092 0093 ColumnLayout { 0094 id: column 0095 width: scrollView.width 0096 spacing: 0 0097 0098 Kirigami.NavigationTabButton { 0099 id: libraryButton 0100 Layout.fillWidth: true 0101 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0102 implicitHeight: 50 0103 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0104 checked: pageStack.currentItem && pageStack.currentItem.objectName == "libraryPage" 0105 0106 action: Kirigami.PagePoolAction { 0107 pagePool: pool 0108 text: i18n("Library") 0109 icon.name: "file-library-symbolic" 0110 page: Qt.resolvedUrl("qrc:/LibraryPage.qml") 0111 } 0112 } 0113 Kirigami.NavigationTabButton { 0114 id: searchButton 0115 Layout.fillWidth: true 0116 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0117 implicitHeight: 50 0118 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0119 text: i18n("Search") 0120 icon.name: "search" 0121 checked: pageStack.currentItem && pageStack.currentItem.objectName == "searchPage" 0122 onClicked: { 0123 searchField.forceActiveFocus() 0124 focusSearch() 0125 } 0126 } 0127 0128 Kirigami.NavigationTabButton { 0129 id: favouritesButton 0130 Layout.fillWidth: true 0131 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0132 implicitHeight: 50 0133 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0134 checked: pageStack.currentItem && pageStack.currentItem.objectName == "favourites" 0135 0136 action: Kirigami.PagePoolAction { 0137 pagePool: pool 0138 text: i18n("Favourites") 0139 icon.name: "non-starred-symbolic" 0140 page: Qt.resolvedUrl("qrc:/PlaybackHistory.qml#favourites") 0141 initialProperties: { 0142 "dataModel": Library.favourites, 0143 "title": i18n("Favourites"), 0144 "objectName": "favourites" 0145 } 0146 } 0147 } 0148 0149 Kirigami.NavigationTabButton { 0150 id: historyButton 0151 Layout.fillWidth: true 0152 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0153 implicitHeight: 50 0154 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0155 checked: pageStack.currentItem && pageStack.currentItem.objectName == "history" 0156 0157 action: Kirigami.PagePoolAction { 0158 pagePool: pool 0159 text: i18n("Played Songs") 0160 icon.name: "edit-undo-history" 0161 page: Qt.resolvedUrl("qrc:/PlaybackHistory.qml#history") 0162 initialProperties: { 0163 "dataModel": Library.playbackHistory, 0164 "title": i18n("Played Songs"), 0165 "objectName": "history" 0166 } 0167 } 0168 } 0169 Kirigami.NavigationTabButton { 0170 id: playlistsButton 0171 Layout.fillWidth: true 0172 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0173 implicitHeight: 50 0174 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0175 checked: pageStack.currentItem && pageStack.currentItem.objectName == "playlists" 0176 0177 action: Kirigami.PagePoolAction { 0178 pagePool: pool 0179 text: i18n("Playlists") 0180 icon.name: "amarok_playlist" 0181 page: Qt.resolvedUrl("qrc:/LocalPlaylistsPage.qml") 0182 initialProperties: { 0183 "objectName": "playlists" 0184 } 0185 } 0186 } 0187 } 0188 } 0189 Kirigami.Separator { 0190 Layout.fillWidth: true 0191 Layout.rightMargin: Kirigami.Units.smallSpacing 0192 Layout.leftMargin: Kirigami.Units.smallSpacing 0193 } 0194 Kirigami.NavigationTabButton { 0195 id: aboutButton 0196 Layout.fillWidth: true 0197 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0198 implicitHeight: 50 0199 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0200 text: i18n("About") 0201 checkable: false 0202 icon.name: "help-about-symbolic" 0203 0204 onClicked: { 0205 pageStack.pushDialogLayer("qrc:/AboutAudiotube.qml") 0206 } 0207 } 0208 0209 Kirigami.NavigationTabButton { 0210 id: collapseButton 0211 Layout.fillWidth: true 0212 width: column.width - column.Layout.leftMargin - column.Layout.rightMargin 0213 display: collapsed ? Controls.AbstractButton.IconOnly : Controls.AbstractButton.TextBesideIcon 0214 text: i18n("Collapse Sidebar") 0215 checked: collapsed == true 0216 implicitHeight: 50 0217 icon.name: "sidebar-collapse" 0218 onClicked: { 0219 if (!sidebar.collapsed) 0220 collapse.running = true 0221 else 0222 show.running = true 0223 0224 sidebar.collapsed = !sidebar.collapsed 0225 } 0226 0227 } 0228 } 0229 }