VirtualBox

Changeset 57178 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 4, 2015 3:57:24 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Closing code adjustment.

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

Legend:

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

    r55401 r57178  
    7070    void asyncChangeVisualState(UIVisualStateType visualStateType);
    7171
     72    /** Close Runtime UI. */
     73    void closeRuntimeUI() { destroy(); }
     74
    7275private slots:
    7376
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r57128 r57178  
    408408    /* Manually close Runtime UI: */
    409409    if (fSuccess)
    410         uisession()->closeRuntimeUI();
     410        closeRuntimeUI();
    411411}
    412412
     
    438438    /* Manually close Runtime UI: */
    439439    if (fSuccess)
    440         uisession()->closeRuntimeUI();
     440        closeRuntimeUI();
     441}
     442
     443void UIMachineLogic::closeRuntimeUI()
     444{
     445    /* First, we have to hide any opened modal/popup widgets.
     446     * They then should unlock their event-loops asynchronously.
     447     * If all such loops are unlocked, we can close Runtime UI: */
     448    QWidget *pWidget = QApplication::activeModalWidget() ?
     449                       QApplication::activeModalWidget() :
     450                       QApplication::activePopupWidget() ?
     451                       QApplication::activePopupWidget() : 0;
     452    if (pWidget)
     453    {
     454        /* First we should try to close this widget: */
     455        pWidget->close();
     456        /* If widget rejected the 'close-event' we can
     457         * still hide it and hope it will behave correctly
     458         * and unlock his event-loop if any: */
     459        if (!pWidget->isHidden())
     460            pWidget->hide();
     461        /* Asynchronously restart this slot: */
     462        QMetaObject::invokeMethod(this, "sltCloseRuntimeUI", Qt::QueuedConnection);
     463        return;
     464    }
     465
     466    /* Asynchronously ask UISession to close Runtime UI: */
     467    QMetaObject::invokeMethod(uisession(), "sltCloseRuntimeUI", Qt::QueuedConnection);
    441468}
    442469
     
    592619                }
    593620
    594                 uisession()->closeRuntimeUI();
     621                closeRuntimeUI();
    595622                return;
    596623            }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r57128 r57178  
    140140#endif /* Q_WS_MAC */
    141141
    142     /* API: Close actions: */
     142    /** Save VM state, then close Runtime UI. */
    143143    void saveState();
     144    /** Call for guest shutdown to close Runtime UI. */
    144145    void shutdown();
     146    /** Power off VM, then close Runtime UI. */
    145147    void powerOff(bool fDiscardingState);
     148    /** Close Runtime UI. */
     149    void closeRuntimeUI();
    146150
    147151    /* API: 3D overlay visibility stuff: */
     
    317321    void sltShowGlobalPreferences();
    318322
     323    /** Close Runtime UI. */
     324    void sltCloseRuntimeUI() { closeRuntimeUI(); }
     325
    319326private:
    320327
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r57129 r57178  
    415415        {
    416416            /* Just close Runtime UI: */
    417             uisession()->closeRuntimeUI();
     417            machineLogic()->closeRuntimeUI();
    418418            break;
    419419        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r57080 r57178  
    456456}
    457457
    458 void UISession::closeRuntimeUI()
    459 {
    460     /* Start corresponding slot asynchronously: */
    461     emit sigCloseRuntimeUI();
    462 }
    463 
    464458UIMachineLogic* UISession::machineLogic() const
    465459{
     
    618612void UISession::sltCloseRuntimeUI()
    619613{
    620     /* First, we have to hide any opened modal/popup widgets.
    621      * They then should unlock their event-loops synchronously.
    622      * If all such loops are unlocked, we can close Runtime UI: */
    623     if (QWidget *pWidget = QApplication::activeModalWidget() ?
    624                            QApplication::activeModalWidget() :
    625                            QApplication::activePopupWidget() ?
    626                            QApplication::activePopupWidget() : 0)
    627     {
    628         /* First we should try to close this widget: */
    629         pWidget->close();
    630         /* If widget rejected the 'close-event' we can
    631          * still hide it and hope it will behave correctly
    632          * and unlock his event-loop if any: */
    633         if (!pWidget->isHidden())
    634             pWidget->hide();
    635         /* Restart this slot: */
    636         emit sigCloseRuntimeUI();
    637         return;
    638     }
    639 
    640     /* Finally close the Runtime UI: */
    641     UIMachine::destroy();
     614    /* Ask UIMachine to close Runtime UI: */
     615    uimachine()->closeRuntimeUI();
    642616}
    643617
     
    11741148{
    11751149    connect(this, SIGNAL(sigInitialized()), this, SLOT(sltMarkInitialized()));
    1176     connect(this, SIGNAL(sigCloseRuntimeUI()), this, SLOT(sltCloseRuntimeUI()));
    11771150
    11781151#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r55724 r57178  
    9898    bool powerOff(bool fIncludingDiscard, bool &fServerCrashed);
    9999    bool restoreCurrentSnapshot();
    100     void closeRuntimeUI();
    101100
    102101    /** Returns the session instance. */
     
    243242
    244243signals:
    245 
    246     /* Notifier: Close Runtime UI stuff: */
    247     void sigCloseRuntimeUI();
    248244
    249245    /** Notifies about frame-buffer resize. */
     
    300296    void sltMarkInitialized() { m_fInitialized = true; }
    301297
    302     /* Handler: Close Runtime UI stuff: */
     298    /** Close Runtime UI. */
    303299    void sltCloseRuntimeUI();
    304300
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