VirtualBox

Changeset 42751 in vbox


Ignore:
Timestamp:
Aug 10, 2012 11:24:04 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79969
Message:

FE/Qt: 6234: Support for VM groups: Add 'save state' action into selector main/context menus.

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

Legend:

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

    r42631 r42751  
    867867};
    868868
     869class UIActionSimpleSave : public UIActionSimple
     870{
     871    Q_OBJECT;
     872
     873public:
     874
     875    UIActionSimpleSave(QObject *pParent)
     876        : UIActionSimple(pParent, ":/state_saved_16px.png")
     877    {
     878        retranslateUi();
     879    }
     880
     881protected:
     882
     883    void retranslateUi()
     884    {
     885        setText(QApplication::translate("UIActionPool", "Save state"));
     886        setStatusTip(QApplication::translate("UIActionPool", "Save the machine state of the selected virtual machine"));
     887        setShortcut(gSS->keySequence(UISelectorShortcuts::SaveVMShortcut));
     888    }
     889};
     890
    869891class UIActionSimpleACPIShutdown : public UIActionSimple
    870892{
     
    9821004
    9831005    /* 'Machine/Close' actions: */
     1006    m_pool[UIActionIndexSelector_Simple_Machine_Close_Save] = new UIActionSimpleSave(this);
    9841007    m_pool[UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown] = new UIActionSimpleACPIShutdown(this);
    9851008    m_pool[UIActionIndexSelector_Simple_Machine_Close_PowerOff] = new UIActionSimplePowerOff(this);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h

    r42563 r42751  
    6969    /* 'Machine/Close' menu actions: */
    7070    UIActionIndexSelector_Menu_Machine_Close,
     71    UIActionIndexSelector_Simple_Machine_Close_Save,
    7172    UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown,
    7273    UIActionIndexSelector_Simple_Machine_Close_PowerOff,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.cpp

    r42631 r42751  
    4343    m_Shortcuts[PauseVMShortcut]             = UIKeySequence("PauseVM",             "Ctrl+P");
    4444    m_Shortcuts[ResetVMShortcut]             = UIKeySequence("ResetVM",             "Ctrl+T");
     45    m_Shortcuts[SaveVMShortcut]              = UIKeySequence("SaveVM",              "Ctrl+V");
    4546    m_Shortcuts[ACPIShutdownVMShortcut]      = UIKeySequence("ACPIShutdownVM",      "Ctrl+H");
    4647    m_Shortcuts[PowerOffVMShortcut]          = UIKeySequence("PowerOffVM",          "Ctrl+F");
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.h

    r42631 r42751  
    4545        PauseVMShortcut,
    4646        ResetVMShortcut,
     47        SaveVMShortcut,
    4748        ACPIShutdownVMShortcut,
    4849        PowerOffVMShortcut,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r42734 r42751  
    562562        /* Reset VM: */
    563563        console.Reset();
     564
     565        /* Unlock machine finally: */
     566        session.UnlockMachine();
     567    }
     568}
     569
     570void UISelectorWindow::sltPerformSaveAction()
     571{
     572    /* Get selected items: */
     573    QList<UIVMItem*> items = currentItems();
     574    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     575
     576    /* Check if all the items could be saved: */
     577    if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_Save, items))
     578        return;
     579
     580    /* For each selected item: */
     581    foreach (UIVMItem *pItem, items)
     582    {
     583        /* Open a session to modify VM state: */
     584        CSession session = vboxGlobal().openExistingSession(pItem->id());
     585        if (session.isNull())
     586        {
     587            msgCenter().cannotOpenSession(session);
     588            return;
     589        }
     590
     591        /* Get session console: */
     592        CConsole console = session.GetConsole();
     593        /* Save machine state: */
     594        CProgress progress = console.SaveState();
     595        if (!console.isOk())
     596            msgCenter().cannotSaveMachineState(console);
     597        else
     598        {
     599            /* Get machine: */
     600            CMachine machine = session.GetMachine();
     601            /* Show the "VM saving" progress dialog: */
     602            msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png", 0, true);
     603            if (progress.GetResultCode() != 0)
     604                msgCenter().cannotSaveMachineState(progress);
     605        }
    564606
    565607        /* Unlock machine finally: */
     
    11811223
    11821224    /* Populate Machine/Close-menu: */
     1225    m_pSaveAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_Save);
     1226    pMenu->addAction(m_pSaveAction);
    11831227    m_pACPIShutdownAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown);
    11841228    pMenu->addAction(m_pACPIShutdownAction);
     
    13291373    /* 'Machine/Close' menu connections: */
    13301374    connect(m_pMachineCloseMenu, SIGNAL(aboutToShow()), this, SLOT(sltMachineCloseMenuAboutToShow()));
     1375    connect(m_pSaveAction, SIGNAL(triggered()), this, SLOT(sltPerformSaveAction()));
    13311376    connect(m_pACPIShutdownAction, SIGNAL(triggered()), this, SLOT(sltPerformACPIShutdownAction()));
    13321377    connect(m_pPowerOffAction, SIGNAL(triggered()), this, SLOT(sltPerformPowerOffAction()));
     
    15341579    /* Enable/disable machine-close actions: */
    15351580    m_pMachineCloseMenuAction->setEnabled(isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, items));
     1581    m_pSaveAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_Save, items));
    15361582    m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, items));
    15371583    m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, items));
     
    17301776            return pItem->machineState() == KMachineState_Running ||
    17311777                   pItem->machineState() == KMachineState_Paused;
     1778        }
     1779        case UIActionIndexSelector_Simple_Machine_Close_Save:
     1780        {
     1781            /* The same as 'Machine/Close' menu is enabled: */
     1782            return isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, items);
    17321783        }
    17331784        case UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown:
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r42722 r42751  
    9393    void sltPerformPauseResumeAction(bool fPause);
    9494    void sltPerformResetAction();
     95    void sltPerformSaveAction();
    9596    void sltPerformACPIShutdownAction();
    9697    void sltPerformPowerOffAction();
     
    217218    UIAction *m_pMachineCloseMenuAction;
    218219    QMenu *m_pMachineCloseMenu;
     220    UIAction *m_pSaveAction;
    219221    UIAction *m_pACPIShutdownAction;
    220222    UIAction *m_pPowerOffAction;
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