Changeset 71373 in vbox for trunk/src/VBox
- Timestamp:
- Mar 19, 2018 12:36:23 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIModalWindowManager.cpp
r71371 r71373 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 27 27 # include "UINetworkManager.h" 28 28 # include "UINetworkManagerDialog.h" 29 # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */29 # endif 30 30 # include "UIProgressDialog.h" 31 31 # include "UISelectorWindow.h" … … 38 38 39 39 /* static */ 40 UIModalWindowManager * UIModalWindowManager::m_spInstance = 0;41 UIModalWindowManager * UIModalWindowManager::instance() { return m_spInstance; }40 UIModalWindowManager *UIModalWindowManager::s_pInstance = 0; 41 UIModalWindowManager *UIModalWindowManager::instance() { return s_pInstance; } 42 42 43 43 /* static */ … … 45 45 { 46 46 /* Make sure instance is NOT created yet: */ 47 if ( m_spInstance)47 if (s_pInstance) 48 48 { 49 49 AssertMsgFailed(("UIModalWindowManager instance is already created!")); … … 59 59 { 60 60 /* Make sure instance is NOT destroyed yet: */ 61 if (! m_spInstance)61 if (!s_pInstance) 62 62 { 63 63 AssertMsgFailed(("UIModalWindowManager instance is already destroyed!")); … … 66 66 67 67 /* Destroy instance: */ 68 delete m_spInstance;68 delete s_pInstance; 69 69 } 70 70 … … 72 72 { 73 73 /* Assign instance: */ 74 m_spInstance = this;74 s_pInstance = this; 75 75 } 76 76 … … 78 78 { 79 79 /* Unassign instance: */ 80 m_spInstance = 0;81 } 82 83 QWidget *UIModalWindowManager::mainWindowShown() const80 s_pInstance = 0; 81 } 82 83 QWidget *UIModalWindowManager::mainWindowShown() const 84 84 { 85 85 /* It may happen that this method is called before VBoxGlobal initialization … … 112 112 113 113 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 114 QWidget* UIModalWindowManager::networkManagerOrMainWindowShown() const 115 { 116 /* It may happen that this method is called before network-manager initialization 117 * or when the network-manager is hidden, return main application window in this case: */ 114 QWidget *UIModalWindowManager::networkManagerOrMainWindowShown() const 115 { 116 /* Return main application window before network-manager initialization: */ 118 117 return gNetworkManager && gNetworkManager->window()->isVisible() ? gNetworkManager->window() : mainWindowShown(); 119 118 } 120 119 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 121 120 122 QWidget *UIModalWindowManager::realParentWindow(QWidget *pWidget)121 QWidget *UIModalWindowManager::realParentWindow(QWidget *pWidget) 123 122 { 124 123 /* Null if widget pointer is null: */ … … 163 162 } 164 163 165 void UIModalWindowManager::registerNewParent(QWidget *pWindow, QWidget *pParentWindow /* = 0 */)164 void UIModalWindowManager::registerNewParent(QWidget *pWindow, QWidget *pParentWindow /* = 0 */) 166 165 { 167 166 /* Make sure passed-widget-pointer is not null: */ … … 274 273 } 275 274 276 bool UIModalWindowManager::contains(QWidget *pParentWindow, bool fAsTheTopOfStack /* = false */)275 bool UIModalWindowManager::contains(QWidget *pParentWindow, bool fAsTheTopOfStack /* = false */) 277 276 { 278 277 /* False if passed-parent-widget pointer is null: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIModalWindowManager.h
r69500 r71373 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIModalWindowManager_h__19 #define __ UIModalWindowManager_h__18 #ifndef ___UIModalWindowManager_h___ 19 #define ___UIModalWindowManager_h___ 20 20 21 21 /* Qt includes: */ … … 24 24 #include <QList> 25 25 26 /* Object which contains stack(s) of guarded-pointer(s) 27 * to the current top-level modal-window(s) 28 * which could be used to determine top-level modal-dialog(s): */ 26 /** QObject subclass which contains a stack(s) of guarded-pointer(s) to the current top-level 27 * modal-window(s) which could be used to determine parents for new top-level modal-dialog(s). */ 29 28 class UIModalWindowManager : public QObject 30 29 { … … 38 37 public: 39 38 40 /* Static API: Create/destroy stuff:*/39 /** Creates the static singleton instance. */ 41 40 static void create(); 41 /** Destroys the static singleton instance. */ 42 42 static void destroy(); 43 43 44 /* API: Access stuff: */ 45 QWidget* realParentWindow(QWidget *pPossibleParentWidget); 44 /** Returns actual top-level parent window for a passed @a pPossibleParentWidget. */ 45 QWidget *realParentWindow(QWidget *pPossibleParentWidget); 46 /** Returns whether passed @a pWindow is in the modal window stack. */ 46 47 bool isWindowInTheModalWindowStack(QWidget *pWindow); 48 /** Returns whether passed @a pWindow is on the top of the modal window stack. */ 47 49 bool isWindowOnTheTopOfTheModalWindowStack(QWidget *pWindow); 48 50 49 /* API: Register stuff:*/51 /** Registers new parent @a pWindow above the passed @a pParentWindow or as separate stack. */ 50 52 void registerNewParent(QWidget *pWindow, QWidget *pParentWindow = 0); 51 53 52 /* API: Main application window stuff:*/53 QWidget *mainWindowShown() const;54 /** Returns main application window. */ 55 QWidget *mainWindowShown() const; 54 56 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 57 /** Returns network manager or main window shown. */ 55 58 QWidget* networkManagerOrMainWindowShown() const; 56 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */59 #endif 57 60 58 61 private slots: 59 62 60 /* Handler: Stack cleanup stuff:*/63 /** Removes window with base-class @a pObject pointer from the stack. */ 61 64 void sltRemoveFromStack(QObject *pObject); 62 65 63 66 private: 64 67 65 /* Constructor/destructor:*/68 /** Constructs Modal Window Manager instance. */ 66 69 UIModalWindowManager(); 70 /** Destructs Modal Window Manager instance. */ 67 71 ~UIModalWindowManager(); 68 72 69 /* Helper: Stack stuff:*/73 /** Returns whether stack contains @a pParentWindow at all or @a fAsTheTopOfStack. */ 70 74 bool contains(QWidget *pParentWindow, bool fAsTheTopOfStack = false); 71 75 72 /* Static helper: Access stuff:*/76 /** WORKAROUND: Preprocess (show) real parent for a passed @a pParent. */ 73 77 static void preprocessRealParent(QWidget *pParent); 74 78 75 /* Variables:*/79 /** Holds the list of the top-level window stacks. */ 76 80 QList<QList<QWidget*> > m_windows; 77 81 78 /* Static API: Instance stuff: */ 79 static UIModalWindowManager* m_spInstance; 80 static UIModalWindowManager* instance(); 81 friend UIModalWindowManager& windowManager(); 82 /** Holds the static singleton instance. */ 83 static UIModalWindowManager *s_pInstance; 84 /** Returns the static singleton instance. */ 85 static UIModalWindowManager *instance(); 86 /** Allows friend-access for static singleton instance. */ 87 friend UIModalWindowManager &windowManager(); 82 88 }; 83 89 84 /* Shortcut to the static UIModalWindowManager::instance() method:*/85 inline UIModalWindowManager &windowManager() { return *(UIModalWindowManager::instance()); }90 /** Singleton Modal Window Manager 'official' name. */ 91 inline UIModalWindowManager &windowManager() { return *(UIModalWindowManager::instance()); } 86 92 87 #endif /* !__UIModalWindowManager_h__ */ 93 #endif /* !___UIModalWindowManager_h___ */ 94
Note:
See TracChangeset
for help on using the changeset viewer.