VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h@ 16083

Last change on this file since 16083 was 14908, checked in by vboxsync, 16 years ago

Fe/Qt4: Systray: Final implementation for now; it uses a separate process for the tray icon. Disabled tray icon menu by default.

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