VirtualBox

Changeset 76159 in vbox


Ignore:
Timestamp:
Dec 11, 2018 11:03:40 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9254. Making scale factor editor's min/max values dynamic wrt. host's pixel ratio(s)

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.cpp

    r75372 r76159  
    3030/* GUI includes: */
    3131# include "QIAdvancedSlider.h"
     32# include "UIDesktopWidgetWatchdog.h"
    3233# include "UIScaleFactorEditor.h"
     34
     35/* External includes: */
     36# include <math.h>
    3337
    3438#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    255259    }
    256260
    257 
     261    configureScaleFactorMinMaxValues();
    258262    setLayout(m_pMainLayout);
    259263    retranslateUi();
     
    305309    }
    306310}
     311
     312void UIScaleFactorEditor::configureScaleFactorMinMaxValues()
     313{
     314    int iHostScreenCount = gpDesktop->screenCount();
     315    if (iHostScreenCount == 0)
     316        return;
     317    double dMaxDevicePixelRatio = gpDesktop->devicePixelRatio(0);
     318    for (int i = 1; i < iHostScreenCount; ++i)
     319        if (dMaxDevicePixelRatio < gpDesktop->devicePixelRatio(i))
     320            dMaxDevicePixelRatio = gpDesktop->devicePixelRatio(i);
     321
     322    const int iMinimum = 100;
     323    const int iMaximum = ceil(iMinimum + 100 * dMaxDevicePixelRatio);
     324
     325    const int iStep = 25;
     326
     327    m_pScaleSlider->setMinimum(iMinimum);
     328    m_pScaleSlider->setMaximum(iMaximum);
     329    m_pScaleSlider->setPageStep(iStep);
     330    m_pScaleSlider->setSingleStep(1);
     331    m_pScaleSlider->setTickInterval(iStep);
     332    m_pScaleSpinBox->setMinimum(iMinimum);
     333    m_pScaleSpinBox->setMaximum(iMaximum);
     334}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h

    r75372 r76159  
    8787    /** Sets the spinbox and slider to scale factor of currently selected monitor. */
    8888    void updateValuesAfterMonitorChange();
    89 
     89    /** Sets the min/max values of related widgets wrt. device pixel ratio(s) */
     90    void configureScaleFactorMinMaxValues();
    9091    /** @name Member widgets.
    9192      * @{ */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette