VirtualBox

Ignore:
Timestamp:
May 2, 2012 3:58:51 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: More predicted close VM handling.

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

Legend:

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

    r41108 r41122  
    10311031        return;
    10321032
    1033     /* Propose to close active machine window: */
    1034     activeMachineWindow()->sltTryClose();
     1033    /* Do not try to close machine-window if restricted: */
     1034    if (isPreventAutoClose())
     1035        return;
     1036
     1037    /* First, we have to close/hide any opened modal & popup application widgets.
     1038     * We have to make sure such window is hidden even if close-event was rejected.
     1039     * We are re-throwing this slot if any widget present to test again.
     1040     * If all opened widgets are closed/hidden, we can try to close machine-window: */
     1041    QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
     1042                       QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;
     1043    if (pWidget)
     1044    {
     1045        /* Closing/hiding all we found: */
     1046        pWidget->close();
     1047        if (!pWidget->isHidden())
     1048            pWidget->hide();
     1049        QTimer::singleShot(0, this, SLOT(sltClose()));
     1050        return;
     1051    }
     1052
     1053    /* Try to close active machine-window: */
     1054    activeMachineWindow()->close();
    10351055}
    10361056
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r41114 r41122  
    169169}
    170170
    171 void UIMachineWindow::sltTryClose()
    172 {
    173     /* Do not try to close window if restricted: */
    174     if (machineLogic()->isPreventAutoClose())
    175         return;
    176 
    177 #if 0
    178     // TODO: Is that really needed?
    179     /* This thing here is from Qt3.
    180      * First close any open modal & popup widgets.
    181      * Use a single shot with timeout 0 to allow the widgets to cleanly close and test then again.
    182      * If all open widgets are closed destroy ourself: */
    183     QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
    184                        QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;
    185     if (pWidget)
    186     {
    187         pWidget->close();
    188         QTimer::singleShot(0, this, SLOT(sltTryClose()));
    189     }
    190     else
    191 #endif
    192 
    193     close();
    194 }
    195 
    196171UIMachineWindow::UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId)
    197172    : QIWithRetranslateUI2<QMainWindow>(0, windowFlags(pMachineLogic->visualStateType()))
     
    218193    if (m_uScreenId == 0)
    219194        vboxGlobal().setMainWindow(this);
    220 }
    221 
    222 UIMachineWindow::~UIMachineWindow()
    223 {
    224 #if 0
    225     // TODO: Is that really needed?
    226     /* This thing here is from Qt3.
    227      * Close any opened modal & popup widgets: */
    228     while (QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
    229                               QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0)
    230     {
    231         /* Set modal/popup window's parent to null early,
    232          * because deleteLater() is synchronous
    233          * and will be called later than this destructor: */
    234         pWidget->setParent(0);
    235         /* Close modal/popup window early to hide it
    236          * because deleteLater() is synchronous
    237          * and will be called later than this destructor: */
    238         pWidget->close();
    239         /* Delete modal/popup window synchronously (safe): */
    240         pWidget->deleteLater();
    241     }
    242 #endif
    243195}
    244196
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r41114 r41122  
    6565    virtual void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
    6666
    67     /* Slot to close machine-window: */
    68     void sltTryClose();
    69 
    7067protected:
    7168
    72     /* Constructor/destructor: */
     69    /* Constructor: */
    7370    UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
    74     ~UIMachineWindow();
    7571
    7672    /* Show stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r41120 r41122  
    497497void UISession::sltCloseVirtualSession()
    498498{
    499     /* Recursively close all the usual modal & popup widgets... */
    500     QWidget *widget = QApplication::activeModalWidget() ?
    501                       QApplication::activeModalWidget() :
    502                       QApplication::activePopupWidget() ?
    503                       QApplication::activePopupWidget() : 0;
    504     if (widget)
    505     {
    506         widget->hide();
     499    /* First, we have to close/hide any opened modal & popup application widgets.
     500     * We have to make sure such window is hidden even if close-event was rejected.
     501     * We are re-throwing this slot if any widget present to test again.
     502     * If all opened widgets are closed/hidden, we can try to close machine-window: */
     503    QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
     504                       QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;
     505    if (pWidget)
     506    {
     507        /* Closing/hiding all we found: */
     508        pWidget->close();
     509        if (!pWidget->isHidden())
     510            pWidget->hide();
    507511        QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
    508512        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r38311 r41122  
    604604}
    605605
    606 void UISettingsDialog::closeEvent(QCloseEvent *pEvent)
    607 {
    608     if (m_fLoaded)
    609         QIMainDialog::closeEvent(pEvent);
    610     else
    611         pEvent->ignore();
    612 }
    613 
    614606void UISettingsDialog::assignValidator(UISettingsPage *pPage)
    615607{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r37168 r41122  
    119119    bool eventFilter(QObject *pObject, QEvent *pEvent);
    120120    void showEvent(QShowEvent *pEvent);
    121     void closeEvent(QCloseEvent *pEvent);
    122121
    123122    void assignValidator(UISettingsPage *pPage);
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