[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: fix precision loss with user interface scale calculation

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Mar 7 06:40:28 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ee11964c by Prince Gupta at 2025-03-07T06:25:38+00:00
qt: fix precision loss with user interface scale calculation

fixes interface scale change on setting dialog show

- - - - -
5f3a52be by Prince Gupta at 2025-03-07T06:25:38+00:00
qt: fix redundant signals on update interface scale

otherwise you've interface scale show up in UI

- - - - -


2 changed files:

- modules/gui/qt/dialogs/preferences/simple_preferences.cpp
- modules/gui/qt/maininterface/mainctx.cpp


Changes:

=====================================
modules/gui/qt/dialogs/preferences/simple_preferences.cpp
=====================================
@@ -838,7 +838,7 @@ SPrefsPanel::SPrefsPanel( qt_intf_t *_p_intf, QWidget *_parent,
             QObject::connect( ui.colorSchemeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged)
                               , p_intf->p_mi->getColorScheme(), &ColorSchemeModel::setCurrentIndex );
 
-            const float intfScaleFloatFactor = 100.f;
+            const double intfScaleFloatFactor = 100;
             const auto updateIntfUserScaleFactorFromControls =
                     [this, slider = ui.intfScaleFactorSlider, spinBox = ui.intfScaleFactorSpinBox, intfScaleFloatFactor](const int value)
             {


=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -516,16 +516,22 @@ void MainCtx::sendVLCHotkey(int vlcHotkey)
 
 void MainCtx::updateIntfScaleFactor()
 {
-    m_intfScaleFactor = m_intfUserScaleFactor;
+    auto newValue = m_intfUserScaleFactor;
     if (QWindow* window = p_intf->p_compositor ? p_intf->p_compositor->interfaceMainWindow() : nullptr)
     {
         QScreen* screen = window->screen();
         if (screen)
         {
             qreal dpi = screen->logicalDotsPerInch();
-            m_intfScaleFactor = m_intfUserScaleFactor * dpi / VLC_REFERENCE_SCALE_FACTOR;
+            newValue = m_intfUserScaleFactor * dpi / VLC_REFERENCE_SCALE_FACTOR;
         }
     }
+
+    const int FACTOR_RESOLUTION = 100;
+    if ( static_cast<int>(m_intfScaleFactor * FACTOR_RESOLUTION)
+         == static_cast<int>(newValue * FACTOR_RESOLUTION) ) return;
+
+    m_intfScaleFactor = newValue;
     emit intfScaleFactorChanged();
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/29793d55e1bbe9f2be97ae77bde48522164d8d7c...5f3a52be8885418dff61aeacc29f348ce0b078cc

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/29793d55e1bbe9f2be97ae77bde48522164d8d7c...5f3a52be8885418dff61aeacc29f348ce0b078cc
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