Changeset 99218 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 30, 2023 12:09:03 PM (22 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.cpp
r98103 r99218 342 342 bool UIToolPaneMachine::isCurrentStateItemSelected() const 343 343 { 344 if (!m_pPaneSnapshots) 345 return false; 346 return m_pPaneSnapshots->isCurrentStateItemSelected(); 344 return m_pPaneSnapshots ? m_pPaneSnapshots->isCurrentStateItemSelected() : false; 345 } 346 347 QUuid UIToolPaneMachine::currentSnapshotId() 348 { 349 return m_pPaneSnapshots ? m_pPaneSnapshots->currentSnapshotId() : QUuid(); 347 350 } 348 351 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.h
r98103 r99218 33 33 34 34 /* Qt includes: */ 35 #include <QUuid> 35 36 #include <QWidget> 36 37 … … 108 109 bool isCurrentStateItemSelected() const; 109 110 111 /** Returns currently selected snapshot ID if any. */ 112 QUuid currentSnapshotId(); 113 110 114 /** Returns the help keyword of the current tool's widget. */ 111 115 QString currentHelpKeyword() const; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r99207 r99218 470 470 , m_pWidget(0) 471 471 , m_iGeometrySaveTimerId(-1) 472 , m_fSnapshotCloneByDefault(false) 472 473 , m_fImportFromOCI(false) 473 474 , m_fExportToOCI(false) … … 990 991 m_wizards[enmType] = new UIWizardNewVM(this, actionPool(), m_pWidget->fullGroupName(), m_strISOFilePath); 991 992 break; 993 case WizardType_CloneVM: 994 { 995 UIVirtualMachineItem *pItem = currentItem(); 996 UIVirtualMachineItemLocal *pItemLocal = pItem ? pItem->toLocal() : 0; 997 CMachine comMachine = pItemLocal ? pItemLocal->machine() : CMachine(); 998 CSnapshot comSnapshot; 999 if (m_fSnapshotCloneByDefault) 1000 { 1001 const QUuid uId = m_pWidget->currentSnapshotId(); 1002 if (!uId.isNull() && comMachine.isNotNull()) 1003 { 1004 printf("Looking for snapshot with ID = {%s}\n", uId.toString().toUtf8().constData()); 1005 comSnapshot = comMachine.FindSnapshot(uId.toString()); 1006 if (comSnapshot.isNotNull()) 1007 { 1008 printf("Snapshot found, acquiring machine ..\n"); 1009 const CMachine comSnapshotMachine = comSnapshot.GetMachine(); 1010 if (comSnapshotMachine.isNotNull()) 1011 comMachine = comSnapshotMachine; 1012 } 1013 } 1014 } 1015 m_wizards[enmType] = new UIWizardCloneVM(this, 1016 comMachine, 1017 pItemLocal->groups().value(0), 1018 comSnapshot); 1019 break; 1020 } 992 1021 case WizardType_ExportAppliance: 993 1022 m_wizards[enmType] = new UIWizardExportApp(this, m_names, m_fExportToOCI); … … 1169 1198 void UIVirtualBoxManager::sltOpenCloneMachineWizard() 1170 1199 { 1171 /* Get current item: */ 1172 UIVirtualMachineItem *pItem = currentItem(); 1173 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 1174 /* Make sure current item is local one: */ 1175 UIVirtualMachineItemLocal *pItemLocal = pItem->toLocal(); 1176 AssertMsgReturnVoid(pItemLocal, ("Current item should be local one!\n")); 1177 1178 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 1179 QWidget *pWizardParent = windowManager().realParentWindow(this); 1180 const QStringList &machineGroupNames = pItemLocal->groups(); 1181 const QString strGroup = !machineGroupNames.isEmpty() ? machineGroupNames.at(0) : QString(); 1182 QPointer<UINativeWizard> pWizard = new UIWizardCloneVM(pWizardParent, pItemLocal->machine(), strGroup, CSnapshot()); 1183 windowManager().registerNewParent(pWizard, pWizardParent); 1184 pWizard->exec(); 1185 delete pWizard; 1200 /* Configure wizard variables: */ 1201 m_fSnapshotCloneByDefault = false; 1202 QAction *pAction = qobject_cast<QAction*>(sender()); 1203 if ( pAction 1204 && pAction == actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone)) 1205 m_fSnapshotCloneByDefault = true; 1206 1207 /* Open Clone VM Wizard: */ 1208 sltOpenWizard(WizardType_CloneVM); 1186 1209 } 1187 1210 … … 2327 2350 connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Clone), &UIAction::triggered, 2328 2351 this, &UIVirtualBoxManager::sltOpenCloneMachineWizard); 2352 connect(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone), &UIAction::triggered, 2353 this, &UIVirtualBoxManager::sltOpenCloneMachineWizard); 2329 2354 connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Move), &UIAction::triggered, 2330 2355 this, &UIVirtualBoxManager::sltPerformMachineMove); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r99207 r99218 525 525 QString m_strISOFilePath; 526 526 527 /** Holds whether snapshot clone should be done by clone VM wizard. */ 528 bool m_fSnapshotCloneByDefault; 529 527 530 /** Holds whether OCI importing should be started by default. */ 528 531 bool m_fImportFromOCI; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r98103 r99218 274 274 { 275 275 return m_pPaneToolsMachine->isCurrentStateItemSelected(); 276 } 277 278 QUuid UIVirtualBoxManagerWidget::currentSnapshotId() 279 { 280 return m_pPaneToolsMachine->currentSnapshotId(); 276 281 } 277 282 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r98103 r99218 33 33 34 34 /* Qt includes: */ 35 #include <QUuid> 35 36 #include <QWidget> 36 37 … … 214 215 /** Returns whether current-state item of Snapshot pane is selected. */ 215 216 bool isCurrentStateItemSelected() const; 217 218 /** Returns currently selected snapshot ID if any. */ 219 QUuid currentSnapshotId(); 216 220 /** @} */ 217 221 -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp
r98779 r99218 63 63 /* COM includes: */ 64 64 #include "CConsole.h" 65 #include "CSnapshot.h" 65 66 66 67 … … 585 586 UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 586 587 return m_currentStateItems.values().contains(pSnapshotItem); 588 } 589 590 QUuid UISnapshotPane::currentSnapshotId() 591 { 592 UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 593 CSnapshot comSnapshot = pSnapshotItem ? pSnapshotItem->snapshot() : CSnapshot(); 594 return comSnapshot.isNotNull() ? comSnapshot.GetId() : QUuid(); 587 595 } 588 596 … … 1303 1311 connect(m_pActionPool->action(UIActionIndexMN_M_Snapshot_T_Properties), &UIAction::toggled, 1304 1312 this, &UISnapshotPane::sltToggleSnapshotDetailsVisibility); 1305 connect(m_pActionPool->action(UIActionIndexMN_M_Snapshot_S_Clone), &UIAction::triggered,1306 this, &UISnapshotPane::sltCloneSnapshot);1307 1313 } 1308 1314 … … 1739 1745 } 1740 1746 1741 void UISnapshotPane::cloneSnapshot()1742 {1743 /* Acquire "current snapshot" item: */1744 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());1745 AssertReturnVoid(pSnapshotItem);1746 1747 /* Get desired machine/snapshot: */1748 CMachine comMachine;1749 CSnapshot comSnapshot;1750 if (pSnapshotItem->isCurrentStateItem())1751 comMachine = pSnapshotItem->machine();1752 else1753 {1754 comSnapshot = pSnapshotItem->snapshot();1755 AssertReturnVoid(!comSnapshot.isNull());1756 comMachine = comSnapshot.GetMachine();1757 }1758 AssertReturnVoid(!comMachine.isNull());1759 1760 /* Show Clone VM wizard: */1761 QPointer<UINativeWizard> pWizard = new UIWizardCloneVM(this, comMachine, QString(), comSnapshot);1762 pWizard->exec();1763 if (pWizard)1764 delete pWizard;1765 }1766 1767 1747 void UISnapshotPane::adjustTreeWidget() 1768 1748 { -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.h
r98103 r99218 32 32 #endif 33 33 34 /* Qt includes: */ 35 #include <QUuid> 36 34 37 /* GUI includes: */ 35 38 #include "QIWithRetranslateUI.h" … … 37 40 38 41 /* COM includes: */ 42 #include "COMEnums.h" 39 43 #include "CMachine.h" 40 44 … … 52 56 class UISnapshotTree; 53 57 class UIVirtualMachineItem; 58 class CSnapshot; 54 59 55 60 … … 90 95 /** Returns whether "current state" item selected. */ 91 96 bool isCurrentStateItemSelected() const; 97 98 /** Returns currently selected snapshot ID if any. */ 99 QUuid currentSnapshotId(); 92 100 93 101 protected: … … 145 153 /** Handles command to apply snapshot details changes. */ 146 154 void sltApplySnapshotDetailsChanges(); 147 /** Proposes to clone the snapshot. */148 void sltCloneSnapshot() { cloneSnapshot(); }149 155 /** @} */ 150 156 … … 202 208 /** Proposes to restore the snapshot. */ 203 209 bool restoreSnapshot(bool fAutomatically = false); 204 /** Proposes to clone the snapshot. */205 void cloneSnapshot();206 210 /** @} */ 207 211
Note:
See TracChangeset
for help on using the changeset viewer.