Changeset 71106 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 22, 2018 3:22:35 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120971
- 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 22 22 /* GUI includes: */ 23 23 # include "UIActionPoolRuntime.h" 24 # include "UIDesktopWidgetWatchdog.h" 24 25 # include "UIMultiScreenLayout.h" 25 26 # include "UIExtraDataManager.h" … … 2800 2801 pMenu->clear(); 2801 2802 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.02808 << 1.12809 << 1.252810 << 1.52811 << 1.752812 << 2.0;2813 2814 2803 /* Create exclusive 'scale-factor' action-group: */ 2815 2804 QActionGroup *pActionGroup = new QActionGroup(pMenu); … … 2818 2807 /* Configure exclusive 'scale-factor' action-group: */ 2819 2808 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 2822 2826 { 2823 2827 /* 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()); 2826 2829 AssertPtrReturnVoid(pAction); 2827 2830 { 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 2828 2854 /* Configure exclusive 'scale-factor' action: */ 2829 pAction->setProperty("Requested Scale Factor", dScaleFactor);2830 2855 pAction->setCheckable(true); 2831 2856 if (dScaleFactor == dCurrentScaleFactor) 2832 2857 pAction->setChecked(true); 2833 2858 } 2859 2860 /* Increment scale-factor: */ 2861 dScaleFactor += dStep; 2834 2862 } 2863 while (dScaleFactor <= dMaximum); 2864 2835 2865 /* Insert group actions into menu: */ 2836 2866 pMenu->addActions(pActionGroup->actions()); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r71104 r71106 247 247 void UIMachineView::applyMachineViewScaleFactor() 248 248 { 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: */ 256 258 frameBuffer()->setScaleFactor(dScaleFactor); 257 259 frameBuffer()->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput); 260 258 261 /* Propagate the scale-factor related attributes to 3D service if necessary: */ 259 262 if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable()) … … 504 507 return; 505 508 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: */ 514 518 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: */ 516 522 if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable()) 517 523 { … … 695 701 m_pFrameBuffer->setScalingOptimizationType(gEDataManager->scalingOptimizationType(vboxGlobal().managedVMUuid())); 696 702 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: */ 698 707 const double dDevicePixelRatioFormal = gpDesktop->devicePixelRatio(machineWindow()); 699 708 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: */ 706 713 m_pFrameBuffer->setDevicePixelRatio(dDevicePixelRatioFormal); 707 714 m_pFrameBuffer->setDevicePixelRatioActual(dDevicePixelRatioActual); 708 715 m_pFrameBuffer->setScaleFactor(dScaleFactor); 709 716 m_pFrameBuffer->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput); 717 710 718 /* Propagate the scale-factor related attributes to 3D service if necessary: */ 711 719 if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
Note:
See TracChangeset
for help on using the changeset viewer.