VirtualBox

Changeset 66397 in vbox


Ignore:
Timestamp:
Apr 3, 2017 11:54:11 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114349
Message:

FE/Qt: Selector UI: Chooser pane: Unify start-or-show VM processing code under one handler.

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

Legend:

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

    r66279 r66397  
    50435043        case LaunchMode_Separate: strType = vboxGlobal().isSeparateProcess() ? "headless" : "separate"; break;
    50445044        case LaunchMode_Headless: strType = "headless"; break;
     5045        default: AssertFailedReturn(false);
    50455046    }
    50465047
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r66152 r66397  
    8181    enum LaunchMode
    8282    {
     83        LaunchMode_Invalid,
    8384        LaunchMode_Default,
    8485        LaunchMode_Headless,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r66152 r66397  
    6969# include "UIDesktopWidgetWatchdog.h"
    7070# include "UIModalWindowManager.h"
    71 # include "VBoxGlobal.h"
    7271# ifdef VBOX_WS_MAC
    7372#  include "VBoxUtils.h"
     
    604603void UISelectorWindow::sltPerformStartOrShowMachine()
    605604{
    606     /* Get selected items: */
     605    /* Start selected VMs in corresponding mode: */
    607606    QList<UIVMItem*> items = currentItems();
    608607    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    609 
    610     /* For every selected item: */
    611     foreach (UIVMItem *pItem, items)
    612     {
    613         /* Check if current item could be started/showed: */
    614         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    615             continue;
    616 
    617         /* Launch/show current VM: */
    618         CMachine machine = pItem->machine();
    619         vboxGlobal().launchMachine(machine,
    620                                    UIVMItem::isItemRunningHeadless(pItem)         ? VBoxGlobal::LaunchMode_Separate :
    621                                    qApp->keyboardModifiers() == Qt::ShiftModifier ? VBoxGlobal::LaunchMode_Headless :
    622                                                                                     VBoxGlobal::LaunchMode_Default);
    623     }
     608    performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Invalid);
    624609}
    625610
    626611void UISelectorWindow::sltPerformStartMachineNormal()
    627612{
    628     /* Get selected items: */
     613    /* Start selected VMs in corresponding mode: */
    629614    QList<UIVMItem*> items = currentItems();
    630615    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    631 
    632     /* For every selected item: */
    633     foreach (UIVMItem *pItem, items)
    634     {
    635         /* Check if current item could be started/showed: */
    636         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    637             continue;
    638 
    639         /* Launch/show current VM: */
    640         CMachine machine = pItem->machine();
    641         vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Default);
    642     }
     616    performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Default);
    643617}
    644618
    645619void UISelectorWindow::sltPerformStartMachineHeadless()
    646620{
    647     /* Get selected items: */
     621    /* Start selected VMs in corresponding mode: */
    648622    QList<UIVMItem*> items = currentItems();
    649623    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    650 
    651     /* For every selected item: */
    652     foreach (UIVMItem *pItem, items)
    653     {
    654         /* Check if current item could be started/showed: */
    655         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    656             continue;
    657 
    658         /* Launch/show current VM: */
    659         CMachine machine = pItem->machine();
    660         vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Headless);
    661     }
     624    performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Headless);
    662625}
    663626
    664627void UISelectorWindow::sltPerformStartMachineDetachable()
    665628{
    666     /* Get selected items: */
     629    /* Start selected VMs in corresponding mode: */
    667630    QList<UIVMItem*> items = currentItems();
    668631    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    669 
    670     /* For every selected item: */
    671     foreach (UIVMItem *pItem, items)
    672     {
    673         /* Check if current item could be started/showed: */
    674         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    675             continue;
    676 
    677         /* Launch/show current VM: */
    678         CMachine machine = pItem->machine();
    679         vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate);
    680     }
     632    performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Separate);
    681633}
    682634
     
    20532005}
    20542006
     2007void UISelectorWindow::performStartOrShowVirtualMachines(const QList<UIVMItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode)
     2008{
     2009    /* For every item => check if it could be launched: */
     2010    foreach (UIVMItem *pItem, items)
     2011        if (isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
     2012        {
     2013            /* Fetch item launch mode: */
     2014            VBoxGlobal::LaunchMode enmItemLaunchMode = enmLaunchMode;
     2015            if (enmItemLaunchMode == VBoxGlobal::LaunchMode_Invalid)
     2016                enmItemLaunchMode = UIVMItem::isItemRunningHeadless(pItem)         ? VBoxGlobal::LaunchMode_Separate :
     2017                                    qApp->keyboardModifiers() == Qt::ShiftModifier ? VBoxGlobal::LaunchMode_Headless :
     2018                                                                                     VBoxGlobal::LaunchMode_Default;
     2019
     2020            /* Launch current VM: */
     2021            CMachine machine = pItem->machine();
     2022            vboxGlobal().launchMachine(machine, enmItemLaunchMode);
     2023        }
     2024}
     2025
    20552026void UISelectorWindow::updateActionsAppearance()
    20562027{
     
    22102181        {
    22112182            return !m_pPaneChooser->isGroupSavingInProgress() &&
    2212                    isAtLeastOneItemCanBeStartedOrShowed(items);
     2183                   isAtLeastOneItemCanBeStartedOrShown(items);
    22132184        }
    22142185        case UIActionIndexST_M_Group_S_Discard:
     
    23702341
    23712342/* static */
    2372 bool UISelectorWindow::isAtLeastOneItemCanBeStartedOrShowed(const QList<UIVMItem*> &items)
     2343bool UISelectorWindow::isAtLeastOneItemCanBeStartedOrShown(const QList<UIVMItem*> &items)
    23732344{
    23742345    foreach (UIVMItem *pItem, items)
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r64767 r66397  
    2525#include "QIMainWindow.h"
    2626#include "QIWithRetranslateUI.h"
     27#include "VBoxGlobal.h"
    2728
    2829/* Forward declarations: */
     
    266267    /** @} */
    267268
     269    /** @name VM launching stuff.
     270      * @{ */
     271        /** Launches or shows virtual machines represented by passed @a items in corresponding @a enmLaunchMode (for launch). */
     272        void performStartOrShowVirtualMachines(const QList<UIVMItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode);
     273    /** @} */
     274
    268275    /** @name Action update stuff.
    269276      * @{ */
     
    288295        static bool isAtLeastOneItemRemovable(const QList<UIVMItem*> &items);
    289296        /** Returns whether at least one of passed @a items can be started or shown. */
    290         static bool isAtLeastOneItemCanBeStartedOrShowed(const QList<UIVMItem*> &items);
     297        static bool isAtLeastOneItemCanBeStartedOrShown(const QList<UIVMItem*> &items);
    291298        /** Returns whether at least one of passed @a items can be discarded. */
    292299        static bool isAtLeastOneItemDiscardable(const QList<UIVMItem*> &items);
Note: See TracChangeset for help on using the changeset viewer.

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