[vlc-commits] [Git][videolan/vlc][master] qt: make "Media Library" context menu action no longer checkable

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Aug 12 11:31:05 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
b6a90210 by Fatih Uzunoglu at 2024-08-12T11:18:15+00:00
qt: make "Media Library" context menu action no longer checkable

... and adjust its title is properly such that:

- If already in player view, the title is "Show main view".
- If already in main view, the title is "Show player view".

Player view is currently considered another page, therefore
toggling does not make sense here (also considering the
navigation history). This button now always pushes into the
history.

- - - - -


11 changed files:

- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/maininterface/qml/BannerSources.qml
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/menus/menus.cpp
- modules/gui/qt/menus/menus.hpp
- modules/gui/qt/menus/qml/Menubar.qml
- modules/gui/qt/menus/qml_menu_wrapper.cpp
- modules/gui/qt/menus/qml_menu_wrapper.hpp
- modules/gui/qt/player/qml/TopBar.qml
- modules/gui/qt/player/qml/controlbarcontrols/MenuButton.qml


Changes:

=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -552,16 +552,6 @@ QString MainCtx::displayMRL(const QUrl &mrl) const
     return urlToDisplayString(mrl);
 }
 
-void MainCtx::setMediaLibraryVisible( bool visible )
-{
-    if (m_mediaLibraryVisible == visible)
-        return;
-
-    m_mediaLibraryVisible = visible;
-
-    emit mediaLibraryVisibleChanged(visible);
-}
-
 void MainCtx::setPlaylistDocked( bool docked )
 {
     b_playlistDocked = docked;


=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -95,8 +95,6 @@ class MainCtx : public QObject
 {
     Q_OBJECT
 
-    Q_PROPERTY(bool mediaLibraryVisible READ isMediaLibraryVisible WRITE setMediaLibraryVisible
-               NOTIFY mediaLibraryVisibleChanged FINAL)
     Q_PROPERTY(bool playlistDocked READ isPlaylistDocked WRITE setPlaylistDocked NOTIFY playlistDockedChanged FINAL)
     Q_PROPERTY(bool playlistVisible READ isPlaylistVisible WRITE setPlaylistVisible NOTIFY playlistVisibleChanged FINAL)
     Q_PROPERTY(double playlistWidthFactor READ getPlaylistWidthFactor WRITE setPlaylistWidthFactor NOTIFY playlistWidthFactorChanged FINAL)
@@ -193,7 +191,6 @@ public:
     Q_ENUM(OsType)
 
     inline QWindow::Visibility interfaceVisibility() const { return m_windowVisibility; }
-    bool isMediaLibraryVisible() { return m_mediaLibraryVisible; }
     bool isPlaylistDocked() { return b_playlistDocked; }
     bool isPlaylistVisible() { return m_playlistVisible; }
     inline double getPlaylistWidthFactor() const { return m_playlistWidthFactor; }
@@ -341,7 +338,6 @@ protected:
     QUrl                 m_dialogFilepath; /* Last path used in dialogs */
 
     /* States */
-    bool                 m_mediaLibraryVisible = true;
     bool                 m_playlistVisible = false;       ///< Is the playlist visible ?
     double               m_playlistWidthFactor = 4.;   ///< playlist size: root.width / playlistScaleFactor
     double               m_playerPlaylistWidthFactor = 4.;
@@ -377,7 +373,6 @@ protected:
 public slots:
     void toggleToolbarMenu();
     void toggleInterfaceFullScreen();
-    void setMediaLibraryVisible( bool );
     void setPlaylistDocked( bool );
     void setPlaylistVisible( bool );
     void setPlaylistWidthFactor( double );
@@ -421,7 +416,6 @@ signals:
     void askRaise();
     void kc_pressed(); /* easter eggs */
 
-    void mediaLibraryVisibleChanged(bool);
     void playlistDockedChanged(bool);
     void playlistVisibleChanged(bool);
     void playlistWidthFactorChanged(double);
@@ -469,6 +463,9 @@ signals:
     void windowSuportExtendedFrameChanged();
     void windowExtendedMarginChanged(unsigned margin);
 
+    void requestShowMainView();
+    void requestShowPlayerView();
+
 private:
     void loadPrefs(bool callSignals);
     void loadFromSettingsImpl(bool callSignals);


=====================================
modules/gui/qt/maininterface/qml/BannerSources.qml
=====================================
@@ -475,6 +475,7 @@ T.ToolBar {
                                 Menus.QmlGlobalMenu {
                                     id: contextMenu
                                     ctx: MainCtx
+                                    playerViewVisible: History.match(History.viewPath, ["player"])
                                 }
                             }
                         }


=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -167,31 +167,21 @@ Item {
         Connections {
             target: MainCtx
 
-            function onMediaLibraryVisibleChanged() {
-                if (MainCtx.mediaLibraryVisible) {
-                    if (History.match(History.viewPath, ["mc"]))
-                        return
-
-                    // NOTE: Useful when we started the application on the 'player' view.
-                    if (History.previousEmpty) {
-                        if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
-                            MainPlaylistController.stop()
+            function onRequestShowMainView() {
+                if (History.match(History.viewPath, ["mc"]))
+                    return
 
-                        _pushHome()
-
-                        return
-                    }
+                if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
+                    MainPlaylistController.stop()
 
-                    if (MainCtx.hasEmbededVideo && MainCtx.canShowVideoPIP === false)
-                        MainPlaylistController.stop()
+                _pushHome()
+            }
 
-                    History.previous()
-                } else {
-                    if (History.match(History.viewPath, ["player"]))
-                        return
+            function onRequestShowPlayerView() {
+                if (History.match(History.viewPath, ["player"]))
+                    return
 
-                    History.push(["player"])
-                }
+                History.push(["player"])
             }
         }
 


=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -281,7 +281,7 @@ void VLCMenuBar::ToolsMenu( qt_intf_t *p_intf, QMenu *menu )
  * Interface modification, load other interfaces, activate Extensions
  * \param current, set to NULL for menu creation, else for menu update
  **/
-void VLCMenuBar::ViewMenu( qt_intf_t *p_intf, QMenu *menu )
+void VLCMenuBar::ViewMenu(qt_intf_t *p_intf, QMenu *menu, std::optional<bool> playerViewVisible)
 {
     QAction *action;
 
@@ -300,21 +300,20 @@ void VLCMenuBar::ViewMenu( qt_intf_t *p_intf, QMenu *menu )
         if( m && m->parent() == menu ) delete m;
     }
 
-    QString title;
+    if (playerViewVisible.has_value())
+    {
+        QString title;
 
-    if (mi->hasMediaLibrary())
-        title = qtr("Media Library");
-    else
-        title = qtr("Browse and Discover");
+        if (*playerViewVisible)
+            title = qtr("Show &main view");
+        else
+            title = qtr("Show &player view");
 
-    action = menu->addAction(
-#ifndef __APPLE__
-            QIcon( ":/menu/media_library.svg" ),
-#endif
-            title);
-    action->setCheckable( true );
-    connect( action, &QAction::triggered, mi, &MainCtx::setMediaLibraryVisible );
-    action->setChecked( mi->isMediaLibraryVisible() );
+        action = menu->addAction(title);
+
+        connect( action, &QAction::triggered, mi, *playerViewVisible ? &MainCtx::requestShowMainView
+                                                                     : &MainCtx::requestShowPlayerView );
+    }
 
     action = menu->addAction(
 #ifndef __APPLE__


=====================================
modules/gui/qt/menus/menus.hpp
=====================================
@@ -80,7 +80,7 @@ public:
 
     static void ToolsMenu( qt_intf_t *, QMenu * );
 
-    static void ViewMenu( qt_intf_t *, QMenu *);
+    static void ViewMenu( qt_intf_t *, QMenu *, std::optional<bool> playerViewVisible = std::nullopt );
 
     static void InterfacesMenu( qt_intf_t *p_intf, QMenu * );
     static void ExtensionsMenu( qt_intf_t *p_intf, QMenu * );


=====================================
modules/gui/qt/menus/qml/Menubar.qml
=====================================
@@ -83,6 +83,7 @@ Item {
         id: menubar
         ctx: MainCtx
         menubar: menubarLayout
+        playerViewVisible: History.match(History.viewPath, ["player"])
 
         onMenuClosed: _menuIndex = -1
         onNavigateMenu: (direction) => {


=====================================
modules/gui/qt/menus/qml_menu_wrapper.cpp
=====================================
@@ -235,7 +235,7 @@ void QmlGlobalMenu::popup(QPoint pos)
 
     /* View menu, a bit different */
     submenu = m_menu->addMenu(qtr( "V&iew" ));
-    ViewMenu( p_intf, submenu );
+    ViewMenu( p_intf, submenu, m_playerViewVisible );
 
     submenu = m_menu->addMenu(qtr( "&Help" ));
     HelpMenu(submenu);
@@ -348,11 +348,11 @@ void QmlMenuBar::popupToolsMenu( QQuickItem* button )
     });
 }
 
-void QmlMenuBar::popupViewMenu( QQuickItem* button )
+void QmlMenuBar::popupViewMenu(QQuickItem* button )
 {
     popupMenuCommon(button, [this](QMenu* menu) {
         qt_intf_t* p_intf = m_ctx->getIntf();
-        ViewMenu( p_intf, menu );
+        ViewMenu( p_intf, menu, m_playerViewVisible );
     });
 }
 


=====================================
modules/gui/qt/menus/qml_menu_wrapper.hpp
=====================================
@@ -117,6 +117,7 @@ class QmlGlobalMenu : public VLCMenuBar
 {
     Q_OBJECT
     SIMPLE_MENU_PROPERTY(MainCtx*, ctx, nullptr)
+    SIMPLE_MENU_PROPERTY(bool, playerViewVisible, false)
 
     Q_PROPERTY(bool shown READ isShown NOTIFY shownChanged FINAL)
 
@@ -131,7 +132,7 @@ signals:
     void shownChanged();
 
 public slots:
-    void popup( QPoint pos );
+    void popup(QPoint pos);
 private:
     std::unique_ptr<QMenu> m_menu;
     bool m_shown = false;
@@ -145,6 +146,7 @@ class QmlMenuBar : public VLCMenuBar
     SIMPLE_MENU_PROPERTY(MainCtx*, ctx, nullptr)
     SIMPLE_MENU_PROPERTY(QQuickItem*, menubar, nullptr)
     SIMPLE_MENU_PROPERTY(bool, openMenuOnHover, false)
+    SIMPLE_MENU_PROPERTY(bool, playerViewVisible, false)
 
 public:
     explicit QmlMenuBar(QObject *parent = nullptr);


=====================================
modules/gui/qt/player/qml/TopBar.qml
=====================================
@@ -440,6 +440,7 @@ FocusScope{
                 id: contextMenu
 
                 ctx: MainCtx
+                playerViewVisible: History.match(History.viewPath, ["player"])
 
                 onAboutToShow: root.requestLockUnlockAutoHide(true)
                 onAboutToHide: root.requestLockUnlockAutoHide(false)


=====================================
modules/gui/qt/player/qml/controlbarcontrols/MenuButton.qml
=====================================
@@ -38,6 +38,7 @@ Widgets.IconToolButton {
         id: contextMenu
 
         ctx: MainCtx
+        playerViewVisible: History.match(History.viewPath, ["player"])
 
         onAboutToShow: menuBtn.requestLockUnlockAutoHide(true)
         onAboutToHide: menuBtn.requestLockUnlockAutoHide(false)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b6a90210b47e1865154db5f680f11266fc091efa

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b6a90210b47e1865154db5f680f11266fc091efa
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list