[vlc-commits] qml: use menubar in the interface
Pierre Lamot
git at videolan.org
Mon Oct 12 11:45:12 CEST 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Oct 5 16:05:44 2020 +0200| [09b288e3add156b97f84241c67222a6c08a7aa16] | committer: Pierre Lamot
qml: use menubar in the interface
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=09b288e3add156b97f84241c67222a6c08a7aa16
---
modules/gui/qt/maininterface/main_interface.cpp | 1 +
modules/gui/qt/maininterface/main_interface.hpp | 4 +
modules/gui/qt/maininterface/qml/BannerSources.qml | 106 +++++++++++++--------
modules/gui/qt/player/qml/TopBar.qml | 16 +++-
modules/gui/qt/playlist/qml/PlaylistMainView.qml | 3 +-
modules/gui/qt/qt.cpp | 6 ++
6 files changed, 91 insertions(+), 45 deletions(-)
diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index f7aeface7d..f2a0a8cf1a 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -161,6 +161,7 @@ MainInterface::MainInterface(intf_thread_t *_p_intf , QWidget* parent, Qt::Windo
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
m_clientSideDecoration = ! var_InheritBool( p_intf, "qt-titlebar" );
#endif
+ m_hasToolbarMenu = var_InheritBool( p_intf, "qt-menubar" );
QString platformName = QGuiApplication::platformName();
diff --git a/modules/gui/qt/maininterface/main_interface.hpp b/modules/gui/qt/maininterface/main_interface.hpp
index 07d6d0e849..1522bd4f3d 100644
--- a/modules/gui/qt/maininterface/main_interface.hpp
+++ b/modules/gui/qt/maininterface/main_interface.hpp
@@ -154,6 +154,7 @@ class MainInterface : public QVLCMW
Q_PROPERTY(ColorSchemeModel* colorScheme READ getColorScheme CONSTANT)
Q_PROPERTY(bool hasVLM READ hasVLM CONSTANT)
Q_PROPERTY(bool clientSideDecoration READ useClientSideDecoration NOTIFY useClientSideDecorationChanged)
+ Q_PROPERTY(bool hasToolbarMenu READ hasToolbarMenu NOTIFY hasToolbarMenuChanged)
public:
/* tors */
@@ -192,6 +193,7 @@ public:
inline ColorSchemeModel* getColorScheme() const { return m_colorScheme; }
bool hasVLM() const;
bool useClientSideDecoration() const;
+ inline bool hasToolbarMenu() const { return m_hasToolbarMenu; }
bool hasEmbededVideo() const;
VideoSurfaceProvider* getVideoSurfaceProvider() const;
@@ -256,6 +258,7 @@ protected:
bool m_gridView;
ColorSchemeModel* m_colorScheme;
bool m_clientSideDecoration = false;
+ bool m_hasToolbarMenu = false;
/* States */
bool playlistVisible; ///< Is the playlist visible ?
@@ -321,6 +324,7 @@ signals:
void gridViewChanged( bool );
void colorSchemeChanged( QString );
void useClientSideDecorationChanged();
+ void hasToolbarMenuChanged();
/// forward window maximise query to the actual window or widget
void requestInterfaceMaximized();
diff --git a/modules/gui/qt/maininterface/qml/BannerSources.qml b/modules/gui/qt/maininterface/qml/BannerSources.qml
index c8810e18c1..0f73fa6912 100644
--- a/modules/gui/qt/maininterface/qml/BannerSources.qml
+++ b/modules/gui/qt/maininterface/qml/BannerSources.qml
@@ -31,7 +31,11 @@ import "qrc:///menus/" as Menus
Widgets.NavigableFocusScope {
id: root
- height: VLCStyle.globalToolbar_height + VLCStyle.localToolbar_height + VLCStyle.applicationVerticalMargin
+ height: VLCStyle.applicationVerticalMargin
+ + (menubar.visible ? menubar.height : 0)
+ + VLCStyle.globalToolbar_height
+ + VLCStyle.localToolbar_height
+
property int selectedIndex: 0
property int subSelectedIndex: 0
@@ -93,7 +97,6 @@ Widgets.NavigableFocusScope {
property alias model: globalMenuGroup.model
Column {
-
id: col
anchors {
fill: parent
@@ -104,6 +107,8 @@ Widgets.NavigableFocusScope {
id: globalToolbar
width: parent.width
height: VLCStyle.globalToolbar_height
+ + (menubar.visible ? menubar.height : 0)
+ anchors.rightMargin: VLCStyle.applicationHorizontalMargin
property bool colapseTabButtons: globalToolbar.width > (Math.max(globalToolbarLeft.width, globalToolbarRight.width) + VLCStyle.applicationHorizontalMargin)* 2
+ globalMenuGroup.model.count * VLCStyle.bannerTabButton_width_large
@@ -115,54 +120,71 @@ Widgets.NavigableFocusScope {
source: "qrc:///widgets/CSDTitlebarTapNDrapHandler.qml"
}
- RowLayout {
- id: globalToolbarLeft
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
+ Column {
+ anchors.fill: parent
anchors.leftMargin: VLCStyle.applicationHorizontalMargin
- spacing: VLCStyle.margin_xxxsmall
+ anchors.rightMargin: VLCStyle.applicationHorizontalMargin
- Widgets.IconToolButton {
- id: history_back
- size: VLCStyle.banner_icon_size
- iconText: VLCIcons.topbar_previous
- text: i18n.qtr("Previous")
- height: localToolbar.height
- colorDisabled: VLCStyle.colors.textDisabled
- onClicked: history.previous()
- enabled: !history.previousEmpty
- }
-
- Image {
- sourceSize.width: VLCStyle.icon_small
- sourceSize.height: VLCStyle.icon_small
- source: "qrc:///logo/cone.svg"
- enabled: false
+ Menus.Menubar {
+ id: menubar
+ width: parent.width
+ height: implicitHeight
+ visible: mainInterface.hasToolbarMenu
}
- }
+ Item {
+ width: parent.width
+ height: VLCStyle.globalToolbar_height
+
+ RowLayout {
+ id: globalToolbarLeft
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ spacing: VLCStyle.margin_xxxsmall
+
+ Widgets.IconToolButton {
+ id: history_back
+ size: VLCStyle.banner_icon_size
+ iconText: VLCIcons.topbar_previous
+ text: i18n.qtr("Previous")
+ height: localToolbar.height
+ colorDisabled: VLCStyle.colors.textDisabled
+ onClicked: history.previous()
+ enabled: !history.previousEmpty
+ }
+
+ Image {
+ sourceSize.width: VLCStyle.icon_small
+ sourceSize.height: VLCStyle.icon_small
+ source: "qrc:///logo/cone.svg"
+ enabled: false
+ }
- /* Button for the sources */
- Widgets.NavigableRow {
- id: globalMenuGroup
+ }
- anchors {
- top: parent.top
- bottom: parent.bottom
- horizontalCenter: parent.horizontalCenter
- }
+ /* Button for the sources */
+ Widgets.NavigableRow {
+ id: globalMenuGroup
- focus: true
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ horizontalCenter: parent.horizontalCenter
+ }
- navigationParent: root
- navigationDownItem: localMenuGroup.visible ? localMenuGroup : playlistGroup
+ focus: true
- delegate: Widgets.BannerTabButton {
- iconTxt: model.icon
- showText: globalToolbar.colapseTabButtons
- selected: model.index === selectedIndex
- onClicked: root.itemClicked(model.index)
- height: globalMenuGroup.height
+ navigationParent: root
+ navigationDownItem: localMenuGroup.visible ? localMenuGroup : playlistGroup
+
+ delegate: Widgets.BannerTabButton {
+ iconTxt: model.icon
+ showText: globalToolbar.colapseTabButtons
+ selected: model.index === selectedIndex
+ onClicked: root.itemClicked(model.index)
+ height: globalMenuGroup.height
+ }
+ }
}
}
@@ -170,10 +192,10 @@ Widgets.NavigableFocusScope {
id: globalToolbarRight
anchors {
top: parent.top
- bottom: parent.bottom
right: parent.right
rightMargin: VLCStyle.applicationHorizontalMargin
}
+ height: VLCStyle.globalToolbar_height
active: mainInterface.clientSideDecoration
source: "qrc:///widgets/CSDWindowButtonSet.qml"
}
diff --git a/modules/gui/qt/player/qml/TopBar.qml b/modules/gui/qt/player/qml/TopBar.qml
index f7802ff832..085b18a246 100644
--- a/modules/gui/qt/player/qml/TopBar.qml
+++ b/modules/gui/qt/player/qml/TopBar.qml
@@ -24,6 +24,7 @@ import org.videolan.vlc 0.1
import "qrc:///style/"
import "qrc:///widgets/" as Widgets
+import "qrc:///menus/" as Menus
Widgets.NavigableFocusScope{
id: topFocusScope
@@ -81,7 +82,18 @@ Widgets.NavigableFocusScope{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
- spacing: VLCStyle.margin_xsmall
+ spacing: 0
+
+ Menus.Menubar {
+ id: menubar
+
+ width: parent.width
+ height: VLCStyle.icon_normal
+
+ Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
+
+ visible: mainInterface.hasToolbarMenu
+ }
RowLayout {
anchors.left: parent.left
@@ -137,7 +149,7 @@ Widgets.NavigableFocusScope{
id: windowAndGlobalButtonsLayout
Layout.alignment: Qt.AlignTop | Qt.AlignRight
- spacing: VLCStyle.margin_xsmall
+ spacing: 0
Loader {
//Layout.alignment: Qt.AlignRight | Qt.AlignTop
diff --git a/modules/gui/qt/playlist/qml/PlaylistMainView.qml b/modules/gui/qt/playlist/qml/PlaylistMainView.qml
index f31a4709df..32c2a951bc 100644
--- a/modules/gui/qt/playlist/qml/PlaylistMainView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistMainView.qml
@@ -36,8 +36,9 @@ Widgets.NavigableFocusScope {
ColumnLayout {
anchors.fill: parent
+ spacing: 0
- Menus.MainMenubar {
+ Menus.Menubar {
Layout.fillWidth: true
}
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index f51f11d1ae..917ee77037 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -238,6 +238,10 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define QT_CLIENT_SIDE_DECORATION_LONGTEXT N_( "This option enables the title bar. Disabling it will remove " \
"the titlebar and move window buttons within the interface (Client Side Decoration)" )
+
+#define QT_MENUBAR_TEXT N_( "Show the menu bar" )
+#define QT_MENUBAR_LONGTEXT N_( "This option displays the classic menu bar" )
+
#define FULLSCREEN_CONTROL_PIXELS N_( "Fullscreen controller mouse sensitivity" )
#define CONTINUE_PLAYBACK_TEXT N_("Continue playback?")
@@ -342,6 +346,8 @@ vlc_module_begin ()
QT_CLIENT_SIDE_DECORATION_TEXT, QT_CLIENT_SIDE_DECORATION_LONGTEXT, false )
#endif
+ add_bool( "qt-menubar", false, QT_MENUBAR_TEXT, QT_MENUBAR_LONGTEXT, false )
+
add_bool( "qt-embedded-open", false, QT_NATIVEOPEN_TEXT,
QT_NATIVEOPEN_TEXT, false )
More information about the vlc-commits
mailing list