VirtualBox

Ignore:
Timestamp:
Aug 6, 2012 12:12:48 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Creating new VM in currently selected group (or parent of currently selected machine).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r42587 r42616  
    3737#include "UIGChooserHandlerMouse.h"
    3838#include "UIGChooserHandlerKeyboard.h"
     39#include "UIWizardNewVM.h"
     40#include "UISelectorWindow.h"
    3941
    4042/* COM includes: */
     
    5153    , m_pMouseHandler(0)
    5254    , m_pKeyboardHandler(0)
    53     , m_pContextMenuRoot(0)
    5455    , m_pContextMenuGroup(0)
    5556    , m_pContextMenuMachine(0)
     
    716717}
    717718
     719void UIGChooserModel::sltCreateNewMachine()
     720{
     721    UIGChooserItem *pGroup = 0;
     722    if (singleGroupSelected())
     723        pGroup = selectionList().first();
     724    else if (!selectionList().isEmpty())
     725        pGroup = selectionList().first()->parentItem();
     726    if (pGroup)
     727    {
     728        UIWizardNewVM wizard(&vboxGlobal().selectorWnd(), fullName(pGroup));
     729        wizard.exec();
     730    }
     731    else
     732    {
     733        UIWizardNewVM wizard(&vboxGlobal().selectorWnd());
     734        wizard.exec();
     735    }
     736}
     737
    718738void UIGChooserModel::sltActionHovered(QAction *pAction)
    719739{
     
    804824void UIGChooserModel::prepareContextMenu()
    805825{
    806     /* Context menu for empty group: */
    807     m_pContextMenuRoot = new QMenu;
    808     m_pContextMenuRoot->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_NewWizard));
    809     m_pContextMenuRoot->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_AddDialog));
    810 
    811826    /* Context menu for group: */
    812827    m_pContextMenuGroup = new QMenu;
     
    851866    m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Common_SortParent));
    852867
    853     connect(m_pContextMenuRoot, SIGNAL(hovered(QAction*)), this, SLOT(sltActionHovered(QAction*)));
    854868    connect(m_pContextMenuGroup, SIGNAL(hovered(QAction*)), this, SLOT(sltActionHovered(QAction*)));
    855869    connect(m_pContextMenuMachine, SIGNAL(hovered(QAction*)), this, SLOT(sltActionHovered(QAction*)));
    856870
     871    connect(gActionPool->action(UIActionIndexSelector_Simple_Group_NewWizard), SIGNAL(triggered()),
     872            this, SLOT(sltCreateNewMachine()));
     873    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_NewWizard), SIGNAL(triggered()),
     874            this, SLOT(sltCreateNewMachine()));
    857875    connect(gActionPool->action(UIActionIndexSelector_Simple_Group_RenameDialog), SIGNAL(triggered()),
    858876            this, SLOT(sltStartEditingSelectedGroup()));
     
    907925void UIGChooserModel::cleanupContextMenu()
    908926{
    909     delete m_pContextMenuRoot;
    910     m_pContextMenuRoot = 0;
    911927    delete m_pContextMenuGroup;
    912928    m_pContextMenuGroup = 0;
     
    14131429                            return true;
    14141430                        }
    1415                         /* Is this root-group item? */
    1416                         else if (!pGroupItem->parentItem())
    1417                         {
    1418                             /* Root context menu in that cases: */
    1419                             popupContextMenu(UIGraphicsSelectorContextMenuType_Root, pEvent->screenPos());
    1420                             return true;
    1421                         }
     1431                        return false;
    14221432                    }
    14231433                    case UIGChooserItemType_Machine:
     
    14311441                }
    14321442            }
    1433             /* Root context menu for all the other cases: */
    1434             popupContextMenu(UIGraphicsSelectorContextMenuType_Root, pEvent->screenPos());
    14351443            return true;
    14361444        }
     
    14631471                }
    14641472            }
    1465             /* Root context menu for all the other cases: */
    1466             popupContextMenu(UIGraphicsSelectorContextMenuType_Root, pEvent->screenPos());
    14671473            return true;
    14681474        }
     
    14791485    switch (type)
    14801486    {
    1481         /* For empty group? */
    1482         case UIGraphicsSelectorContextMenuType_Root:
    1483         {
    1484             m_pContextMenuRoot->exec(point);
    1485             break;
    1486         }
    14871487        /* For group? */
    14881488        case UIGraphicsSelectorContextMenuType_Group:
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