1 | /* $Id: UIPopupCenter.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIPopupCenter class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_globals_UIPopupCenter_h
|
---|
19 | #define FEQT_INCLUDED_SRC_globals_UIPopupCenter_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QMap>
|
---|
26 | #include <QObject>
|
---|
27 | #include <QPointer>
|
---|
28 |
|
---|
29 | /* GUI includes: */
|
---|
30 | #include "UILibraryDefs.h"
|
---|
31 | #include "UIMediumDefs.h"
|
---|
32 |
|
---|
33 | /* Forward declaration: */
|
---|
34 | class QWidget;
|
---|
35 | class UIPopupStack;
|
---|
36 | class CAudioAdapter;
|
---|
37 | class CConsole;
|
---|
38 | class CEmulatedUSB;
|
---|
39 | class CMachine;
|
---|
40 | class CNetworkAdapter;
|
---|
41 | class CVirtualBox;
|
---|
42 | class CVirtualBoxErrorInfo;
|
---|
43 | class CVRDEServer;
|
---|
44 |
|
---|
45 |
|
---|
46 | /** Popup-stack types. */
|
---|
47 | enum UIPopupStackType
|
---|
48 | {
|
---|
49 | UIPopupStackType_Embedded,
|
---|
50 | UIPopupStackType_Separate
|
---|
51 | };
|
---|
52 |
|
---|
53 | /** Popup-stack orientations. */
|
---|
54 | enum UIPopupStackOrientation
|
---|
55 | {
|
---|
56 | UIPopupStackOrientation_Top,
|
---|
57 | UIPopupStackOrientation_Bottom
|
---|
58 | };
|
---|
59 |
|
---|
60 |
|
---|
61 | /** Singleton QObject extension
|
---|
62 | * providing GUI with various popup messages. */
|
---|
63 | class SHARED_LIBRARY_STUFF UIPopupCenter: public QObject
|
---|
64 | {
|
---|
65 | Q_OBJECT;
|
---|
66 |
|
---|
67 | signals:
|
---|
68 |
|
---|
69 | /** Notifies about popup-pane with @a strID is closed with @a iResultCode. */
|
---|
70 | void sigPopupPaneDone(QString strID, int iResultCode);
|
---|
71 |
|
---|
72 | public:
|
---|
73 |
|
---|
74 | /** Creates popup-center singleton. */
|
---|
75 | static void create();
|
---|
76 | /** Destroys message-center singleton. */
|
---|
77 | static void destroy();
|
---|
78 |
|
---|
79 | /** Shows popup-stack for @a pParent. */
|
---|
80 | void showPopupStack(QWidget *pParent);
|
---|
81 | /** Hides popup-stack for @a pParent. */
|
---|
82 | void hidePopupStack(QWidget *pParent);
|
---|
83 |
|
---|
84 | /** Defines popup-stack @a enmType for @a pParent. */
|
---|
85 | void setPopupStackType(QWidget *pParent, UIPopupStackType enmType);
|
---|
86 | /** Defines popup-stack @a enmOrientation for @a pParent. */
|
---|
87 | void setPopupStackOrientation(QWidget *pParent, UIPopupStackOrientation enmOrientation);
|
---|
88 |
|
---|
89 | /** Shows a general type of 'Message'.
|
---|
90 | * @param pParent Brings the popup-pane parent.
|
---|
91 | * @param strID Brings the popup-pane ID.
|
---|
92 | * @param strMessage Brings the message.
|
---|
93 | * @param strDetails Brings the details.
|
---|
94 | * @param strButtonText1 Brings the button 1 text.
|
---|
95 | * @param strButtonText2 Brings the button 2 text.
|
---|
96 | * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
|
---|
97 | void message(QWidget *pParent, const QString &strID,
|
---|
98 | const QString &strMessage, const QString &strDetails,
|
---|
99 | const QString &strButtonText1 = QString(),
|
---|
100 | const QString &strButtonText2 = QString(),
|
---|
101 | bool fProposeAutoConfirmation = false);
|
---|
102 |
|
---|
103 | /** Shows 'Popup' type of 'Message'.
|
---|
104 | * Omits details, provides no buttons.
|
---|
105 | * @param pParent Brings the popup-pane parent.
|
---|
106 | * @param strID Brings the popup-pane ID.
|
---|
107 | * @param strMessage Brings the message. */
|
---|
108 | void popup(QWidget *pParent, const QString &strID,
|
---|
109 | const QString &strMessage);
|
---|
110 |
|
---|
111 | /** Shows 'Alert' type of 'Message'.
|
---|
112 | * Omits details, provides one button.
|
---|
113 | * @param pParent Brings the popup-pane parent.
|
---|
114 | * @param strID Brings the popup-pane ID.
|
---|
115 | * @param strMessage Brings the message.
|
---|
116 | * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
|
---|
117 | void alert(QWidget *pParent, const QString &strID,
|
---|
118 | const QString &strMessage,
|
---|
119 | bool fProposeAutoConfirmation = false);
|
---|
120 |
|
---|
121 | /** Shows 'Alert with Details' type of 'Message'.
|
---|
122 | * 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 strDetails Brings the details.
|
---|
127 | * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
|
---|
128 | void alertWithDetails(QWidget *pParent, const QString &strID,
|
---|
129 | const QString &strMessage, const QString &strDetails,
|
---|
130 | bool fProposeAutoConfirmation = false);
|
---|
131 |
|
---|
132 | /** Shows 'Question' type of 'Message'.
|
---|
133 | * Omits details, provides up to two buttons.
|
---|
134 | * @param pParent Brings the popup-pane parent.
|
---|
135 | * @param strID Brings the popup-pane ID.
|
---|
136 | * @param strMessage Brings the message.
|
---|
137 | * @param strButtonText1 Brings the button 1 text.
|
---|
138 | * @param strButtonText2 Brings the button 2 text.
|
---|
139 | * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
|
---|
140 | void question(QWidget *pParent, const QString &strID,
|
---|
141 | const QString &strMessage,
|
---|
142 | const QString &strButtonText1 = QString(),
|
---|
143 | const QString &strButtonText2 = QString(),
|
---|
144 | bool fProposeAutoConfirmation = false);
|
---|
145 |
|
---|
146 | /** Recalls popup with @a strID of passed @a pParent. */
|
---|
147 | void recall(QWidget *pParent, const QString &strID);
|
---|
148 |
|
---|
149 | /* API: Runtime UI stuff: */
|
---|
150 | void cannotSendACPIToMachine(QWidget *pParent);
|
---|
151 | void remindAboutAutoCapture(QWidget *pParent);
|
---|
152 | void remindAboutMouseIntegration(QWidget *pParent, bool fSupportsAbsolute);
|
---|
153 | void remindAboutPausedVMInput(QWidget *pParent);
|
---|
154 | void forgetAboutPausedVMInput(QWidget *pParent);
|
---|
155 | void remindAboutWrongColorDepth(QWidget *pParent, ulong uRealBPP, ulong uWantedBPP);
|
---|
156 | void forgetAboutWrongColorDepth(QWidget *pParent);
|
---|
157 | void cannotAttachUSBDevice(QWidget *pParent, const CConsole &comConsole, const QString &strDevice);
|
---|
158 | void cannotAttachUSBDevice(QWidget *pParent, const CVirtualBoxErrorInfo &comErrorInfo,
|
---|
159 | const QString &strDevice, const QString &strMachineName);
|
---|
160 | void cannotDetachUSBDevice(QWidget *pParent, const CConsole &comConsole, const QString &strDevice);
|
---|
161 | void cannotDetachUSBDevice(QWidget *pParent, const CVirtualBoxErrorInfo &comErrorInfo,
|
---|
162 | const QString &strDevice, const QString &strMachineName);
|
---|
163 | void cannotAttachWebCam(QWidget *pParent, const CEmulatedUSB &comDispatcher,
|
---|
164 | const QString &strWebCamName, const QString &strMachineName);
|
---|
165 | void cannotDetachWebCam(QWidget *pParent, const CEmulatedUSB &comDispatcher,
|
---|
166 | const QString &strWebCamName, const QString &strMachineName);
|
---|
167 | void cannotToggleRecording(QWidget *pParent, const CMachine &comMachine, bool fEnable);
|
---|
168 | void cannotToggleVRDEServer(QWidget *pParent, const CVRDEServer &comServer,
|
---|
169 | const QString &strMachineName, bool fEnable);
|
---|
170 | void cannotToggleNetworkAdapterCable(QWidget *pParent, const CNetworkAdapter &comAdapter,
|
---|
171 | const QString &strMachineName, bool fConnect);
|
---|
172 | void remindAboutGuestAdditionsAreNotActive(QWidget *pParent);
|
---|
173 | void cannotToggleAudioOutput(QWidget *pParent, const CAudioAdapter &comAdapter,
|
---|
174 | const QString &strMachineName, bool fEnable);
|
---|
175 | void cannotToggleAudioInput(QWidget *pParent, const CAudioAdapter &comAdapter,
|
---|
176 | const QString &strMachineName, bool fEnable);
|
---|
177 | void cannotMountImage(QWidget *pParent, const QString &strMachineName, const QString &strMediumName);
|
---|
178 | void cannotOpenMedium(QWidget *pParent, const CVirtualBox &comVBox, UIMediumDeviceType enmType, const QString &strLocation);
|
---|
179 | void cannotSaveMachineSettings(QWidget *pParent, const CMachine &comMachine);
|
---|
180 |
|
---|
181 | private slots:
|
---|
182 |
|
---|
183 | /** Handles request to close popup-pane with @a strID and @a iResultCode. */
|
---|
184 | void sltPopupPaneDone(QString strID, int iResultCode);
|
---|
185 |
|
---|
186 | /** Handles request to remove popup-stack with @a strID. */
|
---|
187 | void sltRemovePopupStack(QString strID);
|
---|
188 |
|
---|
189 | private:
|
---|
190 |
|
---|
191 | /** Constructs popup-center. */
|
---|
192 | UIPopupCenter();
|
---|
193 | /** Destructs popup-center. */
|
---|
194 | ~UIPopupCenter();
|
---|
195 |
|
---|
196 | /** Prepares all. */
|
---|
197 | void prepare();
|
---|
198 | /** Cleanups all. */
|
---|
199 | void cleanup();
|
---|
200 |
|
---|
201 | /** Shows popup-pane.
|
---|
202 | * @param pParent Brings the popup-pane parent.
|
---|
203 | * @param strID Brings the popup-pane ID.
|
---|
204 | * @param strMessage Brings the message.
|
---|
205 | * @param strDetails Brings the details.
|
---|
206 | * @param strButtonText1 Brings the button 1 text.
|
---|
207 | * @param strButtonText2 Brings the button 2 text.
|
---|
208 | * @param fProposeAutoConfirmation Brings whether auto-confirmation if possible. */
|
---|
209 | void showPopupPane(QWidget *pParent, const QString &strID,
|
---|
210 | const QString &strMessage, const QString &strDetails,
|
---|
211 | QString strButtonText1 = QString(), QString strButtonText2 = QString(),
|
---|
212 | bool fProposeAutoConfirmation = false);
|
---|
213 | /** Hides popup-pane.
|
---|
214 | * @param pParent Brings the popup-pane parent.
|
---|
215 | * @param strID Brings the popup-pane ID. */
|
---|
216 | void hidePopupPane(QWidget *pParent, const QString &strID);
|
---|
217 |
|
---|
218 | /** Returns popup-stack ID for passed @a pParent. */
|
---|
219 | static QString popupStackID(QWidget *pParent);
|
---|
220 | /** Assigns @a pPopupStack @a pParent of passed @a enmStackType. */
|
---|
221 | static void assignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent, UIPopupStackType enmStackType);
|
---|
222 | /** Unassigns @a pPopupStack @a pParent. */
|
---|
223 | static void unassignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent);
|
---|
224 |
|
---|
225 | /** Holds the popup-stack type on per stack ID basis. */
|
---|
226 | QMap<QString, UIPopupStackType> m_stackTypes;
|
---|
227 | /** Holds the popup-stack orientations on per stack ID basis. */
|
---|
228 | QMap<QString, UIPopupStackOrientation> m_stackOrientations;
|
---|
229 | /** Holds the popup-stacks on per stack ID basis. */
|
---|
230 | QMap<QString, QPointer<UIPopupStack> > m_stacks;
|
---|
231 |
|
---|
232 | /** Holds the singleton message-center instance. */
|
---|
233 | static UIPopupCenter *s_pInstance;
|
---|
234 | /** Returns the singleton message-center instance. */
|
---|
235 | static UIPopupCenter *instance();
|
---|
236 | /** Allows for shortcut access. */
|
---|
237 | friend UIPopupCenter &popupCenter();
|
---|
238 | };
|
---|
239 |
|
---|
240 | /** Singleton Popup Center 'official' name. */
|
---|
241 | inline UIPopupCenter &popupCenter() { return *UIPopupCenter::instance(); }
|
---|
242 |
|
---|
243 |
|
---|
244 | #endif /* !FEQT_INCLUDED_SRC_globals_UIPopupCenter_h */
|
---|
245 |
|
---|