VirtualBox

Changeset 17730 in vbox


Ignore:
Timestamp:
Mar 12, 2009 11:10:44 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44245
Message:

FE/Qt4: split VBoxHelpActions out of VBoxProblemReporter

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r17450 r17730  
    327327        src/VBoxMediaComboBox.cpp \
    328328        src/VBoxProblemReporter.cpp \
     329        src/VBoxHelpActions.cpp \
    329330        src/VBoxSelectorWnd.cpp \
    330331        src/VBoxConsoleView.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r17349 r17730  
    2929
    3030#include "VBoxProblemReporter.h"
     31#include "VBoxHelpActions.h"
    3132
    3233/* Qt includes */
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxHelpActions.h

    r17721 r17730  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VBoxProblemReporter class declaration
     4 * VBoxHelpActions class declaration
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
    23 #ifndef __VBoxProblemReporter_h__
    24 #define __VBoxProblemReporter_h__
     23#ifndef __VBoxHelpActions_h__
     24#define __VBoxHelpActions_h__
    2525
    26 #include "COMDefs.h"
    27 #include "QIMessageBox.h"
    28 
    29 /* Qt icludes */
     26/* Qt includes */
    3027#include <QObject>
    3128
    32 class VBoxMedium;
     29class QMenu;
    3330class QAction;
    34 class QMenu;
    35 
    36 // VBoxHelpActions class
    37 ////////////////////////////////////////////////////////////////////////////////
    3831
    3932/**
     
    6962};
    7063
    71 // VBoxProblemReporter class
    72 ////////////////////////////////////////////////////////////////////////////////
     64#endif /* __VBoxHelpActions_h__ */
    7365
    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  */
    88 class VBoxProblemReporter : public QObject
    89 {
    90     Q_OBJECT;
    91 
    92 public:
    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() const;
    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) const;
    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) const
    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) const
    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) const
    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) const
    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) const
    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() const;
    184 
    185     /* Generic problem handlers */
    186     bool askForOverridingFileIfExists (const QString& path, QWidget *aParent = NULL) const;
    187 
    188     /* Special problem handlers */
    189 #ifdef Q_WS_X11
    190     void cannotFindLicenseFiles (const QString &aPath);
    191     void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
    192 #endif
    193 
    194     void cannotOpenURL (const QString &aURL);
    195     void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC);
    196 
    197     void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
    198     void cannotLoadLanguage (const QString &aLangFile);
    199 
    200     void cannotInitCOM (HRESULT rc);
    201     void cannotCreateVirtualBox (const CVirtualBox &vbox);
    202 
    203     void cannotSaveGlobalSettings (const CVirtualBox &vbox,
    204                                    QWidget *parent = 0);
    205 
    206     void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
    207     void cannotSaveGlobalConfig (const CVirtualBox &vbox);
    208     void cannotSetSystemProperties (const CSystemProperties &props);
    209     void cannotAccessUSB (const COMBaseWithEI &aObj);
    210 
    211     void cannotCreateMachine (const CVirtualBox &vbox,
    212                               QWidget *parent = 0);
    213     void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
    214                               QWidget *parent = 0);
    215     void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
    216     void cannotSaveMachineSettings (const CMachine &machine,
    217                                     QWidget *parent = 0);
    218     void cannotLoadMachineSettings (const CMachine &machine,
    219                                     bool strict = true,
    220                                     QWidget *parent = 0);
    221 
    222     void cannotStartMachine (const CConsole &console);
    223     void cannotStartMachine (const CProgress &progress);
    224     void cannotPauseMachine (const CConsole &console);
    225     void cannotResumeMachine (const CConsole &console);
    226     void cannotACPIShutdownMachine (const CConsole &console);
    227     void cannotSaveMachineState (const CConsole &console);
    228     void cannotSaveMachineState (const CProgress &progress);
    229     void cannotTakeSnapshot (const CConsole &console);
    230     void cannotTakeSnapshot (const CProgress &progress);
    231     void cannotStopMachine (const CConsole &console);
    232     void cannotStopMachine (const CProgress &progress);
    233     void cannotDeleteMachine (const CVirtualBox &vbox, const CMachine &machine);
    234     void cannotDiscardSavedState (const CConsole &console);
    235 
    236     void cannotSendACPIToMachine();
    237     bool warnAboutVirtNotEnabled();
    238 
    239     void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath);
    240     void cannotDiscardSnapshot (const CConsole &aConsole,
    241                                 const QString &aSnapshotName);
    242     void cannotDiscardSnapshot (const CProgress &aProgress,
    243                                 const QString &aSnapshotName);
    244     void cannotDiscardCurrentState (const CConsole &console);
    245     void cannotDiscardCurrentState (const CProgress &progress);
    246     void cannotDiscardCurrentSnapshotAndState (const CConsole &console);
    247     void cannotDiscardCurrentSnapshotAndState (const CProgress &progress);
    248 
    249     void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
    250 
    251     void cannotEnterSeamlessMode (ULONG aWidth, ULONG aHeight,
    252                                   ULONG aBpp, ULONG64 aMinVRAM);
    253     int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
    254                                    ULONG aBpp, ULONG64 aMinVRAM);
    255 
    256     bool confirmMachineDeletion (const CMachine &machine);
    257     bool confirmDiscardSavedState (const CMachine &machine);
    258 
    259     bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
    260                                const QString &aUsage);
    261 
    262     bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
    263 
    264     void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
    265                                             const QString &aLocation);
    266     int confirmDeleteHardDiskStorage (QWidget *aParent,
    267                                       const QString &aLocation);
    268     void cannotDeleteHardDiskStorage (QWidget *aParent, const CHardDisk &aHD,
    269                                       const CProgress &aProgress);
    270 
    271     int confirmDetachSATASlots (QWidget *aParent);
    272     int confirmRunNewHDWzdOrVDM (QWidget* aParent);
    273 
    274     void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
    275                                       const QString &aLocaiton,
    276                                       const CHardDisk &aHD,
    277                                       const CProgress &aProgress);
    278     void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine,
    279                                const QString &aLocation, KStorageBus aBus,
    280                                LONG aChannel, LONG aDevice);
    281     void cannotDetachHardDisk (QWidget *aParent, const CMachine &aMachine,
    282                                const QString &aLocation, KStorageBus aBus,
    283                                LONG aChannel, LONG aDevice);
    284 
    285     void cannotMountMedium (QWidget *aParent, const CMachine &aMachine,
    286                             const VBoxMedium &aMedium, const COMResult &aResult);
    287     void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine,
    288                             const VBoxMedium &aMedium, const COMResult &aResult);
    289     void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
    290                            VBoxDefs::MediaType aType, const QString &aLocation);
    291     void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
    292                             const COMResult &aResult);
    293 
    294     void cannotOpenSession (const CSession &session);
    295     void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
    296                             const CProgress &progress = CProgress());
    297 
    298     void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
    299 
    300 #if defined Q_WS_WIN
    301     int confirmDeletingHostInterface (const QString &aName, QWidget *aParent = 0);
    302     void cannotCreateHostInterface (const CHost &aHost,
    303                                     QWidget *aParent = 0);
    304     void cannotCreateHostInterface (const CProgress &aProgress, const QString &aName,
    305                                     QWidget *aParent = 0);
    306     void cannotRemoveHostInterface (const CHost &aHost,
    307                                     const CHostNetworkInterface &aIface,
    308                                     QWidget *aParent = 0);
    309     void cannotRemoveHostInterface (const CProgress &aProgress,
    310                                     const CHostNetworkInterface &aIface,
    311                                     QWidget *aParent = 0);
    312 #endif
    313 
    314     void cannotAttachUSBDevice (const CConsole &console, const QString &device);
    315     void cannotAttachUSBDevice (const CConsole &console, const QString &device,
    316                                 const CVirtualBoxErrorInfo &error);
    317     void cannotDetachUSBDevice (const CConsole &console, const QString &device);
    318     void cannotDetachUSBDevice (const CConsole &console, const QString &device,
    319                                 const CVirtualBoxErrorInfo &error);
    320 
    321     void cannotCreateSharedFolder (QWidget *, const CMachine &,
    322                                    const QString &, const QString &);
    323     void cannotRemoveSharedFolder (QWidget *, const CMachine &,
    324                                    const QString &, const QString &);
    325     void cannotCreateSharedFolder (QWidget *, const CConsole &,
    326                                    const QString &, const QString &);
    327     void cannotRemoveSharedFolder (QWidget *, const CConsole &,
    328                                    const QString &, const QString &);
    329 
    330     int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
    331     void cannotDownloadGuestAdditions (const QString &aURL,
    332                                        const QString &aReason);
    333     bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
    334     bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
    335     void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
    336     void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
    337     void warnAboutNewAdditions (QWidget *, const QString &, const QString &);
    338 
    339     void cannotConnectRegister (QWidget *aParent,
    340                                 const QString &aURL,
    341                                 const QString &aReason);
    342     void showRegisterResult (QWidget *aParent,
    343                              const QString &aResult);
    344 
    345     void showUpdateSuccess (QWidget *aParent,
    346                             const QString &aVersion,
    347                             const QString &aLink);
    348     void showUpdateFailure (QWidget *aParent,
    349                             const QString &aReason);
    350     void showUpdateNotFound (QWidget *aParent);
    351 
    352     bool confirmInputCapture (bool *aAutoConfirmed = NULL);
    353     void remindAboutAutoCapture();
    354     void remindAboutMouseIntegration (bool aSupportsAbsolute);
    355     bool remindAboutPausedVMInput();
    356 
    357     int warnAboutAutoConvertedSettings (const QString &aFormatVersion,
    358                                         const QString &aFileList,
    359                                         bool aAfterRefresh);
    360 
    361     bool remindAboutInaccessibleMedia();
    362 
    363     bool confirmGoingFullscreen (const QString &aHotKey);
    364     bool confirmGoingSeamless (const QString &aHotKey);
    365 
    366     void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
    367 
    368     bool remindAboutGuruMeditation (const CConsole &aConsole,
    369                                     const QString &aLogFolder);
    370 
    371     bool confirmVMReset (QWidget *aParent);
    372 
    373     bool confirmHardDisklessMachine (QWidget *aParent);
    374 
    375     void cannotRunInSelectorMode();
    376 
    377     void cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
    378     void cannotImportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
    379 
    380     void cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
    381     void cannotExportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
    382 
    383     void showRuntimeError (const CConsole &console, bool fatal,
    384                            const QString &errorID,
    385                            const QString &errorMsg) const;
    386 
    387     static QString toAccusative (VBoxDefs::MediaType aType);
    388 
    389     static QString formatRC (HRESULT aRC);
    390 
    391     static QString formatErrorInfo (const COMErrorInfo &aInfo,
    392                                     HRESULT aWrapperRC = S_OK);
    393 
    394     static QString formatErrorInfo (const CVirtualBoxErrorInfo &aInfo)
    395     {
    396         return formatErrorInfo (COMErrorInfo (aInfo));
    397     }
    398 
    399     static QString formatErrorInfo (const COMBaseWithEI &aWrapper)
    400     {
    401         Assert (aWrapper.lastRC() != S_OK);
    402         return formatErrorInfo (aWrapper.errorInfo(), aWrapper.lastRC());
    403     }
    404 
    405     static QString formatErrorInfo (const COMResult &aRC)
    406     {
    407         Assert (aRC.rc() != S_OK);
    408         return formatErrorInfo (aRC.errorInfo(), aRC.rc());
    409     }
    410 
    411 public slots:
    412 
    413     void showHelpWebDialog();
    414     void showHelpAboutDialog();
    415     void showHelpHelpDialog();
    416     void resetSuppressedMessages();
    417 
    418 private:
    419 
    420     friend VBoxProblemReporter &vboxProblem();
    421 
    422     static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
    423                                       HRESULT aWrapperRC = S_OK);
    424 };
    425 
    426 /**
    427  * Shortcut to the static VBoxProblemReporter::instance() method, for
    428  * convenience.
    429  */
    430 inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
    431 
    432 #endif // __VBoxProblemReporter_h__
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r17679 r17730  
    3131
    3232class VBoxMedium;
    33 class QAction;
    34 class 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  */
    51 struct 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 };
    7033
    7134// VBoxProblemReporter class
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxSelectorWnd.h

    r17450 r17730  
    3030#include "VBoxGlobal.h"
    3131#include "VBoxProblemReporter.h"
     32#include "VBoxHelpActions.h"
    3233
    3334/* Qt includes */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxHelpActions.cpp

    r17721 r17730  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VBoxProblemReporter class implementation
     4 * VBoxHelpActions class implementation
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
     23#include "VBoxHelpActions.h"
     24#include "VBoxGlobal.h"
    2325#include "VBoxProblemReporter.h"
    2426
    25 #include "VBoxGlobal.h"
    26 #include "VBoxSelectorWnd.h"
    27 #include "VBoxConsoleWnd.h"
    28 
    29 #include "VBoxAboutDlg.h"
    30 
    31 #include "QIHotKeyEdit.h"
    32 
    33 #ifdef Q_WS_MAC
    34 # include "VBoxUtils-darwin.h"
    35 #endif
    36 
    3727/* Qt includes */
    38 #include <QProgressDialog>
    39 #include <QProcess>
    40 #include <QFileInfo>
    41 #ifdef Q_WS_MAC
    42 # include <QPushButton>
    43 #endif
    44 #include <QAction>
    4528#include <QMenu>
    46 
    47 #include <iprt/err.h>
    48 #include <iprt/param.h>
    49 #include <iprt/path.h>
    50 
    51 #if defined (Q_WS_WIN32)
    52 #include <Htmlhelp.h>
    53 #endif
    54 
    55 ////////////////////////////////////////////////////////////////////////////////
    56 // VBoxProgressDialog class
    57 ////////////////////////////////////////////////////////////////////////////////
    58 
    59 /**
    60  * A QProgressDialog enhancement that allows to:
    61  *
    62  * 1) prevent closing the dialog when it has no cancel button;
    63  * 2) effectively track the IProgress object completion (w/o using
    64  *    IProgress::waitForCompletion() and w/o blocking the UI thread in any other
    65  *    way for too long).
    66  *
    67  * @note The CProgress instance is passed as a non-const reference to the
    68  *       constructor (to memorize COM errors if they happen), and therefore must
    69  *       not be destroyed before the created VBoxProgressDialog instance is
    70  *       destroyed.
    71  */
    72 class VBoxProgressDialog : public QProgressDialog
    73 {
    74 public:
    75 
    76     VBoxProgressDialog (CProgress &aProgress, const QString &aTitle,
    77                         int aMinDuration = 2000, QWidget *aCreator = 0)
    78         : QProgressDialog (aCreator,
    79                            Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint)
    80         , mProgress (aProgress)
    81         , mEventLoop (new QEventLoop (this))
    82         , mCalcelEnabled (false)
    83         , mOpCount (mProgress.GetOperationCount())
    84         , mCurOp (mProgress.GetOperation() + 1)
    85         , mEnded (false)
    86     {
    87         setModal (true);
    88 #ifdef Q_WS_MAC
    89         ::darwinSetHidesAllTitleButtons (this);
    90         ::darwinSetShowsResizeIndicator (this, false);
    91 #endif /* Q_WS_MAC */
    92 
    93         if (mOpCount > 1)
    94             setLabelText (QString (sOpDescTpl)
    95                           .arg (mProgress.GetOperationDescription())
    96                           .arg (mCurOp).arg (mOpCount));
    97         else
    98             setLabelText (QString ("%1...")
    99                           .arg (mProgress.GetOperationDescription()));
    100         setCancelButtonText (QString::null);
    101         setMaximum (100);
    102         setWindowTitle (QString ("%1: %2")
    103                     .arg (aTitle, mProgress.GetDescription()));
    104         setMinimumDuration (aMinDuration);
    105         setValue (0);
    106     }
    107 
    108     int run (int aRefreshInterval)
    109     {
    110         if (mProgress.isOk())
    111         {
    112             /* Start refresh timer */
    113             int id = startTimer (aRefreshInterval);
    114 
    115             /* The progress dialog is automatically shown after the duration is over */
    116 
    117             /* Enter the modal loop */
    118             mEventLoop->exec();
    119 
    120             /* Kill refresh timer */
    121             killTimer (id);
    122 
    123             return result();
    124         }
    125         return Rejected;
    126     }
    127 
    128     /* These methods disabled for now as not used anywhere */
    129     // bool cancelEnabled() const { return mCalcelEnabled; }
    130     // void setCancelEnabled (bool aEnabled) { mCalcelEnabled = aEnabled; }
    131 
    132 protected:
    133 
    134     virtual void timerEvent (QTimerEvent * /* aEvent */)
    135     {
    136         if (!mEnded && (!mProgress.isOk() || mProgress.GetCompleted()))
    137         {
    138             /* Progress finished */
    139             if (mProgress.isOk())
    140             {
    141                 setValue (100);
    142                 setResult (Accepted);
    143             }
    144             /* Progress is not valid */
    145             else
    146                 setResult (Rejected);
    147 
    148             /* Request to exit loop */
    149             mEnded = true;
    150 
    151             /* The progress will be finalized
    152              * on next timer iteration. */
    153             return;
    154         }
    155 
    156         if (mEnded)
    157         {
    158             /* Exit loop if it is running */
    159             if (mEventLoop->isRunning())
    160                 mEventLoop->quit();
    161             return;
    162         }
    163 
    164         /* Update the progress dialog */
    165         ulong newOp = mProgress.GetOperation() + 1;
    166         if (newOp != mCurOp)
    167         {
    168             mCurOp = newOp;
    169             setLabelText (QString (sOpDescTpl)
    170                 .arg (mProgress.GetOperationDescription())
    171                 .arg (mCurOp).arg (mOpCount));
    172         }
    173         setValue (mProgress.GetPercent());
    174     }
    175 
    176     virtual void reject() { if (mCalcelEnabled) QProgressDialog::reject(); }
    177 
    178     virtual void closeEvent (QCloseEvent *aEvent)
    179     {
    180         if (mCalcelEnabled)
    181             QProgressDialog::closeEvent (aEvent);
    182         else
    183             aEvent->ignore();
    184     }
    185 
    186 private:
    187 
    188     CProgress &mProgress;
    189     QEventLoop *mEventLoop;
    190     bool mCalcelEnabled;
    191     const ulong mOpCount;
    192     ulong mCurOp;
    193     bool mEnded;
    194 
    195     static const char *sOpDescTpl;
    196 };
    197 
    198 const char *VBoxProgressDialog::sOpDescTpl = "%1... (%2/%3)";
    199 
    200 ////////////////////////////////////////////////////////////////////////////////
    201 // VBoxHelpActions class
    202 ////////////////////////////////////////////////////////////////////////////////
    20329
    20430void VBoxHelpActions::setup (QObject *aParent)
     
    301127}
    302128
    303 ////////////////////////////////////////////////////////////////////////////////
    304 // VBoxProblemReporter class
    305 ////////////////////////////////////////////////////////////////////////////////
    306 
    307 /**
    308  *  Returns a reference to the global VirtualBox problem reporter instance.
    309  */
    310 VBoxProblemReporter &VBoxProblemReporter::instance()
    311 {
    312     static VBoxProblemReporter vboxProblem_instance;
    313     return vboxProblem_instance;
    314 }
    315 
    316 bool VBoxProblemReporter::isValid() const
    317 {
    318     return qApp != 0;
    319 }
    320 
    321 // Helpers
    322 /////////////////////////////////////////////////////////////////////////////
    323 
    324 /**
    325  *  Shows a message box of the given type with the given text and with buttons
    326  *  according to arguments b1, b2 and b3 (in the same way as QMessageBox does
    327  *  it), and returns the user's choice.
    328  *
    329  *  When all button arguments are zero, a single 'Ok' button is shown.
    330  *
    331  *  If aAutoConfirmId is not null, then the message box will contain a
    332  *  checkbox "Don't show this message again" below the message text and its
    333  *  state will be saved in the global config. When the checkbox is in the
    334  *  checked state, this method doesn't actually show the message box but
    335  *  returns immediately. The return value in this case is the same as if the
    336  *  user has pressed the Enter key or the default button, but with
    337  *  AutoConfirmed bit set (AutoConfirmed alone is returned when no default
    338  *  button is defined in button arguments).
    339  *
    340  *  @param  aParent
    341  *      Parent widget or 0 to use the desktop as the parent. Also,
    342  *      #mainWindowShown can be used to determine the currently shown VBox
    343  *      main window (Selector or Console).
    344  *  @param  aType
    345  *      One of values of the Type enum, that defines the message box
    346  *      title and icon.
    347  *  @param  aMessage
    348  *      Message text to display (can contain sinmple Qt-html tags).
    349  *  @param  aDetails
    350  *      Detailed message description displayed under the main message text using
    351  *      QTextEdit (that provides rich text support and scrollbars when necessary).
    352  *      If equals to QString::null, no details text box is shown.
    353  *  @param  aAutoConfirmId
    354  *      ID used to save the auto confirmation state across calls. If null,
    355  *      the auto confirmation feature is turned off (and no checkbox is shown)
    356  *  @param  aButton1
    357  *      First button code or 0, see QIMessageBox for a list of codes.
    358  *  @param  aButton2
    359  *      Second button code or 0, see QIMessageBox for a list of codes.
    360  *  @param  aButton3
    361  *      Third button code or 0, see QIMessageBox for a list of codes.
    362  *  @param  aText1
    363  *      Optional custom text for the first button.
    364  *  @param  aText2
    365  *      Optional custom text for the second button.
    366  *  @param  aText3
    367  *      Optional custom text for the third button.
    368  *
    369  *  @return
    370  *      code of the button pressed by the user
    371  */
    372 int VBoxProblemReporter::message (QWidget *aParent, Type aType, const QString &aMessage,
    373                                   const QString &aDetails /* = QString::null */,
    374                                   const char *aAutoConfirmId /* = 0 */,
    375                                   int aButton1 /* = 0 */, int aButton2 /* = 0 */,
    376                                   int aButton3 /* = 0 */,
    377                                   const QString &aText1 /* = QString::null */,
    378                                   const QString &aText2 /* = QString::null */,
    379                                   const QString &aText3 /* = QString::null */) const
    380 {
    381     if (aButton1 == 0 && aButton2 == 0 && aButton3 == 0)
    382         aButton1 = QIMessageBox::Ok | QIMessageBox::Default;
    383 
    384     CVirtualBox vbox;
    385     QStringList msgs;
    386 
    387     if (aAutoConfirmId)
    388     {
    389         vbox = vboxGlobal().virtualBox();
    390         msgs = vbox.GetExtraData (VBoxDefs::GUI_SuppressMessages).split (',');
    391         if (msgs.contains (aAutoConfirmId)) {
    392             int rc = AutoConfirmed;
    393             if (aButton1 & QIMessageBox::Default)
    394                 rc |= (aButton1 & QIMessageBox::ButtonMask);
    395             if (aButton2 & QIMessageBox::Default)
    396                 rc |= (aButton2 & QIMessageBox::ButtonMask);
    397             if (aButton3 & QIMessageBox::Default)
    398                 rc |= (aButton3 & QIMessageBox::ButtonMask);
    399             return rc;
    400         }
    401     }
    402 
    403     QString title;
    404     QIMessageBox::Icon icon;
    405 
    406     switch (aType)
    407     {
    408         default:
    409         case Info:
    410             title = tr ("VirtualBox - Information", "msg box title");
    411             icon = QIMessageBox::Information;
    412             break;
    413         case Question:
    414             title = tr ("VirtualBox - Question", "msg box title");
    415             icon = QIMessageBox::Question;
    416             break;
    417         case Warning:
    418             title = tr ("VirtualBox - Warning", "msg box title");
    419             icon = QIMessageBox::Warning;
    420             break;
    421         case Error:
    422             title = tr ("VirtualBox - Error", "msg box title");
    423             icon = QIMessageBox::Critical;
    424             break;
    425         case Critical:
    426             title = tr ("VirtualBox - Critical Error", "msg box title");
    427             icon = QIMessageBox::Critical;
    428             break;
    429         case GuruMeditation:
    430             title = "VirtualBox - Guru Meditation"; /* don't translate this */
    431             icon = QIMessageBox::GuruMeditation;
    432             break;
    433     }
    434 
    435     QIMessageBox *box = new QIMessageBox (title, aMessage, icon, aButton1, aButton2,
    436                                           aButton3, aParent, aAutoConfirmId);
    437 
    438     if (!aText1.isNull())
    439         box->setButtonText (0, aText1);
    440     if (!aText2.isNull())
    441         box->setButtonText (1, aText2);
    442     if (!aText3.isNull())
    443         box->setButtonText (2, aText3);
    444 
    445     if (!aDetails.isEmpty())
    446     {
    447         box->setDetailsText (aDetails);
    448         box->setDetailsShown (true);
    449     }
    450 
    451     if (aAutoConfirmId)
    452     {
    453         box->setFlagText (tr ("Do not show this message again", "msg box flag"));
    454         box->setFlagChecked (false);
    455     }
    456 
    457     int rc = box->exec();
    458 
    459     if (aAutoConfirmId)
    460     {
    461         if (box->isFlagChecked())
    462         {
    463             msgs << aAutoConfirmId;
    464             vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, msgs.join (","));
    465         }
    466     }
    467 
    468     delete box;
    469 
    470     return rc;
    471 }
    472 
    473 /** @fn message (QWidget *, Type, const QString &, const char *, int, int,
    474  *               int, const QString &, const QString &, const QString &)
    475  *
    476  *  A shortcut to #message() that doesn't require to specify the details
    477  *  text (QString::null is assumed).
    478  */
    479 
    480 /** @fn messageYesNo (QWidget *, Type, const QString &, const QString &, const char *)
    481  *
    482  *  A shortcut to #message() that shows 'Yes' and 'No' buttons ('Yes' is the
    483  *  default) and returns true when the user selects Yes.
    484  */
    485 
    486 /** @fn messageYesNo (QWidget *, Type, const QString &, const char *)
    487  *
    488  *  A shortcut to #messageYesNo() that doesn't require to specify the details
    489  *  text (QString::null is assumed).
    490  */
    491 
    492 /**
    493  *  Shows a modal progress dialog using a CProgress object passed as an
    494  *  argument to track the progress.
    495  *
    496  *  @param aProgress    progress object to track
    497  *  @param aTitle       title prefix
    498  *  @param aParent      parent widget
    499  *  @param aMinDuration time (ms) that must pass before the dialog appears
    500  */
    501 bool VBoxProblemReporter::showModalProgressDialog (
    502     CProgress &aProgress, const QString &aTitle, QWidget *aParent,
    503     int aMinDuration)
    504 {
    505     QApplication::setOverrideCursor (QCursor (Qt::WaitCursor));
    506 
    507     VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration,
    508                                     aParent);
    509 
    510     /* run the dialog with the 100 ms refresh interval */
    511     progressDlg.run (100);
    512 
    513     QApplication::restoreOverrideCursor();
    514 
    515     return true;
    516 }
    517 
    518 /**
    519  *  Returns what main window (selector or console) is now shown, or
    520  *  zero if none of them. The selector window takes precedence.
    521  */
    522 QWidget *VBoxProblemReporter::mainWindowShown() const
    523 {
    524     /* It may happen that this method is called during VBoxGlobal
    525      * initialization or even after it failed (for example, to show some
    526      * error message). Return no main window in this case. */
    527     if (!vboxGlobal().isValid())
    528         return 0;
    529 
    530 #if defined (VBOX_GUI_SEPARATE_VM_PROCESS)
    531     if (vboxGlobal().isVMConsoleProcess())
    532     {
    533         if (vboxGlobal().consoleWnd().isVisible())
    534             return &vboxGlobal().consoleWnd();
    535     }
    536     else
    537     {
    538         if (vboxGlobal().selectorWnd().isVisible())
    539             return &vboxGlobal().selectorWnd();
    540     }
    541 #else
    542     if (vboxGlobal().consoleWnd().isVisible())
    543         return &vboxGlobal().consoleWnd();
    544     if (vboxGlobal().selectorWnd().isVisible())
    545         return &vboxGlobal().selectorWnd();
    546 #endif
    547     return 0;
    548 }
    549 
    550 // Generic Problem handlers
    551 /////////////////////////////////////////////////////////////////////////////
    552 
    553 bool VBoxProblemReporter::askForOverridingFileIfExists (const QString& aPath, QWidget *aParent /* = NULL */) const
    554 {
    555     QFileInfo fi (aPath);
    556     if (fi.exists())
    557         return messageYesNo (aParent, Question, tr ("A file named <b>%1</b> already exists. Are you sure you want to replace it?<br /><br />The file already exists in \"%2\". Replacing it will overwrite its contents.").arg (fi.fileName()). arg (fi.absolutePath()));
    558     else
    559         return true;
    560 }
    561 
    562 // Special Problem handlers
    563 /////////////////////////////////////////////////////////////////////////////
    564 
    565 #ifdef Q_WS_X11
    566 void VBoxProblemReporter::cannotFindLicenseFiles (const QString &aPath)
    567 {
    568     message
    569         (0, VBoxProblemReporter::Error,
    570          tr ("Failed to find license files in "
    571              "<nobr><b>%1</b></nobr>.")
    572              .arg (aPath));
    573 }
    574 
    575 void VBoxProblemReporter::cannotOpenLicenseFile (QWidget *aParent,
    576                                                  const QString &aPath)
    577 {
    578     message
    579         (aParent, VBoxProblemReporter::Error,
    580          tr ("Failed to open the license file <nobr><b>%1</b></nobr>. "
    581              "Check file permissions.")
    582              .arg (aPath));
    583 }
    584 #endif
    585 
    586 void VBoxProblemReporter::cannotOpenURL (const QString &aURL)
    587 {
    588     message
    589         (mainWindowShown(), VBoxProblemReporter::Error,
    590          tr ("Failed to open <tt>%1</tt>. Make sure your desktop environment "
    591              "can properly handle URLs of this type.")
    592          .arg (aURL));
    593 }
    594 
    595 void VBoxProblemReporter::
    596 cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC)
    597 {
    598     PCRTSTATUSMSG msg = RTErrGet (aVRC);
    599     Assert (msg);
    600 
    601     QString err = QString ("%1: %2").arg (msg->pszDefine, msg->pszMsgShort);
    602     if (err.endsWith ("."))
    603         err.truncate (err.length() - 1);
    604 
    605     message (mainWindowShown(), VBoxProblemReporter::Error,
    606         tr ("Failed to copy file <b><nobr>%1</nobr></b> to "
    607              "<b><nobr>%2</nobr></b> (%3).")
    608              .arg (aSrc, aDst, err));
    609 }
    610 
    611 void VBoxProblemReporter::cannotFindLanguage (const QString &aLangID,
    612                                               const QString &aNlsPath)
    613 {
    614     message (0, VBoxProblemReporter::Error,
    615         tr ("<p>Could not find a language file for the language "
    616             "<b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>"
    617             "<p>The language will be temporarily reset to the system "
    618             "default language. Please go to the <b>Preferences</b> "
    619             "dialog which you can open from the <b>File</b> menu of the "
    620             "main VirtualBox window, and select one of the existing "
    621             "languages on the <b>Language</b> page.</p>")
    622              .arg (aLangID).arg (aNlsPath));
    623 }
    624 
    625 void VBoxProblemReporter::cannotLoadLanguage (const QString &aLangFile)
    626 {
    627     message (0, VBoxProblemReporter::Error,
    628         tr ("<p>Could not load the language file <b><nobr>%1</nobr></b>. "
    629             "<p>The language will be temporarily reset to English (built-in). "
    630             "Please go to the <b>Preferences</b> "
    631             "dialog which you can open from the <b>File</b> menu of the "
    632             "main VirtualBox window, and select one of the existing "
    633             "languages on the <b>Language</b> page.</p>")
    634              .arg (aLangFile));
    635 }
    636 
    637 void VBoxProblemReporter::cannotInitCOM (HRESULT rc)
    638 {
    639     message (0, Critical,
    640         tr ("<p>Failed to initialize COM or to find the VirtualBox COM server. "
    641             "Most likely, the VirtualBox server is not running "
    642             "or failed to start.</p>"
    643             "<p>The application will now terminate.</p>"),
    644         formatErrorInfo (COMErrorInfo(), rc));
    645 }
    646 
    647 void VBoxProblemReporter::cannotCreateVirtualBox (const CVirtualBox &vbox)
    648 {
    649     message (0, Critical,
    650         tr ("<p>Failed to create the VirtualBox COM object.</p>"
    651             "<p>The application will now terminate.</p>"),
    652         formatErrorInfo (vbox));
    653 }
    654 
    655 void VBoxProblemReporter::cannotSaveGlobalSettings (const CVirtualBox &vbox,
    656                                                     QWidget *parent /* = 0 */)
    657 {
    658     /* preserve the current error info before calling the object again */
    659     COMResult res (vbox);
    660 
    661     message (parent ? parent : mainWindowShown(), Error,
    662              tr ("<p>Failed to save the global VirtualBox settings to "
    663                  "<b><nobr>%1</nobr></b>.</p>")
    664                  .arg (vbox.GetSettingsFilePath()),
    665              formatErrorInfo (res));
    666 }
    667 
    668 void VBoxProblemReporter::cannotLoadGlobalConfig (const CVirtualBox &vbox,
    669                                                   const QString &error)
    670 {
    671     /* preserve the current error info before calling the object again */
    672     COMResult res (vbox);
    673 
    674     message (mainWindowShown(), Critical,
    675         tr ("<p>Failed to load the global GUI configuration from "
    676             "<b><nobr>%1</nobr></b>.</p>"
    677             "<p>The application will now terminate.</p>")
    678              .arg (vbox.GetSettingsFilePath()),
    679         !res.isOk() ? formatErrorInfo (res)
    680                     : QString ("<p>%1.</p>").arg (vboxGlobal().emphasize (error)));
    681 }
    682 
    683 void VBoxProblemReporter::cannotSaveGlobalConfig (const CVirtualBox &vbox)
    684 {
    685     /* preserve the current error info before calling the object again */
    686     COMResult res (vbox);
    687 
    688     message (mainWindowShown(), Critical,
    689         tr ("<p>Failed to save the global GUI configuration to "
    690             "<b><nobr>%1</nobr></b>.</p>"
    691             "<p>The application will now terminate.</p>")
    692              .arg (vbox.GetSettingsFilePath()),
    693         formatErrorInfo (res));
    694 }
    695 
    696 void VBoxProblemReporter::cannotSetSystemProperties (const CSystemProperties &props)
    697 {
    698     message (mainWindowShown(), Critical,
    699         tr ("Failed to set global VirtualBox properties."),
    700         formatErrorInfo (props));
    701 }
    702 
    703 void VBoxProblemReporter::cannotAccessUSB (const COMBaseWithEI &aObj)
    704 {
    705     /* If IMachine::GetUSBController(), IHost::GetUSBDevices() etc. return
    706      * E_NOTIMPL, it means the USB support is intentionally missing
    707      * (as in the OSE version). Don't show the error message in this case. */
    708     COMResult res (aObj);
    709     if (res.rc() == E_NOTIMPL)
    710         return;
    711 
    712 #ifdef RT_OS_LINUX
    713     /* xxx There is no macro to turn an error into a warning, but we need
    714      *     to do that here. */
    715     if (res.rc() == (VBOX_E_HOST_ERROR & ~0x80000000))
    716     {
    717         message (mainWindowShown(), VBoxProblemReporter::Warning,
    718                  tr ("Could not access USB on the host system, because "
    719                      "neither the USB file system (usbfs) nor the DBus "
    720                      "and hal services are currently available. If you "
    721                      "wish to use host USB devices inside guest systems, "
    722                      "you must correct this and restart VirtualBox."),
    723                  formatErrorInfo (res),
    724                  "cannotAccessUSB" /* aAutoConfirmId */);
    725         return;
    726     }
    727 #endif
    728     message (mainWindowShown(), res.isWarning() ? Warning : Error,
    729              tr ("Failed to access the USB subsystem."),
    730              formatErrorInfo (res),
    731              "cannotAccessUSB");
    732 }
    733 
    734 void VBoxProblemReporter::cannotCreateMachine (const CVirtualBox &vbox,
    735                                                QWidget *parent /* = 0 */)
    736 {
    737     message (
    738         parent ? parent : mainWindowShown(),
    739         Error,
    740         tr ("Failed to create a new virtual machine."),
    741         formatErrorInfo (vbox)
    742     );
    743 }
    744 
    745 void VBoxProblemReporter::cannotCreateMachine (const CVirtualBox &vbox,
    746                                                const CMachine &machine,
    747                                                QWidget *parent /* = 0 */)
    748 {
    749     message (
    750         parent ? parent : mainWindowShown(),
    751         Error,
    752         tr ("Failed to create a new virtual machine <b>%1</b>.")
    753             .arg (machine.GetName()),
    754         formatErrorInfo (vbox)
    755     );
    756 }
    757 
    758 void VBoxProblemReporter::
    759 cannotApplyMachineSettings (const CMachine &machine, const COMResult &res)
    760 {
    761     message (
    762         mainWindowShown(),
    763         Error,
    764         tr ("Failed to apply the settings to the virtual machine <b>%1</b>.")
    765             .arg (machine.GetName()),
    766         formatErrorInfo (res)
    767     );
    768 }
    769 
    770 void VBoxProblemReporter::cannotSaveMachineSettings (const CMachine &machine,
    771                                                      QWidget *parent /* = 0 */)
    772 {
    773     /* preserve the current error info before calling the object again */
    774     COMResult res (machine);
    775 
    776     message (parent ? parent : mainWindowShown(), Error,
    777              tr ("Failed to save the settings of the virtual machine "
    778                  "<b>%1</b> to <b><nobr>%2</nobr></b>.")
    779                  .arg (machine.GetName(), machine.GetSettingsFilePath()),
    780              formatErrorInfo (res));
    781 }
    782 
    783 /**
    784  * @param  strict  If |false|, this method will silently return if the COM
    785  *                 result code is E_NOTIMPL.
    786  */
    787 void VBoxProblemReporter::cannotLoadMachineSettings (const CMachine &machine,
    788                                                      bool strict /* = true */,
    789                                                      QWidget *parent /* = 0 */)
    790 {
    791     /* If COM result code is E_NOTIMPL, it means the requested object or
    792      * function is intentionally missing (as in the OSE version). Don't show
    793      * the error message in this case. */
    794     COMResult res (machine);
    795     if (!strict && res.rc() == E_NOTIMPL)
    796         return;
    797 
    798     message (parent ? parent : mainWindowShown(), Error,
    799              tr ("Failed to load the settings of the virtual machine "
    800                  "<b>%1</b> from <b><nobr>%2</nobr></b>.")
    801                 .arg (machine.GetName(), machine.GetSettingsFilePath()),
    802              formatErrorInfo (res));
    803 }
    804 
    805 void VBoxProblemReporter::cannotStartMachine (const CConsole &console)
    806 {
    807     /* preserve the current error info before calling the object again */
    808     COMResult res (console);
    809 
    810     message (mainWindowShown(), Error,
    811         tr ("Failed to start the virtual machine <b>%1</b>.")
    812             .arg (console.GetMachine().GetName()),
    813         formatErrorInfo (res));
    814 }
    815 
    816 void VBoxProblemReporter::cannotStartMachine (const CProgress &progress)
    817 {
    818     AssertWrapperOk (progress);
    819     CConsole console (CProgress (progress).GetInitiator());
    820     AssertWrapperOk (console);
    821 
    822     message (
    823         mainWindowShown(),
    824         Error,
    825         tr ("Failed to start the virtual machine <b>%1</b>.")
    826             .arg (console.GetMachine().GetName()),
    827         formatErrorInfo (progress.GetErrorInfo())
    828     );
    829 }
    830 
    831 void VBoxProblemReporter::cannotPauseMachine (const CConsole &console)
    832 {
    833     /* preserve the current error info before calling the object again */
    834     COMResult res (console);
    835 
    836     message (mainWindowShown(), Error,
    837         tr ("Failed to pause the execution of the virtual machine <b>%1</b>.")
    838             .arg (console.GetMachine().GetName()),
    839         formatErrorInfo (res));
    840 }
    841 
    842 void VBoxProblemReporter::cannotResumeMachine (const CConsole &console)
    843 {
    844     /* preserve the current error info before calling the object again */
    845     COMResult res (console);
    846 
    847     message (mainWindowShown(),  Error,
    848         tr ("Failed to resume the execution of the virtual machine <b>%1</b>.")
    849             .arg (console.GetMachine().GetName()),
    850         formatErrorInfo (res));
    851 }
    852 
    853 void VBoxProblemReporter::cannotACPIShutdownMachine (const CConsole &console)
    854 {
    855     /* preserve the current error info before calling the object again */
    856     COMResult res (console);
    857 
    858     message (mainWindowShown(),  Error,
    859         tr ("Failed to send the ACPI Power Button press event to the "
    860             "virtual machine <b>%1</b>.")
    861             .arg (console.GetMachine().GetName()),
    862         formatErrorInfo (res));
    863 }
    864 
    865 void VBoxProblemReporter::cannotSaveMachineState (const CConsole &console)
    866 {
    867     /* preserve the current error info before calling the object again */
    868     COMResult res (console);
    869 
    870     message (mainWindowShown(), Error,
    871         tr ("Failed to save the state of the virtual machine <b>%1</b>.")
    872             .arg (console.GetMachine().GetName()),
    873         formatErrorInfo (res));
    874 }
    875 
    876 void VBoxProblemReporter::cannotSaveMachineState (const CProgress &progress)
    877 {
    878     AssertWrapperOk (progress);
    879     CConsole console (CProgress (progress).GetInitiator());
    880     AssertWrapperOk (console);
    881 
    882     message (
    883         mainWindowShown(),
    884         Error,
    885         tr ("Failed to save the state of the virtual machine <b>%1</b>.")
    886             .arg (console.GetMachine().GetName()),
    887         formatErrorInfo (progress.GetErrorInfo())
    888     );
    889 }
    890 
    891 void VBoxProblemReporter::cannotTakeSnapshot (const CConsole &console)
    892 {
    893     /* preserve the current error info before calling the object again */
    894     COMResult res (console);
    895 
    896     message (mainWindowShown(), Error,
    897         tr ("Failed to create a snapshot of the virtual machine <b>%1</b>.")
    898             .arg (console.GetMachine().GetName()),
    899         formatErrorInfo (res));
    900 }
    901 
    902 void VBoxProblemReporter::cannotTakeSnapshot (const CProgress &progress)
    903 {
    904     AssertWrapperOk (progress);
    905     CConsole console (CProgress (progress).GetInitiator());
    906     AssertWrapperOk (console);
    907 
    908     message (
    909         mainWindowShown(),
    910         Error,
    911         tr ("Failed to create a snapshot of the virtual machine <b>%1</b>.")
    912             .arg (console.GetMachine().GetName()),
    913         formatErrorInfo (progress.GetErrorInfo())
    914     );
    915 }
    916 
    917 void VBoxProblemReporter::cannotStopMachine (const CConsole &console)
    918 {
    919     /* preserve the current error info before calling the object again */
    920     COMResult res (console);
    921 
    922     message (mainWindowShown(), Error,
    923         tr ("Failed to stop the virtual machine <b>%1</b>.")
    924             .arg (console.GetMachine().GetName()),
    925         formatErrorInfo (res));
    926 }
    927 
    928 void VBoxProblemReporter::cannotStopMachine (const CProgress &progress)
    929 {
    930     AssertWrapperOk (progress);
    931     CConsole console (CProgress (progress).GetInitiator());
    932     AssertWrapperOk (console);
    933 
    934     message (mainWindowShown(), Error,
    935         tr ("Failed to stop the virtual machine <b>%1</b>.")
    936             .arg (console.GetMachine().GetName()),
    937         formatErrorInfo (progress.GetErrorInfo()));
    938 }
    939 
    940 void VBoxProblemReporter::cannotDeleteMachine (const CVirtualBox &vbox,
    941                                                const CMachine &machine)
    942 {
    943     /* preserve the current error info before calling the object again */
    944     COMResult res (machine);
    945 
    946     message (mainWindowShown(), Error,
    947         tr ("Failed to remove the virtual machine <b>%1</b>.")
    948             .arg (machine.GetName()),
    949         !vbox.isOk() ? formatErrorInfo (vbox) : formatErrorInfo (res));
    950 }
    951 
    952 void VBoxProblemReporter::cannotDiscardSavedState (const CConsole &console)
    953 {
    954     /* preserve the current error info before calling the object again */
    955     COMResult res (console);
    956 
    957     message (mainWindowShown(), Error,
    958         tr ("Failed to discard the saved state of the virtual machine <b>%1</b>.")
    959             .arg (console.GetMachine().GetName()),
    960         formatErrorInfo (res));
    961 }
    962 
    963 void VBoxProblemReporter::cannotSendACPIToMachine()
    964 {
    965     message (mainWindowShown(),  Warning,
    966         tr ("You are trying to shut down the guest with the ACPI power "
    967             "button. This is currently not possible because the guest "
    968             "does not use the ACPI subsystem."));
    969 }
    970 
    971 bool VBoxProblemReporter::warnAboutVirtNotEnabled()
    972 {
    973     return messageOkCancel (mainWindowShown(), Error,
    974         tr ("<p>VT-x/AMD-V hardware acceleration has been enabled, but is "
    975             "not operational. Your 64 bits guest will fail to detect a 64 "
    976             "bits CPU and will not be able to boot.</p><p>Please check if you "
    977             "have enabled VT-x/AMD-V properly in the BIOS of your host "
    978             "computer.</p>"),
    979         0 /* aAutoConfirmId */,
    980         tr ("Close VM"), tr ("Continue"));
    981 }
    982 
    983 void VBoxProblemReporter::cannotSetSnapshotFolder (const CMachine &aMachine,
    984                                                    const QString &aPath)
    985 {
    986     message (
    987         mainWindowShown(),
    988         Error,
    989         tr ("Failed to change the snapshot folder path of the "
    990             "virtual machine <b>%1<b> to <nobr><b>%2</b></nobr>.")
    991             .arg (aMachine.GetName())
    992             .arg (aPath),
    993         formatErrorInfo (aMachine));
    994 }
    995 
    996 void VBoxProblemReporter::cannotDiscardSnapshot (const CConsole &aConsole,
    997                                                  const QString &aSnapshotName)
    998 {
    999     message (mainWindowShown(), Error,
    1000         tr ("Failed to discard the snapshot <b>%1</b> of the virtual "
    1001             "machine <b>%2</b>.")
    1002             .arg (aSnapshotName)
    1003             .arg (CConsole (aConsole).GetMachine().GetName()),
    1004         formatErrorInfo (aConsole));
    1005 }
    1006 
    1007 void VBoxProblemReporter::cannotDiscardSnapshot (const CProgress &aProgress,
    1008                                                  const QString &aSnapshotName)
    1009 {
    1010     CConsole console (CProgress (aProgress).GetInitiator());
    1011 
    1012     message (mainWindowShown(), Error,
    1013         tr ("Failed to discard the snapshot <b>%1</b> of the virtual "
    1014             "machine <b>%2</b>.")
    1015             .arg (aSnapshotName)
    1016             .arg (console.GetMachine().GetName()),
    1017         formatErrorInfo (aProgress.GetErrorInfo()));
    1018 }
    1019 
    1020 void VBoxProblemReporter::cannotDiscardCurrentState (const CConsole &console)
    1021 {
    1022     message (
    1023         mainWindowShown(),
    1024         Error,
    1025         tr ("Failed to discard the current state of the virtual "
    1026             "machine <b>%1</b>.")
    1027             .arg (CConsole (console).GetMachine().GetName()),
    1028         formatErrorInfo (console));
    1029 }
    1030 
    1031 void VBoxProblemReporter::cannotDiscardCurrentState (const CProgress &progress)
    1032 {
    1033     CConsole console (CProgress (progress).GetInitiator());
    1034 
    1035     message (
    1036         mainWindowShown(),
    1037         Error,
    1038         tr ("Failed to discard the current state of the virtual "
    1039             "machine <b>%1</b>.")
    1040             .arg (console.GetMachine().GetName()),
    1041         formatErrorInfo (progress.GetErrorInfo()));
    1042 }
    1043 
    1044 void VBoxProblemReporter::cannotDiscardCurrentSnapshotAndState (const CConsole &console)
    1045 {
    1046     message (
    1047         mainWindowShown(),
    1048         Error,
    1049         tr ("Failed to discard the current snapshot and the current state "
    1050             "of the virtual machine <b>%1</b>.")
    1051             .arg (CConsole (console).GetMachine().GetName()),
    1052         formatErrorInfo (console));
    1053 }
    1054 
    1055 void VBoxProblemReporter::cannotDiscardCurrentSnapshotAndState (const CProgress &progress)
    1056 {
    1057     CConsole console (CProgress (progress).GetInitiator());
    1058 
    1059     message (
    1060         mainWindowShown(),
    1061         Error,
    1062         tr ("Failed to discard the current snapshot and the current state "
    1063             "of the virtual machine <b>%1</b>.")
    1064             .arg (console.GetMachine().GetName()),
    1065         formatErrorInfo (progress.GetErrorInfo()));
    1066 }
    1067 
    1068 void VBoxProblemReporter::cannotFindMachineByName (const CVirtualBox &vbox,
    1069                                                    const QString &name)
    1070 {
    1071     message (
    1072         mainWindowShown(),
    1073         Error,
    1074         tr ("There is no virtual machine named <b>%1</b>.")
    1075             .arg (name),
    1076         formatErrorInfo (vbox)
    1077     );
    1078 }
    1079 
    1080 void VBoxProblemReporter::cannotEnterSeamlessMode (ULONG /* aWidth */,
    1081                                                    ULONG /* aHeight */,
    1082                                                    ULONG /* aBpp */,
    1083                                                    ULONG64 aMinVRAM)
    1084 {
    1085     message (&vboxGlobal().consoleWnd(), Error,
    1086              tr ("<p>Could not enter seamless mode due to insufficient guest "
    1087                   "video memory.</p>"
    1088                   "<p>You should configure the virtual machine to have at "
    1089                   "least <b>%1</b> of video memory.</p>")
    1090              .arg (VBoxGlobal::formatSize (aMinVRAM)));
    1091 }
    1092 
    1093 int VBoxProblemReporter::cannotEnterFullscreenMode (ULONG /* aWidth */,
    1094                                                     ULONG /* aHeight */,
    1095                                                     ULONG /* aBpp */,
    1096                                                     ULONG64 aMinVRAM)
    1097 {
    1098     return message (&vboxGlobal().consoleWnd(), Warning,
    1099              tr ("<p>Could not switch the guest display to fullscreen mode due "
    1100                  "to insufficient guest video memory.</p>"
    1101                  "<p>You should configure the virtual machine to have at "
    1102                  "least <b>%1</b> of video memory.</p>"
    1103                  "<p>Press <b>Ignore</b> to switch to fullscreen mode anyway "
    1104                  "or press <b>Cancel</b> to cancel the operation.</p>")
    1105              .arg (VBoxGlobal::formatSize (aMinVRAM)),
    1106              0, /* aAutoConfirmId */
    1107              QIMessageBox::Ignore | QIMessageBox::Default,
    1108              QIMessageBox::Cancel | QIMessageBox::Escape);
    1109 }
    1110 
    1111 bool VBoxProblemReporter::confirmMachineDeletion (const CMachine &machine)
    1112 {
    1113     QString msg;
    1114     QString button;
    1115     QString name;
    1116 
    1117     if (machine.GetAccessible())
    1118     {
    1119         name = machine.GetName();
    1120         msg = tr ("<p>Are you sure you want to permanently delete "
    1121                   "the virtual machine <b>%1</b>?</p>"
    1122                   "<p>This operation cannot be undone.</p>")
    1123                   .arg (name);
    1124         button = tr ("Delete", "machine");
    1125     }
    1126     else
    1127     {
    1128         /* this should be in sync with VBoxVMListBoxItem::recache() */
    1129         QFileInfo fi (machine.GetSettingsFilePath());
    1130         name = fi.suffix().toLower() == "xml" ?
    1131                fi.completeBaseName() : fi.fileName();
    1132         msg = tr ("<p>Are you sure you want to unregister the inaccessible "
    1133                   "virtual machine <b>%1</b>?</p>"
    1134                   "<p>You will no longer be able to register it back from "
    1135                   "GUI.</p>")
    1136                   .arg (name);
    1137         button = tr ("Unregister", "machine");
    1138     }
    1139 
    1140     return messageOkCancel (&vboxGlobal().selectorWnd(), Question, msg,
    1141                             0 /* aAutoConfirmId */, button);
    1142 }
    1143 
    1144 bool VBoxProblemReporter::confirmDiscardSavedState (const CMachine &machine)
    1145 {
    1146     return messageOkCancel (&vboxGlobal().selectorWnd(), Question,
    1147         tr ("<p>Are you sure you want to discard the saved state of "
    1148             "the virtual machine <b>%1</b>?</p>"
    1149             "<p>This operation is equivalent to resetting or powering off "
    1150             "the machine without doing a proper shutdown by means of the "
    1151             "guest OS.</p>")
    1152             .arg (machine.GetName()),
    1153         0 /* aAutoConfirmId */,
    1154         tr ("Discard", "saved state"));
    1155 }
    1156 
    1157 bool VBoxProblemReporter::confirmReleaseMedium (QWidget *aParent,
    1158                                                 const VBoxMedium &aMedium,
    1159                                                 const QString &aUsage)
    1160 {
    1161     /** @todo (translation-related): the gender of "the" in translations
    1162      * will depend on the gender of aMedium.type(). */
    1163     return messageOkCancel (aParent, Question,
    1164         tr ("<p>Are you sure you want to release the %1 "
    1165             "<nobr><b>%2</b></nobr>?</p>"
    1166             "<p>This will detach it from the "
    1167             "following virtual machine(s): <b>%3</b>.</p>")
    1168             .arg (toAccusative (aMedium.type()))
    1169             .arg (aMedium.location())
    1170             .arg (aUsage),
    1171         0 /* aAutoConfirmId */,
    1172         tr ("Release", "detach medium"));
    1173 }
    1174 
    1175 bool VBoxProblemReporter::confirmRemoveMedium (QWidget *aParent,
    1176                                                const VBoxMedium &aMedium)
    1177 {
    1178     /** @todo (translation-related): the gender of "the" in translations
    1179      * will depend on the gender of aMedium.type(). */
    1180     QString msg =
    1181         tr ("<p>Are you sure you want to remove the %1 "
    1182             "<nobr><b>%2</b></nobr> from the list of known media?</p>")
    1183             .arg (toAccusative (aMedium.type()))
    1184             .arg (aMedium.location());
    1185 
    1186     if (aMedium.type() == VBoxDefs::MediaType_HardDisk)
    1187     {
    1188         if (aMedium.state() == KMediaState_Inaccessible)
    1189             msg +=
    1190                 tr ("Note that this hard disk is inaccessible so that its "
    1191                     "storage unit cannot be deleted right now.");
    1192         else
    1193             msg +=
    1194                 tr ("The next dialog will let you choose whether you also "
    1195                     "want to delete the storage unit of this hard disk or "
    1196                     "keep it for later usage.");
    1197     }
    1198     else
    1199         msg +=
    1200             tr ("<p>Note that the storage unit of this medium will not be "
    1201                 "deleted and therefore it will be possible to add it to "
    1202                 "the list later again.</p>");
    1203 
    1204     return messageOkCancel (aParent, Question, msg,
    1205         "confirmRemoveMedium", /* aAutoConfirmId */
    1206         tr ("Remove", "medium"));
    1207 }
    1208 
    1209 void VBoxProblemReporter::sayCannotOverwriteHardDiskStorage (
    1210     QWidget *aParent, const QString &aLocation)
    1211 {
    1212     message (aParent, Info,
    1213         tr ("<p>The hard disk storage unit at location <b>%1</b> already "
    1214             "exists. You cannot create a new virtual hard disk that uses this "
    1215             "location because it can be already used by another virtual hard "
    1216             "disk.</p>"
    1217             "<p>Please specify a different location.</p>")
    1218             .arg (aLocation));
    1219 }
    1220 
    1221 int VBoxProblemReporter::confirmDeleteHardDiskStorage (
    1222     QWidget *aParent, const QString &aLocation)
    1223 {
    1224     return message (aParent, Question,
    1225         tr ("<p>Do you want to delete the storage unit of the hard disk "
    1226             "<nobr><b>%1</b></nobr>?</p>"
    1227             "<p>If you select <b>Delete</b> then the specified storage unit "
    1228             "will be permanently deleted. This operation <b>cannot be "
    1229             "undone</b>.</p>"
    1230             "<p>If you select <b>Keep</b> then the hard disk will be only "
    1231             "removed from the list of known hard disks, but the storage unit "
    1232             "will be left untouched which makes it possible to add this hard "
    1233             "disk to the list later again.</p>")
    1234             .arg (aLocation),
    1235         0, /* aAutoConfirmId */
    1236         QIMessageBox::Yes,
    1237         QIMessageBox::No | QIMessageBox::Default,
    1238         QIMessageBox::Cancel | QIMessageBox::Escape,
    1239         tr ("Delete", "hard disk storage"),
    1240         tr ("Keep", "hard disk storage"));
    1241 }
    1242 
    1243 void VBoxProblemReporter::cannotDeleteHardDiskStorage (QWidget *aParent,
    1244                                                        const CHardDisk &aHD,
    1245                                                        const CProgress &aProgress)
    1246 {
    1247     /* below, we use CHardDisk (aHD) to preserve current error info
    1248      * for formatErrorInfo() */
    1249 
    1250     message (aParent, Error,
    1251         tr ("Failed to delete the storage unit of the hard disk <b>%1</b>.")
    1252             .arg (CHardDisk (aHD).GetLocation()),
    1253         !aHD.isOk() ? formatErrorInfo (aHD) :
    1254         !aProgress.isOk() ? formatErrorInfo (aProgress) :
    1255         formatErrorInfo (aProgress.GetErrorInfo()));
    1256 }
    1257 
    1258 int VBoxProblemReporter::confirmDetachSATASlots (QWidget *aParent)
    1259 {
    1260     return messageOkCancel (aParent, Question,
    1261         tr ("<p>There are hard disks attached to SATA ports of this virtual "
    1262             "machine. If you disable the SATA controller, all these hard disks "
    1263             "will be automatically detached.</p>"
    1264             "<p>Are you sure that you want to "
    1265             "disable the SATA controller?</p>"),
    1266         0 /* aAutoConfirmId */,
    1267         tr ("Disable", "hard disk"));
    1268 }
    1269 
    1270 int VBoxProblemReporter::confirmRunNewHDWzdOrVDM (QWidget* aParent)
    1271 {
    1272     return message (aParent, Info,
    1273         tr ("<p>There are no unused hard disks available for the newly created "
    1274             "attachment.</p>"
    1275             "<p>Press the <b>Create</b> button to start the <i>New Virtual "
    1276             "Disk</i> wizard and create a new hard disk, or press the "
    1277             "<b>Select</b> button to open the <i>Virtual Media Manager</i> "
    1278             "and select what to do.</p>"),
    1279         0, /* aAutoConfirmId */
    1280         QIMessageBox::Yes,
    1281         QIMessageBox::No | QIMessageBox::Default,
    1282         QIMessageBox::Cancel | QIMessageBox::Escape,
    1283         tr ("&Create", "hard disk"),
    1284         tr ("Select", "hard disk"));
    1285 }
    1286 
    1287 void VBoxProblemReporter::cannotCreateHardDiskStorage (
    1288     QWidget *aParent, const CVirtualBox &aVBox, const QString &aLocation,
    1289     const CHardDisk &aHD, const CProgress &aProgress)
    1290 {
    1291     message (aParent, Error,
    1292         tr ("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")
    1293             .arg (aLocation),
    1294         !aVBox.isOk() ? formatErrorInfo (aVBox) :
    1295         !aHD.isOk() ? formatErrorInfo (aHD) :
    1296         !aProgress.isOk() ? formatErrorInfo (aProgress) :
    1297         formatErrorInfo (aProgress.GetErrorInfo()));
    1298 }
    1299 
    1300 void VBoxProblemReporter::cannotAttachHardDisk (
    1301     QWidget *aParent, const CMachine &aMachine, const QString &aLocation,
    1302     KStorageBus aBus, LONG aChannel, LONG aDevice)
    1303 {
    1304     message (aParent, Error,
    1305         tr ("Failed to attach the hard disk <nobr><b>%1</b></nobr> "
    1306             "to the slot <i>%2</i> of the machine <b>%3</b>.")
    1307             .arg (aLocation)
    1308             .arg (vboxGlobal().toFullString (aBus, aChannel, aDevice))
    1309             .arg (CMachine (aMachine).GetName()),
    1310         formatErrorInfo (aMachine));
    1311 }
    1312 
    1313 void VBoxProblemReporter::cannotDetachHardDisk (
    1314     QWidget *aParent, const CMachine &aMachine, const QString &aLocation,
    1315     KStorageBus aBus, LONG aChannel, LONG aDevice)
    1316 {
    1317     message (aParent, Error,
    1318         tr ("Failed to detach the hard disk <nobr><b>%1</b></nobr> "
    1319             "from the slot <i>%2</i> of the machine <b>%3</b>.")
    1320             .arg (aLocation)
    1321             .arg (vboxGlobal().toFullString (aBus, aChannel, aDevice))
    1322             .arg (CMachine (aMachine).GetName()),
    1323          formatErrorInfo (aMachine));
    1324 }
    1325 
    1326 void VBoxProblemReporter::
    1327 cannotMountMedium (QWidget *aParent, const CMachine &aMachine,
    1328                    const VBoxMedium &aMedium, const COMResult &aResult)
    1329 {
    1330     /** @todo (translation-related): the gender of "the" in translations
    1331      * will depend on the gender of aMedium.type(). */
    1332     message (aParent, Error,
    1333         tr ("Failed to mount the %1 <nobr><b>%2</b></nobr> "
    1334             "to the machine <b>%3</b>.")
    1335             .arg (toAccusative (aMedium.type()))
    1336             .arg (aMedium.location())
    1337             .arg (CMachine (aMachine).GetName()),
    1338       formatErrorInfo (aResult));
    1339 }
    1340 
    1341 void VBoxProblemReporter::
    1342 cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine,
    1343                      const VBoxMedium &aMedium, const COMResult &aResult)
    1344 {
    1345     /** @todo (translation-related): the gender of "the" in translations
    1346      * will depend on the gender of aMedium.type(). */
    1347     message (aParent, Error,
    1348         tr ("Failed to unmount the %1 <nobr><b>%2</b></nobr> "
    1349             "from the machine <b>%3</b>.")
    1350             .arg (toAccusative (aMedium.type()))
    1351             .arg (aMedium.location())
    1352             .arg (CMachine (aMachine).GetName()),
    1353       formatErrorInfo (aResult));
    1354 }
    1355 
    1356 void VBoxProblemReporter::cannotOpenMedium (
    1357     QWidget *aParent, const CVirtualBox &aVBox,
    1358     VBoxDefs::MediaType aType, const QString &aLocation)
    1359 {
    1360     /** @todo (translation-related): the gender of "the" in translations
    1361      * will depend on the gender of aMedium.type(). */
    1362     message (aParent, Error,
    1363         tr ("Failed to open the %1 <nobr><b>%2</b></nobr>.")
    1364             .arg (toAccusative (aType))
    1365             .arg (aLocation),
    1366         formatErrorInfo (aVBox));
    1367 }
    1368 
    1369 void VBoxProblemReporter::cannotCloseMedium (
    1370     QWidget *aParent, const VBoxMedium &aMedium, const COMResult &aResult)
    1371 {
    1372     /** @todo (translation-related): the gender of "the" in translations
    1373      * will depend on the gender of aMedium.type(). */
    1374     message (aParent, Error,
    1375         tr ("Failed to close the %1 <nobr><b>%2</b></nobr>.")
    1376             .arg (toAccusative (aMedium.type()))
    1377             .arg (aMedium.location()),
    1378         formatErrorInfo (aResult));
    1379 }
    1380 
    1381 void VBoxProblemReporter::cannotOpenSession (const CSession &session)
    1382 {
    1383     Assert (session.isNull());
    1384 
    1385     message (
    1386         mainWindowShown(),
    1387         Error,
    1388         tr ("Failed to create a new session."),
    1389         formatErrorInfo (session)
    1390     );
    1391 }
    1392 
    1393 void VBoxProblemReporter::cannotOpenSession (
    1394     const CVirtualBox &vbox, const CMachine &machine,
    1395     const CProgress &progress
    1396 ) {
    1397     Assert (!vbox.isOk() || progress.isOk());
    1398 
    1399     QString name = machine.GetName();
    1400     if (name.isEmpty())
    1401         name = QFileInfo (machine.GetSettingsFilePath()).baseName();
    1402 
    1403     message (
    1404         mainWindowShown(),
    1405         Error,
    1406         tr ("Failed to open a session for the virtual machine <b>%1</b>.")
    1407             .arg (name),
    1408         !vbox.isOk() ? formatErrorInfo (vbox) :
    1409                        formatErrorInfo (progress.GetErrorInfo())
    1410     );
    1411 }
    1412 
    1413 void VBoxProblemReporter::cannotGetMediaAccessibility (const VBoxMedium &aMedium)
    1414 {
    1415     message (qApp->activeWindow(), Error,
    1416         tr ("Failed to get the accessibility state of the medium "
    1417             "<nobr><b>%1</b></nobr>.")
    1418             .arg (aMedium.location()),
    1419         formatErrorInfo (aMedium.result()));
    1420 }
    1421 
    1422 #if defined Q_WS_WIN
    1423 
    1424 int VBoxProblemReporter::confirmDeletingHostInterface (const QString &aName,
    1425                                                        QWidget *aParent)
    1426 {
    1427     return vboxProblem().message (aParent, VBoxProblemReporter::Question,
    1428         tr ("<p>Do you want to remove the selected host network interface "
    1429             "<nobr><b>%1</b>?</nobr></p>"
    1430             "<p><b>Note:</b> This interface may be in use by one or more "
    1431             "network adapters of this or another VM. After it is removed, these "
    1432             "adapters will no longer work until you correct their settings by "
    1433             "either choosing a different interface name or a different adapter "
    1434             "attachment type.</p>").arg (aName),
    1435         0, /* autoConfirmId */
    1436         QIMessageBox::Ok | QIMessageBox::Default,
    1437         QIMessageBox::Cancel | QIMessageBox::Escape);
    1438 }
    1439 
    1440 void VBoxProblemReporter::cannotCreateHostInterface (
    1441     const CHost &host, QWidget *parent)
    1442 {
    1443     message (parent ? parent : mainWindowShown(), Error,
    1444         tr ("Failed to create the host network interface ."),
    1445         formatErrorInfo (host));
    1446 }
    1447 
    1448 void VBoxProblemReporter::cannotCreateHostInterface (
    1449     const CProgress &progress, const QString &name, QWidget *parent)
    1450 {
    1451     message (parent ? parent : mainWindowShown(), Error,
    1452         tr ("Failed to create the host network interface <b>%1</b>.")
    1453             .arg (name),
    1454         formatErrorInfo (progress.GetErrorInfo()));
    1455 }
    1456 
    1457 void VBoxProblemReporter::cannotRemoveHostInterface (
    1458     const CHost &host, const CHostNetworkInterface &iface, QWidget *parent)
    1459 {
    1460     message (parent ? parent : mainWindowShown(), Error,
    1461         tr ("Failed to remove the host network interface <b>%1</b>.")
    1462             .arg (iface.GetName()),
    1463         formatErrorInfo (host));
    1464 }
    1465 
    1466 void VBoxProblemReporter::cannotRemoveHostInterface (
    1467     const CProgress &progress, const CHostNetworkInterface &iface, QWidget *parent)
    1468 {
    1469     message (parent ? parent : mainWindowShown(), Error,
    1470         tr ("Failed to remove the host network interface <b>%1</b>.")
    1471             .arg (iface.GetName()),
    1472         formatErrorInfo (progress.GetErrorInfo()));
    1473 }
    1474 
    1475 #endif
    1476 
    1477 void VBoxProblemReporter::cannotAttachUSBDevice (const CConsole &console,
    1478                                                  const QString &device)
    1479 {
    1480     /* preserve the current error info before calling the object again */
    1481     COMResult res (console);
    1482 
    1483     message (&vboxGlobal().consoleWnd(), Error,
    1484         tr ("Failed to attach the USB device <b>%1</b> "
    1485             "to the virtual machine <b>%2</b>.")
    1486             .arg (device)
    1487             .arg (console.GetMachine().GetName()),
    1488         formatErrorInfo (res));
    1489 }
    1490 
    1491 void VBoxProblemReporter::cannotAttachUSBDevice (const CConsole &console,
    1492                                                  const QString &device,
    1493                                                  const CVirtualBoxErrorInfo &error)
    1494 {
    1495     message (&vboxGlobal().consoleWnd(), Error,
    1496         tr ("Failed to attach the USB device <b>%1</b> "
    1497             "to the virtual machine <b>%2</b>.")
    1498             .arg (device)
    1499             .arg (console.GetMachine().GetName()),
    1500         formatErrorInfo (error));
    1501 }
    1502 
    1503 void VBoxProblemReporter::cannotDetachUSBDevice (const CConsole &console,
    1504                                                  const QString &device)
    1505 {
    1506     /* preserve the current error info before calling the object again */
    1507     COMResult res (console);
    1508 
    1509     message (&vboxGlobal().consoleWnd(), Error,
    1510         tr ("Failed to detach the USB device <b>%1</b> "
    1511             "from the virtual machine <b>%2</b>.")
    1512             .arg (device)
    1513             .arg (console.GetMachine().GetName()),
    1514         formatErrorInfo (res));
    1515 }
    1516 
    1517 void VBoxProblemReporter::cannotDetachUSBDevice (const CConsole &console,
    1518                                                  const QString &device,
    1519                                                  const CVirtualBoxErrorInfo &error)
    1520 {
    1521     message (&vboxGlobal().consoleWnd(), Error,
    1522         tr ("Failed to detach the USB device <b>%1</b> "
    1523             "from the virtual machine <b>%2</b>.")
    1524             .arg (device)
    1525             .arg (console.GetMachine().GetName()),
    1526         formatErrorInfo (error));
    1527 }
    1528 
    1529 void VBoxProblemReporter::cannotCreateSharedFolder (QWidget        *aParent,
    1530                                                     const CMachine &aMachine,
    1531                                                     const QString  &aName,
    1532                                                     const QString  &aPath)
    1533 {
    1534     /* preserve the current error info before calling the object again */
    1535     COMResult res (aMachine);
    1536 
    1537     message (aParent, Error,
    1538              tr ("Failed to create a shared folder <b>%1</b> "
    1539                  "(pointing to <nobr><b>%2</b></nobr>) "
    1540                  "for the virtual machine <b>%3</b>.")
    1541                  .arg (aName)
    1542                  .arg (aPath)
    1543                  .arg (aMachine.GetName()),
    1544              formatErrorInfo (res));
    1545 }
    1546 
    1547 void VBoxProblemReporter::cannotRemoveSharedFolder (QWidget        *aParent,
    1548                                                     const CMachine &aMachine,
    1549                                                     const QString  &aName,
    1550                                                     const QString  &aPath)
    1551 {
    1552     /* preserve the current error info before calling the object again */
    1553     COMResult res (aMachine);
    1554 
    1555     message (aParent, Error,
    1556              tr ("Failed to remove the shared folder <b>%1</b> "
    1557                  "(pointing to <nobr><b>%2</b></nobr>) "
    1558                  "from the virtual machine <b>%3</b>.")
    1559                  .arg (aName)
    1560                  .arg (aPath)
    1561                  .arg (aMachine.GetName()),
    1562              formatErrorInfo (res));
    1563 }
    1564 
    1565 void VBoxProblemReporter::cannotCreateSharedFolder (QWidget        *aParent,
    1566                                                     const CConsole &aConsole,
    1567                                                     const QString  &aName,
    1568                                                     const QString  &aPath)
    1569 {
    1570     /* preserve the current error info before calling the object again */
    1571     COMResult res (aConsole);
    1572 
    1573     message (aParent, Error,
    1574              tr ("Failed to create a shared folder <b>%1</b> "
    1575                  "(pointing to <nobr><b>%2</b></nobr>) "
    1576                  "for the virtual machine <b>%3</b>.")
    1577                  .arg (aName)
    1578                  .arg (aPath)
    1579                  .arg (aConsole.GetMachine().GetName()),
    1580              formatErrorInfo (res));
    1581 }
    1582 
    1583 void VBoxProblemReporter::cannotRemoveSharedFolder (QWidget        *aParent,
    1584                                                     const CConsole &aConsole,
    1585                                                     const QString  &aName,
    1586                                                     const QString  &aPath)
    1587 {
    1588     /* preserve the current error info before calling the object again */
    1589     COMResult res (aConsole);
    1590 
    1591     message (aParent, Error,
    1592              tr ("<p>Failed to remove the shared folder <b>%1</b> "
    1593                  "(pointing to <nobr><b>%2</b></nobr>) "
    1594                  "from the virtual machine <b>%3</b>.</p>"
    1595                  "<p>Please close all programs in the guest OS that "
    1596                  "may be using this shared folder and try again.</p>")
    1597                  .arg (aName)
    1598                  .arg (aPath)
    1599                  .arg (aConsole.GetMachine().GetName()),
    1600              formatErrorInfo (res));
    1601 }
    1602 
    1603 int VBoxProblemReporter::cannotFindGuestAdditions (const QString &aSrc1,
    1604                                                    const QString &aSrc2)
    1605 {
    1606     return message (&vboxGlobal().consoleWnd(), Question,
    1607                     tr ("<p>Could not find the VirtualBox Guest Additions "
    1608                         "CD image file <nobr><b>%1</b></nobr> or "
    1609                         "<nobr><b>%2</b>.</nobr></p><p>Do you want to "
    1610                         "download this CD image from the Internet?</p>")
    1611                         .arg (aSrc1).arg (aSrc2),
    1612                     0, /* aAutoConfirmId */
    1613                     QIMessageBox::Yes | QIMessageBox::Default,
    1614                     QIMessageBox::No | QIMessageBox::Escape);
    1615 }
    1616 
    1617 void VBoxProblemReporter::cannotDownloadGuestAdditions (const QString &aURL,
    1618                                                         const QString &aReason)
    1619 {
    1620     message (&vboxGlobal().consoleWnd(), Error,
    1621              tr ("<p>Failed to download the VirtualBox Guest Additions CD "
    1622                  "image from <nobr><a href=\"%1\">%2</a>.</nobr></p><p>%3</p>")
    1623                  .arg (aURL).arg (aURL).arg (aReason));
    1624 }
    1625 
    1626 bool VBoxProblemReporter::confirmDownloadAdditions (const QString &aURL,
    1627                                                     ulong aSize)
    1628 {
    1629     return messageOkCancel (&vboxGlobal().consoleWnd(), Question,
    1630         tr ("<p>Are you sure you want to download the VirtualBox "
    1631             "Guest Additions CD image from "
    1632             "<nobr><a href=\"%1\">%2</a></nobr> "
    1633             "(size %3 bytes)?</p>").arg (aURL).arg (aURL).arg (aSize),
    1634         0, /* aAutoConfirmId */
    1635         tr ("Download", "additions"));
    1636 }
    1637 
    1638 bool VBoxProblemReporter::confirmMountAdditions (const QString &aURL,
    1639                                                 const QString &aSrc)
    1640 {
    1641     return messageOkCancel (&vboxGlobal().consoleWnd(), Question,
    1642         tr ("<p>The VirtualBox Guest Additions CD image has been "
    1643             "successfully downloaded from "
    1644             "<nobr><a href=\"%1\">%2</a></nobr> "
    1645             "and saved locally as <nobr><b>%3</b>.</nobr></p>"
    1646             "<p>Do you want to register this CD image and mount it "
    1647             "on the virtual CD/DVD drive?</p>")
    1648             .arg (aURL).arg (aURL).arg (aSrc),
    1649         0, /* aAutoConfirmId */
    1650         tr ("Mount", "additions"));
    1651 }
    1652 
    1653 void VBoxProblemReporter::warnAboutTooOldAdditions (QWidget *aParent,
    1654                                                     const QString &aInstalledVer,
    1655                                                     const QString &aExpectedVer)
    1656 {
    1657     message (aParent, VBoxProblemReporter::Error,
    1658         tr ("<p>VirtualBox Guest Additions installed in the Guest OS are too "
    1659             "old: the installed version is %1, the expected version is %2. "
    1660             "Some features that require Guest Additions (mouse integration, "
    1661             "guest display auto-resize) will most likely stop "
    1662             "working properly.</p>"
    1663             "<p>Please update Guest Additions to the current version by choosing "
    1664             "<b>Install Guest Additions</b> from the <b>Devices</b> "
    1665             "menu.</p>")
    1666              .arg (aInstalledVer).arg (aExpectedVer),
    1667         "warnAboutTooOldAdditions");
    1668 }
    1669 
    1670 void VBoxProblemReporter::warnAboutOldAdditions (QWidget *aParent,
    1671                                                  const QString &aInstalledVer,
    1672                                                  const QString &aExpectedVer)
    1673 {
    1674     message (aParent, VBoxProblemReporter::Warning,
    1675         tr ("<p>VirtualBox Guest Additions installed in the Guest OS are "
    1676             "outdated: the installed version is %1, the expected version is %2. "
    1677             "Some features that require Guest Additions (mouse integration, "
    1678             "guest display auto-resize) may not work as expected.</p>"
    1679             "<p>It is recommended to update Guest Additions to the current version "
    1680             " by choosing <b>Install Guest Additions</b> from the <b>Devices</b> "
    1681             "menu.</p>")
    1682              .arg (aInstalledVer).arg (aExpectedVer),
    1683         "warnAboutOldAdditions");
    1684 }
    1685 
    1686 void VBoxProblemReporter::warnAboutNewAdditions (QWidget *aParent,
    1687                                                  const QString &aInstalledVer,
    1688                                                  const QString &aExpectedVer)
    1689 {
    1690     message (aParent, VBoxProblemReporter::Error,
    1691         tr ("<p>VirtualBox Guest Additions installed in the Guest OS are "
    1692             "too recent for this version of VirtualBox: the installed version "
    1693             "is %1, the expected version is %2.</p>"
    1694             "<p>Using a newer version of Additions with an older version of "
    1695             "VirtualBox is not supported. Please install the current version "
    1696             "of Guest Additions by choosing <b>Install Guest Additions</b> "
    1697             "from the <b>Devices</b> menu.</p>")
    1698              .arg (aInstalledVer).arg (aExpectedVer),
    1699         "warnAboutNewAdditions");
    1700 }
    1701 
    1702 void VBoxProblemReporter::cannotConnectRegister (QWidget *aParent,
    1703                                                  const QString &aURL,
    1704                                                  const QString &aReason)
    1705 {
    1706     /* we don't want to expose the registration script URL to the user
    1707      * if he simply doesn't have an internet connection */
    1708     Q_UNUSED (aURL);
    1709 
    1710     message (aParent, Error,
    1711              tr ("<p>Failed to connect to the VirtualBox online "
    1712                  "registration service due to the following error:</p><p><b>%1</b></p>")
    1713                  .arg (aReason));
    1714 }
    1715 
    1716 void VBoxProblemReporter::showRegisterResult (QWidget *aParent,
    1717                                               const QString &aResult)
    1718 {
    1719     aResult == "OK" ?
    1720         message (aParent, Info,
    1721                  tr ("<p>Congratulations! You have been successfully registered "
    1722                      "as a user of VirtualBox.</p>"
    1723                      "<p>Thank you for finding time to fill out the "
    1724                      "registration form!</p>")) :
    1725         message (aParent, Error,
    1726                  tr ("<p>Failed to register the VirtualBox product</p><p>%1</p>")
    1727                  .arg (aResult));
    1728 }
    1729 
    1730 void VBoxProblemReporter::showUpdateSuccess (QWidget *aParent,
    1731                                              const QString &aVersion,
    1732                                              const QString &aLink)
    1733 {
    1734     message (aParent, Info,
    1735              tr ("<p>A new version of VirtualBox has been released! Version <b>%1</b> is available at <a href=\"http://www.virtualbox.org/\">virtualbox.org</a>.</p>"
    1736                  "<p>You can download this version from this direct link:</p>"
    1737                  "<p><a href=%2>%3</a></p>")
    1738                  .arg (aVersion, aLink, aLink));
    1739 }
    1740 
    1741 void VBoxProblemReporter::showUpdateFailure (QWidget *aParent,
    1742                                              const QString &aReason)
    1743 {
    1744     message (aParent, Error,
    1745              tr ("<p>Unable to obtain the new version information "
    1746                  "due to the following error:</p><p><b>%1</b></p>")
    1747                  .arg (aReason));
    1748 }
    1749 
    1750 void VBoxProblemReporter::showUpdateNotFound (QWidget *aParent)
    1751 {
    1752     message (aParent, Info,
    1753              tr ("You have already installed the latest VirtualBox "
    1754                  "version. Please repeat the version check later."));
    1755 }
    1756 
    1757 /**
    1758  *  @return @c true if the user has confirmed input capture (this is always
    1759  *  the case if the dialog was autoconfirmed). @a aAutoConfirmed, when not
    1760  *  NULL, will receive @c true if the dialog wasn't actually shown.
    1761  */
    1762 bool VBoxProblemReporter::confirmInputCapture (bool *aAutoConfirmed /* = NULL */)
    1763 {
    1764     int rc = message (&vboxGlobal().consoleWnd(), Info,
    1765         tr ("<p>You have <b>clicked the mouse</b> inside the Virtual Machine display "
    1766             "or pressed the <b>host key</b>. This will cause the Virtual Machine to "
    1767             "<b>capture</b> the host mouse pointer (only if the mouse pointer "
    1768             "integration is not currently supported by the guest OS) and the "
    1769             "keyboard, which will make them unavailable to other applications "
    1770             "running on your host machine."
    1771             "</p>"
    1772             "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the "
    1773             "keyboard and mouse (if it is captured) and return them to normal "
    1774             "operation. The currently assigned host key is shown on the status bar "
    1775             "at the bottom of the Virtual Machine window, next to the&nbsp;"
    1776             "<img src=:/hostkey_16px.png/>&nbsp;icon. This icon, together "
    1777             "with the mouse icon placed nearby, indicate the current keyboard "
    1778             "and mouse capture state."
    1779             "</p>") +
    1780         tr ("<p>The host key is currently defined as <b>%1</b>.</p>",
    1781             "additional message box paragraph")
    1782             .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
    1783         "confirmInputCapture",
    1784         QIMessageBox::Ok | QIMessageBox::Default,
    1785         QIMessageBox::Cancel | QIMessageBox::Escape,
    1786         0,
    1787         tr ("Capture", "do input capture"));
    1788 
    1789     if (aAutoConfirmed)
    1790         *aAutoConfirmed = (rc & AutoConfirmed);
    1791 
    1792     return (rc & QIMessageBox::ButtonMask) == QIMessageBox::Ok;
    1793 }
    1794 
    1795 void VBoxProblemReporter::remindAboutAutoCapture()
    1796 {
    1797     message (&vboxGlobal().consoleWnd(), Info,
    1798         tr ("<p>You have the <b>Auto capture keyboard</b> option turned on. "
    1799             "This will cause the Virtual Machine to automatically <b>capture</b> "
    1800             "the keyboard every time the VM window is activated and make it "
    1801             "unavailable to other applications running on your host machine: "
    1802             "when the keyboard is captured, all keystrokes (including system ones "
    1803             "like Alt-Tab) will be directed to the VM."
    1804             "</p>"
    1805             "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the "
    1806             "keyboard and mouse (if it is captured) and return them to normal "
    1807             "operation. The currently assigned host key is shown on the status bar "
    1808             "at the bottom of the Virtual Machine window, next to the&nbsp;"
    1809             "<img src=:/hostkey_16px.png/>&nbsp;icon. This icon, together "
    1810             "with the mouse icon placed nearby, indicate the current keyboard "
    1811             "and mouse capture state."
    1812             "</p>") +
    1813         tr ("<p>The host key is currently defined as <b>%1</b>.</p>",
    1814             "additional message box paragraph")
    1815             .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
    1816         "remindAboutAutoCapture");
    1817 }
    1818 
    1819 void VBoxProblemReporter::remindAboutMouseIntegration (bool aSupportsAbsolute)
    1820 {
    1821     static const char *kNames [2] =
    1822     {
    1823         "remindAboutMouseIntegrationOff",
    1824         "remindAboutMouseIntegrationOn"
    1825     };
    1826 
    1827     /* Close the previous (outdated) window if any. We use kName as
    1828      * aAutoConfirmId which is also used as the widget name by default. */
    1829     {
    1830         QWidget *outdated =
    1831             VBoxGlobal::findWidget (NULL, kNames [int (!aSupportsAbsolute)],
    1832                                     "QIMessageBox");
    1833         if (outdated)
    1834             outdated->close();
    1835     }
    1836 
    1837     if (aSupportsAbsolute)
    1838     {
    1839         message (&vboxGlobal().consoleWnd(), Info,
    1840             tr ("<p>The Virtual Machine reports that the guest OS supports "
    1841                 "<b>mouse pointer integration</b>. This means that you do not "
    1842                 "need to <i>capture</i> the mouse pointer to be able to use it "
    1843                 "in your guest OS -- all "
    1844                 "mouse actions you perform when the mouse pointer is over the "
    1845                 "Virtual Machine's display are directly sent to the guest OS. "
    1846                 "If the mouse is currently captured, it will be automatically "
    1847                 "uncaptured."
    1848                 "</p>"
    1849                 "<p>The mouse icon on the status bar will look like&nbsp;"
    1850                 "<img src=:/mouse_seamless_16px.png/>&nbsp;to inform you that mouse "
    1851                 "pointer integration is supported by the guest OS and is "
    1852                 "currently turned on."
    1853                 "</p>"
    1854                 "<p><b>Note</b>: Some applications may behave incorrectly in "
    1855                 "mouse pointer integration mode. You can always disable it for "
    1856                 "the current session (and enable it again) by selecting the "
    1857                 "corresponding action from the menu bar."
    1858                 "</p>"),
    1859             kNames [1] /* aAutoConfirmId */);
    1860     }
    1861     else
    1862     {
    1863         message (&vboxGlobal().consoleWnd(), Info,
    1864             tr ("<p>The Virtual Machine reports that the guest OS does not "
    1865                 "support <b>mouse pointer integration</b> in the current video "
    1866                 "mode. You need to capture the mouse (by clicking over the VM "
    1867                 "display or pressing the host key) in order to use the "
    1868                 "mouse inside the guest OS.</p>"),
    1869             kNames [0] /* aAutoConfirmId */);
    1870     }
    1871 }
    1872 
    1873 /**
    1874  * @return @c false if the dialog wasn't actually shown (i.e. it was
    1875  * autoconfirmed).
    1876  */
    1877 bool VBoxProblemReporter::remindAboutPausedVMInput()
    1878 {
    1879     int rc = message (
    1880         &vboxGlobal().consoleWnd(),
    1881         Info,
    1882         tr (
    1883             "<p>The Virtual Machine is currently in the <b>Paused</b> state and "
    1884             "therefore does not accept any keyboard or mouse input. If you want to "
    1885             "continue to work inside the VM, you need to resume it by selecting the "
    1886             "corresponding action from the menu bar.</p>"
    1887         ),
    1888         "remindAboutPausedVMInput"
    1889     );
    1890     return !(rc & AutoConfirmed);
    1891 }
    1892 
    1893 /** @return true if the user has chosen to show the Disk Manager Window */
    1894 bool VBoxProblemReporter::remindAboutInaccessibleMedia()
    1895 {
    1896     int rc = message (&vboxGlobal().selectorWnd(), Warning,
    1897         tr ("<p>One or more virtual hard disks, CD/DVD or "
    1898             "floppy media are not currently accessible. As a result, you will "
    1899             "not be able to operate virtual machines that use these media until "
    1900             "they become accessible later.</p>"
    1901             "<p>Press <b>Check</b> to open the Virtual Media Manager window and "
    1902             "see what media are inaccessible, or press <b>Ignore</b> to "
    1903             "ignore this message.</p>"),
    1904         "remindAboutInaccessibleMedia",
    1905         QIMessageBox::Ok | QIMessageBox::Default,
    1906         QIMessageBox::Ignore | QIMessageBox::Escape,
    1907         0,
    1908         tr ("Check", "inaccessible media message box"));
    1909 
    1910     return rc == QIMessageBox::Ok; /* implies !AutoConfirmed */
    1911 }
    1912 
    1913 /**
    1914  * Shows a list of auto-converted files and asks the user to either Save, Backup
    1915  * or Cancel to leave them as is and exit VirtualBox.
    1916  *
    1917  * @param aFormatVersion    Recent settings file format version.
    1918  * @param aFileList         List of auto-converted files (may use Qt HTML).
    1919  * @param aAfterRefresh     @true when called after the VM refresh.
    1920  *
    1921  * @return QIMessageBox::Yes (Save), QIMessageBox::No (Backup),
    1922  *         QIMessageBox::Cancel (Exit)
    1923  */
    1924 int VBoxProblemReporter::warnAboutAutoConvertedSettings (const QString &aFormatVersion,
    1925                                                          const QString &aFileList,
    1926                                                          bool aAfterRefresh)
    1927 {
    1928     if (!aAfterRefresh)
    1929     {
    1930         int rc = message (mainWindowShown(), Info,
    1931             tr ("<p>Your existing VirtualBox settings files were automatically "
    1932                 "converted from the old format to a new format necessary for the "
    1933                 "new version of VirtualBox.</p>"
    1934                 "<p>Press <b>OK</b> to start VirtualBox now or press <b>More</b> if "
    1935                 "you want to get more information about what files were converted "
    1936                 "and access additional actions.</p>"
    1937                 "<p>Press <b>Exit</b> to terminate the VirtualBox "
    1938                 "application without saving the results of the conversion to "
    1939                 "disk.</p>"),
    1940             NULL /* aAutoConfirmId */,
    1941             QIMessageBox::Ok | QIMessageBox::Default,
    1942             QIMessageBox::No,
    1943             QIMessageBox::Cancel | QIMessageBox::Escape,
    1944             0,
    1945             tr ("&More", "warnAboutAutoConvertedSettings message box"),
    1946             tr ("E&xit", "warnAboutAutoConvertedSettings message box"));
    1947 
    1948         /* in the simplest case we backup */
    1949         if (rc == QIMessageBox::Ok)
    1950             return QIMessageBox::No;
    1951 
    1952         if (rc == QIMessageBox::Cancel)
    1953             return QIMessageBox::Cancel;
    1954     }
    1955 
    1956     return message (mainWindowShown(), Info,
    1957         tr ("<p>The following VirtualBox settings files have been "
    1958             "automatically converted to the new settings file format "
    1959             "version <b>%1</b>.</p>"
    1960             "<p>However, the results of the conversion were not saved back "
    1961             "to disk yet. Please press:</p>"
    1962             "<ul>"
    1963             "<li><b>Backup</b> to create backup copies of the settings files in "
    1964             "the old format before saving them in the new format;</li>"
    1965             "<li><b>Overwrite</b> to save all auto-converted files without "
    1966             "creating backup copies (it will not be possible to use these "
    1967             "settings files with an older version of VirtualBox "
    1968             "afterwards);</li>"
    1969             "%2"
    1970             "</ul>"
    1971             "<p>It is recommended to always select <b>Backup</b> because in "
    1972             "this case it will be possible to go back to the previous "
    1973             "version of VirtualBox (if necessary) without losing your current "
    1974             "settings. See the VirtualBox Manual for more information about "
    1975             "downgrading.</p>")
    1976             .arg (aFormatVersion)
    1977             .arg (aAfterRefresh ? QString::null :
    1978                   tr ("<li><b>Exit</b> to terminate VirtualBox without saving "
    1979                       "the results of the conversion to disk.</li>")),
    1980         QString ("<!--EOM-->%1").arg (aFileList),
    1981         NULL /* aAutoConfirmId */,
    1982         QIMessageBox::Yes,
    1983         aAfterRefresh ? (QIMessageBox::No | QIMessageBox::Default | QIMessageBox::Escape) :
    1984                         (QIMessageBox::No | QIMessageBox::Default),
    1985         aAfterRefresh ? 0 : (QIMessageBox::Cancel | QIMessageBox::Escape),
    1986         tr ("O&verwrite", "warnAboutAutoConvertedSettings message box"),
    1987         tr ("&Backup", "warnAboutAutoConvertedSettings message box"),
    1988         aAfterRefresh ? QString::null :
    1989             tr ("E&xit", "warnAboutAutoConvertedSettings message box"));
    1990 }
    1991 
    1992 /**
    1993  *  @param aHotKey Fullscreen hot key as defined in the menu.
    1994  *
    1995  *  @return @c true if the user has chosen to go fullscreen (this is always
    1996  *  the case if the dialog was autoconfirmed).
    1997  */
    1998 bool VBoxProblemReporter::confirmGoingFullscreen (const QString &aHotKey)
    1999 {
    2000     return messageOkCancel (&vboxGlobal().consoleWnd(), Info,
    2001         tr ("<p>The virtual machine window will be now switched to "
    2002             "<b>fullscreen</b> mode. "
    2003             "You can go back to windowed mode at any time by pressing "
    2004             "<b>%1</b>. Note that the <i>Host</i> key is currently "
    2005             "defined as <b>%2</b>.</p>"
    2006             "<p>Note that the main menu bar is hidden in fullscreen mode. You "
    2007             "can access it by pressing <b>Host+Home</b>.</p>")
    2008             .arg (aHotKey)
    2009             .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
    2010         "confirmGoingFullscreen",
    2011         tr ("Switch", "fullscreen"));
    2012 }
    2013 
    2014 /**
    2015  *  @param aHotKey Seamless hot key as defined in the menu.
    2016  *
    2017  *  @return @c true if the user has chosen to go seamless (this is always
    2018  *  the case if the dialog was autoconfirmed).
    2019  */
    2020 bool VBoxProblemReporter::confirmGoingSeamless (const QString &aHotKey)
    2021 {
    2022     return messageOkCancel (&vboxGlobal().consoleWnd(), Info,
    2023         tr ("<p>The virtual machine window will be now switched to "
    2024             "<b>Seamless</b> mode. "
    2025             "You can go back to windowed mode at any time by pressing "
    2026             "<b>%1</b>. Note that the <i>Host</i> key is currently "
    2027             "defined as <b>%2</b>.</p>"
    2028             "<p>Note that the main menu bar is hidden in seamless mode. You "
    2029             "can access it by pressing <b>Host+Home</b>.</p>")
    2030             .arg (aHotKey)
    2031             .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
    2032         "confirmGoingSeamless",
    2033         tr ("Switch", "seamless"));
    2034 }
    2035 
    2036 void VBoxProblemReporter::remindAboutWrongColorDepth (ulong aRealBPP,
    2037                                                       ulong aWantedBPP)
    2038 {
    2039     const char *kName = "remindAboutWrongColorDepth";
    2040 
    2041     /* Close the previous (outdated) window if any. We use kName as
    2042      * aAutoConfirmId which is also used as the widget name by default. */
    2043     {
    2044         QWidget *outdated = VBoxGlobal::findWidget (NULL, kName, "QIMessageBox");
    2045         if (outdated)
    2046             outdated->close();
    2047     }
    2048 
    2049     int rc = message (&vboxGlobal().consoleWnd(), Info,
    2050         tr ("<p>The virtual machine window is optimized to work in "
    2051             "<b>%1&nbsp;bit</b> color mode but the color quality of the "
    2052             "virtual display is currently set to <b>%2&nbsp;bit</b>.</p>"
    2053             "<p>Please open the display properties dialog of the guest OS and "
    2054             "select a <b>%3&nbsp;bit</b> color mode, if it is available, for "
    2055             "best possible performance of the virtual video subsystem.</p>"
    2056             "<p><b>Note</b>. Some operating systems, like OS/2, may actually "
    2057             "work in 32&nbsp;bit mode but report it as 24&nbsp;bit "
    2058             "(16 million colors). You may try to select a different color "
    2059             "quality to see if this message disappears or you can simply "
    2060             "disable the message now if you are sure the required color "
    2061             "quality (%4&nbsp;bit) is not available in the given guest OS.</p>")
    2062             .arg (aWantedBPP).arg (aRealBPP).arg (aWantedBPP).arg (aWantedBPP),
    2063         kName);
    2064     NOREF(rc);
    2065 }
    2066 
    2067 /**
    2068  *  Returns @c true if the user has selected to power off the machine.
    2069  */
    2070 bool VBoxProblemReporter::remindAboutGuruMeditation (const CConsole &aConsole,
    2071                                                      const QString &aLogFolder)
    2072 {
    2073     Q_UNUSED (aConsole);
    2074 
    2075     int rc = message (&vboxGlobal().consoleWnd(), GuruMeditation,
    2076         tr ("<p>A critical error has occurred while running the virtual "
    2077             "machine and the machine execution has been stopped.</p>"
    2078             ""
    2079             "<p>For help, please see the Community section on "
    2080             "<a href=http://www.virtualbox.org>http://www.virtualbox.org</a> "
    2081             "or your support contract. Please provide the contents of the "
    2082             "log file <tt>VBox.log</tt> and the image file <tt>VBox.png</tt>, "
    2083             "which you can find in the <nobr><b>%1</b></nobr> directory, "
    2084             "as well as a description of what you were doing when this error "
    2085             "happened. "
    2086             ""
    2087             "Note that you can also access the above files by selecting "
    2088             "<b>Show Log</b> from the <b>Machine</b> menu of the main "
    2089             "VirtualBox window.</p>"
    2090             ""
    2091             "<p>Press <b>OK</b> if you want to power off the machine "
    2092             "or press <b>Ignore</b> if you want to leave it as is for debugging. "
    2093             "Please note that debugging requires special knowledge and tools, so "
    2094             "it is recommended to press <b>OK</b> now.</p>")
    2095             .arg (aLogFolder),
    2096         0, /* aAutoConfirmId */
    2097         QIMessageBox::Ok | QIMessageBox::Default,
    2098         QIMessageBox::Ignore | QIMessageBox::Escape);
    2099 
    2100     return rc == QIMessageBox::Ok;
    2101 }
    2102 
    2103 /**
    2104  *  @return @c true if the user has selected to reset the machine.
    2105  */
    2106 bool VBoxProblemReporter::confirmVMReset (QWidget *aParent)
    2107 {
    2108     return messageOkCancel (aParent, Question,
    2109         tr ("<p>Do you really want to reset the virtual machine?</p>"
    2110             "<p>When the machine is reset, unsaved data of all applications "
    2111             "running inside it will be lost.</p>"),
    2112         "confirmVMReset" /* aAutoConfirmId */,
    2113         tr ("Reset", "machine"));
    2114 }
    2115 
    2116 /**
    2117  *  @return @c true if the user has selected to continue without attaching a
    2118  *  hard disk.
    2119  */
    2120 bool VBoxProblemReporter::confirmHardDisklessMachine (QWidget *aParent)
    2121 {
    2122     return message (aParent, Warning,
    2123         tr ("<p>You didn't attach a hard disk to the new virtual machine. "
    2124             "The machine will not be able to boot unless you attach "
    2125             "a hard disk with a guest operating system or some other bootable "
    2126             "media to it later using the machine settings dialog or the First "
    2127             "Run Wizard.</p><p>Do you want to continue?</p>"),
    2128         0, /* aAutoConfirmId */
    2129         QIMessageBox::Ok,
    2130         QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
    2131         0,
    2132         tr ("Continue", "no hard disk attached"),
    2133         tr ("Go Back", "no hard disk attached")) == QIMessageBox::Ok;
    2134 }
    2135 
    2136 void VBoxProblemReporter::cannotRunInSelectorMode()
    2137 {
    2138     message (mainWindowShown(), Critical,
    2139         tr ("<p>Cannot run VirtualBox in <i>VM Selector</i> "
    2140             "mode due to local restrictions.</p>"
    2141             "<p>The application will now terminate.</p>"));
    2142 }
    2143 
    2144 void VBoxProblemReporter::cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent /* = NULL */) const
    2145 {
    2146     if (aAppliance->isNull())
    2147     {
    2148         message (aParent ? aParent : mainWindowShown(),
    2149                  Error,
    2150                  tr ("Failed to open appliance."));
    2151     }else
    2152     {
    2153         /* Preserve the current error info before calling the object again */
    2154         COMResult res (*aAppliance);
    2155 
    2156         message (aParent ? aParent : mainWindowShown(),
    2157                  Error,
    2158                  tr ("Failed to open/interpret appliance <b>%1</b>.").arg (aAppliance->GetPath()),
    2159                  formatErrorInfo (res));
    2160     }
    2161 }
    2162 
    2163 void VBoxProblemReporter::cannotImportAppliance (const CProgress &aProgress, CAppliance* aAppliance, QWidget *aParent /* = NULL */) const
    2164 {
    2165     AssertWrapperOk (aProgress);
    2166 
    2167     message (aParent ? aParent : mainWindowShown(),
    2168              Error,
    2169              tr ("Failed to import appliance <b>%1</b>.").arg (aAppliance->GetPath()),
    2170              formatErrorInfo (aProgress.GetErrorInfo()));
    2171 }
    2172 
    2173 void VBoxProblemReporter::cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent /* = NULL */) const
    2174 {
    2175     if (aAppliance->isNull())
    2176     {
    2177         message (aParent ? aParent : mainWindowShown(),
    2178                  Error,
    2179                  tr ("Failed to create an appliance."));
    2180     }else
    2181     {
    2182         /* Preserve the current error info before calling the object again */
    2183         COMResult res (*aAppliance);
    2184 
    2185         message (aParent ? aParent : mainWindowShown(),
    2186                  Error,
    2187                  tr ("Failed to prepare the export of the appliance <b>%1</b>.").arg (aAppliance->GetPath()),
    2188                  formatErrorInfo (res));
    2189     }
    2190 }
    2191 
    2192 void VBoxProblemReporter::cannotExportAppliance (const CProgress &aProgress, CAppliance* aAppliance, QWidget *aParent /* = NULL */) const
    2193 {
    2194     AssertWrapperOk (aProgress);
    2195 
    2196     message (aParent ? aParent : mainWindowShown(),
    2197              Error,
    2198              tr ("Failed to export appliance <b>%1</b>.").arg (aAppliance->GetPath()),
    2199              formatErrorInfo (aProgress.GetErrorInfo()));
    2200 }
    2201 
    2202 void VBoxProblemReporter::showRuntimeError (const CConsole &aConsole, bool fatal,
    2203                                             const QString &errorID,
    2204                                             const QString &errorMsg) const
    2205 {
    2206     /// @todo (r=dmik) it's just a preliminary box. We need to:
    2207     //  - for fatal errors and non-fatal with-retry errors, listen for a
    2208     //    VM state signal to automatically close the message if the VM
    2209     //    (externally) leaves the Paused state while it is shown.
    2210     //  - make warning messages modeless
    2211     //  - add common buttons like Retry/Save/PowerOff/whatever
    2212 
    2213     QByteArray autoConfimId = "showRuntimeError.";
    2214 
    2215     CConsole console = aConsole;
    2216     KMachineState state = console.GetState();
    2217     Type type;
    2218     QString severity;
    2219 
    2220     if (fatal)
    2221     {
    2222         /* the machine must be paused on fatal errors */
    2223         Assert (state == KMachineState_Paused);
    2224         if (state != KMachineState_Paused)
    2225             console.Pause();
    2226         type = Critical;
    2227         severity = tr ("<nobr>Fatal Error</nobr>", "runtime error info");
    2228         autoConfimId += "fatal.";
    2229     }
    2230     else if (state == KMachineState_Paused)
    2231     {
    2232         type = Error;
    2233         severity = tr ("<nobr>Non-Fatal Error</nobr>", "runtime error info");
    2234         autoConfimId += "error.";
    2235     }
    2236     else
    2237     {
    2238         type = Warning;
    2239         severity = tr ("<nobr>Warning</nobr>", "runtime error info");
    2240         autoConfimId += "warning.";
    2241     }
    2242 
    2243     autoConfimId += errorID.toUtf8();
    2244 
    2245     QString formatted;
    2246 
    2247     if (!errorMsg.isEmpty())
    2248         formatted += QString ("<p>%1.</p><!--EOM-->")
    2249                               .arg (vboxGlobal().emphasize (errorMsg));
    2250 
    2251     if (!errorID.isEmpty())
    2252         formatted += QString ("<table bgcolor=#EEEEEE border=0 cellspacing=0 "
    2253                               "cellpadding=0 width=100%>"
    2254                               "<tr><td>%1</td><td>%2</td></tr>"
    2255                               "<tr><td>%3</td><td>%4</td></tr>"
    2256                               "</table>")
    2257                               .arg (tr ("<nobr>Error ID: </nobr>", "runtime error info"),
    2258                                     errorID)
    2259                               .arg (tr ("Severity: ", "runtime error info"),
    2260                                     severity);
    2261 
    2262     if (!formatted.isEmpty())
    2263         formatted = "<qt>" + formatted + "</qt>";
    2264 
    2265     int rc = 0;
    2266 
    2267     if (type == Critical)
    2268     {
    2269         rc = message (&vboxGlobal().consoleWnd(), type,
    2270             tr ("<p>A fatal error has occurred during virtual machine execution! "
    2271                 "The virtual machine will be powered off. It is suggested to "
    2272                 "use the clipboard to copy the following error message for "
    2273                 "further examination:</p>"),
    2274             formatted, autoConfimId.data());
    2275 
    2276         /* always power down after a fatal error */
    2277         console.PowerDown();
    2278     }
    2279     else if (type == Error)
    2280     {
    2281         rc = message (&vboxGlobal().consoleWnd(), type,
    2282             tr ("<p>An error has occurred during virtual machine execution! "
    2283                 "The error details are shown below. You can try to correct "
    2284                 "the described error and resume the virtual machine "
    2285                 "execution.</p>"),
    2286             formatted, autoConfimId.data());
    2287     }
    2288     else
    2289     {
    2290         rc = message (&vboxGlobal().consoleWnd(), type,
    2291             tr ("<p>The virtual machine execution may run into an error "
    2292                 "condition as described below. "
    2293                 "You may ignore this message, but it is suggested to perform "
    2294                 "an appropriate action to make sure the described error will "
    2295                 "not happen.</p>"),
    2296             formatted, autoConfimId.data());
    2297     }
    2298 
    2299     NOREF (rc);
    2300 }
    2301 
    2302 /* static */
    2303 QString VBoxProblemReporter::toAccusative (VBoxDefs::MediaType aType)
    2304 {
    2305     QString type =
    2306         aType == VBoxDefs::MediaType_HardDisk ?
    2307             tr ("hard disk", "failed to close ...") :
    2308         aType == VBoxDefs::MediaType_DVD ?
    2309             tr ("CD/DVD image", "failed to close ...") :
    2310         aType == VBoxDefs::MediaType_Floppy ?
    2311             tr ("floppy image", "failed to close ...") :
    2312         QString::null;
    2313 
    2314     Assert (!type.isNull());
    2315     return type;
    2316 }
    2317 
    2318 /**
    2319  * Formats the given COM result code as a human-readable string.
    2320  *
    2321  * If a mnemonic name for the given result code is found, a string in format
    2322  * "MNEMONIC_NAME (0x12345678)" is returned where the hex number is the result
    2323  * code as is. If no mnemonic name is found, then the raw hex number only is
    2324  * returned (w/o parenthesis).
    2325  *
    2326  * @param aRC   COM result code to format.
    2327  */
    2328 /* static */
    2329 QString VBoxProblemReporter::formatRC (HRESULT aRC)
    2330 {
    2331     QString str;
    2332 
    2333     PCRTCOMERRMSG msg = NULL;
    2334     const char *errMsg = NULL;
    2335 
    2336     /* first, try as is (only set bit 31 bit for warnings) */
    2337     if (SUCCEEDED_WARNING (aRC))
    2338         msg = RTErrCOMGet (aRC | 0x80000000);
    2339     else
    2340         msg = RTErrCOMGet (aRC);
    2341 
    2342     if (msg != NULL)
    2343         errMsg = msg->pszDefine;
    2344 
    2345 #if defined (Q_WS_WIN)
    2346 
    2347     PCRTWINERRMSG winMsg = NULL;
    2348 
    2349     /* if not found, try again using RTErrWinGet with masked off top 16bit */
    2350     if (msg == NULL)
    2351     {
    2352         winMsg = RTErrWinGet (aRC & 0xFFFF);
    2353 
    2354         if (winMsg != NULL)
    2355             errMsg = winMsg->pszDefine;
    2356     }
    2357 
    2358 #endif
    2359 
    2360     if (errMsg != NULL && *errMsg != '\0')
    2361         str.sprintf ("%s (0x%08X)", errMsg, aRC);
    2362     else
    2363         str.sprintf ("0x%08X", aRC);
    2364 
    2365     return str;
    2366 }
    2367 
    2368 /* static */
    2369 QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &aInfo,
    2370                                               HRESULT aWrapperRC /* = S_OK */)
    2371 {
    2372     QString formatted = doFormatErrorInfo (aInfo, aWrapperRC);
    2373     return QString ("<qt>%1</qt>").arg (formatted);
    2374 }
    2375 
    2376 /* static */
    2377 QString VBoxProblemReporter::doFormatErrorInfo (const COMErrorInfo &aInfo,
    2378                                                 HRESULT aWrapperRC /* = S_OK */)
    2379 {
    2380     /* Compose complex details string with internal <!--EOM--> delimiter to
    2381      * make it possible to split string into info & details parts which will
    2382      * be used separately in QIMessageBox */
    2383     QString formatted;
    2384 
    2385     if (!aInfo.text().isEmpty())
    2386         formatted += QString ("<p>%1.</p><!--EOM-->").arg (vboxGlobal().emphasize (aInfo.text()));
    2387 
    2388     formatted += "<table bgcolor=#EEEEEE border=0 cellspacing=0 "
    2389                  "cellpadding=0 width=100%>";
    2390 
    2391     bool haveResultCode = false;
    2392 
    2393     if (aInfo.isBasicAvailable())
    2394     {
    2395 #if defined (Q_WS_WIN)
    2396         haveResultCode = aInfo.isFullAvailable();
    2397         bool haveComponent = true;
    2398         bool haveInterfaceID = true;
    2399 #else /* defined (Q_WS_WIN) */
    2400         haveResultCode = true;
    2401         bool haveComponent = aInfo.isFullAvailable();
    2402         bool haveInterfaceID = aInfo.isFullAvailable();
    2403 #endif
    2404 
    2405         if (haveResultCode)
    2406         {
    2407             formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>")
    2408                 .arg (tr ("Result&nbsp;Code: ", "error info"))
    2409                 .arg (formatRC (aInfo.resultCode()));
    2410         }
    2411 
    2412         if (haveComponent)
    2413             formatted += QString ("<tr><td>%1</td><td>%2</td></tr>")
    2414                 .arg (tr ("Component: ", "error info"), aInfo.component());
    2415 
    2416         if (haveInterfaceID)
    2417         {
    2418             QString s = aInfo.interfaceID();
    2419             if (!aInfo.interfaceName().isEmpty())
    2420                 s = aInfo.interfaceName() + ' ' + s;
    2421             formatted += QString ("<tr><td>%1</td><td>%2</td></tr>")
    2422                 .arg (tr ("Interface: ", "error info"), s);
    2423         }
    2424 
    2425         if (!aInfo.calleeIID().isNull() && aInfo.calleeIID() != aInfo.interfaceID())
    2426         {
    2427             QString s = aInfo.calleeIID();
    2428             if (!aInfo.calleeName().isEmpty())
    2429                 s = aInfo.calleeName() + ' ' + s;
    2430             formatted += QString ("<tr><td>%1</td><td>%2</td></tr>")
    2431                 .arg (tr ("Callee: ", "error info"), s);
    2432         }
    2433     }
    2434 
    2435     if (FAILED (aWrapperRC) &&
    2436         (!haveResultCode || aWrapperRC != aInfo.resultCode()))
    2437     {
    2438         formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>")
    2439             .arg (tr ("Callee&nbsp;RC: ", "error info"))
    2440             .arg (formatRC (aWrapperRC));
    2441     }
    2442 
    2443     formatted += "</table>";
    2444 
    2445     if (aInfo.next())
    2446         formatted = doFormatErrorInfo (*aInfo.next()) +  "<p></p>" +
    2447                     formatted;
    2448 
    2449     return formatted;
    2450 }
    2451 
    2452 // Public slots
    2453 /////////////////////////////////////////////////////////////////////////////
    2454 
    2455 void VBoxProblemReporter::showHelpWebDialog()
    2456 {
    2457     vboxGlobal().openURL ("http://www.virtualbox.org");
    2458 }
    2459 
    2460 void VBoxProblemReporter::showHelpAboutDialog()
    2461 {
    2462     CVirtualBox vbox = vboxGlobal().virtualBox();
    2463     QString fullVersion (QString ("%1 r%2").arg (vbox.GetVersion())
    2464                                           .arg (vbox.GetRevision()));
    2465     AssertWrapperOk (vbox);
    2466 
    2467     // this (QWidget*) cast is necessary to work around a gcc-3.2 bug */
    2468     VBoxAboutDlg ((QWidget*)mainWindowShown(), fullVersion).exec();
    2469 }
    2470 
    2471 void VBoxProblemReporter::showHelpHelpDialog()
    2472 {
    2473 #ifndef VBOX_OSE
    2474     QString manual = vboxGlobal().helpFile();
    2475 # if defined (Q_WS_WIN32)
    2476     HtmlHelp (GetDesktopWindow(), manual.utf16(),
    2477               HH_DISPLAY_TOPIC, NULL);
    2478 # elif defined (Q_WS_X11)
    2479     char szViewerPath[RTPATH_MAX];
    2480     int rc;
    2481 
    2482     rc = RTPathAppPrivateArch (szViewerPath, sizeof (szViewerPath));
    2483     AssertRC (rc);
    2484 
    2485     QProcess::startDetached (QString(szViewerPath) + "/kchmviewer",
    2486                              QStringList (manual));
    2487 # elif defined (Q_WS_MAC)
    2488     vboxGlobal().openURL ("file://" + manual);
    2489 # endif
    2490 #endif /* VBOX_OSE */
    2491 }
    2492 
    2493 void VBoxProblemReporter::resetSuppressedMessages()
    2494 {
    2495     CVirtualBox vbox = vboxGlobal().virtualBox();
    2496     vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, QString::null);
    2497 }
    2498 
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r17679 r17730  
    197197
    198198const char *VBoxProgressDialog::sOpDescTpl = "%1... (%2/%3)";
    199 
    200 ////////////////////////////////////////////////////////////////////////////////
    201 // VBoxHelpActions class
    202 ////////////////////////////////////////////////////////////////////////////////
    203 
    204 void VBoxHelpActions::setup (QObject *aParent)
    205 {
    206     AssertReturnVoid (contentsAction == NULL);
    207 
    208     contentsAction = new QAction (aParent);
    209     contentsAction->setIcon (VBoxGlobal::iconSet (":/help_16px.png"));
    210 
    211     webAction = new QAction (aParent);
    212     webAction->setIcon (VBoxGlobal::iconSet (":/site_16px.png"));
    213 
    214     resetMessagesAction = new QAction (aParent);
    215     resetMessagesAction->setIcon (VBoxGlobal::iconSet (":/reset_16px.png"));
    216 
    217     registerAction = new QAction (aParent);
    218     registerAction->setIcon (VBoxGlobal::iconSet (":/register_16px.png",
    219                                                   ":/register_disabled_16px.png"));
    220     updateAction = new QAction (aParent);
    221     updateAction->setIcon (VBoxGlobal::iconSet (":/refresh_16px.png",
    222                                                 ":/refresh_disabled_16px.png"));
    223     aboutAction = new QAction (aParent);
    224     aboutAction->setMenuRole (QAction::AboutRole);
    225     aboutAction->setIcon (VBoxGlobal::iconSet (":/about_16px.png"));
    226 
    227     QObject::connect (contentsAction, SIGNAL (triggered()),
    228                       &vboxProblem(), SLOT (showHelpHelpDialog()));
    229     QObject::connect (webAction, SIGNAL (triggered()),
    230                       &vboxProblem(), SLOT (showHelpWebDialog()));
    231     QObject::connect (resetMessagesAction, SIGNAL (triggered()),
    232                       &vboxProblem(), SLOT (resetSuppressedMessages()));
    233     QObject::connect (registerAction, SIGNAL (triggered()),
    234                       &vboxGlobal(), SLOT (showRegistrationDialog()));
    235     QObject::connect (updateAction, SIGNAL (triggered()),
    236                       &vboxGlobal(), SLOT (showUpdateDialog()));
    237     QObject::connect (aboutAction, SIGNAL (triggered()),
    238                       &vboxProblem(), SLOT (showHelpAboutDialog()));
    239 
    240     QObject::connect (&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
    241                       registerAction, SLOT (setEnabled (bool)));
    242     QObject::connect (&vboxGlobal(), SIGNAL (canShowUpdDlg (bool)),
    243                       updateAction, SLOT (setEnabled (bool)));
    244 }
    245 
    246 void VBoxHelpActions::addTo (QMenu *aMenu)
    247 {
    248     AssertReturnVoid (contentsAction != NULL);
    249 
    250     aMenu->addAction (contentsAction);
    251     aMenu->addAction (webAction);
    252     aMenu->addSeparator();
    253 
    254     aMenu->addAction (resetMessagesAction);
    255     aMenu->addSeparator();
    256 
    257 #ifdef VBOX_WITH_REGISTRATION
    258     aMenu->addAction (registerAction);
    259     registerAction->setEnabled (vboxGlobal().virtualBox().
    260         GetExtraData (VBoxDefs::GUI_RegistrationDlgWinID).isEmpty());
    261 #endif
    262 
    263     aMenu->addAction (updateAction);
    264     updateAction->setEnabled (vboxGlobal().virtualBox().
    265         GetExtraData (VBoxDefs::GUI_UpdateDlgWinID).isEmpty());
    266 
    267 #ifndef Q_WS_MAC
    268     aMenu->addSeparator();
    269 #endif /* Q_WS_MAC */
    270     aMenu->addAction (aboutAction);
    271 }
    272 
    273 void VBoxHelpActions::retranslateUi()
    274 {
    275     AssertReturnVoid (contentsAction != NULL);
    276 
    277     contentsAction->setText (VBoxProblemReporter::tr ("&Contents..."));
    278     contentsAction->setShortcut (QKeySequence::HelpContents);
    279     contentsAction->setStatusTip (VBoxProblemReporter::tr (
    280         "Show the online help contents"));
    281 
    282     webAction->setText (VBoxProblemReporter::tr ("&VirtualBox Web Site..."));
    283     webAction->setStatusTip (VBoxProblemReporter::tr (
    284         "Open the browser and go to the VirtualBox product web site"));
    285 
    286     resetMessagesAction->setText (VBoxProblemReporter::tr ("&Reset All Warnings"));
    287     resetMessagesAction->setStatusTip (VBoxProblemReporter::tr (
    288         "Cause all suppressed warnings and messages to be shown again"));
    289 
    290     registerAction->setText (VBoxProblemReporter::tr ("R&egister VirtualBox..."));
    291     registerAction->setStatusTip (VBoxProblemReporter::tr (
    292         "Open VirtualBox registration form"));
    293 
    294     updateAction->setText (VBoxProblemReporter::tr ("C&heck for Updates..."));
    295     updateAction->setStatusTip (VBoxProblemReporter::tr (
    296         "Check for a new VirtualBox version"));
    297 
    298     aboutAction->setText (VBoxProblemReporter::tr ("&About VirtualBox..."));
    299     aboutAction->setStatusTip (VBoxProblemReporter::tr (
    300         "Show a dialog with product information"));
    301 }
    302199
    303200////////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette