VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 4 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.0 KB
Line 
1/* $Id: UIVirtualBoxManager.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVirtualBoxManager class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_manager_UIVirtualBoxManager_h
29#define FEQT_INCLUDED_SRC_manager_UIVirtualBoxManager_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMainWindow>
36#include <QUrl>
37#include <QUuid>
38
39/* GUI includes: */
40#include "QIWithRestorableGeometry.h"
41#include "UIAdvancedSettingsDialog.h"
42#include "UICloudMachineSettingsDialog.h"
43#include "UIDefs.h"
44#include "UIExtraDataDefs.h"
45#include "UIAdvancedSettingsDialog.h"
46
47/* Forward declarations: */
48class QMenu;
49class QIManagerDialog;
50class UIAction;
51class UIActionPool;
52class UINativeWizard;
53struct UIUnattendedInstallData;
54class UIVirtualBoxManagerWidget;
55class UIVirtualMachineItem;
56class CCloudMachine;
57class CUnattended;
58
59/* Type definitions: */
60typedef QIWithRestorableGeometry<QMainWindow> QMainWindowWithRestorableGeometry;
61
62/** Singleton QMainWindow extension used as VirtualBox Manager instance. */
63class UIVirtualBoxManager : public QMainWindowWithRestorableGeometry
64{
65 Q_OBJECT;
66
67 /** Pointer to menu update-handler for this class: */
68 typedef void (UIVirtualBoxManager::*MenuUpdateHandler)(QMenu *pMenu);
69
70signals:
71
72 /** Notifies listeners about this window remapped to another screen. */
73 void sigWindowRemapped();
74
75public:
76
77 /** Singleton constructor. */
78 static void create();
79 /** Singleton destructor. */
80 static void destroy();
81 /** Singleton instance provider. */
82 static UIVirtualBoxManager *instance() { return s_pInstance; }
83
84 /** Returns the action-pool instance. */
85 UIActionPool *actionPool() const { return m_pActionPool; }
86
87 /** Opens Cloud Profile Manager. */
88 void openCloudProfileManager() { sltOpenManagerWindow(UIToolType_Cloud); }
89
90protected:
91
92 /** Constructs VirtualBox Manager. */
93 UIVirtualBoxManager();
94 /** Destructs VirtualBox Manager. */
95 virtual ~UIVirtualBoxManager() RT_OVERRIDE;
96
97 /** Returns whether the window should be maximized when geometry being restored. */
98 virtual bool shouldBeMaximized() const RT_OVERRIDE;
99
100 /** @name Event handling stuff.
101 * @{ */
102#ifdef VBOX_WS_MAC
103 /** Mac OS X: Preprocesses any @a pEvent for passed @a pObject. */
104 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
105#endif
106
107 /** Handles any Qt @a pEvent. */
108 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
109 /** Handles show @a pEvent. */
110 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
111 /** Handles first show @a pEvent. */
112 virtual void polishEvent(QShowEvent *pEvent);
113 /** Handles close @a pEvent. */
114 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
115 /** Handles drag enter @a pEvent. */
116 virtual void dragEnterEvent(QDragEnterEvent *event) RT_OVERRIDE;
117 /** Handles drop @a pEvent. */
118 virtual void dropEvent(QDropEvent *event) RT_OVERRIDE;
119 /** @} */
120
121private slots:
122
123 /** @name Common stuff.
124 * @{ */
125#ifdef VBOX_WS_NIX
126 /** Handles host-screen available-area change. */
127 void sltHandleHostScreenAvailableAreaChange();
128#endif
129
130 /** Handles request to update actions. */
131 void sltHandleUpdateActionAppearanceRequest() { updateActionsAppearance(); }
132
133 /** Handles request to commit data. */
134 void sltHandleCommitData();
135
136 /** Handles signal about medium-enumeration finished. */
137 void sltHandleMediumEnumerationFinish();
138
139 /** Handles call to open a @a list of URLs. */
140 void sltHandleOpenUrlCall(QList<QUrl> list = QList<QUrl>());
141
142 /** Checks if USB device list can be enumerated and host produces any warning during enumeration. */
143 void sltCheckUSBAccesibility();
144
145 /** Handles signal about Chooser-pane index change. */
146 void sltHandleChooserPaneIndexChange();
147 /** Handles signal about group saving progress change. */
148 void sltHandleGroupSavingProgressChange();
149 /** Handles signal about cloud update progress change. */
150 void sltHandleCloudUpdateProgressChange();
151
152 /** Handles signal about Global Tool type change. */
153 void sltHandleGlobalToolTypeChange();
154 /** Handles signal about Machine Tool type change. */
155 void sltHandleMachineToolTypeChange();
156
157 /** Handles create medium request. */
158 void sltCreateMedium();
159 /** Handles copy medium request. */
160 void sltCopyMedium(const QUuid &uMediumId);
161
162 /** Handles current snapshot item change. */
163 void sltCurrentSnapshotItemChange();
164
165 /** Handles request to detach Log Viewer pane. */
166 void sltDetachToolPane(UIToolType enmToolType);
167
168 /** Handles state change for cloud machine with certain @a uId. */
169 void sltHandleCloudMachineStateChange(const QUuid &uId);
170
171 /** Handles translation event. */
172 void sltRetranslateUI();
173 /** @} */
174
175 /** @name CVirtualBox event handling stuff.
176 * @{ */
177 /** Handles CVirtualBox event about state change for machine with @a uID. */
178 void sltHandleStateChange(const QUuid &uID);
179 /** @} */
180
181 /** @name Action-pool stuff.
182 * @{ */
183 /** Handle menu prepare. */
184 void sltHandleMenuPrepare(int iIndex, QMenu *pMenu);
185 /** @} */
186
187 /** @name File menu stuff.
188 * @{ */
189 /** Handles call to open Manager window of certain @a enmType. */
190 void sltOpenManagerWindow(UIToolType enmType = UIToolType_Invalid);
191 /** Handles call to open Manager window by default. */
192 void sltOpenManagerWindowDefault() { sltOpenManagerWindow(); }
193 /** Handles call to embed Manager window of certain @a enmType. */
194 void sltEmbedManagerWindow(UIToolType enmType = UIToolType_Invalid);
195 /** Handles call to close Manager window of certain @a enmType. */
196 void sltCloseManagerWindow(UIToolType enmType = UIToolType_Invalid);
197 /** Handles call to embed Manager window by default. */
198 void sltEmbedManagerWindowDefault() { sltEmbedManagerWindow(); }
199 /** Handles call to close Manager window by default. */
200 void sltCloseManagerWindowDefault() { sltCloseManagerWindow(); }
201
202 /** Handles call to open Import Appliance wizard. */
203 void sltOpenImportApplianceWizard() { openImportApplianceWizard(); }
204 /** Handles call to open Export Appliance wizard. */
205 void sltOpenExportApplianceWizard();
206
207#ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI
208 /** Handles call to open Extra-data Manager window. */
209 void sltOpenExtraDataManagerWindow();
210#endif
211
212 /** Handles call to open Preferences dialog. */
213 void sltOpenPreferencesDialog();
214 /** Handles call to close Preferences dialog. */
215 void sltClosePreferencesDialog();
216
217 /** Handles call to switch to global tool corresponding to passed @a pAction. */
218 void sltPerformSwitchToGlobalTool(QAction *pAction);
219
220 /** Handles call to exit application. */
221 void sltPerformExit();
222 /** @} */
223
224 /** @name Machine menu stuff.
225 * @{ */
226 /** Handles call to open wizard of specified @a enmType. */
227 void sltOpenWizard(WizardType enmType);
228 /** Handles call to close wizard of specified @a enmType. */
229 void sltCloseWizard(WizardType enmType);
230
231 /** Handles call to open new machine wizard. */
232 void sltOpenNewMachineWizard();
233 /** Handles call to open add machine dialog. */
234 void sltOpenAddMachineDialog();
235
236 /** Handles call to open group name editor. */
237 void sltOpenGroupNameEditor();
238 /** Handles call to disband group. */
239 void sltDisbandGroup();
240
241 /** Handles call to open Settings dialog.
242 * @param strCategory can bring the settings category to start from.
243 * @param strControl can bring the widget of the page to focus.
244 * @param uID can bring the ID of machine to manage. */
245 void sltOpenSettingsDialog(QString strCategory = QString(),
246 QString strControl = QString(),
247 const QUuid &uID = QUuid());
248 /** Handles call to open Settings dialog the default way. */
249 void sltOpenSettingsDialogDefault() { sltOpenSettingsDialog(); }
250 /** Handles call to close Settings dialog. */
251 void sltCloseSettingsDialog();
252
253 /** Handles call to open Clone Machine wizard. */
254 void sltOpenCloneMachineWizard();
255
256 /** Handles call to move machine. */
257 void sltPerformMachineMove();
258
259 /** Handles call to remove machine. */
260 void sltPerformMachineRemove();
261
262 /** Handles call to move machine to a new group. */
263 void sltPerformMachineMoveToNewGroup();
264 /** Handles call to move machine to a specific group. */
265 void sltPerformMachineMoveToSpecificGroup();
266
267 /** Handles call to start or show machine. */
268 void sltPerformStartOrShowMachine();
269 /** Handles call to start machine in normal mode. */
270 void sltPerformStartMachineNormal();
271 /** Handles call to start machine in headless mode. */
272 void sltPerformStartMachineHeadless();
273 /** Handles call to start machine in detachable mode. */
274 void sltPerformStartMachineDetachable();
275
276 /** Handles call to create console connection for group. */
277 void sltPerformCreateConsoleConnectionForGroup();
278 /** Handles call to create console connection for machine. */
279 void sltPerformCreateConsoleConnectionForMachine();
280 /** Handles call to delete console connection for group. */
281 void sltPerformDeleteConsoleConnectionForGroup();
282 /** Handles call to delete console connection for machine. */
283 void sltPerformDeleteConsoleConnectionForMachine();
284 /** Handles call to copy console connection key fingerprint. */
285 void sltCopyConsoleConnectionFingerprint();
286 /** Handles call to copy serial console command for Unix. */
287 void sltPerformCopyCommandSerialUnix();
288 /** Handles call to copy serial console command for Windows. */
289 void sltPerformCopyCommandSerialWindows();
290 /** Handles call to copy VNC console command for Unix. */
291 void sltPerformCopyCommandVNCUnix();
292 /** Handles call to copy VNC console command for Windows. */
293 void sltPerformCopyCommandVNCWindows();
294 /** Handles call to show console log. */
295 void sltPerformShowLog();
296 /** Handles call about console @a strLog for cloud VM with @a strName read. */
297 void sltHandleConsoleLogRead(const QString &strName, const QString &strLog);
298 /** Handles call to execute external application. */
299 void sltExecuteExternalApplication();
300
301 /** Handles call to discard machine state. */
302 void sltPerformDiscardMachineState();
303
304 /** Handles call to @a fPause or resume machine otherwise. */
305 void sltPerformPauseOrResumeMachine(bool fPause);
306
307 /** Handles call to reset machine. */
308 void sltPerformResetMachine();
309
310 /** Handles call to detach machine UI. */
311 void sltPerformDetachMachineUI();
312 /** Handles call to save machine state. */
313 void sltPerformSaveMachineState();
314 /** Handles call to terminate machine. */
315 void sltPerformTerminateMachine();
316 /** Handles call to ask machine for shutdown. */
317 void sltPerformShutdownMachine();
318 /** Handles call to power machine off. */
319 void sltPerformPowerOffMachine();
320 /** Handles signal about machine powered off.
321 * @param fSuccess Brings whether machine was powered off successfully.
322 * @param fIncludingDiscard Brings whether machine state should be discarded. */
323 void sltHandlePoweredOffMachine(bool fSuccess, bool fIncludingDiscard);
324
325 /** Handles call to switch to machine tool corresponding to passed @a pAction. */
326 void sltPerformSwitchToMachineTool(QAction *pAction);
327
328 /** Handles call to refresh machine. */
329 void sltPerformRefreshMachine();
330
331 /** Handles call to show machine in File Manager. */
332 void sltShowMachineInFileManager();
333
334 /** Handles call to create machine shortcut. */
335 void sltPerformCreateMachineShortcut();
336
337 /** Handles call to sort group. */
338 void sltPerformGroupSorting();
339
340 /** Handles call to toggle machine search widget visibility to be @a fVisible. */
341 void sltPerformMachineSearchWidgetVisibilityToggling(bool fVisible);
342
343 /** Handles call to show help viewer. */
344 void sltPerformShowHelpBrowser();
345
346 /** Handles signals that are emitted when an ext. pack un/installed. */
347 void sltExtensionPackInstalledUninstalled(const QString &strName);
348 /** @} */
349
350private:
351
352 /** @name Prepare/Cleanup cascade.
353 * @{ */
354 /** Prepares window. */
355 void prepare();
356 /** Prepares cloud machine manager. */
357 void prepareCloudMachineManager();
358 /** Prepares icon. */
359 void prepareIcon();
360 /** Prepares menu-bar. */
361 void prepareMenuBar();
362 /** Prepares status-bar. */
363 void prepareStatusBar();
364 /** Prepares toolbar. */
365 void prepareToolbar();
366 /** Prepares widgets. */
367 void prepareWidgets();
368 /** Prepares connections. */
369 void prepareConnections();
370 /** Loads settings. */
371 void loadSettings();
372
373 /** Cleanups connections. */
374 void cleanupConnections();
375 /** Cleanups widgets. */
376 void cleanupWidgets();
377 /** Cleanups menu-bar. */
378 void cleanupMenuBar();
379 /** Cleanups cloud machine manager. */
380 void cleanupCloudMachineManager();
381 /** Cleanups window. */
382 void cleanup();
383 /** @} */
384
385 /** @name Common stuff.
386 * @{ */
387 /** Returns current-item. */
388 UIVirtualMachineItem *currentItem() const;
389 /** Returns a list of current-items. */
390 QList<UIVirtualMachineItem*> currentItems() const;
391
392 /** Returns whether group saving is in progress. */
393 bool isGroupSavingInProgress() const;
394 /** Returns whether all items of one group is selected. */
395 bool isAllItemsOfOneGroupSelected() const;
396 /** Returns whether single group is selected. */
397 bool isSingleGroupSelected() const;
398 /** Returns whether single local group is selected. */
399 bool isSingleLocalGroupSelected() const;
400 /** Returns whether single cloud provider group is selected. */
401 bool isSingleCloudProviderGroupSelected() const;
402 /** Returns whether single cloud profile group is selected. */
403 bool isSingleCloudProfileGroupSelected() const;
404
405 /** Returns whether at least one cloud profile currently being updated. */
406 bool isCloudProfileUpdateInProgress() const;
407
408 /** Checks if @a comUnattended has any errors.
409 * If so shows an error notification and returns false, else returns true. */
410 bool checkUnattendedInstallError(const CUnattended &comUnattended) const;
411 /** @} */
412
413 /** @name Various VM helpers.
414 * @{ */
415 /** Opens add machine dialog specifying initial name with @a strFileName. */
416 void openAddMachineDialog(const QString &strFileName = QString());
417 /** Opens new machine dialog specifying initial name with @a strFileName. */
418 void openNewMachineWizard(const QString &strISOFilePath = QString());
419
420 /** Opens Import Appliance wizard.
421 * @param strFileName can bring the name of file to import appliance from. */
422 void openImportApplianceWizard(const QString &strFileName = QString());
423
424 /** Launches certain @a comMachine in specified @a enmLaunchMode. */
425 static void launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode = UILaunchMode_Default);
426 /** Launches certain @a comMachine. */
427 static void launchMachine(CCloudMachine &comMachine);
428
429 /** Creates an unattended installer and uses it to install guest os to newly created vm. */
430 void startUnattendedInstall(const CUnattended &comUnattended, bool fStartHeadless, const QString &strMachineId);
431
432 /** Launches or shows virtual machines represented by passed @a items in corresponding @a enmLaunchMode (for launch). */
433 void performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, UILaunchMode enmLaunchMode);
434
435#ifndef VBOX_WS_WIN
436 /** Parses serialized @a strArguments string according to shell rules. */
437 QStringList parseShellArguments(const QString &strArguments);
438#endif
439 /** @} */
440
441 /** @name Action update stuff.
442 * @{ */
443 /** Updates 'Group' menu. */
444 void updateMenuGroup(QMenu *pMenu);
445 /** Updates 'Machine' menu. */
446 void updateMenuMachine(QMenu *pMenu);
447 /** Updates 'Group' : 'Move to Group' menu. */
448 void updateMenuGroupMoveToGroup(QMenu *pMenu);
449 /** Updates 'Group' : 'Console' menu. */
450 void updateMenuGroupConsole(QMenu *pMenu);
451 /** Updates 'Group' : 'Close' menu. */
452 void updateMenuGroupClose(QMenu *pMenu);
453 /** Updates 'Machine' : 'Move to Group' menu. */
454 void updateMenuMachineMoveToGroup(QMenu *pMenu);
455 /** Updates 'Machine' : 'Console' menu. */
456 void updateMenuMachineConsole(QMenu *pMenu);
457 /** Updates 'Machine' : 'Close' menu. */
458 void updateMenuMachineClose(QMenu *pMenu);
459
460 /** Performs update of actions visibility. */
461 void updateActionsVisibility();
462 /** Performs update of actions appearance. */
463 void updateActionsAppearance();
464
465 /** Returns whether the action with @a iActionIndex is enabled.
466 * @param items used to calculate verdict about should the action be enabled. */
467 bool isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items);
468
469 /** Returns whether all passed @a items are local. */
470 static bool isItemsLocal(const QList<UIVirtualMachineItem*> &items);
471 /** Returns whether all passed @a items are cloud. */
472 static bool isItemsCloud(const QList<UIVirtualMachineItem*> &items);
473 /** Returns whether all passed @a items are powered off. */
474 static bool isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items);
475 /** Returns whether at least one of passed @a items is able to shutdown. */
476 static bool isAtLeastOneItemAbleToShutdown(const QList<UIVirtualMachineItem*> &items);
477 /** Returns whether at least one of passed @a items supports shortcut creation. */
478 static bool isAtLeastOneItemSupportsShortcuts(const QList<UIVirtualMachineItem*> &items);
479 /** Returns whether at least one of passed @a items is accessible. */
480 static bool isAtLeastOneItemAccessible(const QList<UIVirtualMachineItem*> &items);
481 /** Returns whether at least one of passed @a items is inaccessible. */
482 static bool isAtLeastOneItemInaccessible(const QList<UIVirtualMachineItem*> &items);
483 /** Returns whether at least one of passed @a items is removable. */
484 static bool isAtLeastOneItemRemovable(const QList<UIVirtualMachineItem*> &items);
485 /** Returns whether at least one of passed @a items can be started. */
486 static bool isAtLeastOneItemCanBeStarted(const QList<UIVirtualMachineItem*> &items);
487 /** Returns whether at least one of passed @a items can be shown. */
488 static bool isAtLeastOneItemCanBeShown(const QList<UIVirtualMachineItem*> &items);
489 /** Returns whether at least one of passed @a items can be started or shown. */
490 static bool isAtLeastOneItemCanBeStartedOrShown(const QList<UIVirtualMachineItem*> &items);
491 /** Returns whether at least one of passed @a items can be discarded. */
492 static bool isAtLeastOneItemDiscardable(const QList<UIVirtualMachineItem*> &items);
493 /** Returns whether at least one of passed @a items is started. */
494 static bool isAtLeastOneItemStarted(const QList<UIVirtualMachineItem*> &items);
495 /** Returns whether at least one of passed @a items is running. */
496 static bool isAtLeastOneItemRunning(const QList<UIVirtualMachineItem*> &items);
497 /** Returns whether at least one of passed @a items is detachable. */
498 static bool isAtLeastOneItemDetachable(const QList<UIVirtualMachineItem*> &items);
499
500#ifdef VBOX_WS_NIX
501 /** Tries to guess default X11 terminal emulator.
502 * @returns Data packed into Qt pair of QString(s),
503 * which is `name` and `--execute argument`. */
504 static QPair<QString, QString> defaultTerminalData();
505#endif
506 /** @} */
507
508 /** Holds the static instance. */
509 static UIVirtualBoxManager *s_pInstance;
510
511 /** Holds whether the dialog is polished. */
512 bool m_fPolished : 1;
513 /** Holds whether first medium-enumeration handled. */
514 bool m_fFirstMediumEnumerationHandled : 1;
515
516 /** Holds the action-pool instance. */
517 UIActionPool *m_pActionPool;
518 /** Holds the map of menu update-handlers. */
519 QMap<int, MenuUpdateHandler> m_menuUpdateHandlers;
520
521 /** Holds the map of various global managers. */
522 QMap<UIToolType, QIManagerDialog*> m_managers;
523
524 /** Holds the map of various settings dialogs. */
525 QMap<UIAdvancedSettingsDialog::DialogType, UIAdvancedSettingsDialog*> m_settings;
526
527 /** Holds the cloud settings dialog instance. */
528 UISafePointerCloudMachineSettingsDialog m_pCloudSettings;
529
530 /** Holds the map of various wizards. */
531 QMap<WizardType, UINativeWizard*> m_wizards;
532
533 /** Holds the central-widget instance. */
534 UIVirtualBoxManagerWidget *m_pWidget;
535
536 /** Holds the geometry save timer ID. */
537 int m_iGeometrySaveTimerId;
538
539 /** Holds the ISO file path used by new VM wizard. */
540 QString m_strISOFilePath;
541
542 /** Holds whether snapshot clone should be done by clone VM wizard. */
543 bool m_fSnapshotCloneByDefault;
544
545 /** Holds whether OCI importing should be started by default. */
546 bool m_fImportFromOCI;
547 /** Holds the file-name used by import wizard. */
548 QString m_strFileName;
549
550 /** Holds whether OCI exporting should be started by default. */
551 bool m_fExportToOCI;
552 /** Holds the list of VMs used by export wizard. */
553 QStringList m_names;
554
555 /** Holds the ID of medium used by clone VD wizard. */
556 QUuid m_uMediumId;
557};
558
559#define gpManager UIVirtualBoxManager::instance()
560
561#endif /* !FEQT_INCLUDED_SRC_manager_UIVirtualBoxManager_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