VirtualBox

Ignore:
Timestamp:
Apr 2, 2013 1:27:59 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Message-center cleanup (part 18): Settings dialog stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r45285 r45288  
    7676}
    7777
    78 void UIMessageCenter::setWarningShown(const QString &strWarningName, bool fWarningShown)
     78void UIMessageCenter::setWarningShown(const QString &strWarningName, bool fWarningShown) const
    7979{
    8080    if (fWarningShown && !m_warnings.contains(strWarningName))
     
    285285
    286286#ifdef RT_OS_LINUX
    287 void UIMessageCenter::warnAboutWrongUSBMounted()
     287void UIMessageCenter::warnAboutWrongUSBMounted() const
    288288{
    289289    message(mainWindowShown(), MessageType_Warning,
     
    295295#endif /* RT_OS_LINUX */
    296296
    297 void UIMessageCenter::cannotStartSelector()
     297void UIMessageCenter::cannotStartSelector() const
    298298{
    299299    message(0, MessageType_Critical,
     
    302302}
    303303
    304 void UIMessageCenter::showBETAWarning()
     304void UIMessageCenter::showBETAWarning() const
    305305{
    306306    message(0, MessageType_Warning,
     
    309309}
    310310
    311 void UIMessageCenter::showBEBWarning()
     311void UIMessageCenter::showBEBWarning() const
    312312{
    313313    message(0, MessageType_Warning,
     
    316316}
    317317
    318 void UIMessageCenter::cannotInitUserHome(const QString &strUserHome)
     318void UIMessageCenter::cannotInitUserHome(const QString &strUserHome) const
    319319{
    320320    message(0, MessageType_Critical,
     
    322322               "configuration directory <b><nobr>%1</nobr></b> is not accessible. "
    323323               "Please check the permissions of this directory and of its parent directory.</p>"
    324                "<p>The application will now terminate.</p>").arg(strUserHome),
     324               "<p>The application will now terminate.</p>")
     325               .arg(strUserHome),
    325326            formatErrorInfo(COMErrorInfo()));
    326327}
    327328
    328 void UIMessageCenter::cannotInitCOM(HRESULT rc)
     329void UIMessageCenter::cannotInitCOM(HRESULT rc) const
    329330{
    330331    message(0, MessageType_Critical,
     
    335336}
    336337
    337 void UIMessageCenter::cannotCreateVirtualBox(const CVirtualBox &vbox)
     338void UIMessageCenter::cannotCreateVirtualBox(const CVirtualBox &vbox) const
    338339{
    339340    message(0, MessageType_Critical,
     
    343344}
    344345
    345 void UIMessageCenter::cannotFindLanguage(const QString &strLangId, const QString &strNlsPath)
     346void UIMessageCenter::cannotFindLanguage(const QString &strLangId, const QString &strNlsPath) const
    346347{
    347348    message(0, MessageType_Error,
     
    353354}
    354355
    355 void UIMessageCenter::cannotLoadLanguage(const QString &strLangFile)
     356void UIMessageCenter::cannotLoadLanguage(const QString &strLangFile) const
    356357{
    357358    message(0, MessageType_Error,
     
    363364}
    364365
    365 void UIMessageCenter::cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError)
     366void UIMessageCenter::cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError) const
    366367{
    367368    /* Preserve error-info: */
     
    370371    message(0, MessageType_Critical,
    371372            tr("<p>Failed to load the global GUI configuration from <b><nobr>%1</nobr></b>.</p>"
    372                "<p>The application will now terminate.</p>").arg(vbox.GetSettingsFilePath()),
    373             !res.isOk() ? formatErrorInfo(res)
    374                         : QString("<!--EOM--><p>%1</p>").arg(vboxGlobal().emphasize(strError)));
    375 }
    376 
    377 void UIMessageCenter::cannotSaveGlobalConfig(const CVirtualBox &vbox)
     373               "<p>The application will now terminate.</p>")
     374               .arg(vbox.GetSettingsFilePath()),
     375            !res.isOk() ? formatErrorInfo(res) : QString("<!--EOM--><p>%1</p>").arg(vboxGlobal().emphasize(strError)));
     376}
     377
     378void UIMessageCenter::cannotSaveGlobalConfig(const CVirtualBox &vbox) const
    378379{
    379380    /* Preserve error-info: */
     
    382383    message(0, MessageType_Critical,
    383384            tr("<p>Failed to save the global GUI configuration to <b><nobr>%1</nobr></b>.</p>"
    384                "<p>The application will now terminate.</p>").arg(vbox.GetSettingsFilePath()),
     385               "<p>The application will now terminate.</p>")
     386               .arg(vbox.GetSettingsFilePath()),
    385387            formatErrorInfo(res));
    386388}
    387389
    388 void UIMessageCenter::cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName)
     390void UIMessageCenter::cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName) const
    389391{
    390392    message(0, MessageType_Error,
    391             tr("There is no virtual machine named <b>%1</b>.").arg(strName),
     393            tr("There is no virtual machine named <b>%1</b>.")
     394               .arg(strName),
    392395            formatErrorInfo(vbox));
    393396}
    394397
    395 void UIMessageCenter::cannotFindMachineById(const CVirtualBox &vbox, const QString &strId)
     398void UIMessageCenter::cannotFindMachineById(const CVirtualBox &vbox, const QString &strId) const
    396399{
    397400    message(0, MessageType_Error,
    398             tr("There is no virtual machine with id <b>%1</b>.").arg(strId),
     401            tr("There is no virtual machine with id <b>%1</b>.")
     402               .arg(strId),
    399403            formatErrorInfo(vbox));
    400404}
    401405
    402 void UIMessageCenter::cannotOpenSession(const CSession &session)
    403 {
    404     Assert(session.isNull());
     406void UIMessageCenter::cannotOpenSession(const CSession &session) const
     407{
    405408    /* Show the message: */
    406409    message(mainWindowShown(), MessageType_Error,
     
    409412}
    410413
    411 void UIMessageCenter::cannotOpenSession(const CMachine &machine,
    412                                         const CProgress &progress /* = CProgress() */)
     414void UIMessageCenter::cannotOpenSession(const CMachine &machine, const CProgress &progress /* = CProgress() */) const
    413415{
    414416    /* Format error-info: */
     
    423425    /* Show the message: */
    424426    message(mainWindowShown(), MessageType_Error,
    425             tr("Failed to open a session for the virtual machine <b>%1</b>.").arg(strName),
     427            tr("Failed to open a session for the virtual machine <b>%1</b>.")
     428               .arg(strName),
    426429            strErrorInfo);
    427430}
    428431
    429 void UIMessageCenter::cannotGetMediaAccessibility(const UIMedium &medium)
     432void UIMessageCenter::cannotGetMediaAccessibility(const UIMedium &medium) const
    430433{
    431434    message(mainWindowShown(), MessageType_Error,
     
    435438}
    436439
    437 void UIMessageCenter::cannotOpenURL(const QString &strUrl)
     440void UIMessageCenter::cannotOpenURL(const QString &strUrl) const
    438441{
    439442    message(mainWindowShown(), MessageType_Error,
     
    443446}
    444447
    445 void UIMessageCenter::cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath)
     448void UIMessageCenter::cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath) const
    446449{
    447450    message(mainWindowShown(), MessageType_Error,
    448             tr("Failed to open virtual machine located in %1.").arg(strMachinePath),
     451            tr("Failed to open virtual machine located in %1.")
     452               .arg(strMachinePath),
    449453            formatErrorInfo(vbox));
    450454}
    451455
    452 void UIMessageCenter::cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName)
     456void UIMessageCenter::cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName) const
    453457{
    454458    message(mainWindowShown(), MessageType_Error,
     
    457461}
    458462
    459 void UIMessageCenter::cannotResolveCollisionAutomatically(const QString &strName, const QString &strGroupName)
     463void UIMessageCenter::cannotResolveCollisionAutomatically(const QString &strName, const QString &strGroupName) const
    460464{
    461465    message(mainWindowShown(), MessageType_Error,
     
    466470}
    467471
    468 bool UIMessageCenter::confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName)
     472bool UIMessageCenter::confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName) const
    469473{
    470474    return messageOkCancel(mainWindowShown(), MessageType_Question,
     
    473477                              "<p>Would you like to automatically rename it?</p>")
    474478                              .arg(strName, strGroupName),
    475                            0, /* auto-confirm id */
     479                           0 /* auto-confirm id */,
    476480                           tr("Rename"));
    477481}
    478482
    479 void UIMessageCenter::cannotSetGroups(const CMachine &machine)
     483void UIMessageCenter::cannotSetGroups(const CMachine &machine) const
    480484{
    481485    /* Preserve error-info: */
     
    487491    /* Show the message: */
    488492    message(mainWindowShown(), MessageType_Error,
    489             tr("Failed to set groups of the virtual machine <b>%1</b>.").arg(strName),
     493            tr("Failed to set groups of the virtual machine <b>%1</b>.")
     494               .arg(strName),
    490495            formatErrorInfo(res));
    491496}
    492497
    493 bool UIMessageCenter::confirmMachineItemRemoval(const QStringList &names)
     498bool UIMessageCenter::confirmMachineItemRemoval(const QStringList &names) const
    494499{
    495500    return messageOkCancel(mainWindowShown(), MessageType_Question,
    496                            tr("<p>You are about to remove following virtual "
    497                               "machine items from the machine list:</p>"
    498                               "<p><b>%1</b></p>"
    499                               "<p>Do you wish to proceed?</p>").arg(names.join(", ")),
    500                            0, /* auto-confirm id */
     501                           tr("<p>You are about to remove following virtual machine items from the machine list:</p>"
     502                              "<p><b>%1</b></p><p>Do you wish to proceed?</p>")
     503                              .arg(names.join(", ")),
     504                           0 /* auto-confirm id */,
    501505                           tr("Remove"));
    502506}
    503507
    504 int UIMessageCenter::confirmMachineRemoval(const QList<CMachine> &machines)
     508int UIMessageCenter::confirmMachineRemoval(const QList<CMachine> &machines) const
    505509{
    506510    /* Enumerate the machines: */
     
    567571    return cInacessibleMachineCount == machines.size() ?
    568572           message(mainWindowShown(), MessageType_Question,
    569                    strText, 0, /* auto-confirm id */
     573                   strText, 0 /* auto-confirm id */,
    570574                   QIMessageBox::Ok | QIMessageBox::Default,
    571575                   QIMessageBox::Cancel | QIMessageBox::Escape,
     
    573577                   tr("Remove")) :
    574578           message(mainWindowShown(), MessageType_Question,
    575                    strText, 0, /* auto-confirm id */
     579                   strText, 0 /* auto-confirm id */,
    576580                   QIMessageBox::Yes,
    577581                   QIMessageBox::No | QIMessageBox::Default,
     
    581585}
    582586
    583 void UIMessageCenter::cannotRemoveMachine(const CMachine &machine)
     587void UIMessageCenter::cannotRemoveMachine(const CMachine &machine) const
    584588{
    585589    /* Preserve error-info: */
     
    593597}
    594598
    595 void UIMessageCenter::cannotRemoveMachine(const CMachine &machine, const CProgress &progress)
     599void UIMessageCenter::cannotRemoveMachine(const CMachine &machine, const CProgress &progress) const
    596600{
    597601    message(mainWindowShown(),
     
    602606}
    603607
    604 bool UIMessageCenter::remindAboutInaccessibleMedia()
     608bool UIMessageCenter::remindAboutInaccessibleMedia() const
    605609{
    606610    return messageOkCancel(mainWindowShown(), MessageType_Warning,
     
    616620}
    617621
    618 bool UIMessageCenter::confirmDiscardSavedState(const QString &strNames)
     622bool UIMessageCenter::confirmDiscardSavedState(const QString &strNames) const
    619623{
    620624    return messageOkCancel(mainWindowShown(), MessageType_Question,
     
    628632}
    629633
    630 bool UIMessageCenter::confirmVMReset(const QString &strNames)
     634bool UIMessageCenter::confirmVMReset(const QString &strNames) const
    631635{
    632636    return messageOkCancel(mainWindowShown(), MessageType_Question,
     
    639643}
    640644
    641 bool UIMessageCenter::confirmVMACPIShutdown(const QString &strNames)
     645bool UIMessageCenter::confirmVMACPIShutdown(const QString &strNames) const
    642646{
    643647    return messageOkCancel(mainWindowShown(), MessageType_Question,
     
    649653}
    650654
    651 bool UIMessageCenter::confirmVMPowerOff(const QString &strNames)
     655bool UIMessageCenter::confirmVMPowerOff(const QString &strNames) const
    652656{
    653657    return messageOkCancel(mainWindowShown(), MessageType_Question,
     
    660664}
    661665
    662 void UIMessageCenter::cannotDiscardSavedState(const CConsole &console)
     666void UIMessageCenter::cannotDiscardSavedState(const CConsole &console) const
    663667{
    664668    /* Preserve error-info: */
     
    671675}
    672676
    673 void UIMessageCenter::cannotStopMachine(const CConsole &console)
     677void UIMessageCenter::cannotStopMachine(const CConsole &console) const
    674678{
    675679    /* Preserve error-info: */
     
    682686}
    683687
    684 int UIMessageCenter::confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot)
     688int UIMessageCenter::confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot) const
    685689{
    686690    return fAlsoCreateNewSnapshot ?
     
    698702                             tr("Restore"), tr("Cancel"), QString() /* 3rd button text */) :
    699703           message(mainWindowShown(), MessageType_Question,
    700                    tr("<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>").arg(strSnapshotName),
     704                   tr("<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>")
     705                      .arg(strSnapshotName),
    701706                   0 /* auto-confirm id */,
    702707                   QIMessageBox::Ok | QIMessageBox::Default,
     
    706711}
    707712
    708 bool UIMessageCenter::confirmSnapshotRemoval(const QString &strSnapshotName)
     713bool UIMessageCenter::confirmSnapshotRemoval(const QString &strSnapshotName) const
    709714{
    710715    return messageOkCancel(mainWindowShown(), MessageType_Question,
    711716                           tr("<p>Deleting the snapshot will cause the state information saved in it to be lost, and disk data spread over "
    712                               "several image files that VirtualBox has created together with the snapshot will be merged into one file. This can be a lengthy process, and the information "
    713                               "in the snapshot cannot be recovered.</p></p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>")
     717                              "several image files that VirtualBox has created together with the snapshot will be merged into one file. "
     718                              "This can be a lengthy process, and the information in the snapshot cannot be recovered.</p>"
     719                              "</p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>")
    714720                              .arg(strSnapshotName),
    715721                           0 /* auto-confirm id */,
    716                            tr("Delete"), tr("Cancel"));
     722                           tr("Delete"));
    717723}
    718724
     
    720726                                                        const QString &strTargetImageName,
    721727                                                        const QString &strTargetImageMaxSize,
    722                                                         const QString &strTargetFileSystemFree)
     728                                                        const QString &strTargetFileSystemFree) const
    723729{
    724730    return messageOkCancel(mainWindowShown(), MessageType_Question,
     
    735741}
    736742
    737 void UIMessageCenter::cannotRestoreSnapshot(const CConsole &console, const QString &strSnapshotName)
     743void UIMessageCenter::cannotRestoreSnapshot(const CConsole &console, const QString &strSnapshotName) const
    738744{
    739745    message(mainWindowShown(), MessageType_Error,
     
    743749}
    744750
    745 void UIMessageCenter::cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName)
     751void UIMessageCenter::cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName) const
    746752{
    747753    /* Get console: */
     
    756762}
    757763
    758 void UIMessageCenter::cannotRemoveSnapshot(const CConsole &console, const QString &strSnapshotName)
     764void UIMessageCenter::cannotRemoveSnapshot(const CConsole &console, const QString &strSnapshotName) const
    759765{
    760766    message(mainWindowShown(), MessageType_Error,
     
    765771}
    766772
    767 void UIMessageCenter::cannotRemoveSnapshot(const CProgress &progress,
    768                                            const QString &strSnapshotName)
     773void UIMessageCenter::cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName) const
    769774{
    770775    /* Get console: */
     
    774779    /* Show the message: */
    775780    message(mainWindowShown(), MessageType_Error,
    776         tr("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
    777             .arg(strSnapshotName)
    778             .arg(console.GetMachine().GetName()),
    779         formatErrorInfo(progress.GetErrorInfo()));
    780 }
    781 
    782 void UIMessageCenter::cannotSetSystemProperties(const CSystemProperties &properties)
    783 {
    784     message(mainWindowShown(), MessageType_Critical,
    785             tr("Failed to set global VirtualBox properties."),
    786             formatErrorInfo(properties));
    787 }
    788 
    789 void UIMessageCenter::cannotAccessUSB(const COMBaseWithEI &object)
     781            tr("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
     782               .arg(strSnapshotName)
     783               .arg(console.GetMachine().GetName()),
     784            formatErrorInfo(progress.GetErrorInfo()));
     785}
     786
     787void UIMessageCenter::cannotAccessUSB(const COMBaseWithEI &object) const
    790788{
    791789    /* If IMachine::GetUSBController(), IHost::GetUSBDevices() etc. return
     
    795793    if (res.rc() == E_NOTIMPL)
    796794        return;
    797 
     795    /* Show the message: */
    798796    message(mainWindowShown(), res.isWarning() ? MessageType_Warning : MessageType_Error,
    799797             tr("Failed to access the USB subsystem."),
     
    802800}
    803801
    804 void UIMessageCenter::cannotLoadMachineSettings(const CMachine &machine, bool fStrict /*= true*/, QWidget *pParent /*= 0*/)
    805 {
    806     /* This function is NOT use currently.
    807      * We are keeping it here just for convinience with Save analog. */
    808 
    809     /* Preserve error-info.
    810      * If COM result code is E_NOTIMPL, it means the requested
    811      * object or function is intentionally missing (as in the OSE version).
    812      * Don't show the error message in this case. */
    813     COMResult res(machine);
    814     if (!fStrict && res.rc() == E_NOTIMPL)
    815         return;
    816 
    817     /* Show the message: */
    818     message(pParent ? pParent : mainWindowShown(), MessageType_Error,
    819             tr("Failed to load the settings of the virtual machine "
    820                "<b>%1</b> from <b><nobr>%2</nobr></b>.")
    821                .arg(machine.GetName(), machine.GetSettingsFilePath()),
    822             formatErrorInfo(res));
    823 }
    824 
    825 void UIMessageCenter::cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent /*= 0*/)
     802void UIMessageCenter::cannotSetSystemProperties(const CSystemProperties &properties) const
     803{
     804    message(mainWindowShown(), MessageType_Critical,
     805            tr("Failed to set global VirtualBox properties."),
     806            formatErrorInfo(properties));
     807}
     808
     809void UIMessageCenter::cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent /*= 0*/) const
    826810{
    827811    /* Preserve error-info: */
     
    829813    /* Show the message: */
    830814    message(pParent ? pParent : mainWindowShown(), MessageType_Error,
    831             tr("Failed to save the settings of the virtual machine "
    832                "<b>%1</b> to <b><nobr>%2</nobr></b>.")
     815            tr("Failed to save the settings of the virtual machine <b>%1</b> to <b><nobr>%2</nobr></b>.")
    833816               .arg(machine.GetName(), machine.GetSettingsFilePath()),
    834817            formatErrorInfo(res));
    835818}
    836819
    837 void UIMessageCenter::warnAboutStateChange(QWidget *pParent)
    838 {
     820void UIMessageCenter::warnAboutStateChange(QWidget *pParent /*= 0*/) const
     821{
     822    /* Do not show this async warning more than one at time: */
    839823    if (warningShown("warnAboutStateChange"))
    840824        return;
    841825    setWarningShown("warnAboutStateChange", true);
    842 
     826    /* Show the message: */
    843827    message(pParent ? pParent : mainWindowShown(), MessageType_Warning,
    844828            tr("The virtual machine that you are changing has been started. "
    845829               "Only certain settings can be changed while a machine is running. "
    846830               "All other changes will be lost if you close this window now."));
    847 
     831    /* Allow to show this async warning: */
    848832    setWarningShown("warnAboutStateChange", false);
    849833}
    850834
    851 bool UIMessageCenter::confirmSettingsReloading(QWidget *pParent)
    852 {
    853     int rc = message(pParent, MessageType_Question,
    854                      tr("<p>The machine settings were changed while you were editing them. "
    855                         "You currently have unsaved setting changes.</p>"
    856                         "<p>Would you like to reload the changed settings or to keep your own changes?</p>"), 0,
    857                      QIMessageBox::Yes, QIMessageBox::No | QIMessageBox::Default | QIMessageBox::Escape, 0,
    858                      tr("Reload settings"), tr("Keep changes"), 0);
    859     return rc == QIMessageBox::Yes;
    860 }
    861 
    862 int UIMessageCenter::askAboutHardDiskAttachmentCreation(QWidget *pParent,
    863                                                         const QString &strControllerName)
    864 {
    865     return message(pParent, MessageType_Question,
     835bool UIMessageCenter::confirmSettingsReloading(QWidget *pParent /*= 0*/) const
     836{
     837    return messageOkCancel(pParent ? pParent : mainWindowShown(), MessageType_Question,
     838                           tr("<p>The machine settings were changed while you were editing them. "
     839                              "You currently have unsaved setting changes.</p>"
     840                              "<p>Would you like to reload the changed settings or to keep your own changes?</p>"),
     841                           0 /* auto-confirm id */,
     842                           tr("Reload settings"), tr("Keep changes"));
     843}
     844
     845bool UIMessageCenter::confirmDeletingHostInterface(const QString &strName, QWidget *pParent /*= 0*/) const
     846{
     847    return messageOkCancel(pParent ? pParent : mainWindowShown(), MessageType_Question,
     848                           tr("<p>Deleting this host-only network will remove "
     849                              "the host-only interface this network is based on. Do you want to "
     850                              "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>"
     851                              "<p><b>Note:</b> this interface may be in use by one or more "
     852                              "virtual network adapters belonging to one of your VMs. "
     853                              "After it is removed, these adapters will no longer be usable until "
     854                              "you correct their settings by either choosing a different interface "
     855                              "name or a different adapter attachment type.</p>")
     856                              .arg(strName),
     857                           0 /* auto-confirm id */,
     858                           tr("Remove"));
     859}
     860
     861int UIMessageCenter::askAboutHardDiskAttachmentCreation(const QString &strControllerName, QWidget *pParent /*= 0*/) const
     862{
     863    return message(pParent ? pParent : mainWindowShown(), MessageType_Question,
    866864                   tr("<p>You are about to add a virtual hard disk to controller <b>%1</b>.</p>"
    867865                      "<p>Would you like to create a new, empty file to hold the disk contents or select an existing one?</p>")
    868                    .arg(strControllerName),
    869                    0, /* auto-confirm id */
     866                      .arg(strControllerName),
     867                   0 /* auto-confirm id */,
    870868                   QIMessageBox::Yes,
    871869                   QIMessageBox::No,
     
    875873}
    876874
    877 int UIMessageCenter::askAboutOpticalAttachmentCreation(QWidget *pParent,
    878                                                        const QString &strControllerName)
    879 {
    880     return message(pParent, MessageType_Question,
     875int UIMessageCenter::askAboutOpticalAttachmentCreation(const QString &strControllerName, QWidget *pParent /*= 0*/) const
     876{
     877    return message(pParent ? pParent : mainWindowShown(), MessageType_Question,
    881878                   tr("<p>You are about to add a new CD/DVD drive to controller <b>%1</b>.</p>"
    882879                      "<p>Would you like to choose a virtual CD/DVD disk to put in the drive "
    883880                      "or to leave it empty for now?</p>")
    884                    .arg(strControllerName),
    885                    0, /* auto-confirm id */
     881                      .arg(strControllerName),
     882                   0 /* auto-confirm id */,
    886883                   QIMessageBox::Yes,
    887884                   QIMessageBox::No,
     
    891888}
    892889
    893 int UIMessageCenter::askAboutFloppyAttachmentCreation(QWidget *pParent,
    894                                                       const QString &strControllerName)
    895 {
    896     return message(pParent, MessageType_Question,
     890int UIMessageCenter::askAboutFloppyAttachmentCreation(const QString &strControllerName, QWidget *pParent /*= 0*/) const
     891{
     892    return message(pParent ? pParent : mainWindowShown(), MessageType_Question,
    897893                   tr("<p>You are about to add a new floppy drive to controller <b>%1</b>.</p>"
    898894                      "<p>Would you like to choose a virtual floppy disk to put in the drive "
    899895                      "or to leave it empty for now?</p>")
    900                    .arg(strControllerName),
    901                    0, /* auto-confirm id */
     896                      .arg(strControllerName),
     897                   0 /* auto-confirm id */,
    902898                   QIMessageBox::Yes,
    903899                   QIMessageBox::No,
     
    907903}
    908904
    909 int UIMessageCenter::confirmRemovingOfLastDVDDevice() const
    910 {
    911     return messageOkCancel(QApplication::activeWindow(), MessageType_Info,
    912                             tr("<p>Are you sure you want to delete the CD/DVD-ROM device?</p>"
    913                                "<p>You will not be able to mount any CDs or ISO images "
    914                                "or install the Guest Additions without it!</p>"),
    915                             0, /* auto-confirm id */
    916                             tr("&Remove", "medium"));
    917 }
    918 
    919 int UIMessageCenter::confirmDeletingHostInterface(const QString &strName,
    920                                                   QWidget *pParent)
    921 {
    922     return msgCenter().message(pParent, MessageType_Question,
    923         tr("<p>Deleting this host-only network will remove "
    924            "the host-only interface this network is based on. Do you want to "
    925            "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>"
    926            "<p><b>Note:</b> this interface may be in use by one or more "
    927            "virtual network adapters belonging to one of your VMs. "
    928            "After it is removed, these adapters will no longer be usable until "
    929            "you correct their settings by either choosing a different interface "
    930            "name or a different adapter attachment type.</p>").arg(strName),
    931         0, /* auto-confirm id */
    932         QIMessageBox::Ok | QIMessageBox::Default,
    933         QIMessageBox::Cancel | QIMessageBox::Escape);
    934 }
    935 
    936 void UIMessageCenter::warnAboutIncorrectPort(QWidget *pParent) const
    937 {
    938     message(pParent, MessageType_Error,
     905int UIMessageCenter::confirmRemovingOfLastDVDDevice(QWidget *pParent /*= 0*/) const
     906{
     907    return messageOkCancel(pParent ? pParent : mainWindowShown(), MessageType_Info,
     908                           tr("<p>Are you sure you want to delete the CD/DVD-ROM device?</p>"
     909                              "<p>You will not be able to mount any CDs or ISO images "
     910                              "or install the Guest Additions without it!</p>"),
     911                           0 /* auto-confirm id */,
     912                           tr("&Remove", "medium"));
     913}
     914
     915void UIMessageCenter::warnAboutIncorrectPort(QWidget *pParent /*= 0*/) const
     916{
     917    message(pParent ? pParent : mainWindowShown(), MessageType_Error,
    939918            tr("The current port forwarding rules are not valid. "
    940919               "None of the host or guest port values may be set to zero."));
    941920}
    942921
    943 bool UIMessageCenter::confirmCancelingPortForwardingDialog(QWidget *pParent) const
    944 {
    945     return messageOkCancel(pParent, MessageType_Question,
    946         tr("<p>There are unsaved changes in the port forwarding configuration.</p>"
    947            "<p>If you proceed your changes will be discarded.</p>"));
     922bool UIMessageCenter::confirmCancelingPortForwardingDialog(QWidget *pParent /*= 0*/) const
     923{
     924    return messageOkCancel(pParent ? pParent : mainWindowShown(), MessageType_Question,
     925                           tr("<p>There are unsaved changes in the port forwarding configuration.</p>"
     926                              "<p>If you proceed your changes will be discarded.</p>"));
    948927}
    949928
     
    1013992
    1014993    return messageOkCancel(pParent, MessageType_Question, msg,
    1015         "confirmRemoveMedium", /* auto-confirm id */
     994        "confirmRemoveMedium" /* auto-confirm id */,
    1016995        tr("Remove", "medium"));
    1017996}
     
    10301009           "disk to the list later again.</p>")
    10311010        .arg(strLocation),
    1032         0, /* auto-confirm id */
     1011        0 /* auto-confirm id */,
    10331012        QIMessageBox::Yes,
    10341013        QIMessageBox::No | QIMessageBox::Default,
     
    12731252           "until you add one. In the mean time you will only be able to start the "
    12741253           "machine using a virtual optical disk or from the network."),
    1275         0, /* auto-confirm id */
     1254        0 /* auto-confirm id */,
    12761255        QIMessageBox::Ok,
    12771256        QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
     
    13541333           strMachineNames.size()).arg(VBoxGlobal::toHumanReadableList(strMachineNames)),
    13551334        0 /* auto-confirm id */,
    1356         tr("Continue"), tr("Cancel"));
     1335        tr("Continue"));
    13571336}
    13581337
     
    15631542             .arg(strMachineName)
    15641543             .arg(strIfNames),
    1565              0, /* auto-confirm id */
     1544             0 /* auto-confirm id */,
    15661545             tr("Change Network Settings"),
    15671546             tr("Close Virtual Machine"));
     
    18611840                 "or press <b>Cancel</b> to cancel the operation.</p>")
    18621841             .arg(VBoxGlobal::formatSize(uMinVRAM)),
    1863              0, /* auto-confirm id */
     1842             0 /* auto-confirm id */,
    18641843             QIMessageBox::Ignore | QIMessageBox::Default,
    18651844             QIMessageBox::Cancel | QIMessageBox::Escape);
     
    18861865                      "or press <b>Cancel</b> to cancel the operation.</p>")
    18871866                   .arg(VBoxGlobal::formatSize(uMinVRAM)),
    1888                    0, /* auto-confirm id */
     1867                   0 /* auto-confirm id */,
    18891868                   QIMessageBox::Ignore | QIMessageBox::Default,
    18901869                   QIMessageBox::Cancel | QIMessageBox::Escape);
     
    20352014           "it is recommended to press <b>OK</b> now.</p>")
    20362015            .arg(strLogFolder),
    2037         0, /* auto-confirm id */
     2016        0 /* auto-confirm id */,
    20382017        QIMessageBox::Ok | QIMessageBox::Default,
    20392018        QIMessageBox::Ignore | QIMessageBox::Escape);
     
    20782057                              "<nobr><a href=\"%1\">%2</a></nobr> "
    20792058                              "(size %3 bytes)?</p>").arg(strUrl).arg(strUrl).arg(loc.toString(uSize)),
    2080                            0, /* auto-confirm id */
     2059                           0 /* auto-confirm id */,
    20812060                           tr("Download", "additions"));
    20822061}
     
    20922071                              "on the virtual CD/DVD drive?</p>")
    20932072                               .arg(strUrl).arg(strUrl).arg(strSrc),
    2094                            0, /* auto-confirm id */
     2073                           0 /* auto-confirm id */,
    20952074                           tr("Mount", "additions"));
    20962075}
     
    21102089                              "download this file from the Internet?</p>")
    21112090                              .arg(strMissedLocation),
    2112                            0, /* Auto-confirm Id */
     2091                           0 /* auto-confirm id */,
    21132092                           tr("Download", "additions"));
    21142093}
     
    21222101                              "<nobr><a href=\"%1\">%2</a></nobr> "
    21232102                              "(size %3 bytes)?</p>").arg(strURL).arg(strURL).arg(loc.toString(uSize)),
    2124                            0, /* Auto-confirm Id */
     2103                           0 /* auto-confirm id */,
    21252104                           tr("Download", "additions"));
    21262105}
     
    21542133                              "<p>Do you wish to download latest one from the Internet?</p>")
    21552134                              .arg(strExtPackVersion).arg(strExtPackName),
    2156                            0, /* Auto-confirm Id */
     2135                           0 /* auto-confirm id */,
    21572136                           tr("Download", "extension pack"));
    21582137}
     
    21642143                      "<p>You should download and install version %3 of this extension pack from Oracle!</p>")
    21652144                      .arg(strExtPackVersion).arg(strExtPackName).arg(strVBoxVersion),
    2166                       0, /* Auto-confirm Id */
     2145                      0 /* auto-confirm id */,
    21672146                      QIMessageBox::Ok | QIMessageBox::Default,
    21682147                      0,
     
    21782157                              "from <nobr><a href=\"%2\">%2</a></nobr> (size %3 bytes)?</p>")
    21792158                              .arg(strExtPackName, strURL, loc.toString(uSize)),
    2180                            0, /* Auto-confirm Id */
     2159                           0 /* auto-confirm id */,
    21812160                           tr("Download", "extension pack"));
    21822161}
     
    21902169                              "<p>Do you wish to install this extension pack?</p>")
    21912170                              .arg(strExtPackName, strFrom, strTo),
    2192                            0, /* Auto-confirm Id */
     2171                           0 /* auto-confirm id */,
    21932172                           tr ("Install", "extension pack"));
    21942173}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r45285 r45288  
    7878    /* API: Warning registration stuff: */
    7979    bool warningShown(const QString &strWarningName) const;
    80     void setWarningShown(const QString &strWarningName, bool fWarningShown);
     80    void setWarningShown(const QString &strWarningName, bool fWarningShown) const;
    8181
    8282    /* API: Alert providing stuff: Main function: */
     
    186186    /* API: Main (startup) warnings: */
    187187#ifdef RT_OS_LINUX
    188     void warnAboutWrongUSBMounted();
     188    void warnAboutWrongUSBMounted() const;
    189189#endif /* RT_OS_LINUX */
    190     void cannotStartSelector();
    191     void showBETAWarning();
    192     void showBEBWarning();
     190    void cannotStartSelector() const;
     191    void showBETAWarning() const;
     192    void showBEBWarning() const;
    193193
    194194    /* API: COM startup warnings: */
    195     void cannotInitUserHome(const QString &strUserHome);
    196     void cannotInitCOM(HRESULT rc);
    197     void cannotCreateVirtualBox(const CVirtualBox &vbox);
     195    void cannotInitUserHome(const QString &strUserHome) const;
     196    void cannotInitCOM(HRESULT rc) const;
     197    void cannotCreateVirtualBox(const CVirtualBox &vbox) const;
    198198
    199199    /* API: Global warnings: */
    200     void cannotFindLanguage(const QString &strLangId, const QString &strNlsPath);
    201     void cannotLoadLanguage(const QString &strLangFile);
    202     void cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError);
    203     void cannotSaveGlobalConfig(const CVirtualBox &vbox);
    204     void cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName);
    205     void cannotFindMachineById(const CVirtualBox &vbox, const QString &strId);
    206     void cannotOpenSession(const CSession &session);
    207     void cannotOpenSession(const CMachine &machine, const CProgress &progress = CProgress());
    208     void cannotGetMediaAccessibility(const UIMedium &medium);
    209     void cannotOpenURL(const QString &strUrl);
     200    void cannotFindLanguage(const QString &strLangId, const QString &strNlsPath) const;
     201    void cannotLoadLanguage(const QString &strLangFile) const;
     202    void cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError) const;
     203    void cannotSaveGlobalConfig(const CVirtualBox &vbox) const;
     204    void cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName) const;
     205    void cannotFindMachineById(const CVirtualBox &vbox, const QString &strId) const;
     206    void cannotOpenSession(const CSession &session) const;
     207    void cannotOpenSession(const CMachine &machine, const CProgress &progress = CProgress()) const;
     208    void cannotGetMediaAccessibility(const UIMedium &medium) const;
     209    void cannotOpenURL(const QString &strUrl) const;
    210210
    211211    /* API: Selector warnings: */
    212     void cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath);
    213     void cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName);
    214     void cannotResolveCollisionAutomatically(const QString &strName, const QString &strGroupName);
    215     bool confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName);
    216     void cannotSetGroups(const CMachine &machine);
    217     bool confirmMachineItemRemoval(const QStringList &names);
    218     int confirmMachineRemoval(const QList<CMachine> &machines);
    219     void cannotRemoveMachine(const CMachine &machine);
    220     void cannotRemoveMachine(const CMachine &machine, const CProgress &progress);
    221     bool remindAboutInaccessibleMedia();
    222     bool confirmDiscardSavedState(const QString &strNames);
    223     bool confirmVMReset(const QString &strNames);
    224     bool confirmVMACPIShutdown(const QString &strNames);
    225     bool confirmVMPowerOff(const QString &strNames);
    226     void cannotDiscardSavedState(const CConsole &console);
    227     void cannotStopMachine(const CConsole &console);
     212    void cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath) const;
     213    void cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName) const;
     214    void cannotResolveCollisionAutomatically(const QString &strName, const QString &strGroupName) const;
     215    bool confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName) const;
     216    void cannotSetGroups(const CMachine &machine) const;
     217    bool confirmMachineItemRemoval(const QStringList &names) const;
     218    int confirmMachineRemoval(const QList<CMachine> &machines) const;
     219    void cannotRemoveMachine(const CMachine &machine) const;
     220    void cannotRemoveMachine(const CMachine &machine, const CProgress &progress) const;
     221    bool remindAboutInaccessibleMedia() const;
     222    bool confirmDiscardSavedState(const QString &strNames) const;
     223    bool confirmVMReset(const QString &strNames) const;
     224    bool confirmVMACPIShutdown(const QString &strNames) const;
     225    bool confirmVMPowerOff(const QString &strNames) const;
     226    void cannotDiscardSavedState(const CConsole &console) const;
     227    void cannotStopMachine(const CConsole &console) const;
    228228
    229229    /* API: Snapshot warnings: */
    230     int confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot);
    231     bool confirmSnapshotRemoval(const QString &strSnapshotName);
     230    int confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot) const;
     231    bool confirmSnapshotRemoval(const QString &strSnapshotName) const;
    232232    bool warnAboutSnapshotRemovalFreeSpace(const QString &strSnapshotName, const QString &strTargetImageName,
    233                                            const QString &strTargetImageMaxSize, const QString &strTargetFileSystemFree);
    234     void cannotRestoreSnapshot(const CConsole &console, const QString &strSnapshotName);
    235     void cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName);
    236     void cannotRemoveSnapshot(const CConsole &console, const QString &strSnapshotName);
    237     void cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName);
     233                                           const QString &strTargetImageMaxSize, const QString &strTargetFileSystemFree) const;
     234    void cannotRestoreSnapshot(const CConsole &console, const QString &strSnapshotName) const;
     235    void cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName) const;
     236    void cannotRemoveSnapshot(const CConsole &console, const QString &strSnapshotName) const;
     237    void cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName) const;
    238238
    239239    /* API: Settings warnings: */
    240     void cannotSetSystemProperties(const CSystemProperties &properties);
    241     void cannotAccessUSB(const COMBaseWithEI &object);
    242     void cannotLoadMachineSettings(const CMachine &machine, bool fStrict = true, QWidget *pParent = 0);
    243     void cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent = 0);
    244     void warnAboutStateChange(QWidget *pParent);
    245     bool confirmSettingsReloading(QWidget *pParent);
    246     int askAboutHardDiskAttachmentCreation(QWidget *pParent, const QString &strControllerName);
    247     int askAboutOpticalAttachmentCreation(QWidget *pParent, const QString &strControllerName);
    248     int askAboutFloppyAttachmentCreation(QWidget *pParent, const QString &strControllerName);
    249     int confirmRemovingOfLastDVDDevice() const;
    250     int confirmDeletingHostInterface(const QString &strName, QWidget *pParent = 0);
    251     void warnAboutIncorrectPort(QWidget *pParent) const;
    252     bool confirmCancelingPortForwardingDialog(QWidget *pParent) const;
     240    void cannotAccessUSB(const COMBaseWithEI &object) const;
     241    void cannotSetSystemProperties(const CSystemProperties &properties) const;
     242    void cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent = 0) const;
     243    void warnAboutStateChange(QWidget *pParent = 0) const;
     244    bool confirmSettingsReloading(QWidget *pParent = 0) const;
     245    bool confirmDeletingHostInterface(const QString &strName, QWidget *pParent = 0) const;
     246    int askAboutHardDiskAttachmentCreation(const QString &strControllerName, QWidget *pParent = 0) const;
     247    int askAboutOpticalAttachmentCreation(const QString &strControllerName, QWidget *pParent = 0) const;
     248    int askAboutFloppyAttachmentCreation(const QString &strControllerName, QWidget *pParent = 0) const;
     249    int confirmRemovingOfLastDVDDevice(QWidget *pParent = 0) const;
     250    void warnAboutIncorrectPort(QWidget *pParent = 0) const;
     251    bool confirmCancelingPortForwardingDialog(QWidget *pParent = 0) const;
    253252
    254253    /* API: Virtual Medium Manager warnings: */
     
    444443
    445444    /* Variables: */
    446     QStringList m_warnings;
     445    mutable QStringList m_warnings;
    447446};
    448447
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r45281 r45288  
    20062006         * with common cleanup in case of failure.
    20072007         * We have to simulate a try-catch block. */
    2008         bool fSuccess = false;
    20092008        CSession session;
    20102009        CMachine machine;
     
    20242023            machine.SetGroups(newGroupList.toVector());
    20252024            if (!machine.isOk())
     2025            {
     2026                msgCenter().cannotSetGroups(machine);
    20262027                break;
     2028            }
    20272029
    20282030            /* 4. Save settings: */
    20292031            machine.SaveSettings();
    20302032            if (!machine.isOk())
     2033            {
     2034                msgCenter().cannotSaveMachineSettings(machine);
    20312035                break;
    2032 
    2033             /* Transaction complete: */
    2034             fSuccess = true;
     2036            }
    20352037        } while (0);
    20362038
    20372039        /* Cleanup if necessary: */
    2038         if (!fSuccess)
    2039         {
    2040             if (!machine.isNull())
    2041                 msgCenter().cannotSaveMachineSettings(machine);
     2040        if (machine.isNull() || !machine.isOk())
    20422041            emit sigReload(strId);
    2043         }
    20442042        if (!session.isNull())
    20452043            session.UnlockMachine();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp

    r45219 r45288  
    453453    QString strInterfaceName(pItem->name());
    454454    /* Asking user about deleting selected network interface: */
    455     if (msgCenter().confirmDeletingHostInterface(strInterfaceName, this) == QIMessageBox::Cancel)
     455    if (!msgCenter().confirmDeletingHostInterface(strInterfaceName, this))
    456456        return;
    457457
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r44528 r45288  
    24032403        && deviceCount (KDeviceType_DVD) == 1)
    24042404    {
    2405         if (msgCenter().confirmRemovingOfLastDVDDevice() != QIMessageBox::Ok)
     2405        if (!msgCenter().confirmRemovingOfLastDVDDevice(this))
    24062406            return;
    24072407    }
     
    30453045        case KDeviceType_HardDisk:
    30463046        {
    3047             int iAnswer = msgCenter().askAboutHardDiskAttachmentCreation(this, strControllerName);
     3047            int iAnswer = msgCenter().askAboutHardDiskAttachmentCreation(strControllerName, this);
    30483048            if (iAnswer == QIMessageBox::Yes)
    30493049                strMediumId = getWithNewHDWizard();
     
    30543054        case KDeviceType_DVD:
    30553055        {
    3056             int iAnswer = msgCenter().askAboutOpticalAttachmentCreation(this, strControllerName);
     3056            int iAnswer = msgCenter().askAboutOpticalAttachmentCreation(strControllerName, this);
    30573057            if (iAnswer == QIMessageBox::Yes)
    30583058                strMediumId = vboxGlobal().openMediumWithFileOpenDialog(UIMediumType_DVD, this, strMachineFolder);
     
    30633063        case KDeviceType_Floppy:
    30643064        {
    3065             int iAnswer = msgCenter().askAboutFloppyAttachmentCreation(this, strControllerName);
     3065            int iAnswer = msgCenter().askAboutFloppyAttachmentCreation(strControllerName, this);
    30663066            if (iAnswer == QIMessageBox::Yes)
    30673067                strMediumId = vboxGlobal().openMediumWithFileOpenDialog(UIMediumType_Floppy, this, strMachineFolder);
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