VirtualBox

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

Last change on this file since 51930 was 51930, checked in by vboxsync, 10 years ago

FE/Qt: 6660: Advanced extra-data management framework: Notifies listeners about extra-data 'changed' (including 'removed' case).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.5 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 extra-data change. */
51 void sigExtraDataChange(QString strID, QString strKey, QString strValue);
52
53 /** Notifies about GUI language change. */
54 void sigLanguageChange(QString strLanguage);
55
56 /** Notifies about Selector UI keyboard shortcut change. */
57 void sigSelectorUIShortcutChange();
58 /** Notifies about Runtime UI keyboard shortcut change. */
59 void sigRuntimeUIShortcutChange();
60
61 /** Notifies about HID LEDs synchronization state change. */
62 void sigHidLedsSyncStateChange(bool fEnabled);
63
64#ifdef RT_OS_DARWIN
65 /** Mac OS X: Notifies about 'presentation mode' status change. */
66 void sigPresentationModeChange(bool fEnabled);
67 /** Mac OS X: Notifies about 'dock icon' appearance change. */
68 void sigDockIconAppearanceChange(bool fEnabled);
69#endif /* RT_OS_DARWIN */
70
71public:
72
73 /** Global extra-data ID. */
74 static const QString GlobalID;
75
76 /** Static Extra-data Manager instance/constructor. */
77 static UIExtraDataManager* instance();
78 /** Static Extra-data Manager destructor. */
79 static void destroy();
80
81 /** @name General
82 * @{ */
83 /** Returns whether Extra-data Manager cached the map with passed @a strID. */
84 bool contains(const QString &strID) const { return m_data.contains(strID); }
85 /** Returns read-only extra-data map for passed @a strID. */
86 const ExtraDataMap map(const QString &strID) const { return m_data.value(strID); }
87
88 /** Returns extra-data value corresponding to passed @a strKey as QString.
89 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
90 QString extraDataString(const QString &strKey, const QString &strID = GlobalID);
91 /** Defines extra-data value corresponding to passed @a strKey as strValue.
92 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
93 void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = GlobalID);
94
95 /** Returns extra-data value corresponding to passed @a strKey as QStringList.
96 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
97 QStringList extraDataStringList(const QString &strKey, const QString &strID = GlobalID);
98 /** Defines extra-data value corresponding to passed @a strKey as strValue.
99 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
100 void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = GlobalID);
101 /** @} */
102
103 /** @name Messaging
104 * @{ */
105 /** Returns the list of supressed messages for the Message/Popup center frameworks. */
106 QStringList suppressedMessages();
107 /** Defines the @a list of supressed messages for the Message/Popup center frameworks. */
108 void setSuppressedMessages(const QStringList &list);
109
110 /** Returns the list of messages for the Message/Popup center frameworks with inverted check-box state. */
111 QStringList messagesWithInvertedOption();
112
113#if !defined(VBOX_BLEEDING_EDGE) && !defined(DEBUG)
114 /** Returns version for which user wants to prevent BETA build warning. */
115 QString preventBetaBuildWarningForVersion();
116#endif /* !defined(VBOX_BLEEDING_EDGE) && !defined(DEBUG) */
117 /** @} */
118
119#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
120 /** @name Application Update
121 * @{ */
122 /** Returns whether Application Update functionality enabled. */
123 bool applicationUpdateEnabled();
124
125 /** Returns Application Update data. */
126 QString applicationUpdateData();
127 /** Defines Application Update data as @a strValue. */
128 void setApplicationUpdateData(const QString &strValue);
129
130 /** Returns Application Update check counter. */
131 qulonglong applicationUpdateCheckCounter();
132 /** Increments Application Update check counter. */
133 void incrementApplicationUpdateCheckCounter();
134 /** @} */
135#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
136
137 /** @name Settings
138 * @{ */
139 /** Returns restricted global settings pages. */
140 QList<GlobalSettingsPageType> restrictedGlobalSettingsPages();
141 /** Returns restricted machine settings pages. */
142 QList<MachineSettingsPageType> restrictedMachineSettingsPages(const QString &strID);
143 /** @} */
144
145 /** @name Settings: Keyboard
146 * @{ */
147 /** Returns shortcut overrides for shortcut-pool with @a strPoolExtraDataID. */
148 QStringList shortcutOverrides(const QString &strPoolExtraDataID);
149 /** @} */
150
151 /** @name Settings: Storage
152 * @{ */
153 /** Returns recent folder for hard-drives. */
154 QString recentFolderForHardDrives();
155 /** Returns recent folder for optical-disks. */
156 QString recentFolderForOpticalDisks();
157 /** Returns recent folder for floppy-disks. */
158 QString recentFolderForFloppyDisks();
159 /** Defines recent folder for hard-drives as @a strValue. */
160 void setRecentFolderForHardDrives(const QString &strValue);
161 /** Defines recent folder for optical-disk as @a strValue. */
162 void setRecentFolderForOpticalDisks(const QString &strValue);
163 /** Defines recent folder for floppy-disk as @a strValue. */
164 void setRecentFolderForFloppyDisks(const QString &strValue);
165
166 /** Returns the list of recently used hard-drives. */
167 QStringList recentListOfHardDrives();
168 /** Returns the list of recently used optical-disk. */
169 QStringList recentListOfOpticalDisks();
170 /** Returns the list of recently used floppy-disk. */
171 QStringList recentListOfFloppyDisks();
172 /** Defines the list of recently used hard-drives as @a value. */
173 void setRecentListOfHardDrives(const QStringList &value);
174 /** Defines the list of recently used optical-disks as @a value. */
175 void setRecentListOfOpticalDisks(const QStringList &value);
176 /** Defines the list of recently used floppy-disks as @a value. */
177 void setRecentListOfFloppyDisks(const QStringList &value);
178 /** @} */
179
180 /** @name VirtualBox Manager
181 * @{ */
182 /** Returns selector-window geometry using @a pWidget as the hint. */
183 QRect selectorWindowGeometry(QWidget *pWidget);
184 /** Returns whether selector-window should be maximized. */
185 bool selectorWindowShouldBeMaximized();
186 /** Defines selector-window @a geometry and @a fMaximized state. */
187 void setSelectorWindowGeometry(const QRect &geometry, bool fMaximized);
188
189 /** Returns selector-window splitter hints. */
190 QList<int> selectorWindowSplitterHints();
191 /** Defines selector-window splitter @a hints. */
192 void setSelectorWindowSplitterHints(const QList<int> &hints);
193
194 /** Returns whether selector-window tool-bar visible. */
195 bool selectorWindowToolBarVisible();
196 /** Defines whether selector-window tool-bar @a fVisible. */
197 void setSelectorWindowToolBarVisible(bool fVisible);
198
199 /** Returns whether selector-window status-bar visible. */
200 bool selectorWindowStatusBarVisible();
201 /** Defines whether selector-window status-bar @a fVisible. */
202 void setSelectorWindowStatusBarVisible(bool fVisible);
203
204 /** Clears all the existing selector-window chooser-pane' group definitions. */
205 void clearSelectorWindowGroupsDefinitions();
206 /** Returns selector-window chooser-pane' groups definitions for passed @a strGroupID. */
207 QStringList selectorWindowGroupsDefinitions(const QString &strGroupID);
208 /** Defines selector-window chooser-pane' groups @a definitions for passed @a strGroupID. */
209 void setSelectorWindowGroupsDefinitions(const QString &strGroupID, const QStringList &definitions);
210
211 /** Returns last-item ID of the item chosen in selector-window chooser-pane. */
212 QString selectorWindowLastItemChosen();
213 /** Defines @a lastItemID of the item chosen in selector-window chooser-pane. */
214 void setSelectorWindowLastItemChosen(const QString &strItemID);
215
216 /** Returns selector-window details-pane' elements. */
217 QMap<DetailsElementType, bool> selectorWindowDetailsElements();
218 /** Defines selector-window details-pane' @a elements. */
219 void setSelectorWindowDetailsElements(const QMap<DetailsElementType, bool> &elements);
220
221 /** Returns selector-window details-pane' preview update interval. */
222 PreviewUpdateIntervalType selectorWindowPreviewUpdateInterval();
223 /** Defines selector-window details-pane' preview update @a interval. */
224 void setSelectorWindowPreviewUpdateInterval(PreviewUpdateIntervalType interval);
225 /** @} */
226
227 /** @name Wizards
228 * @{ */
229 /** Returns mode for wizard of passed @a type. */
230 WizardMode modeForWizardType(WizardType type);
231 /** Defines @a mode for wizard of passed @a type. */
232 void setModeForWizardType(WizardType type, WizardMode mode);
233 /** @} */
234
235 /** @name Virtual Machine
236 * @{ */
237 /** Returns whether machine should be shown in selector-window chooser-pane. */
238 bool showMachineInSelectorChooser(const QString &strID);
239 /** Returns whether machine should be shown in selector-window details-pane. */
240 bool showMachineInSelectorDetails(const QString &strID);
241
242 /** Returns whether machine reconfiguration enabled. */
243 bool machineReconfigurationEnabled(const QString &strID);
244 /** Returns whether machine snapshot operations enabled. */
245 bool machineSnapshotOperationsEnabled(const QString &strID);
246
247 /** Returns whether this machine is first time started. */
248 bool machineFirstTimeStarted(const QString &strID);
249 /** Returns whether this machine is fFirstTimeStarted. */
250 void setMachineFirstTimeStarted(bool fFirstTimeStarted, const QString &strID);
251
252#ifndef Q_WS_MAC
253 /** Except Mac OS X: Returns redefined machine-window icon names. */
254 QStringList machineWindowIconNames(const QString &strID);
255 /** Except Mac OS X: Returns redefined machine-window name postfix. */
256 QString machineWindowNamePostfix(const QString &strID);
257#endif /* !Q_WS_MAC */
258
259 /** Returns geometry for machine-window with @a uScreenIndex in @a visualStateType. */
260 QRect machineWindowGeometry(UIVisualStateType visualStateType, ulong uScreenIndex, const QString &strID);
261 /** Returns whether machine-window with @a uScreenIndex in @a visualStateType should be maximized. */
262 bool machineWindowShouldBeMaximized(UIVisualStateType visualStateType, ulong uScreenIndex, const QString &strID);
263 /** Defines @a geometry and @a fMaximized state for machine-window with @a uScreenIndex in @a visualStateType. */
264 void setMachineWindowGeometry(UIVisualStateType visualStateType, ulong uScreenIndex, const QRect &geometry, bool fMaximized, const QString &strID);
265
266 /** Returns restricted Runtime UI menu types. */
267 RuntimeMenuType restrictedRuntimeMenuTypes(const QString &strID);
268 #ifdef Q_WS_MAC
269 /** Mac OS X: Returns restricted Runtime UI action types for Application menu. */
270 RuntimeMenuApplicationActionType restrictedRuntimeMenuApplicationActionTypes(const QString &strID);
271 #endif /* Q_WS_MAC */
272 /** Returns restricted Runtime UI action types for Machine menu. */
273 RuntimeMenuMachineActionType restrictedRuntimeMenuMachineActionTypes(const QString &strID);
274 /** Returns restricted Runtime UI action types for View menu. */
275 RuntimeMenuViewActionType restrictedRuntimeMenuViewActionTypes(const QString &strID);
276 /** Returns restricted Runtime UI action types for Devices menu. */
277 RuntimeMenuDevicesActionType restrictedRuntimeMenuDevicesActionTypes(const QString &strID);
278 #ifdef VBOX_WITH_DEBUGGER_GUI
279 /** Returns restricted Runtime UI action types for Debugger menu. */
280 RuntimeMenuDebuggerActionType restrictedRuntimeMenuDebuggerActionTypes(const QString &strID);
281 #endif /* VBOX_WITH_DEBUGGER_GUI */
282 /** Returns restricted Runtime UI action types for Help menu. */
283 RuntimeMenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID);
284
285 /** Returns restricted Runtime UI visual-states. */
286 UIVisualStateType restrictedVisualStates(const QString &strID);
287
288 /** Returns requested Runtime UI visual-state. */
289 UIVisualStateType requestedVisualState(const QString &strID);
290 /** Defines requested Runtime UI visual-state as @a visualState. */
291 void setRequestedVisualState(UIVisualStateType visualState, const QString &strID);
292
293 /** Returns whether guest-screen auto-resize according machine-window size is enabled. */
294 bool guestScreenAutoResizeEnabled(const QString &strID);
295 /** Defines whether guest-screen auto-resize according machine-window size is @a fEnabled. */
296 void setGuestScreenAutoResizeEnabled(bool fEnabled, const QString &strID);
297
298 /** Returns last guest-screen size-hint for screen with @a uScreenIndex. */
299 QSize lastGuestSizeHint(ulong uScreenIndex, const QString &strID);
300 /** Defines last guest-screen @a sizeHint for screen with @a uScreenIndex. */
301 void setLastGuestSizeHint(ulong uScreenIndex, const QSize &sizeHint, const QString &strID);
302 /** Returns whether guest size-hint was for full or seamless screen with @a uScreenIndex. */
303 bool wasLastGuestSizeHintForFullScreen(ulong uScreenIndex, const QString &strID);
304 /** Defines whether guest size-hint @a fWas for full or seamless screen with @a uScreenIndex. */
305 void markLastGuestSizeHintAsFullScreen(ulong uScreenIndex, bool fWas, const QString &strID);
306
307 /** Returns host-screen index corresponding to passed guest-screen @a iGuestScreenIndex. */
308 int hostScreenForPassedGuestScreen(int iGuestScreenIndex, const QString &strID);
309 /** Defines @a iHostScreenIndex corresponding to passed guest-screen @a iGuestScreenIndex. */
310 void setHostScreenForPassedGuestScreen(int iGuestScreenIndex, int iHostScreenIndex, const QString &strID);
311
312 /** Returns whether automatic mounting/unmounting of guest-screens enabled. */
313 bool autoMountGuestScreensEnabled(const QString &strID);
314
315#ifdef VBOX_WITH_VIDEOHWACCEL
316 /** Returns whether 2D acceleration should use linear sretch. */
317 bool useLinearStretch(const QString &strID);
318 /** Returns whether 2D acceleration should use YV12 pixel format. */
319 bool usePixelFormatYV12(const QString &strID);
320 /** Returns whether 2D acceleration should use UYVY pixel format. */
321 bool usePixelFormatUYVY(const QString &strID);
322 /** Returns whether 2D acceleration should use YUY2 pixel format. */
323 bool usePixelFormatYUY2(const QString &strID);
324 /** Returns whether 2D acceleration should use AYUV pixel format. */
325 bool usePixelFormatAYUV(const QString &strID);
326#endif /* VBOX_WITH_VIDEOHWACCEL */
327
328 /** Returns Runtime UI HiDPI optimization type. */
329 HiDPIOptimizationType hiDPIOptimizationType(const QString &strID);
330
331 /** Returns whether mini-toolbar is enabled for full and seamless screens. */
332 bool miniToolbarEnabled(const QString &strID);
333 /** Defines whether mini-toolbar is @a fEnabled for full and seamless screens. */
334 void setMiniToolbarEnabled(bool fEnabled, const QString &strID);
335
336 /** Returns whether mini-toolbar should auto-hide itself. */
337 bool autoHideMiniToolbar(const QString &strID);
338 /** Defines whether mini-toolbar should @a fAutoHide itself. */
339 void setAutoHideMiniToolbar(bool fAutoHide, const QString &strID);
340
341 /** Returns mini-toolbar alignment. */
342 Qt::AlignmentFlag miniToolbarAlignment(const QString &strID);
343 /** Returns mini-toolbar @a alignment. */
344 void setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID);
345
346 /** Returns restricted Runtime UI status-bar indicators. */
347 QList<IndicatorType> restrictedStatusBarIndicators(const QString &strID);
348
349#ifdef Q_WS_MAC
350 /** Mac OS X: Returns whether 'presentation mode' enabled. */
351 bool presentationModeEnabled(const QString &strID);
352
353 /** Mac OS X: Returns whether Dock icon should be updated at runtime. */
354 bool realtimeDockIconUpdateEnabled(const QString &strID);
355 /** Mac OS X: Defines whether Dock icon update should be fEnabled at runtime. */
356 void setRealtimeDockIconUpdateEnabled(bool fEnabled, const QString &strID);
357
358 /** Mac OS X: Returns guest-screen which Dock icon should reflect at runtime. */
359 int realtimeDockIconUpdateMonitor(const QString &strID);
360 /** Mac OS X: Defines guest-screen @a iIndex which Dock icon should reflect at runtime. */
361 void setRealtimeDockIconUpdateMonitor(int iIndex, const QString &strID);
362#endif /* Q_WS_MAC */
363
364 /** Returns whether machine should pass CAD to guest. */
365 bool passCADtoGuest(const QString &strID);
366
367 /** Returns redefined guru-meditation handler type. */
368 GuruMeditationHandlerType guruMeditationHandlerType(const QString &strID);
369
370 /** Returns whether machine should perform HID LEDs synchronization. */
371 bool hidLedsSyncState(const QString &strID);
372 /** @} */
373
374 /** @name Virtual Machine: Information dialog
375 * @{ */
376 /** Returns information-window geometry using @a pWidget and @a pParentWidget as hints. */
377 QRect informationWindowGeometry(QWidget *pWidget, QWidget *pParentWidget, const QString &strID);
378 /** Returns whether information-window should be maximized or not. */
379 bool informationWindowShouldBeMaximized(const QString &strID);
380 /** Defines information-window @a geometry and @a fMaximized state. */
381 void setInformationWindowGeometry(const QRect &geometry, bool fMaximized, const QString &strID);
382 /** @} */
383
384 /** @name Virtual Machine: Close dialog
385 * @{ */
386 /** Returns default machine close action. */
387 MachineCloseAction defaultMachineCloseAction(const QString &strID);
388 /** Returns restricted machine close actions. */
389 MachineCloseAction restrictedMachineCloseActions(const QString &strID);
390
391 /** Returns last machine close action. */
392 MachineCloseAction lastMachineCloseAction(const QString &strID);
393 /** Defines last @a machineCloseAction. */
394 void setLastMachineCloseAction(MachineCloseAction machineCloseAction, const QString &strID);
395
396 /** Returns machine close hook script name as simple string. */
397 QString machineCloseHookScript(const QString &strID);
398 /** @} */
399
400#ifdef VBOX_WITH_DEBUGGER_GUI
401 /** @name Virtual Machine: Debug UI
402 * @{ */
403 /** Returns debug flag value for passed @a strDebugFlagKey. */
404 QString debugFlagValue(const QString &strDebugFlagKey);
405 /** @} */
406#endif /* VBOX_WITH_DEBUGGER_GUI */
407
408private slots:
409
410 /** Handles 'extra-data change' event: */
411 void sltExtraDataChange(QString strMachineID, QString strKey, QString strValue);
412
413private:
414
415 /** Prepare Extra-data Manager. */
416 void prepare();
417 /** Prepare global extra-data map. */
418 void prepareGlobalExtraDataMap();
419 /** Prepare extra-data event-handler. */
420 void prepareExtraDataEventHandler();
421 /** Prepare Main event-listener. */
422 void prepareMainEventListener();
423
424 /** Cleanup Main event-listener. */
425 void cleanupMainEventListener();
426 // /** Cleanup extra-data event-handler. */
427 // void cleanupExtraDataEventHandler();
428 // /** Cleanup extra-data map. */
429 // void cleanupExtraDataMap();
430 /** Cleanup Extra-data Manager. */
431 void cleanup();
432
433 /** Hot-load machine extra-data map. */
434 void hotloadMachineExtraDataMap(const QString &strID);
435
436 /** Determines whether feature corresponding to passed @a strKey is allowed.
437 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
438 bool isFeatureAllowed(const QString &strKey, const QString &strID = GlobalID);
439 /** Determines whether feature corresponding to passed @a strKey is restricted.
440 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
441 bool isFeatureRestricted(const QString &strKey, const QString &strID = GlobalID);
442
443 /** Translates bool flag into 'allowed' value. */
444 QString toFeatureAllowed(bool fAllowed);
445 /** Translates bool flag into 'restricted' value. */
446 QString toFeatureRestricted(bool fRestricted);
447
448 /** Returns string consisting of @a strBase appended with @a uScreenIndex for the *non-primary* screen-index.
449 * If @a fSameRuleForPrimary is 'true' same rule will be used for *primary* screen-index. Used for storing per-screen extra-data. */
450 static QString extraDataKeyPerScreen(const QString &strBase, ulong uScreenIndex, bool fSameRuleForPrimary = false);
451
452 /** Singleton Extra-data Manager instance. */
453 static UIExtraDataManager *m_spInstance;
454
455 /** Holds main event-listener instance. */
456 CEventListener m_listener;
457 /** Holds extra-data event-handler instance. */
458 UIExtraDataEventHandler *m_pHandler;
459
460 /** Holds extra-data map instance. */
461 QMap<QString, ExtraDataMap> m_data;
462};
463
464/** Singleton Extra-data Manager 'official' name. */
465#define gEDataManager UIExtraDataManager::instance()
466
467#endif /* !___UIExtraDataManager_h___ */
Note: See TracBrowser for help on using the repository browser.

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