VirtualBox

Changeset 90883 in vbox for trunk/src


Ignore:
Timestamp:
Aug 25, 2021 1:49:13 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Runtime UI: Move close Runtime UI stuff to the place where it belongs (UISession).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r88633 r90883  
    7878    UIVisualStateType requestedVisualState() const;
    7979
    80     /** Close Runtime UI. */
     80public slots:
     81
     82    /** Closes Runtime UI. */
    8183    void closeRuntimeUI();
    8284
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r90878 r90883  
    399399    /* Manually close Runtime UI: */
    400400    if (fSuccess)
    401         closeRuntimeUI();
     401        uisession()->closeRuntimeUI();
    402402}
    403403
     
    455455    /* Manually close Runtime UI: */
    456456    if (fSuccess)
    457         closeRuntimeUI();
    458 }
    459 
    460 void UIMachineLogic::closeRuntimeUI()
    461 {
    462     /* First, we have to hide any opened modal/popup widgets.
    463      * They then should unlock their event-loops asynchronously.
    464      * If all such loops are unlocked, we can close Runtime UI: */
    465     QWidget *pWidget = QApplication::activeModalWidget() ?
    466                        QApplication::activeModalWidget() :
    467                        QApplication::activePopupWidget() ?
    468                        QApplication::activePopupWidget() : 0;
    469     if (pWidget)
    470     {
    471         /* First we should try to close this widget: */
    472         pWidget->close();
    473         /* If widget rejected the 'close-event' we can
    474          * still hide it and hope it will behave correctly
    475          * and unlock his event-loop if any: */
    476         if (!pWidget->isHidden())
    477             pWidget->hide();
    478         /* Asynchronously restart this slot: */
    479         QMetaObject::invokeMethod(this, "sltCloseRuntimeUI", Qt::QueuedConnection);
    480         return;
    481     }
    482 
    483     /* Asynchronously ask UISession to close Runtime UI: */
    484     LogRel(("GUI: Passing request to close Runtime UI from machine-logic to UI session.\n"));
    485     QMetaObject::invokeMethod(uisession(), "sltCloseRuntimeUI", Qt::QueuedConnection);
     457        uisession()->closeRuntimeUI();
    486458}
    487459
     
    643615
    644616                LogRel(("GUI: Request to close Runtime UI because VM is powered off already.\n"));
    645                 closeRuntimeUI();
     617                uisession()->closeRuntimeUI();
    646618                return;
    647619            }
     
    19471919    /* Close Runtime UI if state was saved: */
    19481920    if (fSuccess)
    1949         closeRuntimeUI();
     1921        uisession()->closeRuntimeUI();
    19501922}
    19511923
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r90878 r90883  
    151151    /** Power off VM, then close Runtime UI. */
    152152    void powerOff(bool fDiscardingState);
    153     /** Close Runtime UI. */
    154     void closeRuntimeUI();
    155153
    156154    /* API: 3D overlay visibility stuff: */
     
    356354    void sltShowGlobalPreferences();
    357355
    358     /** Close Runtime UI. */
    359     void sltCloseRuntimeUI() { closeRuntimeUI(); }
    360 
    361356    /** Handles request for visual state change. */
    362357    void sltHandleVisualStateChange();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r90878 r90883  
    455455}
    456456
     457void UISession::closeRuntimeUI()
     458{
     459    /* First, we have to hide any opened modal/popup widgets.
     460     * They then should unlock their event-loops asynchronously.
     461     * If all such loops are unlocked, we can close Runtime UI. */
     462    QWidget *pWidget = QApplication::activeModalWidget()
     463                     ? QApplication::activeModalWidget()
     464                     : QApplication::activePopupWidget()
     465                     ? QApplication::activePopupWidget()
     466                     : 0;
     467    if (pWidget)
     468    {
     469        /* First we should try to close this widget: */
     470        pWidget->close();
     471        /* If widget rejected the 'close-event' we can
     472         * still hide it and hope it will behave correctly
     473         * and unlock his event-loop if any: */
     474        if (!pWidget->isHidden())
     475            pWidget->hide();
     476        /* Asynchronously restart this slot: */
     477        QMetaObject::invokeMethod(this, "closeRuntimeUI", Qt::QueuedConnection);
     478        return;
     479    }
     480
     481    /* Asynchronously ask UIMachine to close Runtime UI: */
     482    LogRel(("GUI: Passing request to close Runtime UI from UI session to UI machine.\n"));
     483    QMetaObject::invokeMethod(uimachine(), "closeRuntimeUI", Qt::QueuedConnection);
     484}
     485
    457486void UISession::sltDetachCOM()
    458487{
     
    462491    cleanupNotificationCenter();
    463492    cleanupSession();
    464 }
    465 
    466 void UISession::sltCloseRuntimeUI()
    467 {
    468     /* Ask UIMachine to close Runtime UI: */
    469     uimachine()->closeRuntimeUI();
    470493}
    471494
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r90878 r90883  
    345345    void setMouseState(int iMouseState) { m_iMouseState = iMouseState; emit sigMouseStateChange(m_iMouseState); }
    346346
     347    /** Closes Runtime UI. */
     348    void closeRuntimeUI();
     349
    347350private slots:
    348351
    349352    /** Detaches COM. */
    350353    void sltDetachCOM();
    351     /** Close Runtime UI. */
    352     void sltCloseRuntimeUI();
    353354
    354355#ifdef RT_OS_DARWIN
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