VirtualBox

Ignore:
Timestamp:
Mar 19, 2018 3:29:54 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121332
Message:

FE/Qt: bugref:9049: Detach UIModalWindowManager from the Runtime/Selector UI stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIModalWindowManager.cpp

    r71373 r71375  
    2121
    2222/* GUI includes: */
    23 # include "VBoxGlobal.h"
    24 # include "UIMachine.h"
    2523# include "UIModalWindowManager.h"
    2624# ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     
    2927# endif
    3028# include "UIProgressDialog.h"
    31 # include "UISelectorWindow.h"
    3229
    3330/* Other VBox includes: */
     
    7067
    7168UIModalWindowManager::UIModalWindowManager()
     69    : m_pMainWindowShown(0)
    7270{
    7371    /* Assign instance: */
     
    7977    /* Unassign instance: */
    8078    s_pInstance = 0;
    81 }
    82 
    83 QWidget *UIModalWindowManager::mainWindowShown() const
    84 {
    85     /* It may happen that this method is called before VBoxGlobal initialization
    86      * or after initialization had failed (for example, to show some message).
    87      * Return NULL pointer in such cases: */
    88     if (!VBoxGlobal::instance() || !vboxGlobal().isValid())
    89         return 0;
    90 
    91     /* For VM console process: */
    92     if (vboxGlobal().isVMConsoleProcess())
    93     {
    94         /* It will be currently active machine-window if visible: */
    95         if (gpMachine &&
    96             gpMachine->activeWindow() &&
    97             gpMachine->activeWindow()->isVisible())
    98             return gpMachine->activeWindow();
    99     }
    100     /* For VM selector process: */
    101     else
    102     {
    103         /* It will be the selector window if visible: */
    104         if (gpSelectorWindow &&
    105             gpSelectorWindow->isVisible())
    106             return gpSelectorWindow;
    107     }
    108 
    109     /* NULL by default: */
    110     return 0;
    11179}
    11280
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIModalWindowManager.h

    r71373 r71375  
    5252    void registerNewParent(QWidget *pWindow, QWidget *pParentWindow = 0);
    5353
    54     /** Returns main application window. */
    55     QWidget *mainWindowShown() const;
     54    /** Defines the main application @a pWindow shown. */
     55    void setMainWindowShown(QWidget *pWindow) { m_pMainWindowShown = pWindow; }
     56    /** Returns the main application window shown. */
     57    QWidget *mainWindowShown() const { return m_pMainWindowShown; }
    5658#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    5759    /** Returns network manager or main window shown. */
     
    8082    QList<QList<QWidget*> > m_windows;
    8183
     84    /** Holds the main application window shown. */
     85    QWidget *m_pMainWindowShown;
     86
    8287    /** Holds the static singleton instance. */
    8388    static UIModalWindowManager *s_pInstance;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r71374 r71375  
    260260}
    261261
     262bool UIMachineWindow::event(QEvent *pEvent)
     263{
     264    /* Call to base-class: */
     265    const bool fResult = QIWithRetranslateUI2<QMainWindow>::event(pEvent);
     266
     267    /* Handle particular events: */
     268    switch (pEvent->type())
     269    {
     270        case QEvent::WindowActivate:
     271        {
     272            /* Initiate registration in the modal window manager: */
     273            windowManager().setMainWindowShown(this);
     274            break;
     275        }
     276        default:
     277            break;
     278    }
     279
     280    /* Return result: */
     281    return fResult;
     282}
     283
    262284void UIMachineWindow::showEvent(QShowEvent *pEvent)
    263285{
     
    265287    QMainWindow::showEvent(pEvent);
    266288
     289    /* Initiate registration in the modal window manager: */
     290    windowManager().setMainWindowShown(this);
     291
    267292    /* Update appearance for indicator-pool: */
    268293    updateAppearanceOf(UIVisualElement_IndicatorPoolStuff);
     294}
     295
     296void UIMachineWindow::hideEvent(QHideEvent *pEvent)
     297{
     298    /* Update registration in the modal window manager: */
     299    if (windowManager().mainWindowShown() == this)
     300    {
     301        if (machineLogic()->activeMachineWindow())
     302            windowManager().setMainWindowShown(machineLogic()->activeMachineWindow());
     303        else
     304            windowManager().setMainWindowShown(machineLogic()->mainMachineWindow());
     305    }
     306
     307    /* Call to base-class: */
     308    QMainWindow::hideEvent(pEvent);
    269309}
    270310
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r71374 r71375  
    3535/* Forward declarations: */
    3636class QCloseEvent;
     37class QEvent;
     38class QHideEvent;
    3739class QGridLayout;
    3840class QShowEvent;
     
    126128    void retranslateUi();
    127129
     130    /** Handles any Qt @a pEvent. */
     131    virtual bool event(QEvent *pEvent) /* override */;
     132
    128133    /** Handles show @a pEvent. */
    129134    virtual void showEvent(QShowEvent *pEvent) /* override */;
     135    /** Handles hide @a pEvent. */
     136    virtual void hideEvent(QHideEvent *pEvent) /* override */;
    130137
    131138    /** Close event handler. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r70756 r71375  
    9797    /* Show selector-window: */
    9898    m_spInstance->show();
     99    /* Register in the modal window manager: */
     100    windowManager().setMainWindowShown(m_spInstance);
    99101}
    100102
     
    105107    AssertPtrReturnVoid(m_spInstance);
    106108
     109    /* Unregister in the modal window manager: */
     110    windowManager().setMainWindowShown(0);
    107111    /* Cleanup selector-window: */
    108112    m_spInstance->cleanup();
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette