From 398b7846a561f62c6bc2f3f744858480977522ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conrad=20H=C3=BCbler?= Date: Sat, 23 Mar 2024 13:32:39 +0100 Subject: [PATCH] playing around with dock player, breaking even more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Conrad Hübler --- qml/pages/FirstPage.qml | 7 +- qml/pages/PlaylistPage.qml | 15 +-- qml/pages/TrackList.qml | 1 + qml/pages/widgets/MiniPlayer.qml | 155 ++++++++++++++++--------------- 4 files changed, 88 insertions(+), 90 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index e181c14..952b016 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -11,14 +11,15 @@ Page { // The effective value will be restricted by ApplicationWindow.allowedOrientations allowedOrientations: Orientation.All + clip: true // To enable PullDownMenu, place our content in a SilicaFlickable SilicaFlickable { + clip: true anchors { fill: parent - bottomMargin: minPlayerPanel.margin + bottom: minPlayerPanel.top } - clip: miniPlayerPanel.expanded contentHeight: parent.height - Theme.itemSizeExtraLarge - Theme.paddingLarge // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView @@ -52,7 +53,9 @@ Page { } SlideshowView { + clip: true id: swipeView + height: parent.height itemWidth: width itemHeight: height orientation: Qt.Horizontal diff --git a/qml/pages/PlaylistPage.qml b/qml/pages/PlaylistPage.qml index 9f7e564..8fa3eed 100644 --- a/qml/pages/PlaylistPage.qml +++ b/qml/pages/PlaylistPage.qml @@ -41,13 +41,12 @@ Item { onPlayListChanged: { pLtrackList.clear(); - console.log("Playlist changed with playlist.qml", playlistManager.size) for(var i = 0; i < playlistManager.size; ++i) { - console.log(i) playlistManager.requestPlaylistItem(i) pLtrackList.addTrack(playlistManager.playlist_track, playlistManager.playlist_artist, playlistManager.playlist_album, playlistManager.playlist_track_id, playlistManager.playlist_duration) } + pLtrackList.highlight_index = playlistManager.current_track } onClearList: @@ -58,19 +57,7 @@ Item { onTrackInformation: { pLtrackList.setTrack(index, id, title, artist, album, image, duration) - console.log(image) } } - Connections { - target: pythonApi - onTrackChanged: - { - console.log("PlaylistPage::onTrackChanged in pythonApi", title) - pLtrackList.addTrack(title, artist, album, id, duration) - } - - - } - } diff --git a/qml/pages/TrackList.qml b/qml/pages/TrackList.qml index 3ca98cf..059072e 100644 --- a/qml/pages/TrackList.qml +++ b/qml/pages/TrackList.qml @@ -176,6 +176,7 @@ SilicaListView { { mediaPlayer.blockAutoNext = true playlistManager.playPosition(model.index) + highlight_index = model.index } } menu: ContextMenu { diff --git a/qml/pages/widgets/MiniPlayer.qml b/qml/pages/widgets/MiniPlayer.qml index 52e4567..a9e2808 100644 --- a/qml/pages/widgets/MiniPlayer.qml +++ b/qml/pages/widgets/MiniPlayer.qml @@ -7,7 +7,6 @@ import org.nemomobile.mpris 1.0 DockedPanel { id: miniPlayerPanel - //parent: pageStack.currentPage width: parent.width height: Theme.itemSizeExtraLarge + Theme.paddingLarge @@ -24,16 +23,6 @@ DockedPanel { progressSlider.visible = true show(); } - - Rectangle { - anchors.fill: parent - color: Theme.overlayBackgroundColor - opacity: 0.8 - SwipeArea { - anchors.fill: parent - onSwipeDown: minPlayerPanel.hide() - } - } Image { id: bgImage height: 0.75 * parent.height @@ -42,77 +31,96 @@ DockedPanel { anchors.bottom: parent.bottom } - Label { - id: mediaTitle + + Column + { anchors.top: parent.top - anchors.topMargin: Theme.paddingSmall - anchors.horizontalCenter: parent.horizontalCenter - truncationMode: TruncationMode.Fade width: parent.width - 2 * Theme.paddingLarge - //horizontalAlignment: (contentWidth > width) ? Text.AlignLeft : Text.AlignHCenter - } - Label { - id: playTime - anchors.top: mediaTitle.bottom - anchors.topMargin: Theme.paddingSmall / 6 - property string pos: { - if ((mediaPlayer.position / 1000) > 3599) Format.formatDuration(minPlayer.position / 1000, Formatter.DurationLong) - else return Format.formatDuration(mediaPlayer.position / 1000, Formatter.DurationShort) - } - property string dur: { - if ((mediaPlayer.duration / 1000) > 3599) Format.formatDuration(minPlayer.duration / 1000, Formatter.DurationLong) - else return Format.formatDuration(mediaPlayer.duration / 1000, Formatter.DurationShort) + Label + { + id: mediaTitle + //anchors.top: parent.top + //anchors.topMargin: Theme.paddingSmall + //anchors.horizontalCenter: parent.horizontalCenter + truncationMode: TruncationMode.Fade + width: parent.width - 2 * Theme.paddingLarge + //horizontalAlignment: (contentWidth > width) ? Text.AlignLeft : Text.AlignHCenter } - text: pos + " / " + dur; - width: parent.width - horizontalAlignment: Text.AlignHCenter - font.pixelSize: Theme.fontSizeExtraSmall - } - - Slider { - id: progressSlider - anchors.top: playTime.bottom - anchors.topMargin: Theme.paddingSmall / 6 - width: parent.width - minimumValue: 0 - maximumValue: 100 - visible: false - } - - Row { - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: progressSlider.bottom - anchors.topMargin: Theme.paddingSmall / 4 - IconButton { - id : prevButton - icon.source: "image://theme/icon-m-previous" - visible: playlistManager.canPrev; - onClicked: { - playlistManager.previousTrackClicked() + Row { + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: mediaTitle.bottom + //anchors.topMargin: Theme.paddingSmall / 4 + width: miniPlayerPanel.width -2 * Theme.paddingLarge + id: buttonsRow + IconButton { + anchors.horizontalCenter: playButton.left + id : prevButton + icon.source: "image://theme/icon-m-previous" + visible: playlistManager.canPrev; + onClicked: { + playlistManager.previousTrackClicked() + } } - } - IconButton { - id:playButton - icon.source: mediaPlayer.isPlaying ? "image://theme/icon-m-pause" : "image://theme/icon-m-play" - onClicked: { - if (mediaPlayer.playbackState == 1) - { - mediaPlayer.pause() + IconButton { + anchors.horizontalCenter: parent.horizontalCenter + id:playButton + icon.source: mediaPlayer.isPlaying ? "image://theme/icon-m-pause" : "image://theme/icon-m-play" + onClicked: { + if (mediaPlayer.playbackState == 1) + { + mediaPlayer.pause() + } + else if(mediaPlayer.playbackState == 2){ + mediaPlayer.play() + } } - else if(mediaPlayer.playbackState == 2){ - mediaPlayer.play() + } + IconButton { + anchors.horizontalCenter: playButton.right + id: nextButton + icon.source: "image://theme/icon-m-next" + visible: playlistManager.canNext; + onClicked: { + console.log("play next") + mediaPlayer.blockAutoNext = true + playlistManager.nextTrackClicked() } } } - IconButton { - id: nextButton - icon.source: "image://theme/icon-m-next" - visible: playlistManager.canNext; - onClicked: { - console.log("play next") - mediaPlayer.blockAutoNext = true - playlistManager.nextTrackClicked() + Row{ + //anchors.centerIn: parent + anchors.top: parent.buttonsRow + width: miniPlayerPanel.width + + id: progressSliderRow + Label + { + id: playedTime + property string pos: { + if ((mediaPlayer.position / 1000) > 3599) Format.formatDuration(minPlayer.position / 1000, Formatter.DurationLong) + else return Format.formatDuration(mediaPlayer.position / 1000, Formatter.DurationShort) + } + text: pos; + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraSmall + } + Slider { + id: progressSlider + minimumValue: 0 + maximumValue: 100 + visible: false + width: miniPlayerPanel.width - Theme.paddingLarge + } + Label { + id: playTime + property string dur: { + if ((mediaPlayer.duration / 1000) > 3599) Format.formatDuration(minPlayer.duration / 1000, Formatter.DurationLong) + else return Format.formatDuration(mediaPlayer.duration / 1000, Formatter.DurationShort) + } + text: dur; + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Theme.fontSizeExtraSmall } } } @@ -146,7 +154,6 @@ DockedPanel { target: pythonApi onCurrentTrackInfo: { - mediaTitle.text = track_num + " - " + title + " - " +album + " - " + artist bgImage.source = album_image prevButton.enabled = playlistManager.canPrev;