VirtualBox

Ignore:
Timestamp:
Oct 18, 2011 9:01:00 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: cleaned up the maximum guest size code

File:
1 edited

Legend:

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

    r39021 r39023  
    154154void UIMachineViewScale::sltDesktopResized()
    155155{
    156     /* Recalculate the maximum guest size if necessary. */
    157     calculateMaxGuestSize();
     156
    158157}
    159158
     
    185184            /* Report to the VM thread that we finished resizing: */
    186185            session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    187 
    188             /* We also recalculate the maximum guest size if necessary.  In
    189              * fact we only need this on the first resize, but it is done
    190              * every time to keep the code simpler. */
    191             calculateMaxGuestSize();
    192186
    193187            /* Emit a signal about guest was resized: */
     
    368362}
    369363
    370 void UIMachineViewScale::calculateMaxGuestSize()
    371 {
    372     /* This method should not get called until we have initially set up the
    373      * maximum guest size policy. */
    374     Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid));
    375     /* If we are not doing automatic adjustment then there is nothing to do. */
    376     if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic)
    377     {
    378         /* The area taken up by the machine window on the desktop,
    379          * including window frame, title, menu bar and status bar: */
    380         QRect windowGeo = machineWindowWrapper()->machineWindow()->frameGeometry();
    381         /* The area taken up by the machine central widget, so excluding all decorations: */
    382         QRect centralWidgetGeo = static_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->centralWidget()->geometry();
    383         /* To work out how big we can make the console window while still fitting on the desktop,
    384          * we calculate workingArea() - (windowGeo - centralWidgetGeo).
    385          * This works because the difference between machine window and machine central widget
    386          * (or at least its width and height) is a constant. */
    387         m_fixedMaxGuestSize = QSize(  workingArea().width()
    388                                     - (windowGeo.width()
    389                                     - centralWidgetGeo.width()),
    390                                       workingArea().height()
    391                                     - (windowGeo.height()
    392                                     - centralWidgetGeo.height()));
    393     }
     364QSize UIMachineViewScale::calculateMaxGuestSize() const
     365{
     366    /* The area taken up by the machine window on the desktop,
     367     * including window frame, title, menu bar and status bar: */
     368    QRect windowGeo = machineWindowWrapper()->machineWindow()->frameGeometry();
     369    /* The area taken up by the machine central widget, so excluding all decorations: */
     370    QRect centralWidgetGeo = static_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->centralWidget()->geometry();
     371    /* To work out how big we can make the console window while still fitting on the desktop,
     372     * we calculate workingArea() - (windowGeo - centralWidgetGeo).
     373     * This works because the difference between machine window and machine central widget
     374     * (or at least its width and height) is a constant. */
     375    return QSize(  workingArea().width()
     376                 - (windowGeo.width() - centralWidgetGeo.width()),
     377                   workingArea().height()
     378                 - (windowGeo.height() - centralWidgetGeo.height()));
    394379}
    395380
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