VirtualBox

Ignore:
Timestamp:
Feb 22, 2018 3:22:35 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120971
Message:

FE/Qt: bugref:8694: Runtime UI: Unify all scaling options under one View menu; that includes Unscaled HiDPI Output, Auto-scaled HiDPI Output and various user scaling-factors.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r71027 r71106  
    2222/* GUI includes: */
    2323# include "UIActionPoolRuntime.h"
     24# include "UIDesktopWidgetWatchdog.h"
    2425# include "UIMultiScreenLayout.h"
    2526# include "UIExtraDataManager.h"
     
    28002801    pMenu->clear();
    28012802
    2802     /* Get corresponding scale-factor: */
    2803     const double dCurrentScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    2804 
    2805     /* Prepare new contents: */
    2806     const QList<double> factors = QList<double>()
    2807                                   << 1.0
    2808                                   << 1.1
    2809                                   << 1.25
    2810                                   << 1.5
    2811                                   << 1.75
    2812                                   << 2.0;
    2813 
    28142803    /* Create exclusive 'scale-factor' action-group: */
    28152804    QActionGroup *pActionGroup = new QActionGroup(pMenu);
     
    28182807        /* Configure exclusive 'scale-factor' action-group: */
    28192808        pActionGroup->setExclusive(true);
    2820         /* For every available scale-factor: */
    2821         foreach (const double &dScaleFactor, factors)
     2809
     2810        /* Get current scale-factor: */
     2811        const double dCurrentScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     2812
     2813        /* Get device-pixel-ratio: */
     2814        bool fDevicePixelRatioMentioned = false;
     2815        const double dDevicePixelRatioActual = qMin(gpDesktop->devicePixelRatioActual(),
     2816                                                    10.0 /* meh, who knows? */);
     2817
     2818        /* Calculate minimum, maximum and step: */
     2819        const double dMinimum = 1.0;
     2820        const double dMaximum = ceil(dMinimum + dDevicePixelRatioActual);
     2821        const double dStep = 0.25;
     2822
     2823        /* Now, iterate possible scale-factors: */
     2824        double dScaleFactor = dMinimum;
     2825        do
    28222826        {
    28232827            /* Create exclusive 'scale-factor' action: */
    2824             QAction *pAction = pActionGroup->addAction(QApplication::translate("UIActionPool", "%1%", "scale-factor")
    2825                                                                                .arg(dScaleFactor * 100));
     2828            QAction *pAction = pActionGroup->addAction(QString());
    28262829            AssertPtrReturnVoid(pAction);
    28272830            {
     2831                /* For the 'unscaled' action: */
     2832                if (dScaleFactor == 1.0)
     2833                {
     2834                    pAction->setProperty("Requested Scale Factor", dScaleFactor);
     2835                    pAction->setText(QApplication::translate("UIActionPool", "Scale to %1% (unscaled output)", "scale-factor")
     2836                                     .arg(dScaleFactor * 100));
     2837                }
     2838                /* For the 'autoscaled' action: */
     2839                else if ((dScaleFactor >= dDevicePixelRatioActual) && !fDevicePixelRatioMentioned)
     2840                {
     2841                    pAction->setProperty("Requested Scale Factor", dDevicePixelRatioActual);
     2842                    pAction->setText(QApplication::translate("UIActionPool", "Scale to %1% (autoscaled output)", "scale-factor")
     2843                                     .arg(dDevicePixelRatioActual * 100));
     2844                    fDevicePixelRatioMentioned = true;
     2845                }
     2846                /* For other actions: */
     2847                else
     2848                {
     2849                    pAction->setProperty("Requested Scale Factor", dScaleFactor);
     2850                    pAction->setText(QApplication::translate("UIActionPool", "Scale to %1%", "scale-factor")
     2851                                     .arg(dScaleFactor * 100));
     2852                }
     2853
    28282854                /* Configure exclusive 'scale-factor' action: */
    2829                 pAction->setProperty("Requested Scale Factor", dScaleFactor);
    28302855                pAction->setCheckable(true);
    28312856                if (dScaleFactor == dCurrentScaleFactor)
    28322857                    pAction->setChecked(true);
    28332858            }
     2859
     2860            /* Increment scale-factor: */
     2861            dScaleFactor += dStep;
    28342862        }
     2863        while (dScaleFactor <= dMaximum);
     2864
    28352865        /* Insert group actions into menu: */
    28362866        pMenu->addActions(pActionGroup->actions());
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r71104 r71106  
    247247void UIMachineView::applyMachineViewScaleFactor()
    248248{
    249     /* Take the scale-factor related attributes into account: */
    250     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    251 #ifdef VBOX_WS_MAC
    252     const bool fUseUnscaledHiDPIOutput = false;
    253 #else
    254     const bool fUseUnscaledHiDPIOutput = true;
    255 #endif
     249    /* Acquire selected scale-factor: */
     250    double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     251
     252    /* Take the device-pixel-ratio into account: */
     253    const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual();
     254    const bool fUseUnscaledHiDPIOutput = dScaleFactor != dDevicePixelRatioActual;
     255    dScaleFactor = fUseUnscaledHiDPIOutput ? dScaleFactor : 1.0;
     256
     257    /* Assign frame-buffer with new values: */
    256258    frameBuffer()->setScaleFactor(dScaleFactor);
    257259    frameBuffer()->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
     260
    258261    /* Propagate the scale-factor related attributes to 3D service if necessary: */
    259262    if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
     
    504507        return;
    505508
    506     /* Take the scale-factor into account: */
    507     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    508 #ifdef VBOX_WS_MAC
    509     const bool fUseUnscaledHiDPIOutput = false;
    510 #else
    511     const bool fUseUnscaledHiDPIOutput = true;
    512 #endif
    513     Q_UNUSED(fUseUnscaledHiDPIOutput);
     509    /* Acquire selected scale-factor: */
     510    double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     511
     512    /* Take the device-pixel-ratio into account: */
     513    const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual();
     514    const bool fUseUnscaledHiDPIOutput = dScaleFactor != dDevicePixelRatioActual;
     515    dScaleFactor = fUseUnscaledHiDPIOutput ? dScaleFactor : 1.0;
     516
     517    /* Assign frame-buffer with new values: */
    514518    frameBuffer()->setScaleFactor(dScaleFactor);
    515     /* Propagate the scale-factor to 3D service if necessary: */
     519    frameBuffer()->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
     520
     521    /* Propagate the scale-factor related attributes to 3D service if necessary: */
    516522    if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    517523    {
     
    695701        m_pFrameBuffer->setScalingOptimizationType(gEDataManager->scalingOptimizationType(vboxGlobal().managedVMUuid()));
    696702
    697         /* Take the scale-factor related attributes into account: */
     703        /* Acquire selected scale-factor: */
     704        double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     705
     706        /* Take the device-pixel-ratio into account: */
    698707        const double dDevicePixelRatioFormal = gpDesktop->devicePixelRatio(machineWindow());
    699708        const double dDevicePixelRatioActual = gpDesktop->devicePixelRatioActual(machineWindow());
    700         const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    701 #ifdef VBOX_WS_MAC
    702         const bool fUseUnscaledHiDPIOutput = false;
    703 #else
    704         const bool fUseUnscaledHiDPIOutput = true;
    705 #endif
     709        const bool fUseUnscaledHiDPIOutput = dScaleFactor != dDevicePixelRatioActual;
     710        dScaleFactor = fUseUnscaledHiDPIOutput ? dScaleFactor : 1.0;
     711
     712        /* Assign frame-buffer with new values: */
    706713        m_pFrameBuffer->setDevicePixelRatio(dDevicePixelRatioFormal);
    707714        m_pFrameBuffer->setDevicePixelRatioActual(dDevicePixelRatioActual);
    708715        m_pFrameBuffer->setScaleFactor(dScaleFactor);
    709716        m_pFrameBuffer->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
     717
    710718        /* Propagate the scale-factor related attributes to 3D service if necessary: */
    711719        if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
Note: See TracChangeset for help on using the changeset viewer.

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