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: */
|
---|
31 | class UIExtraDataEventHandler;
|
---|
32 |
|
---|
33 | /* Type definitions: */
|
---|
34 | typedef 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. */
|
---|
39 | class UIExtraDataManager : public QObject
|
---|
40 | {
|
---|
41 | Q_OBJECT;
|
---|
42 |
|
---|
43 | /** Extra-data Manager constructor. */
|
---|
44 | UIExtraDataManager();
|
---|
45 | /** Extra-data Manager destructor. */
|
---|
46 | ~UIExtraDataManager();
|
---|
47 |
|
---|
48 | signals:
|
---|
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 LED sync 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 |
|
---|
68 | public:
|
---|
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 render-mode for machine with passed @a strId. */
|
---|
134 | RenderMode renderMode(const QString &strId) const;
|
---|
135 |
|
---|
136 | /** Returns whether this machine started for the first time. */
|
---|
137 | bool isFirstRun(const QString &strId) const;
|
---|
138 | /** Defines whether this machine started for the first time. */
|
---|
139 | void setFirstRun(bool fIsFirstRun, const QString &strId);
|
---|
140 |
|
---|
141 | /** Returns whether we should show machine. */
|
---|
142 | bool shouldWeShowMachine(const QString &strID) const;
|
---|
143 | /** Returns whether we should show machine details. */
|
---|
144 | bool shouldWeShowMachineDetails(const QString &strID) const;
|
---|
145 |
|
---|
146 | /** Returns whether we should allow machine reconfiguration. */
|
---|
147 | bool shouldWeAllowMachineReconfiguration(const QString &strID) const;
|
---|
148 | /** Returns whether we should allow machine snapshot operations. */
|
---|
149 | bool shouldWeAllowMachineSnapshotOperations(const QString &strID) const;
|
---|
150 |
|
---|
151 | /** Returns whether we should automatically mount/unmount guest-screens. */
|
---|
152 | bool shouldWeAutoMountGuestScreens(const QString &strID) const;
|
---|
153 |
|
---|
154 | /** Returns restricted Runtime UI menu types. */
|
---|
155 | RuntimeMenuType restrictedRuntimeMenuTypes(const QString &strID) const;
|
---|
156 | #ifdef Q_WS_MAC
|
---|
157 | /** Mac OS X: Returns restricted Runtime UI action types for Application menu. */
|
---|
158 | RuntimeMenuApplicationActionType restrictedRuntimeMenuApplicationActionTypes(const QString &strID) const;
|
---|
159 | #endif /* Q_WS_MAC */
|
---|
160 | /** Returns restricted Runtime UI action types for Machine menu. */
|
---|
161 | RuntimeMenuMachineActionType restrictedRuntimeMenuMachineActionTypes(const QString &strID) const;
|
---|
162 | /** Returns restricted Runtime UI action types for View menu. */
|
---|
163 | RuntimeMenuViewActionType restrictedRuntimeMenuViewActionTypes(const QString &strID) const;
|
---|
164 | /** Returns restricted Runtime UI action types for Devices menu. */
|
---|
165 | RuntimeMenuDevicesActionType restrictedRuntimeMenuDevicesActionTypes(const QString &strID) const;
|
---|
166 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
167 | /** Returns restricted Runtime UI action types for Debugger menu. */
|
---|
168 | RuntimeMenuDebuggerActionType restrictedRuntimeMenuDebuggerActionTypes(const QString &strID) const;
|
---|
169 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
170 | /** Returns restricted Runtime UI action types for Help menu. */
|
---|
171 | RuntimeMenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID) const;
|
---|
172 |
|
---|
173 | /** Returns restricted Runtime UI visual-state types. */
|
---|
174 | UIVisualStateType restrictedVisualStateTypes(const QString &strID) const;
|
---|
175 |
|
---|
176 | /** Returns default machine close action. */
|
---|
177 | MachineCloseAction defaultMachineCloseAction(const QString &strID) const;
|
---|
178 | /** Returns restricted machine close actions. */
|
---|
179 | MachineCloseAction restrictedMachineCloseActions(const QString &strID) const;
|
---|
180 |
|
---|
181 | /** Returns restricted Runtime UI status-bar indicators. */
|
---|
182 | QList<IndicatorType> restrictedStatusBarIndicators(const QString &strID) const;
|
---|
183 |
|
---|
184 | /** Returns global settings pages. */
|
---|
185 | QList<GlobalSettingsPageType> restrictedGlobalSettingsPages() const;
|
---|
186 | /** Returns machine settings pages. */
|
---|
187 | QList<MachineSettingsPageType> restrictedMachineSettingsPages(const QString &strID) const;
|
---|
188 |
|
---|
189 | #ifndef Q_WS_MAC
|
---|
190 | /** Except Mac OS X: Returns redefined machine-window icon names. */
|
---|
191 | QStringList machineWindowIconNames(const QString &strID) const;
|
---|
192 | /** Except Mac OS X: Returns redefined machine-window name postfix. */
|
---|
193 | QString machineWindowNamePostfix(const QString &strID) const;
|
---|
194 | #endif /* !Q_WS_MAC */
|
---|
195 |
|
---|
196 | /** Returns redefined guru-meditation handler type. */
|
---|
197 | GuruMeditationHandlerType guruMeditationHandlerType(const QString &strID) const;
|
---|
198 |
|
---|
199 | /** Returns Runtime UI HiDPI optimization type. */
|
---|
200 | HiDPIOptimizationType hiDPIOptimizationType(const QString &strID) const;
|
---|
201 |
|
---|
202 | private slots:
|
---|
203 |
|
---|
204 | /** Handles 'extra-data change' event: */
|
---|
205 | void sltExtraDataChange(QString strMachineID, QString strKey, QString strValue);
|
---|
206 |
|
---|
207 | private:
|
---|
208 |
|
---|
209 | /** Prepare Extra-data Manager. */
|
---|
210 | void prepare();
|
---|
211 | /** Prepare global extra-data map. */
|
---|
212 | void prepareGlobalExtraDataMap();
|
---|
213 | /** Prepare extra-data event-handler. */
|
---|
214 | void prepareExtraDataEventHandler();
|
---|
215 | /** Prepare Main event-listener. */
|
---|
216 | void prepareMainEventListener();
|
---|
217 |
|
---|
218 | /** Cleanup Extra-data Manager. */
|
---|
219 | void cleanup();
|
---|
220 | /** Cleanup Main event-listener. */
|
---|
221 | void cleanupMainEventListener();
|
---|
222 | // /** Cleanup extra-data event-handler. */
|
---|
223 | // void cleanupExtraDataEventHandler();
|
---|
224 | // /** Cleanup extra-data map. */
|
---|
225 | // void cleanupExtraDataMap();
|
---|
226 |
|
---|
227 | /** Hot-load machine extra-data map. */
|
---|
228 | void hotloadMachineExtraDataMap(const QString &strID) const;
|
---|
229 |
|
---|
230 | /** Determines whether feature corresponding to passed @a strKey is allowed.
|
---|
231 | * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
|
---|
232 | bool isFeatureAllowed(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
|
---|
233 | /** Determines whether feature corresponding to passed @a strKey is restricted.
|
---|
234 | * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
|
---|
235 | bool isFeatureRestricted(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
|
---|
236 |
|
---|
237 | /** Translates bool flag into 'allowed' value. */
|
---|
238 | QString toFeatureAllowed(bool fAllowed);
|
---|
239 | /** Translates bool flag into 'restricted' value. */
|
---|
240 | QString toFeatureRestricted(bool fRestricted);
|
---|
241 |
|
---|
242 | /** Returns extra-data value corresponding to passed @a strKey as QString.
|
---|
243 | * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
|
---|
244 | QString extraDataString(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
|
---|
245 | /** Defines extra-data value corresponding to passed @a strKey as strValue.
|
---|
246 | * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
|
---|
247 | void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = m_sstrGlobalID);
|
---|
248 |
|
---|
249 | /** Returns extra-data value corresponding to passed @a strKey as QStringList.
|
---|
250 | * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
|
---|
251 | QStringList extraDataStringList(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
|
---|
252 | /** Defines extra-data value corresponding to passed @a strKey as strValue.
|
---|
253 | * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
|
---|
254 | void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = m_sstrGlobalID);
|
---|
255 |
|
---|
256 | /** Singleton Extra-data Manager instance. */
|
---|
257 | static UIExtraDataManager *m_pInstance;
|
---|
258 |
|
---|
259 | /** Global extra-data ID. */
|
---|
260 | static QString m_sstrGlobalID;
|
---|
261 |
|
---|
262 | /** Main event-listener instance. */
|
---|
263 | CEventListener m_listener;
|
---|
264 | /** Extra-data event-handler instance. */
|
---|
265 | UIExtraDataEventHandler *m_pHandler;
|
---|
266 |
|
---|
267 | /** Extra-data map. */
|
---|
268 | mutable QMap<QString, ExtraDataMap> m_data;
|
---|
269 | };
|
---|
270 |
|
---|
271 | /** Singleton Extra-data Manager 'official' name. */
|
---|
272 | #define gEDataManager UIExtraDataManager::instance()
|
---|
273 |
|
---|
274 | #endif /* !___UIExtraDataManager_h___ */
|
---|