1 | /* $Id: UIModalWindowManager.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIModalWindowManager class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_globals_UIModalWindowManager_h
|
---|
29 | #define FEQT_INCLUDED_SRC_globals_UIModalWindowManager_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QObject>
|
---|
36 | #include <QWidget>
|
---|
37 | #include <QList>
|
---|
38 |
|
---|
39 | /* GUI includes: */
|
---|
40 | #include "UILibraryDefs.h"
|
---|
41 |
|
---|
42 | /** QObject subclass which contains a stack(s) of guarded-pointer(s) to the current top-level
|
---|
43 | * modal-window(s) which could be used to determine parents for new top-level modal-dialog(s). */
|
---|
44 | class SHARED_LIBRARY_STUFF UIModalWindowManager : public QObject
|
---|
45 | {
|
---|
46 | Q_OBJECT;
|
---|
47 |
|
---|
48 | signals:
|
---|
49 |
|
---|
50 | /** Notifies about stack changed. */
|
---|
51 | void sigStackChanged();
|
---|
52 |
|
---|
53 | public:
|
---|
54 |
|
---|
55 | /** Creates the static singleton instance. */
|
---|
56 | static void create();
|
---|
57 | /** Destroys the static singleton instance. */
|
---|
58 | static void destroy();
|
---|
59 |
|
---|
60 | /** Returns actual top-level parent window for a passed @a pPossibleParentWidget. */
|
---|
61 | QWidget *realParentWindow(QWidget *pPossibleParentWidget);
|
---|
62 | /** Returns whether passed @a pWindow is in the modal window stack. */
|
---|
63 | bool isWindowInTheModalWindowStack(QWidget *pWindow);
|
---|
64 | /** Returns whether passed @a pWindow is on the top of the modal window stack. */
|
---|
65 | bool isWindowOnTheTopOfTheModalWindowStack(QWidget *pWindow);
|
---|
66 |
|
---|
67 | /** Registers new parent @a pWindow above the passed @a pParentWindow or as separate stack. */
|
---|
68 | void registerNewParent(QWidget *pWindow, QWidget *pParentWindow = 0);
|
---|
69 |
|
---|
70 | /** Defines the main application @a pWindow shown. */
|
---|
71 | void setMainWindowShown(QWidget *pWindow) { m_pMainWindowShown = pWindow; }
|
---|
72 | /** Returns the main application window shown. */
|
---|
73 | QWidget *mainWindowShown() const { return m_pMainWindowShown; }
|
---|
74 |
|
---|
75 | private slots:
|
---|
76 |
|
---|
77 | /** Removes window with base-class @a pObject pointer from the stack. */
|
---|
78 | void sltRemoveFromStack(QObject *pObject);
|
---|
79 |
|
---|
80 | private:
|
---|
81 |
|
---|
82 | /** Constructs Modal Window Manager instance. */
|
---|
83 | UIModalWindowManager();
|
---|
84 | /** Destructs Modal Window Manager instance. */
|
---|
85 | ~UIModalWindowManager();
|
---|
86 |
|
---|
87 | /** Returns whether stack contains @a pParentWindow at all or @a fAsTheTopOfStack. */
|
---|
88 | bool contains(QWidget *pParentWindow, bool fAsTheTopOfStack = false);
|
---|
89 |
|
---|
90 | /** WORKAROUND: Preprocess (show) real parent for a passed @a pParent. */
|
---|
91 | static void preprocessRealParent(QWidget *pParent);
|
---|
92 |
|
---|
93 | /** Holds the list of the top-level window stacks. */
|
---|
94 | QList<QList<QWidget*> > m_windows;
|
---|
95 |
|
---|
96 | /** Holds the main application window shown. */
|
---|
97 | QWidget *m_pMainWindowShown;
|
---|
98 |
|
---|
99 | /** Holds the static singleton instance. */
|
---|
100 | static UIModalWindowManager *s_pInstance;
|
---|
101 | /** Returns the static singleton instance. */
|
---|
102 | static UIModalWindowManager *instance();
|
---|
103 | /** Allows friend-access for static singleton instance. */
|
---|
104 | friend UIModalWindowManager &windowManager();
|
---|
105 | };
|
---|
106 |
|
---|
107 | /** Singleton Modal Window Manager 'official' name. */
|
---|
108 | inline UIModalWindowManager &windowManager() { return *(UIModalWindowManager::instance()); }
|
---|
109 |
|
---|
110 | #endif /* !FEQT_INCLUDED_SRC_globals_UIModalWindowManager_h */
|
---|
111 |
|
---|