VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h@ 82781

Last change on this file since 82781 was 81261, checked in by vboxsync, 5 years ago

FE/Qt: Reapplying r133952 with build-fixes for macOS (s.a. r133953).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
Line 
1/* $Id: UIVirtualBoxManager.h 81261 2019-10-14 14:38:47Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVirtualBoxManager class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-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_manager_UIVirtualBoxManager_h
19#define FEQT_INCLUDED_SRC_manager_UIVirtualBoxManager_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QMainWindow>
26#include <QUrl>
27
28/* GUI includes: */
29#include "QIWithRestorableGeometry.h"
30#include "QIWithRetranslateUI.h"
31#include "UICommon.h"
32
33/* Forward declarations: */
34class QMenu;
35class QIManagerDialog;
36class UIAction;
37class UIActionPool;
38class UIVirtualBoxManagerWidget;
39class UIVirtualMachineItem;
40
41/* Type definitions: */
42typedef QIWithRestorableGeometry<QMainWindow> QMainWindowWithRestorableGeometry;
43typedef QIWithRetranslateUI<QMainWindowWithRestorableGeometry> QMainWindowWithRestorableGeometryAndRetranslateUi;
44typedef QMap<QString, QIManagerDialog*> VMLogViewerMap;
45
46/** Singleton QMainWindow extension used as VirtualBox Manager instance. */
47class UIVirtualBoxManager : public QMainWindowWithRestorableGeometryAndRetranslateUi
48{
49 Q_OBJECT;
50
51signals:
52
53 /** Notifies listeners about this window remapped to another screen. */
54 void sigWindowRemapped();
55
56 /** Notifies listeners about Cloud Profile Manager change. */
57 void sigCloudProfileManagerChange();
58
59public:
60
61 /** Singleton constructor. */
62 static void create();
63 /** Singleton destructor. */
64 static void destroy();
65 /** Singleton instance provider. */
66 static UIVirtualBoxManager *instance() { return s_pInstance; }
67
68 /** Returns the action-pool instance. */
69 UIActionPool *actionPool() const { return m_pActionPool; }
70
71 /** Opens Cloud Profile Manager. */
72 void openCloudProfileManager() { sltOpenCloudProfileManagerWindow(); }
73
74protected:
75
76 /** Constructs VirtualBox Manager. */
77 UIVirtualBoxManager();
78 /** Destructs VirtualBox Manager. */
79 virtual ~UIVirtualBoxManager() /* override */;
80
81 /** Returns whether the window should be maximized when geometry being restored. */
82 virtual bool shouldBeMaximized() const /* override */;
83
84 /** @name Event handling stuff.
85 * @{ */
86#ifdef VBOX_WS_MAC
87 /** Mac OS X: Preprocesses any @a pEvent for passed @a pObject. */
88 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
89#endif
90
91 /** Handles translation event. */
92 virtual void retranslateUi() /* override */;
93
94 /** Handles any Qt @a pEvent. */
95 virtual bool event(QEvent *pEvent) /* override */;
96 /** Handles show @a pEvent. */
97 virtual void showEvent(QShowEvent *pEvent) /* override */;
98 /** Handles first show @a pEvent. */
99 virtual void polishEvent(QShowEvent *pEvent) /* override */;
100 /** Handles close @a pEvent. */
101 virtual void closeEvent(QCloseEvent *pEvent) /* override */;
102 /** @} */
103
104private slots:
105
106 /** @name Common stuff.
107 * @{ */
108#if QT_VERSION == 0
109 /** Stupid moc does not warn if it cannot find headers! */
110 void QT_VERSION_NOT_DEFINED
111#elif defined(VBOX_WS_X11)
112 /** Handles host-screen available-area change. */
113 void sltHandleHostScreenAvailableAreaChange();
114#endif /* VBOX_WS_X11 */
115
116 /** Handles signal about medium-enumeration finished. */
117 void sltHandleMediumEnumerationFinish();
118
119 /** Handles call to open a @a list of URLs. */
120 void sltHandleOpenUrlCall(QList<QUrl> list = QList<QUrl>());
121
122 /** Hnadles singal about Chooser-pane index change. */
123 void sltHandleChooserPaneIndexChange();
124 /** Handles signal about group saving progress change. */
125 void sltHandleGroupSavingProgressChange();
126
127 /** Handles singal about Tool type change. */
128 void sltHandleToolTypeChange();
129
130 /** Handles current snapshot item change. */
131 void sltCurrentSnapshotItemChange();
132 /** @} */
133
134 /** @name CVirtualBox event handling stuff.
135 * @{ */
136 /** Handles CVirtualBox event about state change for machine with @a uID. */
137 void sltHandleStateChange(const QUuid &uID);
138 /** @} */
139
140 /** @name File menu stuff.
141 * @{ */
142 /** Handles call to open Virtual Medium Manager window. */
143 void sltOpenVirtualMediumManagerWindow();
144 /** Handles call to close Virtual Medium Manager window. */
145 void sltCloseVirtualMediumManagerWindow();
146
147 /** Handles call to open Host Network Manager window. */
148 void sltOpenHostNetworkManagerWindow();
149 /** Handles call to close Host Network Manager window. */
150 void sltCloseHostNetworkManagerWindow();
151
152 /** Handles call to open Cloud Profile Manager window. */
153 void sltOpenCloudProfileManagerWindow();
154 /** Handles call to close Cloud Profile Manager window. */
155 void sltCloseCloudProfileManagerWindow();
156
157 /** Handles call to open Import Appliance wizard.
158 * @param strFileName can bring the name of file to import appliance from. */
159 void sltOpenImportApplianceWizard(const QString &strFileName = QString());
160 /** Handles call to open Import Appliance wizard the default way. */
161 void sltOpenImportApplianceWizardDefault() { sltOpenImportApplianceWizard(); }
162 /** Handles call to open Export Appliance wizard. */
163 void sltOpenExportApplianceWizard();
164 /** Handles call to open New Cloud VM wizard. */
165 void sltOpenNewCloudVMWizard();
166
167#ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI
168 /** Handles call to open Extra-data Manager window. */
169 void sltOpenExtraDataManagerWindow();
170#endif
171
172 /** Handles call to open Preferences dialog. */
173 void sltOpenPreferencesDialog();
174
175 /** Handles call to exit application. */
176 void sltPerformExit();
177 /** @} */
178
179 /** @name Machine menu stuff.
180 * @{ */
181 /** Handles call to open Add Machine dialog.
182 * @param strFileName can bring the name of file to add machine from. */
183 void sltOpenAddMachineDialog(const QString &strFileName = QString());
184 /** Handles call to open Add Machine dialog the default way. */
185 void sltOpenAddMachineDialogDefault() { sltOpenAddMachineDialog(); }
186
187 /** Handles call to open Machine Settings dialog.
188 * @param strCategory can bring the settings category to start from.
189 * @param strControl can bring the widget of the page to focus.
190 * @param uID can bring the ID of machine to manage. */
191 void sltOpenMachineSettingsDialog(QString strCategory = QString(),
192 QString strControl = QString(),
193 const QUuid &uID = QUuid());
194 /** Handles call to open Machine Settings dialog the default way. */
195 void sltOpenMachineSettingsDialogDefault() { sltOpenMachineSettingsDialog(); }
196
197 /** Handles call to open Clone Machine wizard. */
198 void sltOpenCloneMachineWizard();
199
200 /** Handles the Move Machine action. */
201 void sltPerformMachineMove();
202
203 /** Handles call to start or show machine. */
204 void sltPerformStartOrShowMachine();
205 /** Handles call to start machine in normal mode. */
206 void sltPerformStartMachineNormal();
207 /** Handles call to start machine in headless mode. */
208 void sltPerformStartMachineHeadless();
209 /** Handles call to start machine in detachable mode. */
210 void sltPerformStartMachineDetachable();
211
212 /** Handles call to discard machine state. */
213 void sltPerformDiscardMachineState();
214
215 /** Handles call to @a fPause or resume machine otherwise. */
216 void sltPerformPauseOrResumeMachine(bool fPause);
217
218 /** Handles call to reset machine. */
219 void sltPerformResetMachine();
220
221 /** Handles call to detach machine UI. */
222 void sltPerformDetachMachineUI();
223 /** Handles call to save machine state. */
224 void sltPerformSaveMachineState();
225 /** Handles call to ask machine for shutdown. */
226 void sltPerformShutdownMachine();
227 /** Handles call to power machine off. */
228 void sltPerformPowerOffMachine();
229
230 /** Handles call to show machine tool corresponding to passed @a pAction. */
231 void sltPerformShowMachineTool(QAction *pAction);
232
233 /** Handles call to open machine Log Viewer window. */
234 void sltOpenLogViewerWindow();
235 /** Handles call to close machine Log Viewer window. */
236 void sltCloseLogViewerWindow();
237
238 /** Handles call to show machine in File Manager. */
239 void sltShowMachineInFileManager();
240
241 /** Handles call to create machine shortcut. */
242 void sltPerformCreateMachineShortcut();
243
244 /** Handles call to show group Close menu. */
245 void sltGroupCloseMenuAboutToShow();
246 /** Handles call to show machine Close menu. */
247 void sltMachineCloseMenuAboutToShow();
248 /** @} */
249
250private:
251
252 /** @name Prepare/Cleanup cascade.
253 * @{ */
254 /** Prepares window. */
255 void prepare();
256 /** Prepares icon. */
257 void prepareIcon();
258 /** Prepares menu-bar. */
259 void prepareMenuBar();
260 /** Prepares status-bar. */
261 void prepareStatusBar();
262 /** Prepares toolbar. */
263 void prepareToolbar();
264 /** Prepares widgets. */
265 void prepareWidgets();
266 /** Prepares connections. */
267 void prepareConnections();
268 /** Loads settings. */
269 void loadSettings();
270
271 /** Saves settings. */
272 void saveSettings();
273 /** Cleanups connections. */
274 void cleanupConnections();
275 /** Cleanups widgets. */
276 void cleanupWidgets();
277 /** Cleanups menu-bar. */
278 void cleanupMenuBar();
279 /** Cleanups window. */
280 void cleanup();
281 /** @} */
282
283 /** @name Common stuff.
284 * @{ */
285 /** Returns current-item. */
286 UIVirtualMachineItem *currentItem() const;
287 /** Returns a list of current-items. */
288 QList<UIVirtualMachineItem*> currentItems() const;
289
290 /** Returns whether group saving is in progress. */
291 bool isGroupSavingInProgress() const;
292 /** Returns whether all items of one group is selected. */
293 bool isAllItemsOfOneGroupSelected() const;
294 /** Returns whether single group is selected. */
295 bool isSingleGroupSelected() const;
296 /** @} */
297
298 /** @name VM launching stuff.
299 * @{ */
300 /** Launches or shows virtual machines represented by passed @a items in corresponding @a enmLaunchMode (for launch). */
301 void performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, UICommon::LaunchMode enmLaunchMode);
302 /** @} */
303
304 /** @name Action update stuff.
305 * @{ */
306 /** Performs update of actions visibility. */
307 void updateActionsVisibility();
308 /** Performs update of actions appearance. */
309 void updateActionsAppearance();
310
311 /** Returns whether the action with @a iActionIndex is enabled.
312 * @param items used to calculate verdict about should the action be enabled. */
313 bool isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items);
314
315 /** Returns whether all passed @a items are powered off. */
316 static bool isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items);
317 /** Returns whether at least one of passed @a items is able to shutdown. */
318 static bool isAtLeastOneItemAbleToShutdown(const QList<UIVirtualMachineItem*> &items);
319 /** Returns whether at least one of passed @a items supports shortcut creation. */
320 static bool isAtLeastOneItemSupportsShortcuts(const QList<UIVirtualMachineItem*> &items);
321 /** Returns whether at least one of passed @a items is accessible. */
322 static bool isAtLeastOneItemAccessible(const QList<UIVirtualMachineItem*> &items);
323 /** Returns whether at least one of passed @a items is inaccessible. */
324 static bool isAtLeastOneItemInaccessible(const QList<UIVirtualMachineItem*> &items);
325 /** Returns whether at least one of passed @a items is removable. */
326 static bool isAtLeastOneItemRemovable(const QList<UIVirtualMachineItem*> &items);
327 /** Returns whether at least one of passed @a items can be started. */
328 static bool isAtLeastOneItemCanBeStarted(const QList<UIVirtualMachineItem*> &items);
329 /** Returns whether at least one of passed @a items can be shown. */
330 static bool isAtLeastOneItemCanBeShown(const QList<UIVirtualMachineItem*> &items);
331 /** Returns whether at least one of passed @a items can be started or shown. */
332 static bool isAtLeastOneItemCanBeStartedOrShown(const QList<UIVirtualMachineItem*> &items);
333 /** Returns whether at least one of passed @a items can be discarded. */
334 static bool isAtLeastOneItemDiscardable(const QList<UIVirtualMachineItem*> &items);
335 /** Returns whether at least one of passed @a items is started. */
336 static bool isAtLeastOneItemStarted(const QList<UIVirtualMachineItem*> &items);
337 /** Returns whether at least one of passed @a items is running. */
338 static bool isAtLeastOneItemRunning(const QList<UIVirtualMachineItem*> &items);
339 /** @} */
340
341 /** Holds the static instance. */
342 static UIVirtualBoxManager *s_pInstance;
343
344 /** Holds whether the dialog is polished. */
345 bool m_fPolished : 1;
346 /** Holds whether first medium-enumeration handled. */
347 bool m_fFirstMediumEnumerationHandled : 1;
348
349 /** Holds the action-pool instance. */
350 UIActionPool *m_pActionPool;
351
352 /** Holds the Virtual Media Manager window instance. */
353 QIManagerDialog *m_pManagerVirtualMedia;
354 /** Holds the Host Network Manager window instance. */
355 QIManagerDialog *m_pManagerHostNetwork;
356 /** Holds the Cloud Profile Manager window instance. */
357 QIManagerDialog *m_pManagerCloudProfile;
358 /** Holds a map of (machineUUID, UIVMLogViewerDialog). */
359 VMLogViewerMap m_logViewers;
360
361 /** Holds the central-widget instance. */
362 UIVirtualBoxManagerWidget *m_pWidget;
363};
364
365#define gpManager UIVirtualBoxManager::instance()
366
367#endif /* !FEQT_INCLUDED_SRC_manager_UIVirtualBoxManager_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use