VirtualBox

Changeset 88651 in vbox


Ignore:
Timestamp:
Apr 22, 2021 12:12:33 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8161: More rework for Runtime UI; Save normal/scaled window geometry instantly instead of power off sequence.

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

Legend:

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

    r86051 r88651  
    1818/* Qt includes: */
    1919#include <QMenuBar>
    20 #include <QTimer>
     20#include <QTimerEvent>
    2121#include <QContextMenuEvent>
    2222#include <QResizeEvent>
    2323#include <QScrollBar>
     24#ifdef VBOX_WS_X11
     25# include <QTimer>
     26#endif
    2427
    2528/* GUI includes: */
     
    5659    : UIMachineWindow(pMachineLogic, uScreenId)
    5760    , m_pIndicatorsPool(0)
     61    , m_iGeometrySaveTimerId(-1)
    5862{
    5963}
     
    377381        {
    378382            /* Restore window geometry: */
    379             m_normalGeometry = geo;
    380             UICommon::setTopLevelGeometry(this, m_normalGeometry);
     383            m_geometry = geo;
     384            UICommon::setTopLevelGeometry(this, m_geometry);
    381385
    382386            /* If previous machine-state was NOT SAVED => normalize window to the optimal-size: */
     
    396400
    397401            /* Move it to the screen-center: */
    398             m_normalGeometry = geometry();
    399             m_normalGeometry.moveCenter(gpDesktop->availableGeometry(this).center());
    400             UICommon::setTopLevelGeometry(this, m_normalGeometry);
     402            m_geometry = geometry();
     403            m_geometry.moveCenter(gpDesktop->availableGeometry(this).center());
     404            UICommon::setTopLevelGeometry(this, m_geometry);
    401405        }
    402406
     
    409413    }
    410414#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    411 }
    412 
    413 void UIMachineWindowNormal::saveSettings()
    414 {
    415     /* Save window geometry: */
    416     {
    417         gEDataManager->setMachineWindowGeometry(machineLogic()->visualStateType(),
    418                                                 m_uScreenId, m_normalGeometry,
    419                                                 isMaximizedChecked(), uiCommon().managedVMUuid());
    420     }
    421 
    422     /* Call to base-class: */
    423     UIMachineWindow::saveSettings();
    424415}
    425416
     
    472463            if (!isMaximizedChecked())
    473464            {
    474                 m_normalGeometry.setSize(pResizeEvent->size());
     465                m_geometry.setSize(pResizeEvent->size());
    475466#ifdef VBOX_WITH_DEBUGGER_GUI
    476467                /* Update debugger window position: */
     
    478469#endif /* VBOX_WITH_DEBUGGER_GUI */
    479470            }
     471
     472            /* Restart geometry save timer: */
     473            if (m_iGeometrySaveTimerId != -1)
     474                killTimer(m_iGeometrySaveTimerId);
     475            m_iGeometrySaveTimerId = startTimer(300);
     476
     477            /* Let listeners know about geometry changes: */
    480478            emit sigGeometryChange(geometry());
    481479            break;
     
    491489            if (!isMaximizedChecked())
    492490            {
    493                 m_normalGeometry.moveTo(geometry().x(), geometry().y());
     491                m_geometry.moveTo(geometry().x(), geometry().y());
    494492#ifdef VBOX_WITH_DEBUGGER_GUI
    495493                /* Update debugger window position: */
     
    497495#endif /* VBOX_WITH_DEBUGGER_GUI */
    498496            }
     497
     498            /* Restart geometry save timer: */
     499            if (m_iGeometrySaveTimerId != -1)
     500                killTimer(m_iGeometrySaveTimerId);
     501            m_iGeometrySaveTimerId = startTimer(300);
     502           
     503            /* Let listeners know about geometry changes: */
    499504            emit sigGeometryChange(geometry());
    500505            break;
    501506        }
    502507        case QEvent::WindowActivate:
     508        {
     509            /* Let listeners know about geometry changes: */
    503510            emit sigGeometryChange(geometry());
    504511            break;
     512        }
     513        /* Handle timer event started above: */
     514        case QEvent::Timer:
     515        {
     516            QTimerEvent *pTimerEvent = static_cast<QTimerEvent*>(pEvent);
     517            if (pTimerEvent->timerId() == m_iGeometrySaveTimerId)
     518            {
     519                killTimer(m_iGeometrySaveTimerId);
     520                m_iGeometrySaveTimerId = -1;
     521                LogRel2(("GUI: UIMachineWindowNormal: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
     522                         m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height()));
     523                gEDataManager->setMachineWindowGeometry(machineLogic()->visualStateType(),
     524                                                        m_uScreenId, m_geometry,
     525                                                        isMaximizedChecked(), uiCommon().managedVMUuid());
     526            }
     527            break;
     528        }
    505529        default:
    506530            break;
     
    532556{
    533557    /* Restore the geometry cached by the window: */
    534     resize(m_normalGeometry.size());
    535     move(m_normalGeometry.topLeft());
     558    resize(m_geometry.size());
     559    move(m_geometry.topLeft());
    536560
    537561    /* Adjust machine-view accordingly: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r86061 r88651  
    103103    void loadSettings();
    104104
    105     /** Save settings routine. */
    106     void saveSettings();
    107105    /** Cleanup visual-state routine. */
    108106    void cleanupVisualState();
     
    139137
    140138    /** Holds the current window geometry. */
    141     QRect m_normalGeometry;
     139    QRect  m_geometry;
     140    /** Holds the geometry save timer ID. */
     141    int  m_iGeometrySaveTimerId;
    142142
    143143    /** Factory support. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r86054 r88651  
    1818/* Qt includes: */
    1919#include <QMenu>
    20 #include <QTimer>
     20#include <QTimerEvent>
    2121#include <QSpacerItem>
    2222#include <QResizeEvent>
     23#ifdef VBOX_WS_X11
     24# include <QTimer>
     25#endif
    2326
    2427/* GUI includes: */
     
    3942UIMachineWindowScale::UIMachineWindowScale(UIMachineLogic *pMachineLogic, ulong uScreenId)
    4043    : UIMachineWindow(pMachineLogic, uScreenId)
     44    , m_iGeometrySaveTimerId(-1)
    4145{
    4246}
     
    9599        {
    96100            /* Restore window geometry: */
    97             m_normalGeometry = geo;
    98             UICommon::setTopLevelGeometry(this, m_normalGeometry);
     101            m_geometry = geo;
     102            UICommon::setTopLevelGeometry(this, m_geometry);
    99103
    100104            /* Maximize (if necessary): */
     
    113117            resize(640, 480);
    114118            /* Move newly created window to the screen-center: */
    115             m_normalGeometry = geometry();
    116             m_normalGeometry.moveCenter(availableGeo.center());
    117             UICommon::setTopLevelGeometry(this, m_normalGeometry);
     119            m_geometry = geometry();
     120            m_geometry.moveCenter(availableGeo.center());
     121            UICommon::setTopLevelGeometry(this, m_geometry);
    118122        }
    119123
     
    127131}
    128132
    129 void UIMachineWindowScale::saveSettings()
    130 {
    131     /* Save window geometry: */
    132     {
    133         gEDataManager->setMachineWindowGeometry(machineLogic()->visualStateType(),
    134                                                 m_uScreenId, m_normalGeometry,
    135                                                 isMaximizedChecked(), uiCommon().managedVMUuid());
    136     }
    137 
    138     /* Call to base-class: */
    139     UIMachineWindow::saveSettings();
    140 }
    141 
    142133#ifdef VBOX_WS_MAC
    143134void UIMachineWindowScale::cleanupVisualState()
     
    169160{
    170161    /* Restore the geometry cached by the window: */
    171     resize(m_normalGeometry.size());
    172     move(m_normalGeometry.topLeft());
     162    resize(m_geometry.size());
     163    move(m_geometry.topLeft());
    173164
    174165    /* Adjust machine-view accordingly: */
     
    215206            if (!isMaximizedChecked())
    216207            {
    217                 m_normalGeometry.setSize(pResizeEvent->size());
     208                m_geometry.setSize(pResizeEvent->size());
    218209#ifdef VBOX_WITH_DEBUGGER_GUI
    219210                /* Update debugger window position: */
     
    221212#endif /* VBOX_WITH_DEBUGGER_GUI */
    222213            }
     214
     215            /* Restart geometry save timer: */
     216            if (m_iGeometrySaveTimerId != -1)
     217                killTimer(m_iGeometrySaveTimerId);
     218            m_iGeometrySaveTimerId = startTimer(300);
    223219            break;
    224220        }
     
    233229            if (!isMaximizedChecked())
    234230            {
    235                 m_normalGeometry.moveTo(geometry().x(), geometry().y());
     231                m_geometry.moveTo(geometry().x(), geometry().y());
    236232#ifdef VBOX_WITH_DEBUGGER_GUI
    237233                /* Update debugger window position: */
    238234                updateDbgWindows();
    239235#endif /* VBOX_WITH_DEBUGGER_GUI */
     236            }
     237
     238            /* Restart geometry save timer: */
     239            if (m_iGeometrySaveTimerId != -1)
     240                killTimer(m_iGeometrySaveTimerId);
     241            m_iGeometrySaveTimerId = startTimer(300);
     242            break;
     243        }
     244        /* Handle timer event started above: */
     245        case QEvent::Timer:
     246        {
     247            QTimerEvent *pTimerEvent = static_cast<QTimerEvent*>(pEvent);
     248            if (pTimerEvent->timerId() == m_iGeometrySaveTimerId)
     249            {
     250                killTimer(m_iGeometrySaveTimerId);
     251                m_iGeometrySaveTimerId = -1;
     252                LogRel2(("GUI: UIMachineWindowScale: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
     253                         m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height()));
     254                gEDataManager->setMachineWindowGeometry(machineLogic()->visualStateType(),
     255                                                        m_uScreenId, m_geometry,
     256                                                        isMaximizedChecked(), uiCommon().managedVMUuid());
    240257            }
    241258            break;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.h

    r86061 r88651  
    4747    void loadSettings();
    4848
    49     /** Save settings routine. */
    50     void saveSettings();
    5149#ifdef VBOX_WS_MAC
    5250    /** Cleanup visual-state routine. */
     
    7270
    7371    /** Holds the current window geometry. */
    74     QRect m_normalGeometry;
     72    QRect  m_geometry;
     73    /** Holds the geometry save timer ID. */
     74    int  m_iGeometrySaveTimerId;
    7575
    7676    /** Factory support. */
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