[vlc-commits] qt: allow changing user scale factor from preferences

Prince Gupta git at videolan.org
Mon Mar 1 10:40:13 UTC 2021


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Tue Feb 23 15:53:58 2021 +0530| [4ccb6535aadd1aeb9152094518003e1155e63272] | committer: Pierre Lamot

qt: allow changing user scale factor from preferences

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4ccb6535aadd1aeb9152094518003e1155e63272
---

 .../qt/dialogs/preferences/simple_preferences.cpp  | 28 ++++++++++++++++++++
 .../gui/qt/dialogs/preferences/sprefs_interface.ui | 30 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/modules/gui/qt/dialogs/preferences/simple_preferences.cpp b/modules/gui/qt/dialogs/preferences/simple_preferences.cpp
index a505e86902..adf40d8fc9 100644
--- a/modules/gui/qt/dialogs/preferences/simple_preferences.cpp
+++ b/modules/gui/qt/dialogs/preferences/simple_preferences.cpp
@@ -812,6 +812,34 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             ui.colorSchemeComboBox->insertItems(0, p_intf->p_sys->p_mi->getColorScheme()->stringList());
             QObject::connect( ui.colorSchemeComboBox, &QComboBox::currentTextChanged, p_intf->p_sys->p_mi->getColorScheme(), &ColorSchemeModel::setCurrent );
 
+            const float intfScaleFloatFactor = 100.f;
+            const auto updateIntfUserScaleFactorFromControls =
+                    [this, slider = ui.intfScaleFactorSlider, spinBox = ui.intfScaleFactorSpinBox, intfScaleFloatFactor](const int value)
+            {
+                if (slider->value() != value)
+                {
+                    QSignalBlocker s( slider );
+                    slider->setValue( value );
+                }
+                if (spinBox->value() != value)
+                {
+                    QSignalBlocker s( spinBox );
+                    spinBox->setValue( value );
+                }
+                p_intf->p_sys->p_mi->setIntfUserScaleFactor( value / intfScaleFloatFactor );
+            };
+
+            ui.intfScaleFactorSlider->setRange( p_intf->p_sys->p_mi->getMinIntfUserScaleFactor() * intfScaleFloatFactor
+                                                 , p_intf->p_sys->p_mi->getMaxIntfUserScaleFactor() * intfScaleFloatFactor);
+            ui.intfScaleFactorSpinBox->setRange( p_intf->p_sys->p_mi->getMinIntfUserScaleFactor() * intfScaleFloatFactor
+                                                 , p_intf->p_sys->p_mi->getMaxIntfUserScaleFactor() * intfScaleFloatFactor);
+
+            updateIntfUserScaleFactorFromControls( p_intf->p_sys->p_mi->getIntfUserScaleFactor() * intfScaleFloatFactor );
+            QObject::connect( ui.intfScaleFactorSlider, QOverload<int>::of(&QSlider::valueChanged)
+                              , p_intf->p_sys->p_mi , updateIntfUserScaleFactorFromControls );
+            QObject::connect( ui.intfScaleFactorSpinBox, QOverload<int>::of(&QSpinBox::valueChanged)
+                              , p_intf->p_sys->p_mi , updateIntfUserScaleFactorFromControls );
+
 #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
             CONFIG_BOOL( "qt-titlebar", titleBarCheckBox );
 #else
diff --git a/modules/gui/qt/dialogs/preferences/sprefs_interface.ui b/modules/gui/qt/dialogs/preferences/sprefs_interface.ui
index b14aacf247..cbc8eaaf60 100644
--- a/modules/gui/qt/dialogs/preferences/sprefs_interface.ui
+++ b/modules/gui/qt/dialogs/preferences/sprefs_interface.ui
@@ -304,6 +304,36 @@
                </property>
               </widget>
              </item>
+             <item row="14" column="0">
+              <widget class="QLabel" name="scaleFactorLabel">
+               <property name="text">
+                <string>Interface scale factor:</string>
+               </property>
+               <property name="buddy">
+                <cstring>intfScaleFactorSlider</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="14" column="2">
+              <widget class="QSlider" name="intfScaleFactorSlider">
+               <property name="tracking">
+                <bool>false</bool>
+               </property>
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+              </widget>
+             </item>
+             <item row="14" column="3">
+              <widget class="QSpinBox" name="intfScaleFactorSpinBox">
+               <property name="suffix">
+                <string> %</string>
+               </property>
+               <property name="singleStep">
+                <number>5</number>
+               </property>
+              </widget>
+             </item>
              <item row="5" column="0">
               <widget class="QCheckBox" name="titleBarCheckBox">
                <property name="text">



More information about the vlc-commits mailing list