VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h@ 16565

Last change on this file since 16565 was 16264, checked in by vboxsync, 16 years ago

FE/Qt4: 3225: Disable ACPI actions if the guest did not enter (or exit already) ACPI.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.1 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxProblemReporter 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 __VBoxProblemReporter_h__
24#define __VBoxProblemReporter_h__
25
26#include "COMDefs.h"
27#include "QIMessageBox.h"
28
29/* Qt icludes */
30#include <QObject>
31
32class VBoxMedium;
33class QAction;
34class QMenu;
35
36// VBoxHelpActions class
37////////////////////////////////////////////////////////////////////////////////
38
39/**
40 * Help Menu action container.
41 *
42 * Contains actions for all help menu items and methods to insert them to a
43 * QMenu and to perform NLS string translation.
44 *
45 * Instances of this class are to be created as members of QWidget classes that
46 * need a Help menu. The containing class usually passes itself as an argument
47 * to the #setup() method and then calls #addTo() to add actions to its Help
48 * menu. The #retranslateUi() method is called when it is necessary to
49 * re-translate all action NLS according to the current language.
50 */
51struct VBoxHelpActions
52{
53 VBoxHelpActions()
54 : contentsAction (NULL), webAction (NULL)
55 , resetMessagesAction (NULL), registerAction (NULL)
56 , updateAction (NULL), aboutAction (NULL)
57 {}
58
59 void setup (QObject *aParent);
60 void addTo (QMenu *aMenu);
61 void retranslateUi();
62
63 QAction *contentsAction;
64 QAction *webAction;
65 QAction *resetMessagesAction;
66 QAction *registerAction;
67 QAction *updateAction;
68 QAction *aboutAction;
69};
70
71// VBoxProblemReporter class
72////////////////////////////////////////////////////////////////////////////////
73
74/**
75 * The VBoxProblemReporter class is a central place to handle all problem/error
76 * situations that happen during application runtime and require the user's
77 * attention.
78 *
79 * The role of this class is to describe the problem and/or the cause of the
80 * error to the user and give him the opportunity to select an action (when
81 * appropriate).
82 *
83 * Every problem sutiation has its own (correspondingly named) method in this
84 * class that takes a list of arguments necessary to describe the situation and
85 * to provide the appropriate actions. The method then returns the choice to the
86 * caller.
87 */
88class VBoxProblemReporter : public QObject
89{
90 Q_OBJECT
91
92public:
93
94 enum Type
95 {
96 Info = 1,
97 Question,
98 Warning,
99 Error,
100 Critical,
101 GuruMeditation
102 };
103
104 enum
105 {
106 AutoConfirmed = 0x8000
107 };
108
109 static VBoxProblemReporter &instance();
110
111 bool isValid();
112
113 // helpers
114
115 int message (QWidget *aParent, Type aType, const QString &aMessage,
116 const QString &aDetails = QString::null,
117 const char *aAutoConfirmId = 0,
118 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
119 const QString &aText1 = QString::null,
120 const QString &aText2 = QString::null,
121 const QString &aText3 = QString::null);
122
123 int message (QWidget *aParent, Type aType, const QString &aMessage,
124 const char *aAutoConfirmId,
125 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
126 const QString &aText1 = QString::null,
127 const QString &aText2 = QString::null,
128 const QString &aText3 = QString::null)
129 {
130 return message (aParent, aType, aMessage, QString::null, aAutoConfirmId,
131 aButton1, aButton2, aButton3, aText1, aText2, aText3);
132 }
133
134 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
135 const QString &aDetails = QString::null,
136 const char *aAutoConfirmId = 0,
137 const QString &aYesText = QString::null,
138 const QString &aNoText = QString::null)
139 {
140 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
141 QIMessageBox::Yes | QIMessageBox::Default,
142 QIMessageBox::No | QIMessageBox::Escape,
143 0,
144 aYesText, aNoText, QString::null) &
145 QIMessageBox::ButtonMask) == QIMessageBox::Yes;
146 }
147
148 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
149 const char *aAutoConfirmId,
150 const QString &aYesText = QString::null,
151 const QString &aNoText = QString::null)
152 {
153 return messageYesNo (aParent, aType, aMessage, QString::null,
154 aAutoConfirmId, aYesText, aNoText);
155 }
156
157 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
158 const QString &aDetails = QString::null,
159 const char *aAutoConfirmId = 0,
160 const QString &aOkText = QString::null,
161 const QString &aCancelText = QString::null)
162 {
163 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
164 QIMessageBox::Ok | QIMessageBox::Default,
165 QIMessageBox::Cancel | QIMessageBox::Escape,
166 0,
167 aOkText, aCancelText, QString::null) &
168 QIMessageBox::ButtonMask) == QIMessageBox::Ok;
169 }
170
171 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
172 const char *aAutoConfirmId,
173 const QString &aOkText = QString::null,
174 const QString &aCancelText = QString::null)
175 {
176 return messageOkCancel (aParent, aType, aMessage, QString::null,
177 aAutoConfirmId, aOkText, aCancelText);
178 }
179
180 bool showModalProgressDialog (CProgress &aProgress, const QString &aTitle,
181 QWidget *aParent, int aMinDuration = 2000);
182
183 QWidget *mainWindowShown();
184
185 // problem handlers
186
187#ifdef Q_WS_X11
188 void cannotFindLicenseFiles (const QString &aPath);
189 void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
190#endif
191
192 void cannotOpenURL (const QString &aURL);
193 void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC);
194
195 void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
196 void cannotLoadLanguage (const QString &aLangFile);
197
198 void cannotInitCOM (HRESULT rc);
199 void cannotCreateVirtualBox (const CVirtualBox &vbox);
200
201 void cannotSaveGlobalSettings (const CVirtualBox &vbox,
202 QWidget *parent = 0);
203
204 void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
205 void cannotSaveGlobalConfig (const CVirtualBox &vbox);
206 void cannotSetSystemProperties (const CSystemProperties &props);
207 void cannotAccessUSB (const COMBaseWithEI &aObj);
208
209 void cannotCreateMachine (const CVirtualBox &vbox,
210 QWidget *parent = 0);
211 void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
212 QWidget *parent = 0);
213 void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
214 void cannotSaveMachineSettings (const CMachine &machine,
215 QWidget *parent = 0);
216 void cannotLoadMachineSettings (const CMachine &machine,
217 bool strict = true,
218 QWidget *parent = 0);
219
220 void cannotStartMachine (const CConsole &console);
221 void cannotStartMachine (const CProgress &progress);
222 void cannotPauseMachine (const CConsole &console);
223 void cannotResumeMachine (const CConsole &console);
224 void cannotACPIShutdownMachine (const CConsole &console);
225 void cannotSaveMachineState (const CConsole &console);
226 void cannotSaveMachineState (const CProgress &progress);
227 void cannotTakeSnapshot (const CConsole &console);
228 void cannotTakeSnapshot (const CProgress &progress);
229 void cannotStopMachine (const CConsole &console);
230 void cannotStopMachine (const CProgress &progress);
231 void cannotDeleteMachine (const CVirtualBox &vbox, const CMachine &machine);
232 void cannotDiscardSavedState (const CConsole &console);
233
234 void cannotSendACPIToMachine();
235
236 void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath);
237 void cannotDiscardSnapshot (const CConsole &aConsole,
238 const QString &aSnapshotName);
239 void cannotDiscardSnapshot (const CProgress &aProgress,
240 const QString &aSnapshotName);
241 void cannotDiscardCurrentState (const CConsole &console);
242 void cannotDiscardCurrentState (const CProgress &progress);
243 void cannotDiscardCurrentSnapshotAndState (const CConsole &console);
244 void cannotDiscardCurrentSnapshotAndState (const CProgress &progress);
245
246 void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
247
248 void cannotEnterSeamlessMode (ULONG aWidth, ULONG aHeight,
249 ULONG aBpp, ULONG64 aMinVRAM);
250 int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
251 ULONG aBpp, ULONG64 aMinVRAM);
252
253 bool confirmMachineDeletion (const CMachine &machine);
254 bool confirmDiscardSavedState (const CMachine &machine);
255
256 bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
257 const QString &aUsage);
258
259 bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
260
261 void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
262 const QString &aLocation);
263 int confirmDeleteHardDiskStorage (QWidget *aParent,
264 const QString &aLocation);
265 void cannotDeleteHardDiskStorage (QWidget *aParent, const CHardDisk2 &aHD,
266 const CProgress &aProgress);
267
268 int confirmDetachSATASlots (QWidget *aParent);
269 int confirmRunNewHDWzdOrVDM (QWidget* aParent);
270
271 void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
272 const QString &aLocaiton,
273 const CHardDisk2 &aHD,
274 const CProgress &aProgress);
275 void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine,
276 const QString &aLocation, KStorageBus aBus,
277 LONG aChannel, LONG aDevice);
278 void cannotDetachHardDisk (QWidget *aParent, const CMachine &aMachine,
279 const QString &aLocation, KStorageBus aBus,
280 LONG aChannel, LONG aDevice);
281
282 void cannotMountMedium (QWidget *aParent, const CMachine &aMachine,
283 const VBoxMedium &aMedium, const COMResult &aResult);
284 void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine,
285 const VBoxMedium &aMedium, const COMResult &aResult);
286 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
287 VBoxDefs::MediaType aType, const QString &aLocation);
288 void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
289 const COMResult &aResult);
290
291 void cannotOpenSession (const CSession &session);
292 void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
293 const CProgress &progress = CProgress());
294
295 void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
296
297#if defined Q_WS_WIN
298 void cannotCreateHostInterface (const CHost &host, const QString &name,
299 QWidget *parent = 0);
300 void cannotCreateHostInterface (const CProgress &progress, const QString &name,
301 QWidget *parent = 0);
302 void cannotRemoveHostInterface (const CHost &host,
303 const CHostNetworkInterface &iface,
304 QWidget *parent = 0);
305 void cannotRemoveHostInterface (const CProgress &progress,
306 const CHostNetworkInterface &iface,
307 QWidget *parent = 0);
308#endif
309
310 void cannotAttachUSBDevice (const CConsole &console, const QString &device);
311 void cannotAttachUSBDevice (const CConsole &console, const QString &device,
312 const CVirtualBoxErrorInfo &error);
313 void cannotDetachUSBDevice (const CConsole &console, const QString &device);
314 void cannotDetachUSBDevice (const CConsole &console, const QString &device,
315 const CVirtualBoxErrorInfo &error);
316
317 void cannotCreateSharedFolder (QWidget *, const CMachine &,
318 const QString &, const QString &);
319 void cannotRemoveSharedFolder (QWidget *, const CMachine &,
320 const QString &, const QString &);
321 void cannotCreateSharedFolder (QWidget *, const CConsole &,
322 const QString &, const QString &);
323 void cannotRemoveSharedFolder (QWidget *, const CConsole &,
324 const QString &, const QString &);
325
326 int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
327 void cannotDownloadGuestAdditions (const QString &aURL,
328 const QString &aReason);
329 bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
330 bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
331 void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
332 void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
333 void warnAboutNewAdditions (QWidget *, const QString &, const QString &);
334
335 void cannotConnectRegister (QWidget *aParent,
336 const QString &aURL,
337 const QString &aReason);
338 void showRegisterResult (QWidget *aParent,
339 const QString &aResult);
340
341 void showUpdateSuccess (QWidget *aParent,
342 const QString &aVersion,
343 const QString &aLink);
344 void showUpdateFailure (QWidget *aParent,
345 const QString &aReason);
346 void showUpdateNotFound (QWidget *aParent);
347
348 bool confirmInputCapture (bool *aAutoConfirmed = NULL);
349 void remindAboutAutoCapture();
350 void remindAboutMouseIntegration (bool aSupportsAbsolute);
351 bool remindAboutPausedVMInput();
352
353 int warnAboutAutoConvertedSettings (const QString &aFormatVersion,
354 const QString &aFileList,
355 bool aAfterRefresh);
356
357 bool remindAboutInaccessibleMedia();
358
359 bool confirmGoingFullscreen (const QString &aHotKey);
360 bool confirmGoingSeamless (const QString &aHotKey);
361
362 void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
363
364 bool remindAboutGuruMeditation (const CConsole &aConsole,
365 const QString &aLogFolder);
366
367 bool confirmVMReset (QWidget *aParent);
368
369 bool confirmHardDisklessMachine (QWidget *aParent);
370
371 void cannotRunInSelectorMode();
372
373 void showRuntimeError (const CConsole &console, bool fatal,
374 const QString &errorID,
375 const QString &errorMsg);
376
377 static QString toAccusative (VBoxDefs::MediaType aType);
378
379 static QString formatRC (HRESULT aRC);
380
381 static QString formatErrorInfo (const COMErrorInfo &aInfo,
382 HRESULT aWrapperRC = S_OK);
383
384 static QString formatErrorInfo (const CVirtualBoxErrorInfo &aInfo)
385 {
386 return formatErrorInfo (COMErrorInfo (aInfo));
387 }
388
389 static QString formatErrorInfo (const COMBaseWithEI &aWrapper)
390 {
391 Assert (aWrapper.lastRC() != S_OK);
392 return formatErrorInfo (aWrapper.errorInfo(), aWrapper.lastRC());
393 }
394
395 static QString formatErrorInfo (const COMResult &aRC)
396 {
397 Assert (aRC.rc() != S_OK);
398 return formatErrorInfo (aRC.errorInfo(), aRC.rc());
399 }
400
401public slots:
402
403 void showHelpWebDialog();
404 void showHelpAboutDialog();
405 void showHelpHelpDialog();
406 void resetSuppressedMessages();
407
408private:
409
410 friend VBoxProblemReporter &vboxProblem();
411
412 static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
413 HRESULT aWrapperRC = S_OK);
414};
415
416/**
417 * Shortcut to the static VBoxProblemReporter::instance() method, for
418 * convenience.
419 */
420inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
421
422#endif // __VBoxProblemReporter_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