[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: refactor interface initial mode loading
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Jun 4 10:32:31 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
07ef8ec0 by Fatih Uzunoglu at 2026-06-04T10:04:30+00:00
qt: refactor interface initial mode loading
- - - - -
ffd52502 by Fatih Uzunoglu at 2026-06-04T10:04:30+00:00
qml: use `MouseArea` for back button handling in `Player.qml`
Normally we prefer to use modern handlers, but handlers tend
to be problematic to play nice alongside other items and
handlers.
In this case, pressing back button on the control bar is not
being handled by the handler, for example. We could try to
explore adjusting `grabPermissions`, but considering this is
mainly intended for mouse interaction, we can just use the
legacy `MouseArea` instead.
- - - - -
3f8f180c by Fatih Uzunoglu at 2026-06-04T10:04:30+00:00
qt: introduce property `MainCtx::initialEffectiveMainInterfaceMode`
- - - - -
5a028ff2 by Fatih Uzunoglu at 2026-06-04T10:04:30+00:00
qml: disable playlist initial animation if initial mode is not main display in player
- - - - -
5 changed files:
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/player/qml/Player.qml
- modules/gui/qt/player/qml/PlayerPlaylistVisibilityFSM.qml
Changes:
=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -135,6 +135,24 @@ MainCtx::MainCtx(qt_intf_t *_p_intf)
: p_intf(_p_intf)
, m_csdButtonModel {std::make_unique<CSDButtonModel>(this, this)}
{
+ // If `playlist-autostart` is set, and there are initial files
+ // we don't bother loading main display just to unload it
+ // immediately after. Instead, we directly load the player
+ // page:
+ if (var_InheritBool(p_intf, "playlist-autostart"))
+ {
+ // We can not use `vlc_playlist_GetCurrentIndex()`, because
+ // playlist starts playing after the interface is added.
+ // We also can not use the playlist controller because it
+ // is not updated yet.
+ vlc_playlist_locker lock(p_intf->p_playlist);
+
+ if (vlc_playlist_Count(p_intf->p_playlist) > 0)
+ {
+ m_mainInterfaceModes |= MAININTERFACE_MODE_PLAYER;
+ }
+ }
+
/**
* Configuration and settings
* Pre-building of interface
@@ -282,6 +300,8 @@ MainCtx::MainCtx(qt_intf_t *_p_intf)
#endif
m_threadRunner = new ThreadRunner();
+
+ m_initialEffectiveMainInterfaceMode = getEffectiveMainInterfaceMode();
}
MainCtx::~MainCtx()
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -134,6 +134,7 @@ class MainCtx : public QObject
Q_PROPERTY(CSDButtonModel *csdButtonModel READ csdButtonModel CONSTANT FINAL)
Q_PROPERTY(MainInterfaceModes mainInterfaceModes READ getMainInterfaceModes NOTIFY mainInterfaceModesChanged FINAL)
Q_PROPERTY(MainInterfaceMode effectiveMainInterfaceMode READ getEffectiveMainInterfaceMode NOTIFY mainInterfaceModesChanged FINAL)
+ Q_PROPERTY(MainInterfaceMode initialEffectiveMainInterfaceMode READ getInitialEffectiveMainInterfaceMode CONSTANT FINAL)
//Property to get Operating System info
Q_PROPERTY(OsType osName READ getOSName CONSTANT)
@@ -385,6 +386,8 @@ public:
inline MainInterfaceModes getMainInterfaceModes() const { return m_mainInterfaceModes; };
MainInterfaceMode getEffectiveMainInterfaceMode() const;
+ MainInterfaceMode getInitialEffectiveMainInterfaceMode() const { return m_initialEffectiveMainInterfaceMode; }
+
Q_INVOKABLE static double dp(const double px, const double scale);
Q_INVOKABLE double dp(const double px) const;
@@ -452,6 +455,7 @@ protected:
double m_playlistWidthFactor = 4.; ///< playlist size: root.width / playlistScaleFactor
double m_playerPlaylistWidthFactor = 4.;
MainInterfaceModes m_mainInterfaceModes = { MAININTERFACE_MODE_MAINDISPLAY };
+ MainInterfaceMode m_initialEffectiveMainInterfaceMode = MAININTERFACE_MODE_MAINDISPLAY;
double m_artistAlbumsWidthFactor = 4.;
=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -42,45 +42,10 @@ import VLC.PlayerControls
Item {
id: root
- property bool _interfaceReady: false
- property bool _playlistReady: false
property bool _extendedFrameVisible: MainCtx.windowSuportExtendedFrame
&& MainCtx.clientSideDecoration
&& (MainCtx.intfMainWindow.visibility === Window.Windowed)
- property int _currentMode: MainCtx.MAININTERFACE_MODE_INVALID
-
- function setInitialView() {
- if (!MainCtx.minimalView && !MainPlaylistController.empty)
- MainCtx.playerView = true
- else
- _loadView()
- }
-
- function _loadView() {
- if (_currentMode === MainCtx.effectiveMainInterfaceMode)
- return
- // priority applies accross modes
- // minimal > player > medialib
- // MEDIALIB_MODE flag should always be set
- switch (MainCtx.effectiveMainInterfaceMode) {
- case MainCtx.MAININTERFACE_MODE_MINIMAL:
- viewLoader.source = "qrc:///qt/qml/VLC/Player/MinimalView.qml"
- break
- case MainCtx.MAININTERFACE_MODE_PLAYER:
- viewLoader.source = "qrc:///qt/qml/VLC/Player/Player.qml"
- break
- case MainCtx.MAININTERFACE_MODE_MAINDISPLAY:
- viewLoader.source = "qrc:///qt/qml/VLC/MainInterface/MainDisplay.qml"
- break
- default:
- console.error("unexpected interface mode", MainCtx.effectiveMainInterfaceMode)
- viewLoader.source = "qrc:///qt/qml/VLC/MainInterface/MainDisplay.qml"
- break
- }
- _currentMode = MainCtx.effectiveMainInterfaceMode
- }
-
Item {
id: g_mainInterface
@@ -140,26 +105,6 @@ Item {
source: "qrc:///qt/qml/VLC/Playlist/PlaylistDetachedWindow.qml"
}
- Connections {
- target: MainPlaylistController
-
- function onInitializedChanged() {
- console.assert(MainPlaylistController.initialized)
- if (root._interfaceReady && !root._playlistReady) {
- root._playlistReady = true
- setInitialView()
- }
- }
- }
-
- Connections {
- target: MainCtx
-
- function onEffectiveMainInterfaceModeChanged() {
- root._loadView()
- }
- }
-
Connections {
target: Player
function onPlayingStateChanged() {
@@ -169,14 +114,6 @@ Item {
}
}
- Component.onCompleted: {
- root._interfaceReady = true
- if (!root._playlistReady && MainPlaylistController.initialized) {
- root._playlistReady = true
- setInitialView()
- }
- }
-
DropArea {
anchors.fill: parent
z: -1
@@ -237,6 +174,23 @@ Item {
focus: true
// If there is depth buffer, clipping is not necessary:
clip: _extendedFrameVisible && !effect.hasDepthBuffer
+
+ source: {
+ // priority applies accross modes
+ // minimal > player > medialib
+ // MEDIALIB_MODE flag should always be set
+
+ switch (MainCtx.effectiveMainInterfaceMode) {
+ case MainCtx.MAININTERFACE_MODE_MINIMAL:
+ return "qrc:///qt/qml/VLC/Player/MinimalView.qml"
+ case MainCtx.MAININTERFACE_MODE_PLAYER:
+ return "qrc:///qt/qml/VLC/Player/Player.qml"
+ default:
+ console.error("unexpected interface mode", MainCtx.effectiveMainInterfaceMode)
+ case MainCtx.MAININTERFACE_MODE_MAINDISPLAY:
+ return "qrc:///qt/qml/VLC/MainInterface/MainDisplay.qml"
+ }
+ }
}
Loader {
=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -1003,9 +1003,14 @@ FocusScope {
}
}
- TapHandler {
+ MouseArea {
+ anchors.fill: parent
acceptedButtons: Qt.BackButton
- onTapped: MainCtx.playerView = false
+ propagateComposedEvents: true
+ cursorShape: undefined
+ onClicked: {
+ MainCtx.playerView = false
+ }
}
//filter key events to keep toolbar
=====================================
modules/gui/qt/player/qml/PlayerPlaylistVisibilityFSM.qml
=====================================
@@ -80,7 +80,11 @@ FSM {
FSMState {
id: fsmDocked
- initialState: (MainCtx.hasEmbededVideo || !MainCtx.playlistVisible )
+ initialState: (MainCtx.hasEmbededVideo || !MainCtx.playlistVisible ||
+ // Playlist animation is only enabled if the previous effective mode is main display
+ // mode. We currently don't care about animations when going to main display mode and back
+ // to player mode if the initial mode is not main display mode:
+ (MainCtx.initialEffectiveMainInterfaceMode !== MainCtx.MAININTERFACE_MODE_MAINDISPLAY))
? fsmHidden : fsmVisible
transitions: ({
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2fa826c9057635861bea94e48d6c87d242df659b...5a028ff2060b425efa28098b9027206bce1facfb
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2fa826c9057635861bea94e48d6c87d242df659b...5a028ff2060b425efa28098b9027206bce1facfb
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list