[vlc-commits] qt: enable windowed playlist

Abel Tesfaye git at videolan.org
Wed Jul 3 17:48:25 CEST 2019


vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Wed Jul  3 09:46:18 2019 +0300| [3d7215299e9d34e073977a64ed7644441b5e61f6] | committer: Jean-Baptiste Kempf

qt: enable windowed playlist

fixes #22173

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3d7215299e9d34e073977a64ed7644441b5e61f6
---

 modules/gui/qt/main_interface.cpp                | 14 +++++++++
 modules/gui/qt/main_interface.hpp                |  9 ++++++
 modules/gui/qt/qml/BannerSources.qml             | 16 ++++++----
 modules/gui/qt/qml/MainInterface.qml             | 15 ++++++++++
 modules/gui/qt/qml/mediacenter/MCMainDisplay.qml | 38 ++++++++++--------------
 modules/gui/qt/qml/menus/ViewMenu.qml            | 11 +++++++
 modules/gui/qt/qml/player/ControlBar.qml         |  2 ++
 modules/gui/qt/qml/player/ModalControlBar.qml    |  3 --
 modules/gui/qt/qml/player/Player.qml             | 30 +++++++++----------
 9 files changed, 91 insertions(+), 47 deletions(-)

diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 029a9f9d0b..b6c9219d53 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -537,6 +537,20 @@ void MainInterface::setVideoOnTop( bool on_top )
     }
 }
 
+void MainInterface::setPlaylistDocked( bool docked )
+{
+    b_playlistDocked = docked;
+
+    emit playlistDockedChanged(docked);
+}
+
+void MainInterface::setPlaylistVisible( bool visible )
+{
+    playlistVisible = visible;
+
+    emit playlistVisibleChanged(visible);
+}
+
 void MainInterface::setInterfaceAlwaysOnTop( bool on_top )
 {
     b_interfaceOnTop = on_top;
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index 3ceb91b40f..61a11ec4bf 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -63,6 +63,8 @@ class MainInterface : public QVLCMW
 {
     Q_OBJECT
 
+    Q_PROPERTY(bool playlistDocked READ isPlaylistDocked WRITE setPlaylistDocked NOTIFY playlistDockedChanged)
+    Q_PROPERTY(bool playlistVisible READ isPlaylistVisible WRITE setPlaylistVisible NOTIFY playlistVisibleChanged)
     Q_PROPERTY(bool interfaceAlwaysOnTop READ isInterfaceAlwaysOnTop WRITE setInterfaceAlwaysOnTop NOTIFY interfaceAlwaysOnTopChanged)
     Q_PROPERTY(bool interfaceFullScreen READ isInterfaceFullScreen WRITE setInterfaceFullScreen NOTIFY interfaceFullScreenChanged)
     Q_PROPERTY(bool hasEmbededVideo READ hasEmbededVideo NOTIFY hasEmbededVideoChanged)
@@ -111,6 +113,8 @@ public:
         RAISE_AUDIOVIDEO,
     };
     bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
+    bool isPlaylistDocked() { return b_playlistDocked; }
+    bool isPlaylistVisible() { return playlistVisible; }
     bool isInterfaceAlwaysOnTop() { return b_interfaceOnTop; }
     bool hasEmbededVideo() { return m_hasEmbededVideo; }
     QList<QQmlError> qmlErrors() const;
@@ -171,6 +175,7 @@ protected:
     bool                 b_videoFullScreen;     ///< --fullscreen
     bool                 b_hideAfterCreation;
     bool                 b_minimalView;         ///< Minimal video
+    bool                 b_playlistDocked;
     bool                 b_interfaceFullScreen;
     bool                 b_interfaceOnTop;      ///keep UI on top
     bool                 b_pauseOnMinimize;
@@ -196,6 +201,8 @@ public slots:
     void showUpdateSystrayMenu();
     void hideUpdateSystrayMenu();
     void toggleInterfaceFullScreen();
+    void setPlaylistDocked( bool );
+    void setPlaylistVisible( bool );
     void setInterfaceAlwaysOnTop( bool );
 
     void emitBoss();
@@ -242,6 +249,8 @@ signals:
     void askPopupMenu( bool show );
     void kc_pressed(); /* easter eggs */
 
+    void playlistDockedChanged(bool);
+    void playlistVisibleChanged(bool);
     void interfaceAlwaysOnTopChanged(bool);
     void interfaceFullScreenChanged(bool);
     void hasEmbededVideoChanged(bool);
diff --git a/modules/gui/qt/qml/BannerSources.qml b/modules/gui/qt/qml/BannerSources.qml
index 67d99dae57..e6acb42c93 100644
--- a/modules/gui/qt/qml/BannerSources.qml
+++ b/modules/gui/qt/qml/BannerSources.qml
@@ -352,7 +352,7 @@ Utils.NavigableFocusScope {
                             size: VLCStyle.icon_normal
                             text: VLCIcons.playlist
 
-                            onClicked: root.toogleMenu()
+                            onClicked: rootWindow.playlistVisible = !rootWindow.playlistVisible
 
                             KeyNavigation.right: menu_selector
                             KeyNavigation.up: buttonView
@@ -364,14 +364,17 @@ Utils.NavigableFocusScope {
                             size: VLCStyle.icon_normal
                             text: VLCIcons.menu
 
+                            KeyNavigation.left: playlist_btn
+                            KeyNavigation.right: playlist
+
                             onClicked: mainMenu.openBelow(this)
 
-                            Menus.MainDropdownMenu {
-                                id: mainMenu
-                                onClosed: menu_selector.forceActiveFocus()
+                        Menus.MainDropdownMenu {
+                            id: mainMenu
+                            onClosed: {
+                                if (mainMenu.activeFocus)
+                                    menu_selector.forceActiveFocus()
                             }
-
-                            KeyNavigation.up: buttonView
                         }
                     }
                 }
@@ -413,3 +416,4 @@ Utils.NavigableFocusScope {
             defaultKeyAction(event, 0)
     }
 }
+}
diff --git a/modules/gui/qt/qml/MainInterface.qml b/modules/gui/qt/qml/MainInterface.qml
index 0d23bc068b..e898d9a5d3 100644
--- a/modules/gui/qt/qml/MainInterface.qml
+++ b/modules/gui/qt/qml/MainInterface.qml
@@ -27,11 +27,26 @@ import "qrc:///style/"
 import "qrc:///player/" as Player
 import "qrc:///about/" as AB
 import "qrc:///dialogs/" as DG
+import "qrc:///playlist/" as PL
+import QtQuick.Window 2.11
 
 Rectangle {
     id: root
     color: "transparent"
 
+    Window {
+        id: playlistWindow
+        visible: !rootWindow.playlistDocked && rootWindow.playlistVisible
+        title: qsTr("Playlist")
+        color: VLCStyle.colors.bg
+        onClosing: rootWindow.playlistVisible = false
+        PL.PlaylistListView {
+            id: playlistView
+            focus: true
+            anchors.fill: parent
+        }
+    }
+
     PlaylistControllerModel {
         id: mainPlaylistController
         playlistPtr: mainctx.playlist
diff --git a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
index a7cfaa2252..25b78d4cde 100644
--- a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
@@ -88,7 +88,7 @@ Utils.NavigableFocusScope {
             focus: true
             id: medialibId
             anchors.fill: parent
-            onActionRight: playlist.show()
+            onActionRight: rootWindow.playlistVisible = true
 
             ColumnLayout {
                 id: column
@@ -135,8 +135,6 @@ Utils.NavigableFocusScope {
                     onActionRight: root.actionRight(index)
                     onActionUp: root.actionUp(index)
                     onActionCancel: root.actionCancel(index)
-
-                    onToogleMenu: playlist.toggleState()
                 }
 
                 Utils.StackViewExt {
@@ -169,7 +167,11 @@ Utils.NavigableFocusScope {
                         focus: false
                         expandHorizontally: true
 
-                        state: "hidden"
+                        state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden"
+                        onVisibleChanged: {
+                            if (playlist.visible)
+                                playlist.forceActiveFocus()
+                        }
                         component: Rectangle {
                             color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.9)
                             width: root.width/3
@@ -186,28 +188,18 @@ Utils.NavigableFocusScope {
                                     id: playlistView
                                     focus: true
                                     anchors.fill: parent
-                                    onActionLeft: playlist.quit()
-                                    onActionCancel: playlist.quit()
-                                    onActionUp: {
-                                        playlist.state = "hidden"
-                                        sourcesBanner.forceActiveFocus()
-                                    }
+                                    onActionLeft: playlist.closeAndFocus(stackView.currentItem)
+                                    onActionCancel: playlist.closeAndFocus(stackView.currentItem)
+                                    onActionUp: playlist.closeAndFocus(sourcesBanner)
                                 }
                             }
                         }
-                        function toggleState() {
-                            if (state === "hidden")
-                                show()
-                            else
-                                quit()
-                        }
-                        function quit() {
-                            state = "hidden"
-                            stackView.currentItem.forceActiveFocus()
-                        }
-                        function show() {
-                            state = "visible"
-                            playlist.forceActiveFocus()
+                        function closeAndFocus(item){
+                            if (!item)
+                                return
+
+                            rootWindow.playlistVisible = false
+                            item.forceActiveFocus()
                         }
                     }
                 }
diff --git a/modules/gui/qt/qml/menus/ViewMenu.qml b/modules/gui/qt/qml/menus/ViewMenu.qml
index 7a58605092..f8fd0abf2b 100644
--- a/modules/gui/qt/qml/menus/ViewMenu.qml
+++ b/modules/gui/qt/qml/menus/ViewMenu.qml
@@ -22,6 +22,17 @@ import "qrc:///style/"
 import "qrc:///utils/" as Utils
 
 Utils.MenuExt {
+    id: viewMenu
+    Action {
+        text: qsTr("Play&list")
+        onTriggered: rootWindow.playlistVisible = !rootWindow.playlistVisible
+    }
+    Action {
+        text: qsTr("Docked Playlist")
+        checkable: true
+        checked: rootWindow.playlistDocked
+        onTriggered: rootWindow.playlistDocked = !rootWindow.playlistDocked
+    }
     Action {
         text: qsTr("&Always on Top")
         checkable: true
diff --git a/modules/gui/qt/qml/player/ControlBar.qml b/modules/gui/qt/qml/player/ControlBar.qml
index 76399d488d..6d17375e13 100644
--- a/modules/gui/qt/qml/player/ControlBar.qml
+++ b/modules/gui/qt/qml/player/ControlBar.qml
@@ -26,6 +26,7 @@ import org.videolan.vlc 0.1
 import "qrc:///style/"
 import "qrc:///utils/" as Utils
 import "qrc:///menus/" as Menus
+import "qrc:///playlist/" as PL
 
 
 Utils.NavigableFocusScope {
@@ -121,6 +122,7 @@ Utils.NavigableFocusScope {
                                 if (buttonindex > 0)
                                     buttonloader.item.KeyNavigation.left = buttonrow.children[buttonindex-1].item
 
+
                             }
                         }
                     }
diff --git a/modules/gui/qt/qml/player/ModalControlBar.qml b/modules/gui/qt/qml/player/ModalControlBar.qml
index d534c8cdd0..a8e0d5ebeb 100644
--- a/modules/gui/qt/qml/player/ModalControlBar.qml
+++ b/modules/gui/qt/qml/player/ModalControlBar.qml
@@ -26,8 +26,6 @@ import "qrc:///utils/" as Utils
 
 Utils.NavigableFocusScope {
     id: root
-    signal showPlaylist();
-
     property bool showPlaylistButton: false
 
     property bool forceNoAutoHide: false
@@ -41,7 +39,6 @@ Utils.NavigableFocusScope {
             showPlaylistButton: root.showPlaylistButton
 
             onShowTrackBar: root.state = "tracks"
-            onShowPlaylist: root.showPlaylist()
 
             onActionUp: root.actionUp(index)
             onActionDown: root.actionDown(index)
diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index 403b8650ed..7beb818947 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -125,7 +125,11 @@ Utils.NavigableFocusScope {
         }
         focus: false
         expandHorizontally: true
-
+        state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden"
+        onVisibleChanged: {
+            if (playlistpopup.visible)
+                playlistpopup.forceActiveFocus()
+        }
         component: Rectangle {
             color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.8)
             width: root.width/4
@@ -135,18 +139,22 @@ Utils.NavigableFocusScope {
                 id: playlistView
                 focus: true
                 anchors.fill: parent
-                onActionLeft: playlistpopup.quit()
-                onActionCancel: playlistpopup.quit()
+                onActionLeft: playlistpopup.closeAndFocus(controlBarView)
+                onActionCancel: playlistpopup.closeAndFocus(controlBarView)
             }
         }
-        function quit() {
-            state = "hidden"
-            controlBarView.focus = true
-        }
         onStateChanged: {
             if (state === "hidden")
                 toolbarAutoHide.restart()
         }
+
+        function closeAndFocus(item){
+            if (!item)
+                return
+
+            rootWindow.playlistVisible = false
+            item.forceActiveFocus()
+        }
     }
 
 
@@ -193,14 +201,6 @@ Utils.NavigableFocusScope {
                     onActionLeft: root.actionLeft(index)
                     onActionRight: root.actionRight(index)
                     onActionCancel: root.actionCancel(index)
-                    onShowPlaylist: {
-                        if (playlistpopup.state === "visible") {
-                            playlistpopup.state = "hidden"
-                        } else {
-                            playlistpopup.state = "visible"
-                            playlistpopup.focus = true
-                        }
-                    }
 
                     //unhandled keys are forwarded to the vout window
                     Keys.forwardTo: videoSurface



More information about the vlc-commits mailing list