Implement swipe to open/close miniplayer/full player

This commit is contained in:
Bart De Vries 2021-04-14 22:35:20 +02:00
parent 0d778c2a47
commit 364dd52f9a
6 changed files with 19 additions and 74 deletions

View File

@ -31,7 +31,6 @@ private:
Entry* m_entry = nullptr; Entry* m_entry = nullptr;
bool m_readyToPlay = false; bool m_readyToPlay = false;
bool playerOpen = false;
bool m_isSeekable = false; bool m_isSeekable = false;
bool m_lockPositionSaving = false; // sort of lock mutex to prevent updating the player position while changing sources (which will emit lots of playerPositionChanged signals) bool m_lockPositionSaving = false; // sort of lock mutex to prevent updating the player position while changing sources (which will emit lots of playerPositionChanged signals)
@ -69,11 +68,6 @@ Entry* AudioManager::entry () const
return d->m_entry; return d->m_entry;
} }
bool AudioManager::playerOpen() const
{
return d->playerOpen;
}
bool AudioManager::muted() const bool AudioManager::muted() const
{ {
return d->m_player.isMuted(); return d->m_player.isMuted();
@ -245,12 +239,6 @@ void AudioManager::setEntry(Entry* entry)
d->m_lockPositionSaving = false; d->m_lockPositionSaving = false;
} }
void AudioManager::setPlayerOpen(bool state)
{
d->playerOpen = state;
Q_EMIT playerOpenChanged(state);
}
void AudioManager::setMuted(bool muted) void AudioManager::setMuted(bool muted)
{ {
d->m_player.setMuted(muted); d->m_player.setMuted(muted);

View File

@ -22,11 +22,6 @@ class AudioManager : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool playerOpen
READ playerOpen
WRITE setPlayerOpen
NOTIFY playerOpenChanged)
Q_PROPERTY(Entry* entry Q_PROPERTY(Entry* entry
READ entry READ entry
WRITE setEntry WRITE setEntry
@ -111,8 +106,6 @@ public:
[[nodiscard]] Entry* entry() const; [[nodiscard]] Entry* entry() const;
[[nodiscard]] bool playerOpen() const;
[[nodiscard]] bool muted() const; [[nodiscard]] bool muted() const;
[[nodiscard]] qreal volume() const; [[nodiscard]] qreal volume() const;
@ -149,8 +142,6 @@ public:
Q_SIGNALS: Q_SIGNALS:
void playerOpenChanged(bool state);
void entryChanged(Entry* entry); void entryChanged(Entry* entry);
void mutedChanged(bool muted); void mutedChanged(bool muted);
@ -193,8 +184,6 @@ public Q_SLOTS:
void setEntry(Entry* entry); void setEntry(Entry* entry);
void setPlayerOpen(bool state);
void setMuted(bool muted); void setMuted(bool muted);
void setVolume(qreal volume); void setVolume(qreal volume);

View File

@ -87,14 +87,14 @@ Flickable {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: root.height + footerLoader.minimizedSize height: root.height + root.miniplayerSize
spacing: 0 spacing: 0
MinimizedPlayerControls { MinimizedPlayerControls {
id: playControlItem id: playControlItem
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: Kirigami.Units.gridUnit * 2.5 Layout.minimumHeight: root.miniplayerSize
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
focus: true focus: true
} }

View File

@ -18,14 +18,9 @@ Item {
property int miniplayerheight: Kirigami.Units.gridUnit * 3 property int miniplayerheight: Kirigami.Units.gridUnit * 3
property int progressbarheight: Kirigami.Units.gridUnit / 6 property int progressbarheight: Kirigami.Units.gridUnit / 6
property int buttonsize: Kirigami.Units.gridUnit * 2 property int buttonsize: Kirigami.Units.gridUnit * 2
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
width: parent.width
//height: (audio.entry == undefined || audio.playerOpen) ? 0 : Kirigami.Units.gridUnit * 3.5 + (Kirigami.Units.gridUnit / 6)
height: miniplayerheight + progressbarheight height: miniplayerheight + progressbarheight
//margins.bottom: miniprogressbar.height
visible: (audio.entry !== undefined) && !audio.playerOpen visible: (audio.entry)
// Set background // Set background
Rectangle { Rectangle {
@ -100,14 +95,14 @@ Item {
id: trackClick id: trackClick
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: pageStack.layers.push("qrc:/PlayerControls.qml") onClicked: toOpen.restart()
} }
} }
Controls.Button { Controls.Button {
id: playButton id: playButton
icon.name: audio.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start" icon.name: audio.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
icon.height: parent.parent.buttonsize //Kirigami.Units.gridUnit * 2.5 icon.height: parent.parent.buttonsize
icon.width: parent.parent.buttonsize //Kirigami.Units.gridUnit * 2.5 icon.width: parent.parent.buttonsize
flat: true flat: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.maximumHeight: parent.parent.miniplayerheight Layout.maximumHeight: parent.parent.miniplayerheight

View File

@ -20,9 +20,6 @@ Kirigami.Page {
clip: true clip: true
Layout.margins: 0 Layout.margins: 0
Component.onCompleted: audio.playerOpen = true
Component.onDestruction: audio.playerOpen = false
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
Controls.SwipeView { Controls.SwipeView {

View File

@ -17,12 +17,9 @@ import org.kde.alligator 1.0
Kirigami.ApplicationWindow { Kirigami.ApplicationWindow {
id: root id: root
title: "Alligator" title: "Alligator"
//pageStack.initialPage: SettingsManager.lastOpenedPage === "FeedListPage" ? feedList property var miniplayerSize: Kirigami.Units.gridUnit * 3 + Kirigami.Units.gridUnit / 6
// : SettingsManager.lastOpenedPage === "QueuePage" ? queueList
// : feedList
Kirigami.PagePool { Kirigami.PagePool {
id: mainPagePool id: mainPagePool
cachePages: true cachePages: true
@ -84,17 +81,8 @@ Kirigami.ApplicationWindow {
id: contextDrawer id: contextDrawer
} }
/*FeedListPage {
id: feedList
}
QueuePage {
id: queueList
}*/
AudioManager { AudioManager {
id: audio id: audio
playerOpen: false
} }
Mpris2 { Mpris2 {
@ -109,20 +97,14 @@ Kirigami.ApplicationWindow {
} }
} }
footer: Loader { // create space at the bottom to show miniplayer without it hiding stuff
active: (audio.entry) && !audio.playerOpen // underneath
visible: (audio.entry) && !audio.playerOpen pageStack.anchors.bottomMargin: (audio.entry) ? miniplayerSize : 0
sourceComponent: MinimizedPlayerControls { }
}
/*
Loader { Loader {
id: footerLoader id: footerLoader
property var minimizedSize: Kirigami.Units.gridUnit * 3.0
anchors.fill: parent anchors.fill: parent
active: (audio.entry == undefined) ? false : true active: (audio.entry) ? true : false
visible: active visible: active
z: (!item || item.contentY == 0) ? -1 : 999 z: (!item || item.contentY == 0) ? -1 : 999
sourceComponent: FooterBar { sourceComponent: FooterBar {
@ -132,18 +114,12 @@ Kirigami.ApplicationWindow {
} }
Item { // Doesn't look like this is needed at all:
visible: (audio.entry !== undefined) // capture mouse events behind flickable when it is open
height: footerLoader.minimizedSize /*MouseArea {
} visible: footerLoader.item.contentY != 0 // only capture when the mobile footer panel is open
*/ anchors.fill: footerLoader
preventStealing: true
/*Kirigami.OverlaySheet { onClicked: mouse.accepted = true
id: playeroverlay
sheetOpen: False
PlayerControls {
height: root.height*5.0/6.0
width: root.width*5.0/6.0;
}
}*/ }*/
} }