VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h@ 51666

Last change on this file since 51666 was 51666, checked in by vboxsync, 11 years ago

FE/Qt: 6660: Advanced extra-data management framework: Integrate GUI_Dbg_Enabled, GUI_Dbg_AutoShow.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.1 KB
Line 
1/** @file
2 * VBox Qt GUI - UIExtraDataManager class declaration.
3 */
4
5/*
6 * Copyright (C) 2010-2014 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___UIExtraDataManager_h___
18#define ___UIExtraDataManager_h___
19
20/* Qt includes: */
21#include <QObject>
22#include <QMap>
23
24/* GUI includes: */
25#include "UIExtraDataDefs.h"
26
27/* COM includes: */
28#include "CEventListener.h"
29
30/* Forward declarations: */
31class UIExtraDataEventHandler;
32
33/* Type definitions: */
34typedef QMap<QString, QString> ExtraDataMap;
35
36/** Singleton QObject extension
37 * providing GUI with corresponding extra-data values,
38 * and notifying it whenever any of those values changed. */
39class UIExtraDataManager : public QObject
40{
41 Q_OBJECT;
42
43 /** Extra-data Manager constructor. */
44 UIExtraDataManager();
45 /** Extra-data Manager destructor. */
46 ~UIExtraDataManager();
47
48signals:
49
50 /** Notifies about GUI language change. */
51 void sigLanguageChange(QString strLanguage);
52
53 /** Notifies about Selector UI keyboard shortcut change. */
54 void sigSelectorUIShortcutChange();
55 /** Notifies about Runtime UI keyboard shortcut change. */
56 void sigRuntimeUIShortcutChange();
57
58 /** Notifies about HID LEDs synchronization state change. */
59 void sigHidLedsSyncStateChange(bool fEnabled);
60
61#ifdef RT_OS_DARWIN
62 /** Mac OS X: Notifies about 'presentation mode' status change. */
63 void sigPresentationModeChange(bool fEnabled);
64 /** Mac OS X: Notifies about 'dock icon' appearance change. */
65 void sigDockIconAppearanceChange(bool fEnabled);
66#endif /* RT_OS_DARWIN */
67
68public:
69
70 /** Static Extra-data Manager instance/constructor. */
71 static UIExtraDataManager* instance();
72 /** Static Extra-data Manager destructor. */
73 static void destroy();
74
75 /** Returns version for which user wants to prevent BETA warning. */
76 QString preventBETAwarningForVersion() const;
77
78#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
79 /** Returns whether we should allow Application Update. */
80 bool shouldWeAllowApplicationUpdate() const;
81 /** Returns last Application Update date. */
82 QString applicationUpdateData() const;
83 /** Defines last Application Update date as @a strValue. */
84 void setApplicationUpdateData(const QString &strValue);
85 /** Returns Application Update check counter. */
86 qulonglong applicationUpdateCheckCounter() const;
87 /** Increments Application Update check counter. */
88 void incrementApplicationUpdateCheckCounter();
89#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
90
91 /** Returns shortcut overrides for shortcut-pool with @a strPoolExtraDataID. */
92 QStringList shortcutOverrides(const QString &strPoolExtraDataID) const;
93
94 /** Returns recent hard-drive folder. */
95 QString recentFolderForHardDrives() const;
96 /** Returns recent optical-disk folder. */
97 QString recentFolderForOpticalDisks() const;
98 /** Returns recent floppy-disk folder. */
99 QString recentFolderForFloppyDisks() const;
100 /** Defines recent hard-drive folder as @a strValue. */
101 void setRecentFolderForHardDrives(const QString &strValue);
102 /** Defines recent optical-disk folder as @a strValue. */
103 void setRecentFolderForOpticalDisks(const QString &strValue);
104 /** Defines recent floppy-disk folder as @a strValue. */
105 void setRecentFolderForFloppyDisks(const QString &strValue);
106
107 /** Returns recent hard-drive list. */
108 QStringList recentListOfHardDrives() const;
109 /** Returns recent optical-disk list. */
110 QStringList recentListOfOpticalDisks() const;
111 /** Returns recent floppy-disk list. */
112 QStringList recentListOfFloppyDisks() const;
113 /** Defines recent hard-drive list as @a value. */
114 void setRecentListOfHardDrives(const QStringList &value);
115 /** Defines recent optical-disk list as @a value. */
116 void setRecentListOfOpticalDisks(const QStringList &value);
117 /** Defines recent floppy-disk list as @a value. */
118 void setRecentListOfFloppyDisks(const QStringList &value);
119
120 /** Returns list of the supressed messages for the Message/Popup center frameworks. */
121 QStringList suppressedMessages() const;
122 /** Defines list of the supressed messages for the Message/Popup center frameworks as @a value. */
123 void setSuppressedMessages(const QStringList &value);
124
125 /** Returns list of the messages for the Message/Popup center frameworks with inverted check-box state. */
126 QStringList messagesWithInvertedOption() const;
127
128 /** Returns mode (basic/expert) for wizard of @a type. */
129 WizardMode modeForWizard(WizardType type);
130 /** Defines @a mode (basic/expert) for wizard of @a type. */
131 void setModeForWizard(WizardType type, WizardMode mode);
132
133 /** Returns selector-window geometry using @a pWidget as the hint. */
134 QRect selectorWindowGeometry(QWidget *pWidget) const;
135 /** Returns whether selector-window should be maximized or not. */
136 bool isSelectorWindowShouldBeMaximized() const;
137 /** Defines selector-window geometry to passed @a geometry which is @a fMaximized. */
138 void setSelectorWindowGeometry(const QRect &geometry, bool fMaximized);
139
140 /** Returns selector-window splitter hints. */
141 QList<int> selectorWindowSplitterHints() const;
142 /** Defines selector-window splitter @a hints. */
143 void setSelectorWindowSplitterHints(const QList<int> &hints);
144
145 /** Returns whether selector-window tool-bar visible. */
146 bool selectorWindowToolBarVisible() const;
147 /** Defines whether selector-window tool-bar @a fVisible. */
148 void setSelectorWindowToolBarVisible(bool fVisible);
149 /** Returns whether selector-window status-bar visible. */
150 bool selectorWindowStatusBarVisible() const;
151 /** Defines whether selector-window status-bar @a fVisible. */
152 void setSelectorWindowStatusBarVisible(bool fVisible);
153
154 /** Clears all the existing selector-window chooser-pane' group definitions. */
155 void clearSelectorWindowGroupsDefinitions();
156 /** Returns selector-window chooser-pane' groups definitions for passed @a strGroupID. */
157 QStringList selectorWindowGroupsDefinitions(const QString &strGroupID) const;
158 /** Defines selector-window chooser-pane' groups definitions for passed @a strGroupID as @a definitions. */
159 void setSelectorWindowGroupsDefinitions(const QString &strGroupID, const QStringList &definitions);
160
161 /** Returns last item chosen in selector-window chooser-pane. */
162 QString selectorWindowLastItemChosen() const;
163 /** Defines last item chosen in selector-window chooser-pane as @a strItemID. */
164 void setSelectorWindowLastItemChosen(const QString &strItemID);
165
166 /** Returns selector-window details-pane elements. */
167 QMap<DetailsElementType, bool> selectorWindowDetailsElements();
168 /** Defines selector-window details-pane @a elements. */
169 void setSelectorWindowDetailsElements(const QMap<DetailsElementType, bool> &elements);
170
171 /** Returns selector-window preview update interval. */
172 PreviewUpdateIntervalType selectorWindowPreviewUpdateInterval() const;
173 /** Defines selector-window preview update @a interval. */
174 void setSelectorWindowPreviewUpdateInterval(PreviewUpdateIntervalType interval);
175
176#ifdef VBOX_WITH_DEBUGGER_GUI
177 /** Returns debug flag value for passed @a strDebugFlagKey. */
178 QString debugFlagValue(const QString &strDebugFlagKey) const;
179#endif /* VBOX_WITH_DEBUGGER_GUI */
180
181 /** Returns geometry for machine-window with @a uScreenIndex in @a visualStateType. */
182 QRect machineWindowGeometry(UIVisualStateType visualStateType, ulong uScreenIndex, const QString &strId) const;
183 /** Returns whether machine-window with @a uScreenIndex in @a visualStateType should be maximized or not. */
184 bool isMachineWindowShouldBeMaximized(UIVisualStateType visualStateType, ulong uScreenIndex, const QString &strId) const;
185 /** Defines geometry for machine-window with @a uScreenIndex in @a visualStateType as @a geometry and @a fMaximized. */
186 void setMachineWindowGeometry(UIVisualStateType visualStateType, ulong uScreenIndex, const QRect &geometry, bool fMaximized, const QString &strId);
187
188 /** Returns last guest-screen size-hint for screen with @a uScreenIndex. */
189 QSize lastGuestSizeHint(ulong uScreenIndex, const QString &strId) const;
190 /** Defines last guest-screen size-hint for screen with @a uScreenIndex as @a size. */
191 void setLastGuestSizeHint(ulong uScreenIndex, const QSize &size, const QString &strId);
192 /** Returns whether guest size hint was for full or seamless screen with @a uScreenIndex. */
193 bool wasLastGuestSizeHintForFullScreen(ulong uScreenIndex, const QString &strId) const;
194 /** Defines whether guest size hint @a fWas for full or seamless screen with @a uScreenIndex. */
195 void markLastGuestSizeHintAsFullScreen(ulong uScreenIndex, bool fWas, const QString &strId);
196
197 /** Returns whether this machine started for the first time. */
198 bool isFirstRun(const QString &strId) const;
199 /** Defines whether this machine started for the first time. */
200 void setFirstRun(bool fIsFirstRun, const QString &strId);
201
202 /** Returns whether we should show machine. */
203 bool shouldWeShowMachine(const QString &strID) const;
204 /** Returns whether we should show machine details. */
205 bool shouldWeShowMachineDetails(const QString &strID) const;
206
207 /** Returns whether we should allow machine reconfiguration. */
208 bool shouldWeAllowMachineReconfiguration(const QString &strID) const;
209 /** Returns whether we should allow machine snapshot operations. */
210 bool shouldWeAllowMachineSnapshotOperations(const QString &strID) const;
211
212 /** Returns whether we should automatically mount/unmount guest-screens. */
213 bool shouldWeAutoMountGuestScreens(const QString &strID) const;
214
215 /** Returns restricted Runtime UI menu types. */
216 RuntimeMenuType restrictedRuntimeMenuTypes(const QString &strID) const;
217#ifdef Q_WS_MAC
218 /** Mac OS X: Returns restricted Runtime UI action types for Application menu. */
219 RuntimeMenuApplicationActionType restrictedRuntimeMenuApplicationActionTypes(const QString &strID) const;
220#endif /* Q_WS_MAC */
221 /** Returns restricted Runtime UI action types for Machine menu. */
222 RuntimeMenuMachineActionType restrictedRuntimeMenuMachineActionTypes(const QString &strID) const;
223 /** Returns restricted Runtime UI action types for View menu. */
224 RuntimeMenuViewActionType restrictedRuntimeMenuViewActionTypes(const QString &strID) const;
225 /** Returns restricted Runtime UI action types for Devices menu. */
226 RuntimeMenuDevicesActionType restrictedRuntimeMenuDevicesActionTypes(const QString &strID) const;
227#ifdef VBOX_WITH_DEBUGGER_GUI
228 /** Returns restricted Runtime UI action types for Debugger menu. */
229 RuntimeMenuDebuggerActionType restrictedRuntimeMenuDebuggerActionTypes(const QString &strID) const;
230#endif /* VBOX_WITH_DEBUGGER_GUI */
231 /** Returns restricted Runtime UI action types for Help menu. */
232 RuntimeMenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID) const;
233
234 /** Returns restricted Runtime UI visual-states. */
235 UIVisualStateType restrictedVisualStates(const QString &strID) const;
236
237 /** Returns requested Runtime UI visual-state. */
238 UIVisualStateType requestedVisualState(const QString &strID) const;
239 /** Defines requested Runtime UI visual-state as @a visualState. */
240 void setRequestedVisualState(UIVisualStateType visualState, const QString &strID);
241
242 /** Returns host-screen index corresponding to passed guest-screen @a iGuestScreenIndex. */
243 int hostScreenForPassedGuestScreen(int iGuestScreenIndex, const QString &strID);
244 /** Defines host-screen index corresponding to passed guest-screen @a iGuestScreenIndex as @a iHostScreenIndex. */
245 void setHostScreenForPassedGuestScreen(int iGuestScreenIndex, int iHostScreenIndex, const QString &strID);
246
247 /** Returns whether guest-screen should auto-resize according machine-window size. */
248 bool guestScreenAutoResize(const QString &strID) const;
249 /** Defines whether guest-screen auto-resize according machine-window size is @a fEnabled. */
250 void setGuestScreenAutoResize(bool fEnabled, const QString &strID);
251
252 /** Returns restricted Runtime UI status-bar indicators. */
253 QList<IndicatorType> restrictedStatusBarIndicators(const QString &strID) const;
254
255 /** Returns global settings pages. */
256 QList<GlobalSettingsPageType> restrictedGlobalSettingsPages() const;
257 /** Returns machine settings pages. */
258 QList<MachineSettingsPageType> restrictedMachineSettingsPages(const QString &strID) const;
259
260#ifndef Q_WS_MAC
261 /** Except Mac OS X: Returns redefined machine-window icon names. */
262 QStringList machineWindowIconNames(const QString &strID) const;
263 /** Except Mac OS X: Returns redefined machine-window name postfix. */
264 QString machineWindowNamePostfix(const QString &strID) const;
265#endif /* !Q_WS_MAC */
266
267 /** Returns information-window geometry using @a pWidget and @a pParentWidget as hints. */
268 QRect informationWindowGeometry(QWidget *pWidget, QWidget *pParentWidget, const QString &strID) const;
269 /** Returns whether information-window should be maximized or not. */
270 bool isInformationWindowShouldBeMaximized(const QString &strID) const;
271 /** Defines information-window geometry to passed @a geometry which is @a fMaximized. */
272 void setInformationWindowGeometry(const QRect &geometry, bool fMaximized, const QString &strID);
273
274 /** Returns redefined guru-meditation handler type. */
275 GuruMeditationHandlerType guruMeditationHandlerType(const QString &strID) const;
276
277 /** Returns Runtime UI HiDPI optimization type. */
278 HiDPIOptimizationType hiDPIOptimizationType(const QString &strID) const;
279
280 /** Returns whether VM should pass CAD to guest. */
281 bool passCADtoGuest(const QString &strID) const;
282
283 /** Returns whether VM should perform HID LEDs synchronization. */
284 bool hidLedsSyncState(const QString &strID) const;
285
286 /** Returns whether mini-toolbar should be shown for full and seamless screens. */
287 bool showMiniToolbar(const QString &strID) const;
288 /** Defines whether mini-toolbar should be @a fShown for full and seamless screens. */
289 void setShowMiniToolbar(bool fShown, const QString &strID);
290
291 /** Returns whether mini-toolbar should auto-hide itself. */
292 bool autoHideMiniToolbar(const QString &strID) const;
293 /** Defines whether mini-toolbar should @a fAutoHide itself. */
294 void setAutoHideMiniToolbar(bool fAutoHide, const QString &strID);
295
296 /** Returns mini-toolbar alignment. */
297 Qt::AlignmentFlag miniToolbarAlignment(const QString &strID) const;
298 /** Returns mini-toolbar @a alignment. */
299 void setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID);
300
301 /** Returns default machine close action. */
302 MachineCloseAction defaultMachineCloseAction(const QString &strID) const;
303 /** Returns restricted machine close actions. */
304 MachineCloseAction restrictedMachineCloseActions(const QString &strID) const;
305
306 /** Returns last machine close action. */
307 MachineCloseAction lastMachineCloseAction(const QString &strID) const;
308 /** Defines last @a machineCloseAction. */
309 void setLastMachineCloseAction(MachineCloseAction machineCloseAction, const QString &strID);
310
311 /** Returns machine close hook script name as simple string. */
312 QString machineCloseHookScript(const QString &strID) const;
313
314private slots:
315
316 /** Handles 'extra-data change' event: */
317 void sltExtraDataChange(QString strMachineID, QString strKey, QString strValue);
318
319private:
320
321 /** Prepare Extra-data Manager. */
322 void prepare();
323 /** Prepare global extra-data map. */
324 void prepareGlobalExtraDataMap();
325 /** Prepare extra-data event-handler. */
326 void prepareExtraDataEventHandler();
327 /** Prepare Main event-listener. */
328 void prepareMainEventListener();
329
330 /** Cleanup Extra-data Manager. */
331 void cleanup();
332 /** Cleanup Main event-listener. */
333 void cleanupMainEventListener();
334 // /** Cleanup extra-data event-handler. */
335 // void cleanupExtraDataEventHandler();
336 // /** Cleanup extra-data map. */
337 // void cleanupExtraDataMap();
338
339 /** Hot-load machine extra-data map. */
340 void hotloadMachineExtraDataMap(const QString &strID) const;
341
342 /** Determines whether feature corresponding to passed @a strKey is allowed.
343 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
344 bool isFeatureAllowed(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
345 /** Determines whether feature corresponding to passed @a strKey is restricted.
346 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
347 bool isFeatureRestricted(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
348
349 /** Translates bool flag into 'allowed' value. */
350 QString toFeatureAllowed(bool fAllowed);
351 /** Translates bool flag into 'restricted' value. */
352 QString toFeatureRestricted(bool fRestricted);
353
354 /** Returns extra-data value corresponding to passed @a strKey as QString.
355 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
356 QString extraDataString(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
357 /** Defines extra-data value corresponding to passed @a strKey as strValue.
358 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
359 void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = m_sstrGlobalID);
360
361 /** Returns extra-data value corresponding to passed @a strKey as QStringList.
362 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
363 QStringList extraDataStringList(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
364 /** Defines extra-data value corresponding to passed @a strKey as strValue.
365 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
366 void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = m_sstrGlobalID);
367
368 /** Returns string consisting of @a strBase appended with @a uScreenIndex for the *non-primary* screen-index.
369 * If @a fSameRuleForPrimary is 'true' same rule will be used for *primary* screen-index. Used for storing per-screen extra-data. */
370 static QString extraDataKeyPerScreen(const QString &strBase, ulong uScreenIndex, bool fSameRuleForPrimary = false);
371
372 /** Singleton Extra-data Manager instance. */
373 static UIExtraDataManager *m_pInstance;
374
375 /** Global extra-data ID. */
376 static QString m_sstrGlobalID;
377
378 /** Main event-listener instance. */
379 CEventListener m_listener;
380 /** Extra-data event-handler instance. */
381 UIExtraDataEventHandler *m_pHandler;
382
383 /** Extra-data map. */
384 mutable QMap<QString, ExtraDataMap> m_data;
385};
386
387/** Singleton Extra-data Manager 'official' name. */
388#define gEDataManager UIExtraDataManager::instance()
389
390#endif /* !___UIExtraDataManager_h___ */
Note: See TracBrowser for help on using the repository browser.

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