[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: reduce minimal window size and take into account scaling factor

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat Jan 14 18:25:29 UTC 2023



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


Commits:
a51d776d by Yann Lochet at 2023-01-14T17:36:56+00:00
qt: reduce minimal window size and take into account scaling factor

- - - - -
539678c4 by Yann Lochet at 2023-01-14T17:36:56+00:00
qml: introduce small screen breakpoint and isScreenSmall variable

- - - - -
3f2ff09e by Yann Lochet at 2023-01-14T17:36:56+00:00
qml: hide the artist list in the album list for small screens

- - - - -
0bb5d3c2 by Yann Lochet at 2023-01-14T17:36:56+00:00
qml/MainDisplay: make PlayQueue behave like a drawer at smaller window sizes

- - - - -


4 changed files:

- modules/gui/qt/maininterface/interface_window_handler.cpp
- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/style/VLCStyle.qml


Changes:

=====================================
modules/gui/qt/maininterface/interface_window_handler.cpp
=====================================
@@ -23,6 +23,7 @@
 #include "util/keyhelper.hpp"
 #include <QScreen>
 #include <QQmlProperty>
+#include <cmath>
 
 
 InterfaceWindowHandler::InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QWidget* widget, QObject *parent)
@@ -41,9 +42,6 @@ InterfaceWindowHandler::InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* main
     m_window->setIcon( QApplication::windowIcon() );
     m_window->setOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
 
-    m_window->setMinimumWidth( 450 );
-    m_window->setMinimumHeight( 300 );
-
     // this needs to be called asynchronously
     // otherwise QQuickWidget won't initialize properly
     QMetaObject::invokeMethod(this, [this]()
@@ -64,7 +62,20 @@ InterfaceWindowHandler::InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* main
         connect( THEMIM, &PlayerController::nameChanged, m_window, &QWindow::setTitle );
     }
 
-    connect( m_window, &QWindow::screenChanged, m_mainCtx, &MainCtx::updateIntfScaleFactor);
+    connect( m_window, &QWindow::screenChanged, m_mainCtx, &MainCtx::updateIntfScaleFactor );
+
+    const auto updateMinimumSize = [this]()
+    {
+        int width = 320;
+        int height = 300;
+
+        double intfScaleFactor = m_mainCtx->getIntfScaleFactor();
+        int scaledWidth = std::ceil( intfScaleFactor * width );
+        int scaledHeight = std::ceil( intfScaleFactor * height );
+
+        m_window->setMinimumSize( QSize(scaledWidth, scaledHeight) );
+    };
+    connect( m_mainCtx, &MainCtx::intfScaleFactorChanged, this, updateMinimumSize );
     m_mainCtx->updateIntfScaleFactor();
 
     m_mainCtx->onWindowVisibilityChanged(m_window->visibility());


=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -295,7 +295,9 @@ FocusScope {
 
                             bottomMargin: root.displayMargin
 
-                            right: playlistColumn.visible ? playlistColumn.left : parent.right
+                            right: (playlistColumn.visible && !VLCStyle.isScreenSmall)
+                                   ? playlistColumn.left
+                                   : parent.right
                             rightMargin: (MainCtx.playlistDocked && MainCtx.playlistVisible)
                                          ? 0
                                          : VLCStyle.applicationHorizontalMargin
@@ -303,6 +305,26 @@ FocusScope {
                         }
                     }
 
+                    Rectangle {
+                        anchors.fill: parent
+                        visible: VLCStyle.isScreenSmall && MainCtx.playlistVisible
+                        color: "black"
+                        opacity: 0.4
+
+                        MouseArea {
+                            anchors.fill: parent
+                            hoverEnabled: true
+                            onClicked: {
+                                MainCtx.playlistVisible = false
+                            }
+
+                            // Capture WheelEvents before they reach stackView
+                            onWheel: {
+                                wheel.accepted = true
+                            }
+                        }
+                    }
+
                     FocusScope {
                         id: playlistColumn
                         anchors {
@@ -311,9 +333,11 @@ FocusScope {
                         }
                         focus: false
 
-                        implicitWidth: Helpers.clamp(root.width / resizeHandle.widthFactor,
-                                                     playlist.minimumWidth,
-                                                     root.width / 2)
+                        implicitWidth: VLCStyle.isScreenSmall
+                                       ? root.width * 0.8
+                                       : Helpers.clamp(root.width / resizeHandle.widthFactor,
+                                                       playlist.minimumWidth,
+                                                       root.width / 2)
                         width: 0
                         height: parent.height - root.displayMargin
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -65,7 +65,11 @@ FocusScope {
     }
 
     function setCurrentItemFocus(reason) {
-        artistList.setCurrentItemFocus(reason);
+        if (VLCStyle.isScreenSmall) {
+            albumSubView.setCurrentItemFocus(reason);
+        } else {
+            artistList.setCurrentItemFocus(reason);
+        }
     }
 
     function _actionAtIndex(index) {
@@ -118,12 +122,14 @@ FocusScope {
             currentIndex: -1
             z: 1
             height: parent.height
-            width: Helpers.clamp(root.width / resizeHandle.widthFactor,
-                                 VLCStyle.colWidth(1) + VLCStyle.column_spacing,
-                                 root.width * .5)
+            width: VLCStyle.isScreenSmall
+                   ? 0
+                   : Helpers.clamp(root.width / resizeHandle.widthFactor,
+                                   VLCStyle.colWidth(1) + VLCStyle.column_spacing,
+                                   root.width * .5)
 
-            visible: artistModel.count > 0
-            focus: artistModel.count > 0
+            visible: !VLCStyle.isScreenSmall && (artistModel.count > 0)
+            focus: !VLCStyle.isScreenSmall && (artistModel.count > 0)
 
             backgroundColor: artistListBackground.usingAcrylic ? "transparent"
                                                                : artistListBackground.alternativeColor
@@ -209,7 +215,7 @@ FocusScope {
             focus: true
             initialIndex: root.initialAlbumIndex
             Navigation.parentItem: root
-            Navigation.leftItem: artistList
+            Navigation.leftItem: VLCStyle.isScreenSmall ? null : artistList
         }
     }
 


=====================================
modules/gui/qt/style/VLCStyle.qml
=====================================
@@ -232,6 +232,9 @@ QtObject {
     property int appWidth: 0
     property int appHeight: 0
 
+    readonly property int smallWidth: dp(600, scale)
+    readonly property bool isScreenSmall: appWidth <= smallWidth
+
     //global application margin "safe area"
     readonly property int applicationHorizontalMargin: 0
     readonly property int applicationVerticalMargin: 0



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/73f7ae0ff7fd1f9d95356934736ee526df9b564a...0bb5d3c2b67be91904a9e38c2105cf29c84fba1c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/73f7ae0ff7fd1f9d95356934736ee526df9b564a...0bb5d3c2b67be91904a9e38c2105cf29c84fba1c
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