Warning, /multimedia/audiotube/src/contents/ui/SearchPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Jonah BrĂ¼chert <jbb@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.14 as Controls
0008 import org.kde.kirigami 2.14 as Kirigami
0009
0010 import org.kde.ytmusic 1.0
0011
0012 Kirigami.ScrollablePage {
0013 id: searchPage
0014 property alias searchQuery: searchModel.searchQuery
0015 objectName: "searchPage"
0016 title: listView.count === 0 && !searchModel.loading? i18n("Previous Searches:") : searchQuery
0017
0018 ListView {
0019 reuseItems: true
0020
0021 section.delegate: Kirigami.ListSectionHeader {
0022 width: parent.width
0023
0024 required property string section
0025 text: {
0026 switch (parseInt(section)) {
0027 case SearchModel.Album:
0028 return i18n("Albums")
0029 case SearchModel.Artist:
0030 return i18n("Artists")
0031 case SearchModel.Playlist:
0032 return i18n("Playlists")
0033 case SearchModel.Song:
0034 return i18n("Songs")
0035 case SearchModel.Video:
0036 return i18n("Videos")
0037 case SearchModel.TopResult:
0038 return i18n("Top Results")
0039 }
0040
0041 return i18n("Unknown")
0042 }
0043 }
0044 section.property: "type"
0045 id: listView
0046 model: SearchModel {
0047 id: searchModel
0048
0049 onOpenAlbum: (browseId) => {
0050 pageStack.push("qrc:/AlbumPage.qml", {
0051 "browseId": browseId
0052 })
0053 }
0054
0055 onOpenArtist: (channelId, radioId, shuffleId) => {
0056 pageStack.push("qrc:/ArtistPage.qml", {
0057 "channelId": channelId,
0058 "radioId": radioId,
0059 "shuffleId": shuffleId
0060 })
0061 }
0062
0063 onOpenPlaylist: (browseId) => {
0064 pageStack.push("qrc:/PlaylistPage.qml", {
0065 "playlistId": browseId
0066 })
0067 }
0068
0069 onOpenSong: (videoId) => {
0070 play(videoId)
0071 }
0072
0073 onOpenVideo: (videoId, title) => {
0074 videoPlayMessage.text = i18n("Video playback is not supported yet. Do you want to play only the audio of \"%1\"?", title)
0075 videoPlayMessage.visible = true
0076 videoPlayMessage.okAction = function() {
0077 play(videoId)
0078 videoPlayMessage.visible = false
0079 }
0080 videoPlayMessage.cancelAction = function() {
0081 videoPlayMessage.visible = false
0082 }
0083 }
0084 }
0085
0086 SongMenu {
0087 id: menu
0088 }
0089
0090 delegate: Controls.ItemDelegate {
0091 id: delegateItem
0092
0093 required property int index
0094 required property string title
0095 required property int type
0096 required property string videoId
0097 required property var artists
0098 required property string artistsDisplayString
0099 required property string radioPlaylistId
0100 required property string thumbnailUrl
0101
0102 width: parent.width
0103
0104 contentItem: MouseArea {
0105 implicitHeight: content.implicitHeight
0106 acceptedButtons: Qt.LeftButton | Qt.RightButton
0107 onClicked: (mouse) => {
0108 if (mouse.button === Qt.RightButton) {
0109 if (delegateItem.type === SearchModel.Song || delegateItem.type === SearchModel.Video) {
0110 menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString)
0111 }
0112 } else if (mouse.button === Qt.LeftButton) {
0113 searchModel.triggerItem(index)
0114 }
0115 }
0116 RowLayout {
0117 id: content
0118 anchors.fill: parent
0119 RoundedImage {
0120 source: delegateItem.thumbnailUrl
0121 height: 35
0122 width: height
0123 radius: delegateItem.type === SearchModel.Artist ? height / 2 : 5
0124 }
0125
0126 ColumnLayout {
0127 Layout.fillWidth: true
0128
0129 Controls.Label {
0130 Layout.fillWidth: true
0131 text: title
0132 elide: Qt.ElideRight
0133 }
0134
0135 Controls.Label {
0136 Layout.fillWidth: true
0137 visible: delegateItem.artistsDisplayString
0138 color: Kirigami.Theme.disabledTextColor
0139 text: delegateItem.artistsDisplayString
0140 elide: Qt.ElideRight
0141
0142 }
0143 }
0144
0145 Controls.ToolButton {
0146 icon.name: "overflow-menu"
0147 display: Controls.AbstractButton.IconOnly
0148 text: i18n("More")
0149 visible: delegateItem.type === SearchModel.Song || delegateItem.type === SearchModel.Video
0150 onClicked: menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString)
0151 }
0152 }
0153 }
0154 }
0155
0156 Controls.BusyIndicator {
0157 anchors.centerIn: parent
0158 visible: searchModel.loading
0159 }
0160 }
0161
0162 footer: ConfirmationMessage {
0163 id: videoPlayMessage
0164 }
0165 }