VirtualBox

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

Last change on this file since 35740 was 34961, checked in by vboxsync, 13 years ago

FE/Qt: Recent opened mediums list implemented for machine settings and running VM device menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * UIMachineLogic class declaration
5 */
6
7/*
8 * Copyright (C) 2010 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef __UIMachineLogic_h__
20#define __UIMachineLogic_h__
21
22/* Local includes */
23#include "UIMachineDefs.h"
24#include <QIWithRetranslateUI.h>
25#ifdef VBOX_WITH_DEBUGGER_GUI
26# include <VBox/dbggui.h>
27#endif
28
29/* Global forwards */
30class QAction;
31class QActionGroup;
32
33/* Local forwards */
34class CSession;
35class CMachine;
36class CSnapshot;
37class CUSBDevice;
38class CVirtualBoxErrorInfo;
39class UISession;
40class UIActionsPool;
41class UIKeyboardHandler;
42class UIMouseHandler;
43class UIMachineWindow;
44class UIMachineView;
45class UIDockIconPreview;
46
47class UIMachineLogic : public QIWithRetranslateUI3<QObject>
48{
49 Q_OBJECT;
50
51public:
52
53 /* Factory function to create required logic sub-child: */
54 static UIMachineLogic* create(QObject *pParent,
55 UISession *pSession,
56 UIActionsPool *pActionsPool,
57 UIVisualStateType visualStateType);
58
59 /* Check if this mode is available: */
60 virtual bool checkAvailability();
61
62 /* Do the real initialization of the object: */
63 virtual void initialize() = 0;
64
65 /* Main getters/setters: */
66 UISession* uisession() const { return m_pSession; }
67 CSession& session();
68 UIActionsPool* actionsPool() const { return m_pActionsPool; }
69 UIVisualStateType visualStateType() const { return m_visualStateType; }
70 const QList<UIMachineWindow*>& machineWindows() const { return m_machineWindowsList; }
71 UIKeyboardHandler* keyboardHandler() const { return m_pKeyboardHandler; }
72 UIMouseHandler* mouseHandler() const { return m_pMouseHandler; }
73 UIMachineWindow* mainMachineWindow() const;
74 UIMachineWindow* defaultMachineWindow() const;
75
76 /* Maintenance getters/setters: */
77 bool isPreventAutoClose() const { return m_fIsPreventAutoClose; }
78 void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; }
79
80#ifdef Q_WS_MAC
81 void updateDockIcon();
82 void updateDockIconSize(int screenId, int width, int height);
83 UIMachineView* dockPreviewView() const;
84#endif /* Q_WS_MAC */
85
86signals:
87
88 /* Signal to notify listeners about additions downloader created: */
89 void sigDownloaderAdditionsCreated();
90
91protected:
92
93 /* Machine logic constructor/destructor: */
94 UIMachineLogic(QObject *pParent,
95 UISession *pSession,
96 UIActionsPool *pActionsPool,
97 UIVisualStateType visualStateType);
98 virtual ~UIMachineLogic();
99
100 /* Protected getters/setters: */
101 bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; }
102 void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }
103
104 /* Protected members: */
105 void setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler);
106 void setMouseHandler(UIMouseHandler *pMouseHandler);
107 void addMachineWindow(UIMachineWindow *pMachineWindow);
108 void retranslateUi();
109#ifdef Q_WS_MAC
110 bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }
111 void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; }
112 void updateDockOverlay();
113#endif /* Q_WS_MAC */
114
115 /* Prepare helpers: */
116 virtual void prepareSessionConnections();
117 virtual void prepareActionConnections();
118 virtual void prepareActionGroups();
119 virtual void prepareHandlers();
120#ifdef Q_WS_MAC
121 virtual void prepareDock();
122#endif /* Q_WS_MAC */
123 virtual void prepareRequiredFeatures();
124#ifdef VBOX_WITH_DEBUGGER_GUI
125 virtual void prepareDebugger();
126#endif /* VBOX_WITH_DEBUGGER_GUI */
127
128 /* Cleanup helpers: */
129 //virtual void cleanupRequiredFeatures() {}
130#ifdef Q_WS_MAC
131 virtual void cleanupDock();
132#endif /* Q_WS_MAC */
133 virtual void cleanupHandlers();
134 //virtual void cleanupActionGroups() {}
135 //virtual void cleanupActionConnections() {}
136 //virtual void cleanupSessionConnections() {}
137
138protected slots:
139
140 /* Console callback handlers: */
141 virtual void sltMachineStateChanged();
142 virtual void sltAdditionsStateChanged();
143 virtual void sltMouseCapabilityChanged();
144 virtual void sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error);
145 virtual void sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage);
146#ifdef RT_OS_DARWIN
147 virtual void sltShowWindows();
148#endif /* RT_OS_DARWIN */
149
150 /* Mode request watch dog: */
151 void sltCheckRequestedModes();
152
153private slots:
154
155 /* "Machine" menu functionality */
156 void sltToggleGuestAutoresize(bool fEnabled);
157 void sltAdjustWindow();
158 void sltToggleMouseIntegration(bool fDisabled);
159 void sltTypeCAD();
160#ifdef Q_WS_X11
161 void sltTypeCABS();
162#endif
163 void sltTakeSnapshot();
164 void sltShowInformationDialog();
165 void sltReset();
166 void sltPause(bool fOn);
167 void sltACPIShutdown();
168 void sltClose();
169
170 /* "Device" menu functionality */
171 void sltPrepareStorageMenu();
172 void sltMountStorageMedium();
173 void sltMountRecentStorageMedium();
174 void sltPrepareUSBMenu();
175 void sltAttachUSBDevice();
176 void sltOpenNetworkAdaptersDialog();
177 void sltOpenSharedFoldersDialog();
178 void sltSwitchVrde(bool fOn);
179 void sltInstallGuestAdditions();
180
181#ifdef VBOX_WITH_DEBUGGER_GUI
182 void sltPrepareDebugMenu();
183 void sltShowDebugStatistics();
184 void sltShowDebugCommandLine();
185 void sltLoggingToggled(bool);
186#endif
187
188#ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */
189 void sltDockPreviewModeChanged(QAction *pAction);
190 void sltDockPreviewMonitorChanged(QAction *pAction);
191 void sltChangeDockIconUpdate(bool fEnabled);
192#endif /* RT_OS_DARWIN */
193
194private:
195
196 /* Utility functions: */
197 static int searchMaxSnapshotIndex(const CMachine &machine,
198 const CSnapshot &snapshot,
199 const QString &strNameTemplate);
200
201 /* Private variables: */
202 UISession *m_pSession;
203 UIActionsPool *m_pActionsPool;
204 UIVisualStateType m_visualStateType;
205 UIKeyboardHandler *m_pKeyboardHandler;
206 UIMouseHandler *m_pMouseHandler;
207 QList<UIMachineWindow*> m_machineWindowsList;
208
209 QActionGroup *m_pRunningActions;
210 QActionGroup *m_pRunningOrPausedActions;
211
212 bool m_fIsWindowsCreated : 1;
213 bool m_fIsPreventAutoClose : 1;
214
215#ifdef VBOX_WITH_DEBUGGER_GUI
216 /* Debugger functionality: */
217 bool dbgCreated();
218 void dbgDestroy();
219 void dbgAdjustRelativePos();
220 /* The handle to the debugger GUI: */
221 PDBGGUI m_pDbgGui;
222 /* The virtual method table for the debugger GUI: */
223 PCDBGGUIVT m_pDbgGuiVT;
224#endif
225
226#ifdef Q_WS_MAC
227 bool m_fIsDockIconEnabled;
228 UIDockIconPreview *m_pDockIconPreview;
229 QActionGroup *m_pDockPreviewSelectMonitorGroup;
230 int m_DockIconPreviewMonitor;
231#endif /* Q_WS_MAC */
232
233 /* Friend classes: */
234 friend class UIMachineWindow;
235};
236
237#endif // __UIMachineLogic_h__
238
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use