[vlc-devel] [PATCH 08/16] qt: allow changing user scale factor from preferences
Prince Gupta
guptaprince8832 at gmail.com
Tue Feb 23 10:05:58 UTC 2021
---
.../preferences/simple_preferences.cpp | 30 ++++++++++++++++++-
.../dialogs/preferences/sprefs_interface.ui | 30 +++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt/dialogs/preferences/simple_preferences.cpp b/modules/gui/qt/dialogs/preferences/simple_preferences.cpp
index d92c94d990..5a39e1af63 100644
--- a/modules/gui/qt/dialogs/preferences/simple_preferences.cpp
+++ b/modules/gui/qt/dialogs/preferences/simple_preferences.cpp
@@ -807,7 +807,35 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
CONFIG_BOOL( "qt-menubar", menuBarCheck );
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 );
+ 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 );
diff --git a/modules/gui/qt/dialogs/preferences/sprefs_interface.ui b/modules/gui/qt/dialogs/preferences/sprefs_interface.ui
index b14aacf247..63e6b4aecd 100644
--- a/modules/gui/qt/dialogs/preferences/sprefs_interface.ui
+++ b/modules/gui/qt/dialogs/preferences/sprefs_interface.ui
@@ -303,6 +303,36 @@
<string>Show the menu bar</string>
</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">
--
2.25.1
More information about the vlc-devel
mailing list