VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/* $Id: UIPopupCenter.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIPopupCenter 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_UIPopupCenter_h
29#define FEQT_INCLUDED_SRC_globals_UIPopupCenter_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMap>
36#include <QObject>
37#include <QPointer>
38
39/* GUI includes: */
40#include "UILibraryDefs.h"
41#include "UIMediumDefs.h"
42
43/* Forward declaration: */
44class QWidget;
45class UIPopupStack;
46class CAudioAdapter;
47class CConsole;
48class CEmulatedUSB;
49class CMachine;
50class CNetworkAdapter;
51class CVirtualBox;
52class CVirtualBoxErrorInfo;
53class CVRDEServer;
54
55
56/** Popup-stack types. */
57enum UIPopupStackType
58{
59 UIPopupStackType_Embedded,
60 UIPopupStackType_Separate
61};
62
63/** Popup-stack orientations. */
64enum UIPopupStackOrientation
65{
66 UIPopupStackOrientation_Top,
67 UIPopupStackOrientation_Bottom
68};
69
70
71/** Singleton QObject extension
72 * providing GUI with various popup messages. */
73class SHARED_LIBRARY_STUFF UIPopupCenter: public QObject
74{
75 Q_OBJECT;
76
77signals:
78
79 /** Notifies about popup-pane with @a strID is closed with @a iResultCode. */
80 void sigPopupPaneDone(QString strID, int iResultCode);
81
82public:
83
84 /** Creates popup-center singleton. */
85 static void create();
86 /** Destroys message-center singleton. */
87 static void destroy();
88
89 /** Shows popup-stack for @a pParent. */
90 void showPopupStack(QWidget *pParent);
91 /** Hides popup-stack for @a pParent. */
92 void hidePopupStack(QWidget *pParent);
93
94 /** Defines popup-stack @a enmType for @a pParent. */
95 void setPopupStackType(QWidget *pParent, UIPopupStackType enmType);
96 /** Defines popup-stack @a enmOrientation for @a pParent. */
97 void setPopupStackOrientation(QWidget *pParent, UIPopupStackOrientation enmOrientation);
98
99 /** Shows a general type of 'Message'.
100 * @param pParent Brings the popup-pane parent.
101 * @param strID Brings the popup-pane ID.
102 * @param strMessage Brings the message.
103 * @param strDetails Brings the details.
104 * @param strButtonText1 Brings the button 1 text.
105 * @param strButtonText2 Brings the button 2 text.
106 * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
107 void message(QWidget *pParent, const QString &strID,
108 const QString &strMessage, const QString &strDetails,
109 const QString &strButtonText1 = QString(),
110 const QString &strButtonText2 = QString(),
111 bool fProposeAutoConfirmation = false);
112
113 /** Shows 'Popup' type of 'Message'.
114 * Omits details, provides no buttons.
115 * @param pParent Brings the popup-pane parent.
116 * @param strID Brings the popup-pane ID.
117 * @param strMessage Brings the message. */
118 void popup(QWidget *pParent, const QString &strID,
119 const QString &strMessage);
120
121 /** Shows 'Alert' type of 'Message'.
122 * Omits details, provides one button.
123 * @param pParent Brings the popup-pane parent.
124 * @param strID Brings the popup-pane ID.
125 * @param strMessage Brings the message.
126 * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
127 void alert(QWidget *pParent, const QString &strID,
128 const QString &strMessage,
129 bool fProposeAutoConfirmation = false);
130
131 /** Shows 'Alert with Details' type of 'Message'.
132 * Provides one button.
133 * @param pParent Brings the popup-pane parent.
134 * @param strID Brings the popup-pane ID.
135 * @param strMessage Brings the message.
136 * @param strDetails Brings the details.
137 * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
138 void alertWithDetails(QWidget *pParent, const QString &strID,
139 const QString &strMessage, const QString &strDetails,
140 bool fProposeAutoConfirmation = false);
141
142 /** Shows 'Question' type of 'Message'.
143 * Omits details, provides up to two buttons.
144 * @param pParent Brings the popup-pane parent.
145 * @param strID Brings the popup-pane ID.
146 * @param strMessage Brings the message.
147 * @param strButtonText1 Brings the button 1 text.
148 * @param strButtonText2 Brings the button 2 text.
149 * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
150 void question(QWidget *pParent, const QString &strID,
151 const QString &strMessage,
152 const QString &strButtonText1 = QString(),
153 const QString &strButtonText2 = QString(),
154 bool fProposeAutoConfirmation = false);
155
156 /** Recalls popup with @a strID of passed @a pParent. */
157 void recall(QWidget *pParent, const QString &strID);
158
159private slots:
160
161 /** Handles request to close popup-pane with @a strID and @a iResultCode. */
162 void sltPopupPaneDone(QString strID, int iResultCode);
163
164 /** Handles request to remove popup-stack with @a strID. */
165 void sltRemovePopupStack(QString strID);
166
167private:
168
169 /** Constructs popup-center. */
170 UIPopupCenter();
171 /** Destructs popup-center. */
172 ~UIPopupCenter();
173
174 /** Prepares all. */
175 void prepare();
176 /** Cleanups all. */
177 void cleanup();
178
179 /** Shows popup-pane.
180 * @param pParent Brings the popup-pane parent.
181 * @param strID Brings the popup-pane ID.
182 * @param strMessage Brings the message.
183 * @param strDetails Brings the details.
184 * @param strButtonText1 Brings the button 1 text.
185 * @param strButtonText2 Brings the button 2 text.
186 * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
187 void showPopupPane(QWidget *pParent, const QString &strID,
188 const QString &strMessage, const QString &strDetails,
189 QString strButtonText1 = QString(), QString strButtonText2 = QString(),
190 bool fProposeAutoConfirmation = false);
191 /** Hides popup-pane.
192 * @param pParent Brings the popup-pane parent.
193 * @param strID Brings the popup-pane ID. */
194 void hidePopupPane(QWidget *pParent, const QString &strID);
195
196 /** Returns popup-stack ID for passed @a pParent. */
197 static QString popupStackID(QWidget *pParent);
198 /** Assigns @a pPopupStack @a pParent of passed @a enmStackType. */
199 static void assignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent, UIPopupStackType enmStackType);
200 /** Unassigns @a pPopupStack @a pParent. */
201 static void unassignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent);
202
203 /** Holds the popup-stack type on per stack ID basis. */
204 QMap<QString, UIPopupStackType> m_stackTypes;
205 /** Holds the popup-stack orientations on per stack ID basis. */
206 QMap<QString, UIPopupStackOrientation> m_stackOrientations;
207 /** Holds the popup-stacks on per stack ID basis. */
208 QMap<QString, QPointer<UIPopupStack> > m_stacks;
209
210 /** Holds the singleton message-center instance. */
211 static UIPopupCenter *s_pInstance;
212 /** Returns the singleton message-center instance. */
213 static UIPopupCenter *instance();
214 /** Allows for shortcut access. */
215 friend UIPopupCenter &popupCenter();
216};
217
218/** Singleton Popup Center 'official' name. */
219inline UIPopupCenter &popupCenter() { return *UIPopupCenter::instance(); }
220
221
222#endif /* !FEQT_INCLUDED_SRC_globals_UIPopupCenter_h */
223
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use