Warning, /maui/vvave/src/widgets/MainPlaylist/MainPlaylist.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.15 0002 import QtQml 2.15 0003 0004 import QtQuick.Layouts 1.3 0005 import QtQuick.Controls 2.14 0006 import QtGraphicalEffects 1.15 0007 0008 import org.mauikit.controls 1.3 as Maui 0009 0010 import org.maui.vvave 1.0 0011 0012 import "../../utils/Player.js" as Player 0013 import "../../db/Queries.js" as Q 0014 0015 import "../BabeTable" 0016 0017 Maui.Page 0018 { 0019 id: control 0020 0021 Maui.Theme.colorSet: Maui.Theme.Window 0022 0023 property alias listModel: table.listModel 0024 readonly property alias listView : table.listView 0025 readonly property alias table: table 0026 0027 readonly property alias contextMenu: table.contextMenu 0028 0029 headBar.visible: false 0030 footBar.visible: !mainlistEmpty 0031 0032 footBar.rightContent: ToolButton 0033 { 0034 icon.name: "edit-delete" 0035 onClicked: 0036 { 0037 player.stop() 0038 listModel.list.clear() 0039 root.sync = false 0040 root.syncPlaylist = "" 0041 } 0042 } 0043 0044 footBar.leftContent: ToolButton 0045 { 0046 icon.name: "document-save" 0047 onClicked: saveList() 0048 } 0049 0050 BabeTable 0051 { 0052 id: table 0053 anchors.fill: parent 0054 0055 background: Rectangle 0056 { 0057 color: Maui.Theme.backgroundColor 0058 opacity: 0.2 0059 0060 Behavior on color 0061 { 0062 Maui.ColorTransition{} 0063 } 0064 } 0065 0066 Binding on currentIndex 0067 { 0068 value: currentTrackIndex 0069 restoreMode: Binding.RestoreBindingOrValue 0070 } 0071 0072 listModel.sort: "" 0073 listBrowser.enableLassoSelection: false 0074 headBar.visible: false 0075 footBar.visible: false 0076 Maui.Theme.colorSet: Maui.Theme.Window 0077 0078 holder.emoji: "qrc:/assets/view-media-track.svg" 0079 holder.title : "Nothing to play!" 0080 holder.body: i18n("Start putting together your playlist.") 0081 0082 listView.header: Column 0083 { 0084 width: parent.width 0085 0086 Loader 0087 { 0088 width: visible ? parent.width : 0 0089 height: width 0090 0091 asynchronous: true 0092 active: !focusView && control.height > control.width*3 && currentTrackIndex >= 0 0093 visible: active 0094 sourceComponent: Item 0095 { 0096 // color: Maui.Theme.highlightColor 0097 id: _imgHeader 0098 0099 Maui.GalleryRollTemplate 0100 { 0101 id: _image 0102 anchors.fill: parent 0103 anchors.bottomMargin: Maui.Style.space.medium 0104 radius: Maui.Style.radiusV 0105 interactive: true 0106 fillMode: Image.PreserveAspectCrop 0107 0108 images: ["image://artwork/album:"+currentTrack.artist + ":"+ currentTrack.album, "image://artwork/artist:"+currentTrack.artist] 0109 0110 } 0111 } 0112 } 0113 0114 Rectangle 0115 { 0116 visible: root.sync 0117 Maui.Theme.inherit: false 0118 Maui.Theme.colorSet:Maui.Theme.Complementary 0119 z: table.z + 999 0120 width: parent.width 0121 height: visible ? Maui.Style.rowHeightAlt : 0 0122 color: Maui.Theme.backgroundColor 0123 0124 RowLayout 0125 { 0126 anchors.fill: parent 0127 anchors.leftMargin: Maui.Style.space.small 0128 0129 Label 0130 { 0131 Layout.fillWidth: true 0132 Layout.fillHeight: true 0133 anchors.margins: Maui.Style.space.small 0134 text: i18n("Syncing to ") + root.syncPlaylist 0135 } 0136 0137 ToolButton 0138 { 0139 Layout.fillHeight: true 0140 icon.name: "dialog-close" 0141 onClicked: 0142 { 0143 root.sync = false 0144 root.syncPlaylist = "" 0145 } 0146 } 0147 } 0148 } 0149 } 0150 0151 delegate: TableDelegate 0152 { 0153 id: delegate 0154 0155 width: ListView.view.width 0156 height: Math.max(implicitHeight, Maui.Style.rowHeight) 0157 appendButton: false 0158 0159 property int mindex : index 0160 0161 isCurrentItem: ListView.isCurrentItem 0162 mouseArea.drag.axis: Drag.YAxis 0163 Drag.source: delegate 0164 0165 number : false 0166 coverArt : settings.showArtwork 0167 draggable: true 0168 checkable: false 0169 checked: false 0170 0171 onPressAndHold: if(Maui.Handy.isTouch && table.allowMenu) table.openItemMenu(index) 0172 0173 onRightClicked: tryOpenContextMenu() 0174 0175 function tryOpenContextMenu() : undefined 0176 { 0177 if (table.allowMenu) 0178 table.openItemMenu(index) 0179 } 0180 0181 sameAlbum: control.totalMoves, evaluate(listModel.get(mindex-1)) 0182 0183 function evaluate(item) 0184 { 0185 return coverArt && item && item.album === model.album && item.artist === model.artist 0186 } 0187 0188 Item 0189 { 0190 visible: mindex === currentTrackIndex 0191 Layout.fillHeight: true 0192 Layout.preferredWidth: Maui.Style.rowHeight 0193 0194 AnimatedImage 0195 { 0196 id: _playingIcon 0197 height: 16 0198 width: height 0199 playing: root.isPlaying && Maui.Style.enableEffects 0200 anchors.centerIn: parent 0201 source: "qrc:/assets/playing.gif" 0202 } 0203 0204 ColorOverlay 0205 { 0206 anchors.fill: _playingIcon 0207 source: _playingIcon 0208 color: delegate.label1.color 0209 } 0210 } 0211 0212 AbstractButton 0213 { 0214 Layout.fillHeight: true 0215 Layout.preferredWidth: Maui.Style.rowHeight 0216 visible: (Maui.Handy.isTouch ? true : delegate.hovered) && index !== currentTrackIndex 0217 icon.name: "edit-clear" 0218 onClicked: 0219 { 0220 if(index === currentTrackIndex) 0221 player.stop() 0222 0223 root.playlistManager.remove(index) 0224 } 0225 0226 Maui.Icon 0227 { 0228 color: delegate.label1.color 0229 anchors.centerIn: parent 0230 height: Maui.Style.iconSizes.small 0231 width: height 0232 source: parent.icon.name 0233 } 0234 opacity: delegate.hovered ? 0.8 : 0.6 0235 } 0236 0237 onClicked: 0238 { 0239 table.forceActiveFocus() 0240 if(Maui.Handy.isTouch) 0241 Player.playAt(index) 0242 } 0243 0244 onDoubleClicked: 0245 { 0246 if(!Maui.Handy.isTouch) 0247 Player.playAt(index) 0248 } 0249 0250 0251 onContentDropped: (drop) => 0252 { 0253 console.log("Move or insert ", drop.source.mindex) 0254 if(typeof drop.source.mindex !== 'undefined') 0255 { 0256 console.log("Move ", drop.source.mindex, 0257 delegate.mindex) 0258 0259 root.playlistManager.move(drop.source.mindex, delegate.mindex) 0260 0261 }else 0262 { 0263 root.playlistManager.insert(String(drop.urls).split(","), delegate.mindex) 0264 } 0265 0266 control.totalMoves++ 0267 } 0268 } 0269 } 0270 0271 property int totalMoves: 0 0272 0273 function saveList() 0274 { 0275 var trackList = listModel.list.urls() 0276 if(listModel.list.count > 0) 0277 { 0278 _dialogLoader.sourceComponent = _playlistDialogComponent 0279 dialog.composerList.urls = trackList 0280 dialog.open() 0281 } 0282 } 0283 }