VirtualBox

Changeset 66398 in vbox for trunk


Ignore:
Timestamp:
Apr 3, 2017 12:04:28 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Chooser pane: Ask user for a confirmation when starting multiple VMs.

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

Legend:

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

    r65599 r66398  
    844844             .arg(strMachineName),
    845845          formatErrorInfo(progress));
     846}
     847
     848bool UIMessageCenter::confirmStartMultipleMachines(const QString &strNames) const
     849{
     850    return questionBinary(0, MessageType_Question,
     851                          tr("<p>You are about to start all of the following virtual machines:</p>"
     852                             "<p><b>%1</b></p><p>This could take some time and consume a lot of "
     853                             "host system resources. Do you wish to proceed?</p>").arg(strNames),
     854                          "confirmStartMultipleMachines" /* auto-confirm id */);
    846855}
    847856
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r65268 r66398  
    201201    void cannotPowerDownMachine(const CConsole &console) const;
    202202    void cannotPowerDownMachine(const CProgress &progress, const QString &strMachineName) const;
     203    bool confirmStartMultipleMachines(const QString &strNames) const;
    203204
    204205    /* API: Snapshot warnings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r66397 r66398  
    20072007void UISelectorWindow::performStartOrShowVirtualMachines(const QList<UIVMItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode)
    20082008{
     2009    /* Do nothing while group saving is in progress: */
     2010    if (m_pPaneChooser->isGroupSavingInProgress())
     2011        return;
     2012
     2013    /* Compose the list of startable items: */
     2014    QStringList startableMachineNames;
     2015    QList<UIVMItem*> startableItems;
     2016    foreach (UIVMItem *pItem, items)
     2017        if (isAtLeastOneItemCanBeStarted(QList<UIVMItem*>() << pItem))
     2018        {
     2019            startableItems << pItem;
     2020            startableMachineNames << pItem->name();
     2021        }
     2022
     2023    /* Initially we have start auto-confirmed: */
     2024    bool fStartConfirmed = true;
     2025    /* But if we have more than one item to start =>
     2026     * We should still ask user for a confirmation: */
     2027    if (startableItems.size() > 1)
     2028        fStartConfirmed = msgCenter().confirmStartMultipleMachines(startableMachineNames.join(", "));
     2029
    20092030    /* For every item => check if it could be launched: */
    20102031    foreach (UIVMItem *pItem, items)
    2011         if (isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
     2032        if (   isAtLeastOneItemCanBeShown(QList<UIVMItem*>() << pItem)
     2033            || (   isAtLeastOneItemCanBeStarted(QList<UIVMItem*>() << pItem)
     2034                && fStartConfirmed))
    20122035        {
    20132036            /* Fetch item launch mode: */
     
    23412364
    23422365/* static */
     2366bool UISelectorWindow::isAtLeastOneItemCanBeStarted(const QList<UIVMItem*> &items)
     2367{
     2368    foreach (UIVMItem *pItem, items)
     2369    {
     2370        if (UIVMItem::isItemPoweredOff(pItem) && UIVMItem::isItemEditable(pItem))
     2371            return true;
     2372    }
     2373    return false;
     2374}
     2375
     2376/* static */
     2377bool UISelectorWindow::isAtLeastOneItemCanBeShown(const QList<UIVMItem*> &items)
     2378{
     2379    foreach (UIVMItem *pItem, items)
     2380    {
     2381        if (UIVMItem::isItemStarted(pItem) && (pItem->canSwitchTo() || UIVMItem::isItemRunningHeadless(pItem)))
     2382            return true;
     2383    }
     2384    return false;
     2385}
     2386
     2387/* static */
    23432388bool UISelectorWindow::isAtLeastOneItemCanBeStartedOrShown(const QList<UIVMItem*> &items)
    23442389{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r66397 r66398  
    294294        /** Returns whether at least one of passed @a items is removable. */
    295295        static bool isAtLeastOneItemRemovable(const QList<UIVMItem*> &items);
     296        /** Returns whether at least one of passed @a items can be started. */
     297        static bool isAtLeastOneItemCanBeStarted(const QList<UIVMItem*> &items);
     298        /** Returns whether at least one of passed @a items can be shown. */
     299        static bool isAtLeastOneItemCanBeShown(const QList<UIVMItem*> &items);
    296300        /** Returns whether at least one of passed @a items can be started or shown. */
    297301        static bool isAtLeastOneItemCanBeStartedOrShown(const QList<UIVMItem*> &items);
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