[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt/qml_menu_wrapper: Create QmlRendererMenu

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Apr 7 13:37:24 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
97d60ade by Benjamin Arnaud at 2022-04-07T13:21:56+00:00
qt/qml_menu_wrapper: Create QmlRendererMenu

- - - - -
eff2fe40 by Benjamin Arnaud at 2022-04-07T13:21:56+00:00
qml/controlbarcontrols: Create RendererButton

- - - - -
3864ec3f by Benjamin Arnaud at 2022-04-07T13:21:56+00:00
qml/ControlbarControls: Add RENDERER_BUTTON

- - - - -
399e96d3 by Benjamin Arnaud at 2022-04-07T13:21:56+00:00
custom_menus/ListMenuHelper: Fix event warning

- - - - -


9 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/menus/custom_menus.cpp
- modules/gui/qt/menus/qml_menu_wrapper.cpp
- modules/gui/qt/menus/qml_menu_wrapper.hpp
- modules/gui/qt/player/control_list_model.hpp
- modules/gui/qt/player/qml/ControlbarControls.qml
- + modules/gui/qt/player/qml/controlbarcontrols/RendererButton.qml
- modules/gui/qt/vlc.qrc


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -845,6 +845,7 @@ libqt_plugin_la_QML = \
 	gui/qt/player/qml/controlbarcontrols/PreviousButton.qml \
 	gui/qt/player/qml/controlbarcontrols/QuitButton.qml \
 	gui/qt/player/qml/controlbarcontrols/RandomButton.qml \
+	gui/qt/player/qml/controlbarcontrols/RendererButton.qml \
 	gui/qt/player/qml/controlbarcontrols/RecordButton.qml \
 	gui/qt/player/qml/controlbarcontrols/ReverseButton.qml \
 	gui/qt/player/qml/controlbarcontrols/SkipBackButton.qml \


=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -265,6 +265,7 @@ void MainUI::registerQMLTypes()
         qmlRegisterType<QmlGlobalMenu>( uri, versionMajor, versionMinor, "QmlGlobalMenu" );
         qmlRegisterType<QmlMenuBar>( uri, versionMajor, versionMinor, "QmlMenuBar" );
         qmlRegisterType<QmlBookmarkMenu>( uri, versionMajor, versionMinor, "QmlBookmarkMenu" );
+        qmlRegisterType<QmlRendererMenu>( uri, versionMajor, versionMinor, "QmlRendererMenu" );
         qmlRegisterType<NetworkMediaContextMenu>( uri, versionMajor, versionMinor, "NetworkMediaContextMenu" );
         qmlRegisterType<NetworkDeviceContextMenu>( uri, versionMajor, versionMinor, "NetworkDeviceContextMenu" );
         qmlRegisterType<PlaylistContextMenu>( uri, versionMajor, versionMinor, "PlaylistContextMenu" );


=====================================
modules/gui/qt/menus/custom_menus.cpp
=====================================
@@ -418,7 +418,7 @@ void ListMenuHelper::onModelReset()
         onRowsInserted(QModelIndex(), 0, count - 1);
 }
 
-void ListMenuHelper::onTriggered(bool checked)
+void ListMenuHelper::onTriggered(bool)
 {
     QAction * action = static_cast<QAction *> (sender());
 


=====================================
modules/gui/qt/menus/qml_menu_wrapper.cpp
=====================================
@@ -471,6 +471,34 @@ QmlBookmarkMenu::~QmlBookmarkMenu()
     m_menu->popup(pos);
 }
 
+// QmlRendererMenu
+
+/* explicit */ QmlRendererMenu::QmlRendererMenu(QObject * parent) : QObject(parent) {}
+
+QmlRendererMenu::~QmlRendererMenu()
+{
+    if (m_menu)
+        delete m_menu;
+}
+
+// Interface
+
+/* Q_INVOKABLE */ void QmlRendererMenu::popup(QPoint pos)
+{
+    if (m_ctx == nullptr)
+        return;
+
+    if (m_menu)
+        delete m_menu;
+
+    m_menu = new RendererMenu(nullptr, m_ctx->getIntf());
+
+    connect(m_menu, &QMenu::aboutToHide, this, &QmlRendererMenu::aboutToHide);
+    connect(m_menu, &QMenu::aboutToShow, this, &QmlRendererMenu::aboutToShow);
+
+    m_menu->popup(pos);
+}
+
 BaseMedialibMenu::BaseMedialibMenu(QObject* parent)
     : QObject(parent)
 {}


=====================================
modules/gui/qt/menus/qml_menu_wrapper.hpp
=====================================
@@ -204,6 +204,28 @@ private:
     QMenu * m_menu = nullptr;
 };
 
+class QmlRendererMenu : public QObject
+{
+    Q_OBJECT
+
+    SIMPLE_MENU_PROPERTY(MainCtx *, ctx, nullptr)
+
+public:
+    explicit QmlRendererMenu(QObject * parent = nullptr);
+
+    ~QmlRendererMenu();
+
+public: // Interface
+    Q_INVOKABLE void popup(QPoint pos);
+
+signals:
+    void aboutToHide();
+    void aboutToShow();
+
+private:
+    RendererMenu * m_menu = nullptr;
+};
+
 class BaseMedialibMenu : public QObject
 {
     Q_OBJECT


=====================================
modules/gui/qt/player/control_list_model.hpp
=====================================
@@ -74,6 +74,7 @@ public:
         DVD_MENUS_BUTTON,
         REVERSE_BUTTON,
         BOOKMARK_BUTTON,
+        RENDERER_BUTTON,
         SPECIAL_MAX,
 
         WIDGET_SPACER = 0x40,


=====================================
modules/gui/qt/player/qml/ControlbarControls.qml
=====================================
@@ -60,6 +60,7 @@ QtObject {
         { id: ControlListModel.VOLUME, file: "VolumeWidget.qml", label: VLCIcons.volume_high, text: I18n.qtr("Volume Widget") },
         { id: ControlListModel.DVD_MENUS_BUTTON, file: "DvdMenuButton.qml", label: VLCIcons.dvd_menu, text: I18n.qtr("DVD menus") },
         { id: ControlListModel.TELETEXT_BUTTONS, file: "TeletextWidget.qml", label: VLCIcons.tvtelx, text: I18n.qtr("Teletext") },
+        { id: ControlListModel.RENDERER_BUTTON, file: "RendererButton.qml", label: VLCIcons.renderer, text: I18n.qtr("Renderer Button") },
         { id: ControlListModel.ASPECT_RATIO_COMBOBOX, file: "AspectRatioWidget.qml", label: VLCIcons.aspect_ratio, text: I18n.qtr("Aspect Ratio") },
         { id: ControlListModel.WIDGET_SPACER, file: "SpacerWidget.qml", label: VLCIcons.space, text: I18n.qtr("Spacer") },
         { id: ControlListModel.WIDGET_SPACER_EXTEND, file: "ExpandingSpacerWidget.qml", label: VLCIcons.space, text: I18n.qtr("Expanding Spacer") },


=====================================
modules/gui/qt/player/qml/controlbarcontrols/RendererButton.qml
=====================================
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (C) 2021 VLC authors and VideoLAN
+ *
+ * Authors: Benjamin Arnaud <bunjee at omega.gg>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+import QtQuick 2.11
+
+import org.videolan.vlc 0.1
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+Widgets.IconControlButton {
+    size: VLCStyle.icon_medium
+
+    iconText: VLCIcons.renderer
+    text: I18n.qtr("Renderer")
+
+    // NOTE: We want to pop the menu after the button.
+    onClicked: menu.popup(this.mapToGlobal(width, 0))
+
+    QmlRendererMenu {
+        id: menu
+
+        ctx: MainCtx
+
+        onAboutToShow: playerControlLayout.requestLockUnlockAutoHide(true, menu)
+        onAboutToHide: playerControlLayout.requestLockUnlockAutoHide(false, menu)
+    }
+}


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -382,6 +382,7 @@
         <file alias="PreviousButton.qml">player/qml/controlbarcontrols/PreviousButton.qml</file>
         <file alias="QuitButton.qml">player/qml/controlbarcontrols/QuitButton.qml</file>
         <file alias="RandomButton.qml">player/qml/controlbarcontrols/RandomButton.qml</file>
+        <file alias="RendererButton.qml">player/qml/controlbarcontrols/RendererButton.qml</file>
         <file alias="RecordButton.qml">player/qml/controlbarcontrols/RecordButton.qml</file>
         <file alias="ReverseButton.qml">player/qml/controlbarcontrols/ReverseButton.qml</file>
         <file alias="SkipBackButton.qml">player/qml/controlbarcontrols/SkipBackButton.qml</file>



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/828ee7e601eed001470a94d99717ab1527106dcb...399e96d32027aed728a822e731e4f02cf6160943

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/828ee7e601eed001470a94d99717ab1527106dcb...399e96d32027aed728a822e731e4f02cf6160943
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