1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxSelectorWnd class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __VBoxSelectorWnd_h__
|
---|
24 | #define __VBoxSelectorWnd_h__
|
---|
25 |
|
---|
26 | #include "COMDefs.h"
|
---|
27 |
|
---|
28 | #include "QIWithRetranslateUI.h"
|
---|
29 |
|
---|
30 | #include "VBoxGlobal.h"
|
---|
31 | #include "VBoxProblemReporter.h"
|
---|
32 | #include "VBoxHelpActions.h"
|
---|
33 |
|
---|
34 | /* Qt includes */
|
---|
35 | #include <QMainWindow>
|
---|
36 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
37 | #include <QSystemTrayIcon>
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | class VBoxSnapshotsWgt;
|
---|
41 | class VBoxVMDetailsView;
|
---|
42 | class VBoxVMDescriptionPage;
|
---|
43 | class VBoxVMLogViewer;
|
---|
44 | class VBoxVMListView;
|
---|
45 | class VBoxVMModel;
|
---|
46 | class VBoxVMItem;
|
---|
47 | class VBoxTrayIcon;
|
---|
48 | class VBoxToolBar;
|
---|
49 |
|
---|
50 | class QTabWidget;
|
---|
51 | class QListView;
|
---|
52 | class QEvent;
|
---|
53 |
|
---|
54 | class VBoxSelectorWnd : public QIWithRetranslateUI2 <QMainWindow>
|
---|
55 | {
|
---|
56 | Q_OBJECT;
|
---|
57 |
|
---|
58 | public:
|
---|
59 |
|
---|
60 | VBoxSelectorWnd (VBoxSelectorWnd **aSelf,
|
---|
61 | QWidget* aParent = 0,
|
---|
62 | Qt::WindowFlags aFlags = Qt::Window);
|
---|
63 | virtual ~VBoxSelectorWnd();
|
---|
64 |
|
---|
65 | signals:
|
---|
66 |
|
---|
67 | void closing();
|
---|
68 |
|
---|
69 | public slots:
|
---|
70 |
|
---|
71 | void fileMediaMgr();
|
---|
72 | void fileImportAppliance();
|
---|
73 | void fileExportAppliance();
|
---|
74 | void fileSettings();
|
---|
75 | void fileExit();
|
---|
76 |
|
---|
77 | void vmNew();
|
---|
78 | void vmSettings (const QString &aCategory = QString::null,
|
---|
79 | const QString &aControl = QString::null,
|
---|
80 | const QString & = QString::null);
|
---|
81 | void vmDelete (const QString & = QString::null);
|
---|
82 | void vmStart (const QString & = QString::null);
|
---|
83 | void vmDiscard (const QString & = QString::null);
|
---|
84 | void vmPause (bool, const QString & = QString::null);
|
---|
85 | void vmRefresh (const QString & = QString::null);
|
---|
86 | void vmShowLogs (const QString & = QString::null);
|
---|
87 |
|
---|
88 | void refreshVMList();
|
---|
89 | void refreshVMItem (const QString &aID, bool aDetails,
|
---|
90 | bool aSnapshots,
|
---|
91 | bool aDescription);
|
---|
92 |
|
---|
93 | void showContextMenu (const QPoint &aPoint);
|
---|
94 |
|
---|
95 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
96 | void trayIconActivated (QSystemTrayIcon::ActivationReason aReason);
|
---|
97 | void showWindow();
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | const QAction *vmNewAction() const { return mVmNewAction; }
|
---|
101 | const QAction *vmConfigAction() const { return mVmConfigAction; }
|
---|
102 | const QAction *vmDeleteAction() const { return mVmDeleteAction; }
|
---|
103 | const QAction *vmStartAction() const { return mVmStartAction; }
|
---|
104 | const QAction *vmDiscardAction() const { return mVmDiscardAction; }
|
---|
105 | const QAction *vmPauseAction() const { return mVmPauseAction; }
|
---|
106 | const QAction *vmRefreshAction() const { return mVmRefreshAction; }
|
---|
107 | const QAction *vmShowLogsAction() const { return mVmShowLogsAction; }
|
---|
108 |
|
---|
109 | protected:
|
---|
110 |
|
---|
111 | /* Events */
|
---|
112 | bool event (QEvent *aEvent);
|
---|
113 | void closeEvent (QCloseEvent *aEvent);
|
---|
114 | #if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
|
---|
115 | bool eventFilter (QObject *aObject, QEvent *aEvent);
|
---|
116 | #endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
|
---|
117 |
|
---|
118 | void retranslateUi();
|
---|
119 |
|
---|
120 | private slots:
|
---|
121 |
|
---|
122 | void vmListViewCurrentChanged (bool aRefreshDetails = true,
|
---|
123 | bool aRefreshSnapshots = true,
|
---|
124 | bool aRefreshDescription = true);
|
---|
125 |
|
---|
126 | void mediumEnumStarted();
|
---|
127 | void mediumEnumFinished (const VBoxMediaList &);
|
---|
128 |
|
---|
129 | /* VirtualBox callback events we're interested in */
|
---|
130 |
|
---|
131 | void machineStateChanged (const VBoxMachineStateChangeEvent &e);
|
---|
132 | void machineDataChanged (const VBoxMachineDataChangeEvent &e);
|
---|
133 | void machineRegistered (const VBoxMachineRegisteredEvent &e);
|
---|
134 | void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
|
---|
135 | void snapshotChanged (const VBoxSnapshotEvent &e);
|
---|
136 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
137 | void mainWindowCountChanged (const VBoxMainWindowCountChangeEvent &aEvent);
|
---|
138 | void trayIconCanShow (const VBoxCanShowTrayIconEvent &e);
|
---|
139 | void trayIconShow (const VBoxShowTrayIconEvent &e);
|
---|
140 | void trayIconChanged (const VBoxChangeTrayIconEvent &e);
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | private:
|
---|
144 |
|
---|
145 | /* Main menus */
|
---|
146 | QMenu *mFileMenu;
|
---|
147 | QMenu *mVMMenu;
|
---|
148 | QMenu *mHelpMenu;
|
---|
149 |
|
---|
150 | /* Main toolbar */
|
---|
151 | VBoxToolBar *mVMToolBar;
|
---|
152 |
|
---|
153 | /* VM list context menu */
|
---|
154 | QMenu *mVMCtxtMenu;
|
---|
155 |
|
---|
156 | /* Actions */
|
---|
157 | QAction *mFileMediaMgrAction;
|
---|
158 | QAction *mFileApplianceImportAction;
|
---|
159 | QAction *mFileApplianceExportAction;
|
---|
160 | QAction *mFileSettingsAction;
|
---|
161 | QAction *mFileExitAction;
|
---|
162 | QAction *mVmNewAction;
|
---|
163 | QAction *mVmConfigAction;
|
---|
164 | QAction *mVmDeleteAction;
|
---|
165 | QAction *mVmStartAction;
|
---|
166 | QAction *mVmDiscardAction;
|
---|
167 | QAction *mVmPauseAction;
|
---|
168 | QAction *mVmRefreshAction;
|
---|
169 | QAction *mVmShowLogsAction;
|
---|
170 |
|
---|
171 | VBoxHelpActions mHelpActions;
|
---|
172 |
|
---|
173 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
174 | /* The systray icon */
|
---|
175 | VBoxTrayIcon *mTrayIcon;
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | /* The vm list view/model */
|
---|
179 | VBoxVMListView *mVMListView;
|
---|
180 | VBoxVMModel *mVMModel;
|
---|
181 |
|
---|
182 | /* The right information widgets */
|
---|
183 | QTabWidget *mVmTabWidget;
|
---|
184 | VBoxVMDetailsView *mVmDetailsView;
|
---|
185 | VBoxSnapshotsWgt *mVmSnapshotsWgt;
|
---|
186 | VBoxVMDescriptionPage *mVmDescriptionPage;
|
---|
187 |
|
---|
188 | QRect mNormalGeo;
|
---|
189 |
|
---|
190 | bool mDoneInaccessibleWarningOnce : 1;
|
---|
191 | };
|
---|
192 |
|
---|
193 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
194 |
|
---|
195 | Q_DECLARE_METATYPE(QString);
|
---|
196 |
|
---|
197 | class VBoxTrayIcon : public QSystemTrayIcon
|
---|
198 | {
|
---|
199 | Q_OBJECT;
|
---|
200 |
|
---|
201 | public:
|
---|
202 |
|
---|
203 | VBoxTrayIcon (VBoxSelectorWnd* aParent, VBoxVMModel* aVMModel);
|
---|
204 | virtual ~VBoxTrayIcon ();
|
---|
205 |
|
---|
206 | void refresh ();
|
---|
207 | void retranslateUi ();
|
---|
208 |
|
---|
209 | protected:
|
---|
210 |
|
---|
211 | VBoxVMItem* GetItem (QObject* aObject);
|
---|
212 |
|
---|
213 | signals:
|
---|
214 |
|
---|
215 | public slots:
|
---|
216 |
|
---|
217 | void trayIconShow (bool aShow = false);
|
---|
218 |
|
---|
219 | private slots:
|
---|
220 |
|
---|
221 | void showSubMenu();
|
---|
222 | void hideSubMenu ();
|
---|
223 |
|
---|
224 | void vmSettings();
|
---|
225 | void vmDelete();
|
---|
226 | void vmStart();
|
---|
227 | void vmDiscard();
|
---|
228 | void vmPause(bool aPause);
|
---|
229 | void vmRefresh();
|
---|
230 | void vmShowLogs();
|
---|
231 |
|
---|
232 | private:
|
---|
233 |
|
---|
234 | bool mActive; /* Is systray menu active/available? */
|
---|
235 |
|
---|
236 | /* The vm list model */
|
---|
237 | VBoxVMModel *mVMModel;
|
---|
238 |
|
---|
239 | VBoxSelectorWnd* mParent;
|
---|
240 | QMenu *mTrayIconMenu;
|
---|
241 |
|
---|
242 | QAction *mShowSelectorAction;
|
---|
243 | QAction *mHideSystrayMenuAction;
|
---|
244 | QAction *mVmConfigAction;
|
---|
245 | QAction *mVmDeleteAction;
|
---|
246 | QAction *mVmStartAction;
|
---|
247 | QAction *mVmDiscardAction;
|
---|
248 | QAction *mVmPauseAction;
|
---|
249 | QAction *mVmRefreshAction;
|
---|
250 | QAction *mVmShowLogsAction;
|
---|
251 | };
|
---|
252 |
|
---|
253 | #endif // VBOX_GUI_WITH_SYSTRAY
|
---|
254 |
|
---|
255 | #endif // __VBoxSelectorWnd_h__
|
---|