儲存庫 vbox 的更動 67540
- 時間撮記:
- 2017-6-21 下午01:40:27 (7 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r67535 r67540 1085 1085 { 1086 1086 /* As snapshot-restore procedure: */ 1087 if (pSnapshotItem->snapshot().isNotNull()) 1087 if (pSnapshotItem->isCurrentStateItem()) 1088 takeSnapshot(true /* automatically */); 1089 else 1088 1090 restoreSnapshot(true /* suppress non-critical warnings */); 1089 1091 } … … 1179 1181 QString(), this, &UISnapshotPane::sltTakeSnapshot); 1180 1182 { 1181 m_pActionTakeSnapshot->setShortcut(QString("Ctrl+Shift+ S"));1183 m_pActionTakeSnapshot->setShortcut(QString("Ctrl+Shift+T")); 1182 1184 } 1183 1185 … … 1453 1455 } 1454 1456 1455 bool UISnapshotPane::takeSnapshot( )1457 bool UISnapshotPane::takeSnapshot(bool fAutomatically /* = false */) 1456 1458 { 1457 1459 /* Simulate try-catch block: */ … … 1474 1476 CMachine comMachine = comSession.GetMachine(); 1475 1477 1476 /* Create take-snapshot dialog: */ 1477 QWidget *pDlgParent = windowManager().realParentWindow(this); 1478 QPointer<UITakeSnapshotDialog> pDlg = new UITakeSnapshotDialog(pDlgParent, m_comMachine); 1479 windowManager().registerNewParent(pDlg, pDlgParent); 1480 1481 /* Assign corresponding icon: */ 1482 QPixmap pixmap = vboxGlobal().vmUserPixmapDefault(m_comMachine); 1483 if (pixmap.isNull()) 1484 pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(m_comMachine.GetOSTypeId()); 1485 pDlg->setPixmap(pixmap); 1486 1487 /* Search for the max available snapshot index: */ 1488 int iMaxSnapShotIndex = 0; 1489 QString strSnapshotName = tr("Snapshot %1"); 1490 QRegExp regExp(QString("^") + strSnapshotName.arg("([0-9]+)") + QString("$")); 1478 /* Search for a maximum available snapshot index: */ 1479 int iMaximumIndex = 0; 1480 const QString strNameTemplate = tr("Snapshot %1"); 1481 const QRegExp reName(QString("^") + strNameTemplate.arg("([0-9]+)") + QString("$")); 1491 1482 QTreeWidgetItemIterator iterator(m_pSnapshotTree); 1492 1483 while (*iterator) 1493 1484 { 1494 QString strSnapshot = static_cast<UISnapshotItem*>(*iterator)->text(Column_Name); 1495 int iPos = regExp.indexIn(strSnapshot); 1496 if (iPos != -1) 1497 iMaxSnapShotIndex = regExp.cap(1).toInt() > iMaxSnapShotIndex ? regExp.cap(1).toInt() : iMaxSnapShotIndex; 1485 const QString strName = static_cast<UISnapshotItem*>(*iterator)->text(Column_Name); 1486 const int iPosition = reName.indexIn(strName); 1487 if (iPosition != -1) 1488 iMaximumIndex = reName.cap(1).toInt() > iMaximumIndex 1489 ? reName.cap(1).toInt() 1490 : iMaximumIndex; 1498 1491 ++iterator; 1499 1492 } 1500 /* Assign corresponding snapshot name: */ 1501 pDlg->setName(strSnapshotName.arg(iMaxSnapShotIndex + 1)); 1502 1503 /* Show Take Snapshot dialog: */ 1504 if (pDlg->exec() != QDialog::Accepted) 1493 1494 /* Prepare final snapshot name/description: */ 1495 QString strFinalName = strNameTemplate.arg(iMaximumIndex + 1); 1496 QString strFinalDescription; 1497 1498 /* Should we take snapshot manually? */ 1499 if (!fAutomatically) 1505 1500 { 1506 /* Cleanup dialog if it wasn't destroyed in own loop: */ 1507 if (pDlg) 1508 delete pDlg; 1501 /* Create take-snapshot dialog: */ 1502 QWidget *pDlgParent = windowManager().realParentWindow(this); 1503 QPointer<UITakeSnapshotDialog> pDlg = new UITakeSnapshotDialog(pDlgParent, comMachine); 1504 windowManager().registerNewParent(pDlg, pDlgParent); 1505 1506 /* Assign corresponding icon: */ 1507 QPixmap pixmap = vboxGlobal().vmUserPixmapDefault(comMachine); 1508 if (pixmap.isNull()) 1509 pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(comMachine.GetOSTypeId()); 1510 pDlg->setPixmap(pixmap); 1511 1512 /* Assign corresponding snapshot name: */ 1513 pDlg->setName(strFinalName); 1514 1515 /* Show Take Snapshot dialog: */ 1516 if (pDlg->exec() != QDialog::Accepted) 1517 { 1518 /* Cleanup dialog if it wasn't destroyed in own loop: */ 1519 if (pDlg) 1520 delete pDlg; 1521 break; 1522 } 1523 1524 /* Acquire final snapshot name/description: */ 1525 strFinalName = pDlg->name().trimmed(); 1526 strFinalDescription = pDlg->description(); 1527 1528 /* Cleanup dialog: */ 1529 delete pDlg; 1530 } 1531 1532 /* Take snapshot: */ 1533 QString strSnapshotId; 1534 CProgress comProgress = comMachine.TakeSnapshot(strFinalName, strFinalDescription, true, strSnapshotId); 1535 if (!comMachine.isOk()) 1536 { 1537 msgCenter().cannotTakeSnapshot(comMachine, comMachine.GetName()); 1509 1538 break; 1510 1539 } 1511 1540 1512 /* Acquire real snapshot name/description: */1513 const QString strRealSnapshotName = pDlg->name().trimmed();1514 const QString strRealSnapshotDescription = pDlg->description();1515 1516 /* Cleanup dialog: */1517 delete pDlg;1518 1519 /* Take snapshot: */1520 QString strSnapshotID;1521 CProgress comProgress = comMachine.TakeSnapshot(strRealSnapshotName, strRealSnapshotDescription, true, strSnapshotID);1522 if (!comMachine.isOk())1523 {1524 msgCenter().cannotTakeSnapshot(comMachine, m_comMachine.GetName());1525 break;1526 }1527 1528 1541 /* Show snapshot taking progress: */ 1529 msgCenter().showModalProgressDialog(comProgress, m_comMachine.GetName(), ":/progress_snapshot_create_90px.png");1542 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_snapshot_create_90px.png"); 1530 1543 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1531 1544 { 1532 msgCenter().cannotTakeSnapshot(comProgress, m_comMachine.GetName());1545 msgCenter().cannotTakeSnapshot(comProgress, comMachine.GetName()); 1533 1546 break; 1534 1547 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r67517 r67540 167 167 168 168 /** Proposes to take a snapshot. */ 169 bool takeSnapshot( );169 bool takeSnapshot(bool fAutomatically = false); 170 170 /** Proposes to delete the snapshot. */ 171 171 bool deleteSnapshot();
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器