VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h@ 104158

Last change on this file since 104158 was 103977, checked in by vboxsync, 9 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.3 KB
Line 
1/* $Id: UIMachineLogic.h 103977 2024-03-21 02:04:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineLogic class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2023 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_runtime_UIMachineLogic_h
29#define FEQT_INCLUDED_SRC_runtime_UIMachineLogic_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "QIWithRetranslateUI.h"
36#include "UIExtraDataDefs.h"
37#include "UIAdvancedSettingsDialog.h"
38
39/* COM includes: */
40#include "KGuestMonitorChangedEventType.h"
41
42/* Forward declarations: */
43class QAction;
44class QActionGroup;
45class QIManagerDialog;
46class UIActionPool;
47class UIKeyboardHandler;
48class UIMachine;
49class UIMachineWindow;
50class UIMachineView;
51class UIMouseHandler;
52class UIDockIconPreview;
53class UISoftKeyboard;
54class UIVMInformationDialog;
55class CUSBDevice;
56class CVirtualBoxErrorInfo;
57#if defined(VBOX_WS_NIX)
58 struct DBusScreenSaverInhibitMethod;
59#endif
60
61/* Machine logic interface: */
62class UIMachineLogic : public QIWithRetranslateUI3<QObject>
63{
64 Q_OBJECT;
65
66 /** Pointer to menu update-handler for this class: */
67 typedef void (UIMachineLogic::*MenuUpdateHandler)(QMenu *pMenu);
68
69public:
70
71 /** Factory function to create a logic of required type.
72 * @param pMachine Brings the machine this logic belongs to.
73 * @param pSession Brings the session this logic is created for.
74 * @param enmVisualStateType Brings the visual state type of logic to be created. */
75 static UIMachineLogic *create(UIMachine *pMachine, UIVisualStateType enmVisualStateType);
76 /** Factory function to destroy passed @a pLogic. */
77 static void destroy(UIMachineLogic *&pLogic);
78
79 /** Returns visual state type. */
80 virtual UIVisualStateType visualStateType() const = 0;
81
82 /* Check if this logic is available: */
83 virtual bool checkAvailability() = 0;
84
85 /** Returns machine-window flags for current machine-logic and passed @a uScreenId. */
86 virtual Qt::WindowFlags windowFlags(ulong uScreenId) const = 0;
87
88 /* Prepare/cleanup the logic: */
89 virtual void prepare();
90 virtual void cleanup();
91
92 /** Returns machine UI reference. */
93 UIMachine *uimachine() const { return m_pMachine; }
94 /** Returns action-pool reference. */
95 UIActionPool *actionPool() const;
96
97 /** Returns the machine name. */
98 QString machineName() const;
99 const QList<UIMachineWindow*>& machineWindows() const { return m_machineWindowsList; }
100 UIKeyboardHandler* keyboardHandler() const { return m_pKeyboardHandler; }
101 UIMouseHandler* mouseHandler() const { return m_pMouseHandler; }
102 UIMachineWindow* mainMachineWindow() const;
103 UIMachineWindow* activeMachineWindow() const;
104
105 /** Adjusts machine-window(s) geometry if necessary. */
106 virtual void adjustMachineWindowsGeometry();
107
108 /** Send machine-window(s) size-hint(s) to the guest. */
109 virtual void sendMachineWindowsSizeHints();
110
111 /* Wrapper to open Machine settings / Network page: */
112 void openNetworkSettingsDialog() { sltOpenSettingsDialogNetwork(); }
113
114#ifdef VBOX_WS_MAC
115 void updateDockIcon();
116 void updateDockIconSize(int screenId, int width, int height);
117 UIMachineView* dockPreviewView() const;
118 virtual void updateDock();
119#endif /* VBOX_WS_MAC */
120
121 /** An public interface to sltTypeHostKeyComboPressRelease. */
122 void typeHostKeyComboPressRelease(bool fToggleSequence);
123
124protected slots:
125
126 /** Handles the VBoxSVC availability change. */
127 void sltHandleVBoxSVCAvailabilityChange();
128
129 /** Handles Machine UI initialized event. */
130 void sltHandleMachineInitialized();
131
132 /** Checks if some visual-state type was requested. */
133 virtual void sltCheckForRequestedVisualStateType() {}
134
135 /** Requests visual-state change to 'normal' (window). */
136 virtual void sltChangeVisualStateToNormal();
137 /** Requests visual-state change to 'fullscreen'. */
138 virtual void sltChangeVisualStateToFullscreen();
139 /** Requests visual-state change to 'seamless'. */
140 virtual void sltChangeVisualStateToSeamless();
141 /** Requests visual-state change to 'scale'. */
142 virtual void sltChangeVisualStateToScale();
143
144 /* Console callback handlers: */
145 virtual void sltMachineStateChanged();
146 virtual void sltSessionStateChanged(const QUuid &uId, const KSessionState enmState);
147 virtual void sltAdditionsStateChanged();
148 virtual void sltMouseCapabilityChanged();
149 virtual void sltKeyboardLedsChanged();
150 virtual void sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error);
151 virtual void sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage);
152#ifdef RT_OS_DARWIN
153 virtual void sltShowWindows();
154#endif /* RT_OS_DARWIN */
155 /** Handles guest-screen count change. */
156 virtual void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
157
158 /** Handles host-screen count change. */
159 virtual void sltHostScreenCountChange();
160 /** Handles host-screen geometry change. */
161 virtual void sltHostScreenGeometryChange();
162 /** Handles host-screen available-area change. */
163 virtual void sltHostScreenAvailableAreaChange();
164 /* Handles Help Request. */
165 virtual void sltHandleHelpRequest();
166
167protected:
168
169 /** Constructs a logic passing @a pMachine to the base-class.
170 * @param pMachine Brings the machine this logic belongs to. */
171 UIMachineLogic(UIMachine *pMachine);
172 /* Destructs the logic. */
173 virtual ~UIMachineLogic() RT_OVERRIDE;
174
175 /* Protected getters/setters: */
176 bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; }
177 void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }
178
179 /* Protected members: */
180 void setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler);
181 void setMouseHandler(UIMouseHandler *pMouseHandler);
182 void addMachineWindow(UIMachineWindow *pMachineWindow);
183 void retranslateUi() RT_OVERRIDE;
184#ifdef VBOX_WS_MAC
185 bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }
186 void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; }
187 void updateDockOverlay();
188#endif /* VBOX_WS_MAC */
189
190 /* Prepare helpers: */
191 virtual void prepareRequiredFeatures() {}
192 virtual void prepareSessionConnections();
193 virtual void prepareActionGroups();
194 virtual void prepareActionConnections();
195 virtual void prepareOtherConnections();
196 virtual void prepareHandlers();
197 virtual void prepareMachineWindows() = 0;
198 virtual void prepareMenu() {}
199#ifdef VBOX_WS_MAC
200 virtual void prepareDock();
201#endif /* VBOX_WS_MAC */
202#ifdef VBOX_WITH_DEBUGGER_GUI
203 virtual void prepareDebugger();
204#endif /* VBOX_WITH_DEBUGGER_GUI */
205 virtual void loadSettings();
206
207 /* Cleanup helpers: */
208#ifdef VBOX_WITH_DEBUGGER_GUI
209 virtual void cleanupDebugger();
210#endif /* VBOX_WITH_DEBUGGER_GUI */
211#ifdef VBOX_WS_MAC
212 virtual void cleanupDock();
213#endif /* VBOX_WS_MAC */
214 virtual void cleanupMenu() {}
215 virtual void cleanupMachineWindows() = 0;
216 virtual void cleanupHandlers();
217 //virtual void cleanupOtherConnections() {}
218 virtual void cleanupActionConnections() {}
219 virtual void cleanupActionGroups() {}
220 virtual void cleanupSessionConnections();
221 //virtual void cleanupRequiredFeatures() {}
222
223 /* Handler: Event-filter stuff: */
224 bool eventFilter(QObject *pWatched, QEvent *pEvent) RT_OVERRIDE;
225
226private slots:
227
228 /** Handle menu prepare. */
229 void sltHandleMenuPrepare(int iIndex, QMenu *pMenu);
230
231 /* "Application" menu functionality: */
232 void sltOpenPreferencesDialog(const QString &strCategory = QString(), const QString &strControl = QString());
233 void sltOpenPreferencesDialogDefault() { sltOpenPreferencesDialog(); }
234 void sltClosePreferencesDialog();
235 void sltClose();
236
237 /* "Machine" menu functionality: */
238 void sltOpenSettingsDialog(const QString &strCategory = QString(), const QString &strControl = QString());
239 void sltOpenSettingsDialogDefault() { sltOpenSettingsDialog(); }
240 void sltCloseSettingsDialog();
241 void sltTakeSnapshot();
242 void sltShowInformationDialog();
243 void sltCloseInformationDialog();
244 void sltShowFileManagerDialog();
245 void sltCloseFileManagerDialog();
246 void sltShowLogDialog();
247 void sltCloseLogDialog();
248 void sltPause(bool fOn);
249 void sltReset();
250 void sltDetach();
251 void sltSaveState();
252 void sltShutdown();
253 void sltPowerOff();
254
255 /* "View" menu functionality: */
256 void sltMinimizeActiveMachineWindow();
257 void sltAdjustMachineWindows();
258 void sltToggleGuestAutoresize(bool fEnabled);
259 void sltTakeScreenshot();
260 void sltOpenRecordingOptions();
261 void sltToggleRecording(bool fEnabled);
262 void sltToggleVRDE(bool fEnabled);
263
264 /* "Input" menu functionality: */
265 void sltShowKeyboardSettings();
266 void sltShowSoftKeyboard();
267 void sltCloseSoftKeyboard();
268 void sltTypeCAD();
269#ifdef VBOX_WS_NIX
270 void sltTypeCABS();
271#endif /* VBOX_WS_NIX */
272 void sltTypeCtrlBreak();
273 void sltTypeInsert();
274 void sltTypePrintScreen();
275 void sltTypeAltPrintScreen();
276 void sltTypeHostKeyComboPressRelease(bool fToggleSequence);
277 void sltToggleMouseIntegration(bool fEnabled);
278
279 /* "Device" menu functionality: */
280 void sltOpenSettingsDialogStorage();
281 void sltMountStorageMedium();
282 void sltToggleAudioOutput(bool fEnabled);
283 void sltToggleAudioInput(bool fEnabled);
284 void sltOpenSettingsDialogNetwork();
285 void sltOpenSettingsDialogUSBDevices();
286 void sltOpenSettingsDialogSharedFolders();
287 void sltAttachUSBDevice();
288 void sltAttachWebcamDevice();
289 void sltChangeSharedClipboardType(QAction *pAction);
290 void sltFileTransferToggled(bool fChecked);
291 void sltToggleNetworkAdapterConnection(bool fChecked);
292 void sltChangeDragAndDropType(QAction *pAction);
293 void sltInstallGuestAdditions();
294
295#ifdef VBOX_WITH_DEBUGGER_GUI
296 /* "Debug" menu functionality: */
297 void sltShowDebugStatistics();
298 void sltShowDebugCommandLine();
299 void sltLoggingToggled(bool);
300 void sltShowGuestControlConsoleDialog();
301 void sltCloseGuestControlConsoleDialog();
302#endif /* VBOX_WITH_DEBUGGER_GUI */
303
304#ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */
305 /* "Window" menu functionality: */
306 void sltSwitchToMachineWindow();
307
308 /* "Dock" menu functionality: */
309 void sltDockPreviewModeChanged(QAction *pAction);
310 void sltDockPreviewMonitorChanged(QAction *pAction);
311 void sltChangeDockIconUpdate(bool fEnabled);
312 /** Handles dock icon overlay change event. */
313 void sltChangeDockIconOverlayAppearance(bool fDisabled);
314 /** Handles dock icon overlay disable action triggering. */
315 void sltDockIconDisableOverlayChanged(bool fDisabled);
316#endif /* RT_OS_DARWIN */
317
318 /* Handlers: Keyboard LEDs sync logic: */
319 void sltSwitchKeyboardLedsToGuestLeds();
320 void sltSwitchKeyboardLedsToPreviousLeds();
321
322 /* Handle disabling/enabling host screen saver. */
323 void sltDisableHostScreenSaverStateChanged(bool fDisabled);
324
325 /** Handles request for visual state change. */
326 void sltHandleVisualStateChange();
327
328 /** Handles request to commit data. */
329 void sltHandleCommitData();
330
331private:
332
333 /** Update 'Devices' : 'Optical/Floppy Devices' menu routine. */
334 void updateMenuDevicesStorage(QMenu *pMenu);
335 /** Update 'Devices' : 'Network' menu routine. */
336 void updateMenuDevicesNetwork(QMenu *pMenu);
337 /** Update 'Devices' : 'USB Devices' menu routine. */
338 void updateMenuDevicesUSB(QMenu *pMenu);
339 /** Update 'Devices' : 'Web Cams' menu routine. */
340 void updateMenuDevicesWebcams(QMenu *pMenu);
341 /** Update 'Devices' : 'Shared Clipboard' menu routine. */
342 void updateMenuDevicesSharedClipboard(QMenu *pMenu);
343 /** Update 'Devices' : 'Drag and Drop' menu routine. */
344 void updateMenuDevicesDragAndDrop(QMenu *pMenu);
345#ifdef VBOX_WITH_DEBUGGER_GUI
346 /** Update 'Debug' menu routine. */
347 void updateMenuDebug(QMenu *pMenu);
348#endif /* VBOX_WITH_DEBUGGER_GUI */
349#ifdef VBOX_WS_MAC
350 /** Update 'Window' menu routine. */
351 void updateMenuWindow(QMenu *pMenu);
352#endif /* VBOX_WS_MAC */
353
354 /** Asks user for the disks encryption passwords. */
355 void askUserForTheDiskEncryptionPasswords();
356
357 /* Helpers: */
358 void takeScreenshot(const QString &strFile, const QString &strFormat /* = "png" */) const;
359
360 /** Reactivates the screen saver. This is possbily called during vm window close and enables host screen
361 * if there are no other vms running at the moment. Note that this seems to be not needed on Linux since
362 * closing vm windows re-activates screen saver automatically. On Windows explicit re-activation is needed. */
363 void activateScreenSaver();
364 /* Shows the boot failure dialog through which user can mount a boot DVD and reset the vm. */
365 void showBootFailureDialog();
366 /** Resets the machine. If @p fShowConfirmation is true then a confirmation messag box is shown first. */
367 void reset(bool fShowConfirmation);
368
369 /* Private variables: */
370 UIMachine *m_pMachine;
371 UIKeyboardHandler *m_pKeyboardHandler;
372 UIMouseHandler *m_pMouseHandler;
373 QList<UIMachineWindow*> m_machineWindowsList;
374
375 QActionGroup *m_pRunningActions;
376 QActionGroup *m_pRunningOrPausedActions;
377 QActionGroup *m_pRunningOrPausedOrStuckActions;
378 QActionGroup *m_pSharedClipboardActions;
379 QAction *m_pFileTransferToggleAction;
380 QActionGroup *m_pDragAndDropActions;
381
382 /** Holds the map of menu update-handlers. */
383 QMap<int, MenuUpdateHandler> m_menuUpdateHandlers;
384
385 bool m_fIsWindowsCreated : 1;
386
387#ifdef VBOX_WS_MAC
388 bool m_fIsDockIconEnabled;
389 UIDockIconPreview *m_pDockIconPreview;
390 QActionGroup *m_pDockPreviewSelectMonitorGroup;
391 QAction *m_pDockSettingsMenuSeparator;
392 int m_DockIconPreviewMonitor;
393 QAction *m_pDockSettingMenuAction;
394 /* Keeps a list of machine menu actions that we add to dock menu. */
395 QList<QAction*> m_dockMachineMenuActions;
396#endif /* VBOX_WS_MAC */
397
398 void *m_pHostLedsState;
399
400 /** Holds the map of settings dialogs. */
401 QMap<UIAdvancedSettingsDialog::DialogType, UIAdvancedSettingsDialog*> m_settings;
402
403 /** Holds the log viewer dialog instance. */
404 QIManagerDialog *m_pLogViewerDialog;
405 QIManagerDialog *m_pFileManagerDialog;
406 QIManagerDialog *m_pProcessControlDialog;
407 UISoftKeyboard *m_pSoftKeyboardDialog;
408 UIVMInformationDialog *m_pVMInformationDialog;
409
410 /* Holds the cookies returnd by QDBus inhibition calls. Map keys are service name. These are required during uninhibition.*/
411 QMap<QString, uint> m_screenSaverInhibitionCookies;
412#if defined(VBOX_WS_NIX)
413 QVector<DBusScreenSaverInhibitMethod*> m_methods;
414#endif
415};
416
417#endif /* !FEQT_INCLUDED_SRC_runtime_UIMachineLogic_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