[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: don't show the bookmark section in --no-medialibrary mode

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Jul 15 08:48:45 UTC 2022



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


Commits:
f8bbef35 by Pierre Lamot at 2022-07-15T08:34:25+00:00
qt: don't show the bookmark section in --no-medialibrary mode

fix: #27104

- - - - -
2c71cbdf by Pierre Lamot at 2022-07-15T08:34:25+00:00
qt: conditionally hide the chapter button

hides the chapters button when medialib is disabled and no chapters/bookmarks
are present

- - - - -


5 changed files:

- modules/gui/qt/menus/qml_menu_wrapper.cpp
- modules/gui/qt/player/control_list_filter.cpp
- modules/gui/qt/player/control_list_filter.hpp
- modules/gui/qt/player/qml/PlayerControlLayout.qml
- modules/gui/qt/player/qml/controlbarcontrols/BookmarkButton.qml


Changes:

=====================================
modules/gui/qt/menus/qml_menu_wrapper.cpp
=====================================
@@ -428,7 +428,10 @@ bool QmlMenuPositioner::eventFilter(QObject * object, QEvent * event)
 
     QAction * sectionTitles    = m_menu->addSection(qtr("Titles"));
     QAction * sectionChapters  = m_menu->addSection(qtr("Chapters"));
-    QAction * sectionBookmarks = m_menu->addSection(qtr("Bookmarks"));
+    QAction * sectionBookmarks = nullptr;
+
+    if (m_ctx->hasMediaLibrary())
+        sectionBookmarks = m_menu->addSection(qtr("Bookmarks"));
 
     // Titles
 
@@ -469,21 +472,23 @@ bool QmlMenuPositioner::eventFilter(QObject * object, QEvent * event)
     });
 
     // Bookmarks
+    if (m_ctx->hasMediaLibrary())
+    {
+        // FIXME: Do we really need a translation call for the string shortcut ?
+        m_menu->addAction(qtr("&Manage"), THEDP, &DialogsProvider::bookmarksDialog, qtr("Ctrl+B"));
 
-    // FIXME: Do we really need a translation call for the string shortcut ?
-    m_menu->addAction(qtr("&Manage"), THEDP, &DialogsProvider::bookmarksDialog, qtr("Ctrl+B"));
-
-    m_menu->addSeparator();
+        m_menu->addSeparator();
 
-    MLBookmarkModel * bookmarks = new MLBookmarkModel(m_ctx->getMediaLibrary(),
-                                                      m_player->getPlayer(), m_menu.get());
+        MLBookmarkModel * bookmarks = new MLBookmarkModel(m_ctx->getMediaLibrary(),
+                                                          m_player->getPlayer(), m_menu.get());
 
-    helper = new ListMenuHelper(m_menu.get(), bookmarks, nullptr, m_menu.get());
+        helper = new ListMenuHelper(m_menu.get(), bookmarks, nullptr, m_menu.get());
 
-    connect(helper, &ListMenuHelper::select, [bookmarks](int index)
-    {
-        bookmarks->select(bookmarks->index(index, 0));
-    });
+        connect(helper, &ListMenuHelper::select, [bookmarks](int index)
+        {
+            bookmarks->select(bookmarks->index(index, 0));
+        });
+    }
 
     m_positioner.popup(m_menu.get(), position, above);
 }


=====================================
modules/gui/qt/player/control_list_filter.cpp
=====================================
@@ -23,6 +23,7 @@
 // Player includes
 #include "player_controller.hpp"
 #include "control_list_model.hpp"
+#include "maininterface/mainctx.hpp"
 
 // Ctor / dtor
 
@@ -60,6 +61,12 @@ bool ControlListFilter::filterAcceptsRow(int source_row, const QModelIndex &) co
     {
         return (m_player->hasMenu() || m_player->isTeletextAvailable());
     }
+    else if (type == ControlListModel::BOOKMARK_BUTTON)
+    {
+        assert(m_ctx);
+        return (m_ctx->hasMediaLibrary() || m_player->hasChapters() || m_player->hasTitles());
+    }
+
 
     return true;
 }
@@ -82,8 +89,23 @@ void ControlListFilter::setPlayer(PlayerController * player)
 
     connect(player, &PlayerController::teletextAvailableChanged, this, &ControlListFilter::invalidate);
     connect(player, &PlayerController::hasMenuChanged,           this, &ControlListFilter::invalidate);
+    connect(player, &PlayerController::hasChaptersChanged,       this, &ControlListFilter::invalidate);
+    connect(player, &PlayerController::hasTitlesChanged,         this, &ControlListFilter::invalidate);
 
     invalidate();
 
     emit playerChanged();
 }
+
+MainCtx* ControlListFilter::ctx() const
+{
+    return m_ctx;
+}
+
+void ControlListFilter::setCtx(MainCtx* ctx)
+{
+    if (m_ctx == ctx)
+        return;
+    m_ctx = ctx;
+    emit ctxChanged();
+}


=====================================
modules/gui/qt/player/control_list_filter.hpp
=====================================
@@ -26,12 +26,14 @@
 
 // Forward declarations
 class PlayerController;
+class MainCtx;
 
 class ControlListFilter : public QSortFilterProxyModel
 {
     Q_OBJECT
 
     Q_PROPERTY(PlayerController * player READ player WRITE setPlayer NOTIFY playerChanged)
+    Q_PROPERTY(MainCtx* ctx READ ctx WRITE setCtx NOTIFY ctxChanged)
 
 public:
     explicit ControlListFilter(QObject * parent = nullptr);
@@ -44,13 +46,18 @@ protected: // QSortFilterProxyModel reimplementation
 
 signals:
     void playerChanged();
+    void ctxChanged();
 
 public: // Properties
     PlayerController * player();
     void setPlayer(PlayerController * player);
 
+    MainCtx* ctx() const;
+    void setCtx(MainCtx* ctx);
+
 private: // Variables
     PlayerController * m_player = nullptr;
+    MainCtx* m_ctx = nullptr;
 };
 
 #endif // CONTROLLISTFILTER_HPP


=====================================
modules/gui/qt/player/qml/PlayerControlLayout.qml
=====================================
@@ -73,6 +73,7 @@ FocusScope {
                 sourceModel: playerControlLayout.model.left
 
                 player: Player
+                ctx: MainCtx
             }
 
             Navigation.parentItem: playerControlLayout
@@ -106,6 +107,7 @@ FocusScope {
                 sourceModel: playerControlLayout.model.center
 
                 player: Player
+                ctx: MainCtx
             }
 
             Navigation.parentItem: playerControlLayout
@@ -141,6 +143,7 @@ FocusScope {
                 sourceModel: playerControlLayout.model.right
 
                 player: Player
+                ctx: MainCtx
             }
 
             rightAligned: true


=====================================
modules/gui/qt/player/qml/controlbarcontrols/BookmarkButton.qml
=====================================
@@ -38,6 +38,8 @@ Widgets.IconControlButton {
     // NOTE: We want to pop the menu above the button.
     onClicked: menu.popup(this.mapToGlobal(0, 0), true)
 
+    enabled: !paintOnly && (Player.hasChapters || Player.hasTitles || MainCtx.mediaLibraryAvailable)
+
     QmlBookmarkMenu {
         id: menu
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9dfe4399a0c00e469ceb9411e15e1835f1695859...2c71cbdfc105e3ab99db42d13ab2c5eb94bc257c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9dfe4399a0c00e469ceb9411e15e1835f1695859...2c71cbdfc105e3ab99db42d13ab2c5eb94bc257c
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