[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: add dp() to MainCtx

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Feb 12 17:33:51 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0a73fb78 by Fatih Uzunoglu at 2023-02-12T17:15:31+00:00
qt: add dp() to MainCtx

- - - - -
0e6b5460 by Fatih Uzunoglu at 2023-02-12T17:15:31+00:00
qml: refer to MainCtx.dp with VLCStyle.dp

- - - - -


3 changed files:

- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/style/VLCStyle.qml


Changes:

=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -850,3 +850,13 @@ void MainCtx::setAttachedToolTip(QObject *toolTip)
     obj->deleteLater();
 #endif
 }
+
+double MainCtx::dp(const double px, const double scale)
+{
+    return std::round(px * scale);
+}
+
+double MainCtx::dp(const double px) const
+{
+    return dp(px, m_intfScaleFactor);
+}


=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -296,6 +296,9 @@ public:
 
     CSDButtonModel *csdButtonModel() { return m_csdButtonModel.get(); }
 
+    Q_INVOKABLE static double dp(const double px, const double scale);
+    Q_INVOKABLE double dp(const double px) const;
+
 protected:
     /* Systray */
     void createSystray();


=====================================
modules/gui/qt/style/VLCStyle.qml
=====================================
@@ -302,19 +302,7 @@ QtObject {
     // Player controlbar
     readonly property int maxControlbarControlHeight: dp(64, scale)
 
-    //device pixel
-    function dp(px, scale) {
-        if (typeof scale === "undefined")
-            scale = MainCtx.intfScaleFactor
-
-        var scaledPx = Math.round(px * scale)
-        if (scaledPx < 0)
-            return Math.min(-1, scaledPx)
-        else if (scaledPx > 0)
-            return Math.max(1, scaledPx)
-        else // scaledPx == 0
-            return 0
-    }
+    readonly property var dp: MainCtx.dp
 
     function colWidth(nb) {
       return nb * VLCStyle.column_width + ( nb - 1 ) * VLCStyle.column_spacing;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d99fb8edc1715aebbddaa1c5342c6a9eeb3e5700...0e6b54602144269fe844a0ca536b83f9c941cc1b

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