VirtualBox

Ignore:
Timestamp:
Oct 26, 2022 4:55:35 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10313 Some more fixes and additions.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r97307 r97311  
    267267
    268268const char *UIExtraDataDefs::GUI_MediumSelector_DialogGeometry = "GUI/MediumSelector/DialogGeometry";
     269
     270const int UIExtraDataDefs::iFontScaleMin = 50;
     271const int UIExtraDataDefs::iFontScaleMax = 150;
    269272
    270273/* Obsolete keys: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r97307 r97311  
    489489        SHARED_LIBRARY_STUFF extern QMultiMap<QString, QString> g_mapOfObsoleteKeys;
    490490    /** @} */
     491
     492    /** @name Font scaling factor min-max.
     493      * @{ */
     494        extern const int iFontScaleMin;
     495        extern const int iFontScaleMax;
     496    /** @} */
    491497}
    492498
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r97307 r97311  
    26122612void UIExtraDataManager::setFontScaleFactor(int iFontScaleFactor)
    26132613{
    2614     int iMax = 200;
    2615     int iMin = 40;
    2616     if (iFontScaleFactor < iMin || iFontScaleFactor > iMax)
     2614    if (iFontScaleFactor < UIExtraDataDefs::iFontScaleMin || iFontScaleFactor > UIExtraDataDefs::iFontScaleMax)
    26172615        return;
    26182616    setExtraDataString(GUI_FontScaleFactor, QString::number(iFontScaleFactor));
     
    26242622    bool fConversion = false;
    26252623    int iScaleFactor = strFontScaleFactor.toInt(&fConversion);
    2626     int iMax = 200;
    2627     int iMin = 40;
    2628     if (!fConversion || iScaleFactor < iMin || iScaleFactor > iMax)
     2624    if (!fConversion || iScaleFactor < UIExtraDataDefs::iFontScaleMin || iScaleFactor > UIExtraDataDefs::iFontScaleMax)
    26292625        return 100;
    26302626    return iScaleFactor;
     
    48474843                    emit sigDetailsOptionsChange(enmType);
    48484844            }
     4845            /* Font scaling factor has changed: */
     4846            else if (strKey == GUI_FontScaleFactor)
     4847                emit sigFontScaleFactorChanged(fontScaleFactor());
    48494848        }
    48504849    }
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r97307 r97311  
    121121    void sigScalingOptimizationTypeChange(const QUuid &uMachineID);
    122122
     123    /** Notifies about font scale factor. */
     124    void sigFontScaleFactorChanged(int iFontScaleFactor);
     125
    123126#ifdef VBOX_WS_MAC
    124127    /** Notifies about the HiDPI optimization type change. */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r97307 r97311  
    6363#include "UIConverter.h"
    6464#include "UIDesktopWidgetWatchdog.h"
     65#include "UIExtraDataDefs.h"
    6566#include "UIExtraDataManager.h"
    6667#include "UIFDCreationDialog.h"
     
    321322    connect(gEDataManager, &UIExtraDataManager::sigLanguageChange,
    322323            this, &UICommon::sltGUILanguageChange);
     324    connect(gEDataManager, &UIExtraDataManager::sigFontScaleFactorChanged,
     325            this, &UICommon::sltHandleFontScaleFactorChanged);
    323326
    324327    qApp->installEventFilter(this);
     
    731734#endif
    732735
    733     scaleApplicationFont(gEDataManager->fontScaleFactor());
    734 }
    735 
    736 void UICommon::scaleApplicationFont(int iFontScaleFactor)
    737 {
    738     QFont appFont = qApp->font();
    739     if (appFont.pixelSize() != -1)
    740         appFont.setPixelSize(iFontScaleFactor / 100 * appFont.pixelSize());
    741     else
    742         appFont.setPointSize(iFontScaleFactor / 100 * appFont.pointSize());
    743     qApp->setFont(appFont);
     736
     737    iOriginalFontPixelSize = qApp->font().pixelSize();
     738    iOriginalFontPointSize = qApp->font().pointSize();
     739    sltHandleFontScaleFactorChanged(gEDataManager->fontScaleFactor());
    744740}
    745741
     
    27222718}
    27232719
     2720
     2721void UICommon::sltHandleFontScaleFactorChanged(int iFontScaleFactor)
     2722{
     2723    QFont appFont = qApp->font();
     2724
     2725    if (iOriginalFontPixelSize != -1)
     2726        appFont.setPixelSize(iFontScaleFactor / 100.f * iOriginalFontPixelSize);
     2727    else
     2728        appFont.setPointSize(iFontScaleFactor / 100.f * iOriginalFontPointSize);
     2729    qApp->setFont(appFont);
     2730}
     2731
    27242732void UICommon::retranslateUi()
    27252733{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r97307 r97311  
    527527    /** @} */
    528528
    529     /* Scales the qApp's font. iFontScaleFactor is percentage thus 100% is for no scaling. */
    530     void scaleApplicationFont(int iFontScaleFactor);
    531 
    532529public slots:
    533530
     
    590587        void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
    591588    /** @} */
     589
     590    /* Handle font scale factor change. */
     591    void sltHandleFontScaleFactorChanged(int iFontScaleFactor);
    592592
    593593private:
     
    782782    /** @} */
    783783#endif
     784    /** @name Font scaling related variables.
     785     * @{ */
     786       int iOriginalFontPixelSize;
     787       int iOriginalFontPointSize;
     788    /** @} */
    784789
    785790    /** Allows for shortcut access. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIFontScaleEditor.cpp

    r97307 r97311  
    3636#include "QIAdvancedSlider.h"
    3737#include "UIDesktopWidgetWatchdog.h"
     38#include "UIExtraDataDefs.h"
    3839#include "UIFontScaleEditor.h"
    3940
     
    176177    m_pScaleSlider->blockSignals(true);
    177178    m_pScaleSpinBox->blockSignals(true);
    178     const int iMinimum = 40;
    179     const int iMaximum = 200;
    180 
    181     const int iStep = 25;
     179    const int iMinimum = UIExtraDataDefs::iFontScaleMin;
     180    const int iMaximum = UIExtraDataDefs::iFontScaleMax;
    182181
    183182    m_pScaleSlider->setMinimum(iMinimum);
    184183    m_pScaleSlider->setMaximum(iMaximum);
    185     m_pScaleSlider->setPageStep(iStep);
    186     m_pScaleSlider->setSingleStep(1);
    187     m_pScaleSlider->setTickInterval(iStep);
     184    m_pScaleSlider->setPageStep(20);
     185    m_pScaleSlider->setSingleStep(10);
     186    m_pScaleSlider->setTickInterval(20);
     187    m_pScaleSpinBox->setSingleStep(10);
    188188    m_pScaleSpinBox->setMinimum(iMinimum);
    189189    m_pScaleSpinBox->setMaximum(iMaximum);
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