VirtualBox

Changeset 42542 in vbox


Ignore:
Timestamp:
Aug 2, 2012 2:04:02 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Menu action for group creating added.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp

    r42526 r42542  
    531531};
    532532
     533class UIActionSimpleMachineAddGroupDialog : public UIActionSimple
     534{
     535    Q_OBJECT;
     536
     537public:
     538
     539    UIActionSimpleMachineAddGroupDialog(QObject *pParent)
     540        : UIActionSimple(pParent, ":/add_shared_folder_16px.png")
     541    {
     542        retranslateUi();
     543    }
     544
     545protected:
     546
     547    void retranslateUi()
     548    {
     549        setText(QApplication::translate("UIActionPool", "&Add group..."));
     550        setStatusTip(QApplication::translate("UIActionPool", "Add a new group based on the items selected"));
     551        setShortcut(gSS->keySequence(UISelectorShortcuts::AddVMGroupShortcut));
     552    }
     553};
     554
    533555class UIActionSimpleMachineSettingsDialog : public UIActionSimple
    534556{
     
    944966    m_pool[UIActionIndexSelector_Simple_Machine_NewWizard] = new UIActionSimpleMachineNewWizard(this);
    945967    m_pool[UIActionIndexSelector_Simple_Machine_AddDialog] = new UIActionSimpleMachineAddDialog(this);
     968    m_pool[UIActionIndexSelector_Simple_Machine_AddGroupDialog] = new UIActionSimpleMachineAddGroupDialog(this);
    946969    m_pool[UIActionIndexSelector_Simple_Machine_SettingsDialog] = new UIActionSimpleMachineSettingsDialog(this);
    947970    m_pool[UIActionIndexSelector_Simple_Machine_CloneWizard] = new UIActionSimpleMachineCloneWizard(this);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h

    r42526 r42542  
    5252    UIActionIndexSelector_Simple_Machine_NewWizard,
    5353    UIActionIndexSelector_Simple_Machine_AddDialog,
     54    UIActionIndexSelector_Simple_Machine_AddGroupDialog,
    5455    UIActionIndexSelector_Simple_Machine_SettingsDialog,
    5556    UIActionIndexSelector_Simple_Machine_CloneWizard,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.cpp

    r42526 r42542  
    3333    m_Shortcuts[NewVMShortcut]               = UIKeySequence("NewVM",               "Ctrl+N");
    3434    m_Shortcuts[AddVMShortcut]               = UIKeySequence("AddVM",               "Ctrl+A");
     35    m_Shortcuts[AddVMGroupShortcut]          = UIKeySequence("AddVMGroup",          "Ctrl+U");
    3536    m_Shortcuts[SettingsVMShortcut]          = UIKeySequence("SettingsVM",          "Ctrl+S");
    3637    m_Shortcuts[CloneVMShortcut]             = UIKeySequence("CloneVM",             "Ctrl+O");
     
    4243    m_Shortcuts[PauseVMShortcut]             = UIKeySequence("PauseVM",             "Ctrl+P");
    4344    m_Shortcuts[ResetVMShortcut]             = UIKeySequence("ResetVM",             "Ctrl+T");
    44     m_Shortcuts[ACPIShutdownVMShortcut]      = UIKeySequence("ACPIShutdownVM",      "Ctrl+U");
     45    m_Shortcuts[ACPIShutdownVMShortcut]      = UIKeySequence("ACPIShutdownVM",      "Ctrl+H");
    4546    m_Shortcuts[PowerOffVMShortcut]          = UIKeySequence("PowerOffVM",          "Ctrl+F");
    4647    m_Shortcuts[RefreshVMShortcut]           = UIKeySequence("RefreshVM");
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.h

    r42526 r42542  
    3535        NewVMShortcut,
    3636        AddVMShortcut,
     37        AddVMGroupShortcut,
    3738        SettingsVMShortcut,
    3839        CloneVMShortcut,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r42533 r42542  
    759759    m_pActionMachineSettingsDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, items));
    760760    m_pActionMachineCloneWizard->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, items));
     761    m_pActionMachineAddGroupDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_AddGroupDialog, items));
    761762    m_pActionMachineRemoveDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, items));
    762763    m_pActionMachineStartOrShow->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, items));
     
    12061207    m_pActionMachineCloneWizard = gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard);
    12071208    pMenu->addAction(m_pActionMachineCloneWizard);
     1209    m_pActionMachineAddGroupDialog = gActionPool->action(UIActionIndexSelector_Simple_Machine_AddGroupDialog);
     1210    pMenu->addAction(m_pActionMachineAddGroupDialog);
    12081211    m_pActionMachineRemoveDialog = gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog);
    12091212    pMenu->addAction(m_pActionMachineRemoveDialog);
     
    12351238    m_machineActions << m_pActionMachineNewWizard << m_pActionMachineAddDialog
    12361239                     << m_pActionMachineSettingsDialog << m_pActionMachineCloneWizard
     1240                     << m_pActionMachineAddGroupDialog
    12371241                     << m_pActionMachineRemoveDialog << m_pActionMachineStartOrShow
    12381242                     << m_pActionMachineDiscard << m_pActionMachinePauseAndResume
     
    15891593                   pItem->sessionState() == KSessionState_Unlocked;
    15901594        }
     1595        case UIActionIndexSelector_Simple_Machine_AddGroupDialog:
     1596        {
     1597            /* Check that there is more than one item,
     1598             * all items are accessible and in 'powered off' states: */
     1599            return items.size() > 1 &&
     1600                   isItemsAccessible(items) &&
     1601                   isItemsPoweredOff(items);
     1602        }
    15911603        case UIActionIndexSelector_Simple_Group_RenameDialog:
    15921604        case UIActionIndexSelector_Simple_Group_RemoveDialog:
     
    17681780}
    17691781
     1782/* static */
     1783bool UISelectorWindow::isItemsPoweredOff(const QList<UIVMItem*> &items)
     1784{
     1785    foreach (UIVMItem *pItem, items)
     1786        if (!(pItem->machineState() == KMachineState_PoweredOff ||
     1787              pItem->machineState() == KMachineState_Saved ||
     1788              pItem->machineState() == KMachineState_Teleported ||
     1789              pItem->machineState() == KMachineState_Aborted))
     1790        return false;
     1791    return true;
     1792}
     1793
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r42533 r42542  
    139139    static bool isItemsHasUnlockedSession(const QList<UIVMItem*> &items);
    140140    static bool isItemsSupportsShortcuts(const QList<UIVMItem*> &items);
     141    static bool isItemsPoweredOff(const QList<UIVMItem*> &items);
    141142
    142143    /* Central splitter window: */
     
    192193    UIAction *m_pActionMachineSettingsDialog;
    193194    UIAction *m_pActionMachineCloneWizard;
     195    UIAction *m_pActionMachineAddGroupDialog;
    194196    UIAction *m_pActionMachineRemoveDialog;
    195197    UIAction *m_pActionMachineStartOrShow;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r42529 r42542  
    657657        unregisterMachines(names);
    658658    }
     659}
     660
     661void UIGChooserModel::sltAddGroupBasedOnChosenItems()
     662{
     663    /* Create new group in the current root: */
     664    UIGChooserItemGroup *pNewGroupItem = new UIGChooserItemGroup(root(), uniqueGroupName(root()));
     665    /* Enumerate all the currently chosen items: */
     666    QStringList busyGroupNames;
     667    QStringList busyMachineNames;
     668    foreach (UIGChooserItem *pItem, selectionList())
     669    {
     670        /* For each of known types: */
     671        switch (pItem->type())
     672        {
     673            case UIGChooserItemType_Group:
     674            {
     675                /* Avoid name collisions: */
     676                if (busyGroupNames.contains(pItem->name()))
     677                    break;
     678                /* Copy group item: */
     679                new UIGChooserItemGroup(pNewGroupItem, pItem->toGroupItem());
     680                busyGroupNames << pItem->name();
     681                break;
     682            }
     683            case UIGChooserItemType_Machine:
     684            {
     685                /* Avoid name collisions: */
     686                if (busyMachineNames.contains(pItem->name()))
     687                    break;
     688                /* Copy machine item: */
     689                new UIGChooserItemMachine(pNewGroupItem, pItem->toMachineItem());
     690                busyMachineNames << pItem->name();
     691                break;
     692            }
     693        }
     694    }
     695    /* Update model: */
     696    updateNavigation();
     697    updateLayout();
     698    setCurrentItem(pNewGroupItem);
    659699}
    660700
     
    774814    m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog));
    775815    m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard));
     816    m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_AddGroupDialog));
    776817    m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog));
    777818    m_pContextMenuMachine->addSeparator();
     
    798839    connect(gActionPool->action(UIActionIndexSelector_Simple_Group_RemoveDialog), SIGNAL(triggered()),
    799840            this, SLOT(sltRemoveCurrentlySelectedGroup()));
     841    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_AddGroupDialog), SIGNAL(triggered()),
     842            this, SLOT(sltAddGroupBasedOnChosenItems()));
    800843    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog), SIGNAL(triggered()),
    801844            this, SLOT(sltRemoveCurrentlySelectedMachine()));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r42529 r42542  
    156156    void sltRemoveCurrentlySelectedMachine();
    157157
     158    /* Handler: Group add stuff: */
     159    void sltAddGroupBasedOnChosenItems();
     160
    158161    /* Handler: Group name editing stuff: */
    159162    void sltStartEditingSelectedGroup();
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