- Timestamp:
- May 31, 2017 9:44:38 AM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 7 edited
- 8 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc
r67068 r67160 136 136 <file alias="site_oracle_16px.png">images/site_oracle_16px.png</file> 137 137 <file alias="site_warning_16px.png">images/site_warning_16px.png</file> 138 <file alias="snapshot_commit_details_16px.png">images/snapshot_commit_details_16px.png</file> 139 <file alias="snapshot_commit_details_22px.png">images/snapshot_commit_details_22px.png</file> 140 <file alias="snapshot_commit_details_disabled_16px.png">images/snapshot_commit_details_disabled_16px.png</file> 141 <file alias="snapshot_commit_details_disabled_22px.png">images/snapshot_commit_details_disabled_22px.png</file> 138 142 <file alias="snapshot_delete_16px.png">images/snapshot_delete_16px.png</file> 139 143 <file alias="snapshot_delete_22px.png">images/snapshot_delete_22px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2_hidpi.qrc
r67068 r67160 145 145 <file alias="site_oracle_16px_hidpi.png">images/hidpi/site_oracle_16px_hidpi.png</file> 146 146 <file alias="site_warning_16px_hidpi.png">images/hidpi/site_warning_16px_hidpi.png</file> 147 <file alias="snapshot_manager_16px_hidpi.png">images/hidpi/snapshot_manager_16px_hidpi.png</file> 148 <file alias="snapshot_manager_22px_hidpi.png">images/hidpi/snapshot_manager_22px_hidpi.png</file> 147 <file alias="snapshot_commit_details_16px_hidpi.png">images/hidpi/snapshot_commit_details_16px_hidpi.png</file> 148 <file alias="snapshot_commit_details_22px_hidpi.png">images/hidpi/snapshot_commit_details_22px_hidpi.png</file> 149 <file alias="snapshot_commit_details_disabled_16px_hidpi.png">images/hidpi/snapshot_commit_details_disabled_16px_hidpi.png</file> 150 <file alias="snapshot_commit_details_disabled_22px_hidpi.png">images/hidpi/snapshot_commit_details_disabled_22px_hidpi.png</file> 149 151 <file alias="snapshot_delete_16px_hidpi.png">images/hidpi/snapshot_delete_16px_hidpi.png</file> 150 152 <file alias="snapshot_delete_22px_hidpi.png">images/hidpi/snapshot_delete_22px_hidpi.png</file> 151 153 <file alias="snapshot_delete_disabled_16px_hidpi.png">images/hidpi/snapshot_delete_disabled_16px_hidpi.png</file> 152 154 <file alias="snapshot_delete_disabled_22px_hidpi.png">images/hidpi/snapshot_delete_disabled_22px_hidpi.png</file> 155 <file alias="snapshot_manager_16px_hidpi.png">images/hidpi/snapshot_manager_16px_hidpi.png</file> 156 <file alias="snapshot_manager_22px_hidpi.png">images/hidpi/snapshot_manager_22px_hidpi.png</file> 153 157 <file alias="snapshot_offline_16px_hidpi.png">images/hidpi/snapshot_offline_16px_hidpi.png</file> 154 158 <file alias="snapshot_online_16px_hidpi.png">images/hidpi/snapshot_online_16px_hidpi.png</file> -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotDetailsDlg.cpp
r67147 r67160 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBoxSnapshotDetailsDlgclass implementation.3 * VBox Qt GUI - UISnapshotDetailsWidget class implementation. 4 4 */ 5 5 … … 256 256 257 257 /********************************************************************************************************************************* 258 * Class VBoxSnapshotDetailsDlg implementation.*258 * Class UISnapshotDetailsWidget implementation. * 259 259 *********************************************************************************************************************************/ 260 260 261 VBoxSnapshotDetailsDlg::VBoxSnapshotDetailsDlg(QWidget *pParent /* = 0 */)262 : QIWithRetranslateUI<Q Dialog>(pParent)261 UISnapshotDetailsWidget::UISnapshotDetailsWidget(QWidget *pParent /* = 0 */) 262 : QIWithRetranslateUI<QWidget>(pParent) 263 263 { 264 264 /* Prepare: */ … … 266 266 } 267 267 268 void VBoxSnapshotDetailsDlg::setData(const UIDataSnapshot &data, const CSnapshot &comSnapshot)268 void UISnapshotDetailsWidget::setData(const UIDataSnapshot &data, const CSnapshot &comSnapshot) 269 269 { 270 270 /* Cache old/new data: */ … … 275 275 m_comSnapshot = comSnapshot; 276 276 277 /* Load general snapshot properties: */ 278 mLeName->setText(m_newData.m_strName); 279 mTeDescription->setText(m_newData.m_strDescription); 280 281 /* If there is really a snapshot: */ 282 if (m_comSnapshot.isNotNull()) 283 { 284 /* Calculate snapshot timestamp info: */ 285 QDateTime timestamp; 286 timestamp.setTime_t(m_comSnapshot.GetTimeStamp() / 1000); 287 bool fDateTimeToday = timestamp.date() == QDate::currentDate(); 288 QString dateTime = fDateTimeToday ? timestamp.time().toString(Qt::LocalDate) : timestamp.toString(Qt::LocalDate); 289 mTxTaken->setText(dateTime); 290 291 /* Read snapshot display contents: */ 292 CMachine comMachine = m_comSnapshot.GetMachine(); 293 ULONG iWidth = 0, iHeight = 0; 294 295 /* Get thumbnail if present: */ 296 QVector<BYTE> thumbData = comMachine.ReadSavedThumbnailToArray(0, KBitmapFormat_BGR0, iWidth, iHeight); 297 m_pixmapThumbnail = thumbData.size() != 0 ? QPixmap::fromImage(QImage(thumbData.data(), 298 iWidth, iHeight, 299 QImage::Format_RGB32).copy()) 300 : QPixmap(); 301 302 /* Get screenshot if present: */ 303 QVector<BYTE> screenData = comMachine.ReadSavedScreenshotToArray(0, KBitmapFormat_PNG, iWidth, iHeight); 304 m_pixmapScreenshot = screenData.size() != 0 ? QPixmap::fromImage(QImage::fromData(screenData.data(), 305 screenData.size(), 306 "PNG")) 307 : QPixmap(); 308 309 // TODO: Check whether layout manipulations are really 310 // necessary, they looks a bit dangerous to me.. 311 QGridLayout *pLayout = qobject_cast<QGridLayout*>(layout()); 312 AssertPtrReturnVoid(pLayout); 313 if (m_pixmapThumbnail.isNull()) 314 { 315 pLayout->removeWidget(mLbThumbnail); 316 mLbThumbnail->setHidden(true); 317 318 pLayout->removeWidget(mLeName); 319 pLayout->removeWidget(mTxTaken); 320 pLayout->addWidget(mLeName, 0, 1, 1, 2); 321 pLayout->addWidget(mTxTaken, 1, 1, 1, 2); 322 } 323 else 324 { 325 pLayout->removeWidget(mLeName); 326 pLayout->removeWidget(mTxTaken); 327 pLayout->addWidget(mLeName, 0, 1); 328 pLayout->addWidget(mTxTaken, 1, 1); 329 330 pLayout->removeWidget(mLbThumbnail); 331 pLayout->addWidget(mLbThumbnail, 0, 2, 2, 1); 332 mLbThumbnail->setHidden(false); 333 } 334 } 335 else 336 { 337 /* Clear snapshot timestamp info: */ 338 mTxTaken->clear(); 339 340 // TODO: Check whether layout manipulations are really 341 // necessary, they looks a bit dangerous to me.. 342 QGridLayout *pLayout = qobject_cast<QGridLayout*>(layout()); 343 AssertPtrReturnVoid(pLayout); 344 { 345 pLayout->removeWidget(mLbThumbnail); 346 mLbThumbnail->setHidden(true); 347 348 pLayout->removeWidget(mLeName); 349 pLayout->removeWidget(mTxTaken); 350 pLayout->addWidget(mLeName, 0, 1, 1, 2); 351 pLayout->addWidget(mTxTaken, 1, 1, 1, 2); 352 } 353 } 354 355 /* Retranslate: */ 356 retranslateUi(); 357 } 358 359 void VBoxSnapshotDetailsDlg::saveData() 360 { 361 /* Make sure there is a snapshot: */ 362 AssertReturnVoid(m_comSnapshot.isNotNull()); 363 364 /* We need a session when we manipulate the snapshot data of a machine. */ 365 CSession comSession = vboxGlobal().openExistingSession(m_comSnapshot.GetMachine().GetId()); 366 if (comSession.isNull()) 367 return; 368 369 /* Save snapshot name: */ 370 m_comSnapshot.SetName(m_newData.m_strName); 371 /* Save snapshot description: */ 372 m_comSnapshot.SetDescription(m_newData.m_strDescription); 373 374 /* Close the session again. */ 375 comSession.UnlockMachine(); 376 } 377 378 bool VBoxSnapshotDetailsDlg::eventFilter(QObject *pObject, QEvent *pEvent) 277 /* Load snapshot data: */ 278 loadSnapshotData(); 279 } 280 281 void UISnapshotDetailsWidget::clearData() 282 { 283 /* Reset old/new data: */ 284 m_oldData = UIDataSnapshot(); 285 m_newData = m_oldData; 286 287 /* Reset snapshot: */ 288 m_comSnapshot = CSnapshot(); 289 290 /* Load snapshot data: */ 291 loadSnapshotData(); 292 } 293 294 bool UISnapshotDetailsWidget::eventFilter(QObject *pObject, QEvent *pEvent) 379 295 { 380 296 /* We have filter for thumbnail label only: */ … … 394 310 395 311 /* Call to base-class: */ 396 return Q Dialog::eventFilter(pObject, pEvent);397 } 398 399 void VBoxSnapshotDetailsDlg::retranslateUi()312 return QWidget::eventFilter(pObject, pEvent); 313 } 314 315 void UISnapshotDetailsWidget::retranslateUi() 400 316 { 401 317 /* Translate uic generated strings: */ … … 424 340 } 425 341 426 void VBoxSnapshotDetailsDlg::showEvent(QShowEvent *pEvent)342 void UISnapshotDetailsWidget::showEvent(QShowEvent *pEvent) 427 343 { 428 344 /* Call to base-class: */ 429 QIWithRetranslateUI<Q Dialog>::showEvent(pEvent);345 QIWithRetranslateUI<QWidget>::showEvent(pEvent); 430 346 431 347 /* Make sure we should polish dialog: */ … … 440 356 } 441 357 442 void VBoxSnapshotDetailsDlg::polishEvent(QShowEvent * /* pEvent */)358 void UISnapshotDetailsWidget::polishEvent(QShowEvent * /* pEvent */) 443 359 { 444 360 /* If we haven't assigned the thumbnail yet, do it now: */ … … 453 369 } 454 370 455 void VBoxSnapshotDetailsDlg::sltHandleNameChange(const QString &strName) 456 { 457 /* Recache snapshot name: */ 458 m_newData.m_strName = strName; 459 /* Perform snapshot name sanity check: */ 460 mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!strName.trimmed().isEmpty()); 461 } 462 463 void VBoxSnapshotDetailsDlg::sltHandleDescriptionChange() 464 { 465 /* Recache snapshot description: */ 371 void UISnapshotDetailsWidget::sltHandleNameChange() 372 { 373 m_newData.m_strName = mLeName->text(); 374 //revalidate(m_pErrorPaneName); 375 notify(); 376 } 377 378 void UISnapshotDetailsWidget::sltHandleDescriptionChange() 379 { 466 380 m_newData.m_strDescription = mTeDescription->toPlainText(); 467 } 468 469 void VBoxSnapshotDetailsDlg::prepare() 381 //revalidate(m_pErrorPaneName); 382 notify(); 383 } 384 385 void UISnapshotDetailsWidget::prepare() 470 386 { 471 387 /* Apply UI decorations: */ … … 479 395 /* Configure editor: */ 480 396 connect(mLeName, &QLineEdit::textChanged, 481 this, & VBoxSnapshotDetailsDlg::sltHandleNameChange);397 this, &UISnapshotDetailsWidget::sltHandleNameChange); 482 398 } 483 399 … … 487 403 /* Configure editor: */ 488 404 connect(mTeDescription, &QTextEdit::textChanged, 489 this, & VBoxSnapshotDetailsDlg::sltHandleDescriptionChange);405 this, &UISnapshotDetailsWidget::sltHandleDescriptionChange); 490 406 } 491 407 … … 508 424 } 509 425 426 void UISnapshotDetailsWidget::loadSnapshotData() 427 { 428 /* Read general snapshot properties: */ 429 mLeName->setText(m_newData.m_strName); 430 mTeDescription->setText(m_newData.m_strDescription); 431 432 /* If there is a snapshot: */ 433 if (m_comSnapshot.isNotNull()) 434 { 435 /* Calculate snapshot timestamp info: */ 436 QDateTime timestamp; 437 timestamp.setTime_t(m_comSnapshot.GetTimeStamp() / 1000); 438 bool fDateTimeToday = timestamp.date() == QDate::currentDate(); 439 QString dateTime = fDateTimeToday ? timestamp.time().toString(Qt::LocalDate) : timestamp.toString(Qt::LocalDate); 440 mTxTaken->setText(dateTime); 441 442 /* Read snapshot display contents: */ 443 CMachine comMachine = m_comSnapshot.GetMachine(); 444 ULONG iWidth = 0, iHeight = 0; 445 446 /* Get thumbnail if present: */ 447 QVector<BYTE> thumbData = comMachine.ReadSavedThumbnailToArray(0, KBitmapFormat_BGR0, iWidth, iHeight); 448 m_pixmapThumbnail = thumbData.size() != 0 ? QPixmap::fromImage(QImage(thumbData.data(), 449 iWidth, iHeight, 450 QImage::Format_RGB32).copy()) 451 : QPixmap(); 452 453 /* Get screenshot if present: */ 454 QVector<BYTE> screenData = comMachine.ReadSavedScreenshotToArray(0, KBitmapFormat_PNG, iWidth, iHeight); 455 m_pixmapScreenshot = screenData.size() != 0 ? QPixmap::fromImage(QImage::fromData(screenData.data(), 456 screenData.size(), 457 "PNG")) 458 : QPixmap(); 459 460 // TODO: Check whether layout manipulations are really 461 // necessary, they looks a bit dangerous to me.. 462 QGridLayout *pLayout = qobject_cast<QGridLayout*>(layout()); 463 AssertPtrReturnVoid(pLayout); 464 if (m_pixmapThumbnail.isNull()) 465 { 466 pLayout->removeWidget(mLbThumbnail); 467 mLbThumbnail->setHidden(true); 468 469 pLayout->removeWidget(mLeName); 470 pLayout->removeWidget(mTxTaken); 471 pLayout->addWidget(mLeName, 0, 1, 1, 2); 472 pLayout->addWidget(mTxTaken, 1, 1, 1, 2); 473 } 474 else 475 { 476 pLayout->removeWidget(mLeName); 477 pLayout->removeWidget(mTxTaken); 478 pLayout->addWidget(mLeName, 0, 1); 479 pLayout->addWidget(mTxTaken, 1, 1); 480 481 pLayout->removeWidget(mLbThumbnail); 482 pLayout->addWidget(mLbThumbnail, 0, 2, 2, 1); 483 mLbThumbnail->setHidden(false); 484 } 485 } 486 else 487 { 488 /* Clear snapshot timestamp info: */ 489 mTxTaken->clear(); 490 491 // TODO: Check whether layout manipulations are really 492 // necessary, they looks a bit dangerous to me.. 493 QGridLayout *pLayout = qobject_cast<QGridLayout*>(layout()); 494 AssertPtrReturnVoid(pLayout); 495 { 496 pLayout->removeWidget(mLbThumbnail); 497 mLbThumbnail->setHidden(true); 498 499 pLayout->removeWidget(mLeName); 500 pLayout->removeWidget(mTxTaken); 501 pLayout->addWidget(mLeName, 0, 1, 1, 2); 502 pLayout->addWidget(mTxTaken, 1, 1, 1, 2); 503 } 504 } 505 506 /* Retranslate: */ 507 retranslateUi(); 508 } 509 510 void UISnapshotDetailsWidget::notify() 511 { 512 // if (m_oldData != m_newData) 513 // printf("Snapshot: %s, %s\n", 514 // m_newData.m_strName.toUtf8().constData(), 515 // m_newData.m_strDescription.toUtf8().constData()); 516 517 emit sigDataChanged(m_oldData != m_newData); 518 } 519 510 520 #include "VBoxSnapshotDetailsDlg.moc" 511 521 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotDetailsDlg.h
r67147 r67160 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBoxSnapshotDetailsDlgclass declaration.3 * VBox Qt GUI - UISnapshotDetailsWidget class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef ___ VBoxSnapshotDetailsDlg_h___19 #define ___ VBoxSnapshotDetailsDlg_h___18 #ifndef ___UISnapshotDetailsWidget_h___ 19 #define ___UISnapshotDetailsWidget_h___ 20 20 21 21 /* GUI includes: */ … … 57 57 58 58 59 /** Q Dialog extension providing GUI with snapshot details dialog. */60 class VBoxSnapshotDetailsDlg : public QIWithRetranslateUI<QDialog>, public Ui::VBoxSnapshotDetailsDlg59 /** QWidget extension providing GUI with snapshot details-widget. */ 60 class UISnapshotDetailsWidget : public QIWithRetranslateUI<QWidget>, public Ui::VBoxSnapshotDetailsDlg 61 61 { 62 62 Q_OBJECT; 63 63 64 signals: 65 66 /** Notifies listeners about data changed and whether it @a fDiffers. */ 67 void sigDataChanged(bool fDiffers); 68 64 69 public: 65 70 66 /** Constructs snapshot details dialogpassing @a pParent to the base-class. */67 VBoxSnapshotDetailsDlg(QWidget *pParent = 0);71 /** Constructs snapshot details-widget passing @a pParent to the base-class. */ 72 UISnapshotDetailsWidget(QWidget *pParent = 0); 68 73 74 /** Returns the snapshot data. */ 75 const UIDataSnapshot &data() const { return m_newData; } 69 76 /** Defines the snapshot @a data. */ 70 77 void setData(const UIDataSnapshot &data, const CSnapshot &comSnapshot); 71 /** Saves the snapshot data. */72 void saveData();78 /** Clears the snapshot data. */ 79 void clearData(); 73 80 74 81 protected: … … 87 94 private slots: 88 95 89 /** Handles snapshot @a strName change. */90 void sltHandleNameChange( const QString &strName);96 /** Handles snapshot name change. */ 97 void sltHandleNameChange(); 91 98 /** Handles snapshot description change. */ 92 99 void sltHandleDescriptionChange(); … … 96 103 /** Prepares all. */ 97 104 void prepare(); 105 106 /** Loads snapshot data. */ 107 void loadSnapshotData(); 108 109 /** Notifies listeners about data changed or not. */ 110 void notify(); 98 111 99 112 /** Holds whether this widget was polished. */ … … 114 127 }; 115 128 116 #endif /* !___ VBoxSnapshotDetailsDlg_h___ */129 #endif /* !___UISnapshotDetailsWidget_h___ */ 117 130 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotDetailsDlg.ui
r67067 r67160 14 14 </comment> 15 15 <class>VBoxSnapshotDetailsDlg</class> 16 <widget class="Q Dialog" name="VBoxSnapshotDetailsDlg">16 <widget class="QWidget" name="VBoxSnapshotDetailsDlg"> 17 17 <property name="geometry"> 18 18 <rect> … … 147 147 </widget> 148 148 </item> 149 <item row="4" column="0" colspan="3">150 <widget class="QIDialogButtonBox" name="mButtonBox">151 <property name="standardButtons">152 <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>153 </property>154 </widget>155 </item>156 149 </layout> 157 150 </widget> 158 <customwidgets>159 <customwidget>160 <class>QIDialogButtonBox</class>161 <extends>QDialogButtonBox</extends>162 <header>QIDialogButtonBox.h</header>163 </customwidget>164 </customwidgets>165 151 <resources> 166 152 <include location="../VirtualBox1.qrc"/> 167 153 </resources> 168 <connections>169 <connection>170 <sender>mButtonBox</sender>171 <signal>accepted()</signal>172 <receiver>VBoxSnapshotDetailsDlg</receiver>173 <slot>accept()</slot>174 <hints>175 <hint type="sourcelabel">176 <x>203</x>177 <y>365</y>178 </hint>179 <hint type="destinationlabel">180 <x>203</x>181 <y>193</y>182 </hint>183 </hints>184 </connection>185 <connection>186 <sender>mButtonBox</sender>187 <signal>rejected()</signal>188 <receiver>VBoxSnapshotDetailsDlg</receiver>189 <slot>reject()</slot>190 <hints>191 <hint type="sourcelabel">192 <x>203</x>193 <y>365</y>194 </hint>195 <hint type="destinationlabel">196 <x>203</x>197 <y>193</y>198 </hint>199 </hints>200 </connection>201 </connections>202 154 </ui> -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r67147 r67160 531 531 , m_pActionRestoreSnapshot(0) 532 532 , m_pActionShowSnapshotDetails(0) 533 , m_pActionCommitSnapshotDetails(0) 533 534 , m_pActionCloneSnapshot(0) 534 535 , m_pSnapshotTree(0) 535 536 , m_pCurrentSnapshotItem(0) 537 , m_pDetailsWidget(0) 536 538 { 537 539 /* Prepare: */ … … 583 585 m_pActionRestoreSnapshot->setText(tr("&Restore")); 584 586 m_pActionShowSnapshotDetails->setText(tr("D&etails...")); 587 m_pActionCommitSnapshotDetails->setText(tr("&Apply...")); 585 588 m_pActionCloneSnapshot->setText(tr("&Clone...")); 586 589 /* Translate actions tool-tips: */ … … 591 594 m_pActionRestoreSnapshot->setToolTip(tr("Restore Snapshot (%1)") 592 595 .arg(m_pActionRestoreSnapshot->shortcut().toString())); 593 m_pActionShowSnapshotDetails->setToolTip(tr(" ShowSnapshot Details (%1)")596 m_pActionShowSnapshotDetails->setToolTip(tr("Open Snapshot Details (%1)") 594 597 .arg(m_pActionShowSnapshotDetails->shortcut().toString())); 598 m_pActionCommitSnapshotDetails->setToolTip(tr("Apply Changes in Snapshot Details (%1)") 599 .arg(m_pActionCommitSnapshotDetails->shortcut().toString())); 595 600 m_pActionCloneSnapshot->setToolTip(tr("Clone Virtual Machine (%1)") 596 601 .arg(m_pActionCloneSnapshot->shortcut().toString())); … … 599 604 m_pActionDeleteSnapshot->setStatusTip(tr("Delete selected snapshot of the virtual machine")); 600 605 m_pActionRestoreSnapshot->setStatusTip(tr("Restore selected snapshot of the virtual machine")); 601 m_pActionShowSnapshotDetails->setStatusTip(tr("Display a window with selected snapshot details")); 606 m_pActionShowSnapshotDetails->setStatusTip(tr("Open pane with the selected snapshot details")); 607 m_pActionCommitSnapshotDetails->setStatusTip(tr("Apply changes in snapshot details pane")); 602 608 m_pActionCloneSnapshot->setStatusTip(tr("Clone selected virtual machine")); 603 609 … … 677 683 } 678 684 685 void UISnapshotPane::sltToggleSnapshotDetailsVisibility(bool fVisible) 686 { 687 /* Show/hide commit action and details-widget: */ 688 m_pActionCommitSnapshotDetails->setVisible(fVisible); 689 m_pDetailsWidget->setVisible(fVisible); 690 /* If details-widget is visible: */ 691 if (m_pDetailsWidget->isVisible()) 692 { 693 /* Acquire current snapshot item: */ 694 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 695 /* Update details-widget: */ 696 m_pDetailsWidget->setData(*pSnapshotItem, pSnapshotItem->snapshot()); 697 } 698 } 699 700 void UISnapshotPane::sltCommitSnapshotDetailsChanges() 701 { 702 /* Make sure nothing being edited in the meantime: */ 703 if (!m_pLockReadWrite->tryLockForWrite()) 704 return; 705 706 /* Disable button first of all: */ 707 m_pActionCommitSnapshotDetails->setEnabled(false); 708 709 /* Acquire current snapshot item: */ 710 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 711 AssertPtr(pSnapshotItem); 712 if (pSnapshotItem) 713 { 714 /* Make sure that's a snapshot item indeed: */ 715 CSnapshot comSnapshot = pSnapshotItem->snapshot(); 716 if (comSnapshot.isNotNull()) 717 { 718 /* Get item data: */ 719 UIDataSnapshot oldData = *pSnapshotItem; 720 UIDataSnapshot newData = m_pDetailsWidget->data(); 721 722 /* Update corresponding snapshot attributes if necessary: */ 723 if (newData != oldData) 724 { 725 /* We need to open a session when we manipulate the snapshot data of a machine: */ 726 CSession comSession = vboxGlobal().openExistingSession(comSnapshot.GetMachine().GetId()); 727 if (!comSession.isNull()) 728 { 729 // TODO: Add settings save validation. 730 731 /* Save snapshot name: */ 732 if (newData.m_strName != oldData.m_strName) 733 comSnapshot.SetName(newData.m_strName); 734 /* Save snapshot description: */ 735 if (newData.m_strDescription != oldData.m_strDescription) 736 comSnapshot.SetDescription(newData.m_strDescription); 737 738 /* Close the session again: */ 739 comSession.UnlockMachine(); 740 } 741 } 742 } 743 } 744 745 /* Allows editing again: */ 746 m_pLockReadWrite->unlock(); 747 } 748 679 749 void UISnapshotPane::sltHandleCurrentItemChange() 680 750 { 681 /* Acquire c orrespondingsnapshot item: */751 /* Acquire current snapshot item: */ 682 752 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 683 753 … … 734 804 && !pSnapshotItem->isCurrentStateItem() 735 805 ); 806 m_pActionCommitSnapshotDetails->setEnabled( 807 false 808 ); 736 809 m_pActionCloneSnapshot->setEnabled( 737 810 pSnapshotItem … … 739 812 || !fBusy) 740 813 ); 814 815 /* If there is a proper snasphot item: */ 816 if ( m_pCurrentSnapshotItem 817 && pSnapshotItem 818 && !pSnapshotItem->isCurrentStateItem()) 819 { 820 /* Update details-widget if it's visible: */ 821 if (m_pDetailsWidget->isVisible()) 822 m_pDetailsWidget->setData(*pSnapshotItem, pSnapshotItem->snapshot()); 823 } 824 else 825 { 826 /* Clear details-widget if it's visible: */ 827 if (m_pDetailsWidget->isVisible()) 828 m_pDetailsWidget->clearData(); 829 /* Toggle details button off and hide the widget: */ 830 m_pActionShowSnapshotDetails->setChecked(false); 831 sltToggleSnapshotDetailsVisibility(false); 832 } 741 833 } 742 834 … … 761 853 menu.addAction(m_pActionRestoreSnapshot); 762 854 menu.addAction(m_pActionShowSnapshotDetails); 855 menu.addAction(m_pActionCommitSnapshotDetails); 763 856 menu.addSeparator(); 764 857 menu.addAction(m_pActionCloneSnapshot); … … 784 877 /* Acquire corresponding snapshot item: */ 785 878 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(pItem); 786 AssertReturnVoid(pSnapshotItem); 787 788 /* Rename corresponding snapshot: */ 789 CSnapshot comSnapshot = pSnapshotItem->snapshotID().isNull() 790 ? CSnapshot() 791 : m_comMachine.FindSnapshot(pSnapshotItem->snapshotID()); 792 if (!comSnapshot.isNull() && comSnapshot.isOk() && comSnapshot.GetName() != pSnapshotItem->text(0)) 793 comSnapshot.SetName(pSnapshotItem->text(0)); 879 AssertPtr(pSnapshotItem); 880 if (pSnapshotItem) 881 { 882 /* Make sure that's a snapshot item indeed: */ 883 CSnapshot comSnapshot = pSnapshotItem->snapshot(); 884 if (comSnapshot.isNotNull()) 885 { 886 /* Rename corresponding snapshot if necessary: */ 887 if (comSnapshot.GetName() != pSnapshotItem->text(0)) 888 { 889 /* We need to open a session when we manipulate the snapshot data of a machine: */ 890 CSession comSession = vboxGlobal().openExistingSession(comSnapshot.GetMachine().GetId()); 891 if (!comSession.isNull()) 892 { 893 // TODO: Add settings save validation. 894 895 /* Save snapshot name: */ 896 comSnapshot.SetName(pSnapshotItem->text(0)); 897 898 /* Close the session again: */ 899 comSession.UnlockMachine(); 900 } 901 } 902 } 903 } 794 904 795 905 /* Allows editing again: */ … … 803 913 AssertReturnVoid(pSnapshotItem); 804 914 805 /* Handle Ctrl+DoubleClick: */ 806 if (QApplication::keyboardModifiers() == Qt::ControlModifier) 807 { 808 /* As snapshot-restore procedure: */ 809 restoreSnapshot(true /* suppress non-critical warnings */); 915 /* If this is a snapshot item: */ 916 if ( m_pCurrentSnapshotItem 917 && pSnapshotItem 918 && !pSnapshotItem->isCurrentStateItem()) 919 { 920 /* Handle Ctrl+DoubleClick: */ 921 if (QApplication::keyboardModifiers() == Qt::ControlModifier) 922 { 923 /* As snapshot-restore procedure: */ 924 restoreSnapshot(true /* suppress non-critical warnings */); 925 } 926 /* Handle other kinds of DoubleClick: */ 927 else 928 { 929 /* As show details-widget procedure: */ 930 m_pActionShowSnapshotDetails->setChecked(true); 931 } 810 932 } 811 933 } … … 862 984 /* Prepare tree-widget: */ 863 985 prepareTreeWidget(); 986 /* Prepare details-widget: */ 987 prepareDetailsWidget(); 864 988 } 865 989 } … … 912 1036 ":/snapshot_show_details_16px.png", 913 1037 ":/snapshot_show_details_disabled_22px.png", 914 ":/snapshot_ details_show_disabled_16px.png"),915 QString() , this, &UISnapshotPane::sltShowSnapshotDetails);1038 ":/snapshot_show_details_disabled_16px.png"), 1039 QString()); 916 1040 { 1041 connect(m_pActionShowSnapshotDetails, &QAction::toggled, 1042 this, &UISnapshotPane::sltToggleSnapshotDetailsVisibility); 1043 m_pActionShowSnapshotDetails->setCheckable(true); 917 1044 m_pActionShowSnapshotDetails->setShortcut(QString("Ctrl+Space")); 1045 } 1046 1047 /* Add Commit Snapshot Details action: */ 1048 m_pActionCommitSnapshotDetails = m_pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_commit_details_22px.png", 1049 ":/snapshot_commit_details_16px.png", 1050 ":/snapshot_commit_details_disabled_22px.png", 1051 ":/snapshot_commit_details_disabled_16px.png"), 1052 QString(), this, &UISnapshotPane::sltCommitSnapshotDetailsChanges); 1053 { 1054 connect(m_pActionShowSnapshotDetails, &QAction::toggled, 1055 m_pActionCommitSnapshotDetails, &QAction::setVisible); 1056 m_pActionCommitSnapshotDetails->setShortcut(QString("Ctrl+Return")); 918 1057 } 919 1058 … … 942 1081 { 943 1082 /* Configure tree: */ 1083 m_pSnapshotTree->setExpandsOnDoubleClick(false); 1084 m_pSnapshotTree->setEditTriggers( QAbstractItemView::SelectedClicked 1085 | QAbstractItemView::EditKeyPressed); 944 1086 connect(m_pSnapshotTree, &UISnapshotTree::currentItemChanged, 945 1087 this, &UISnapshotPane::sltHandleCurrentItemChange); … … 953 1095 /* Add into layout: */ 954 1096 layout()->addWidget(m_pSnapshotTree); 1097 } 1098 } 1099 1100 void UISnapshotPane::prepareDetailsWidget() 1101 { 1102 /* Create details-widget: */ 1103 m_pDetailsWidget = new UISnapshotDetailsWidget; 1104 AssertPtrReturnVoid(m_pDetailsWidget); 1105 { 1106 /* Configure details-widget: */ 1107 m_pDetailsWidget->setVisible(false); 1108 connect(m_pDetailsWidget, &UISnapshotDetailsWidget::sigDataChanged, 1109 m_pActionCommitSnapshotDetails, &QAction::setEnabled); 1110 1111 /* Add into layout: */ 1112 layout()->addWidget(m_pDetailsWidget); 955 1113 } 956 1114 } … … 1179 1337 do 1180 1338 { 1181 /* Acquire current ly chosensnapshot item: */1339 /* Acquire current snapshot item: */ 1182 1340 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 1183 1341 AssertPtr(pSnapshotItem); … … 1253 1411 do 1254 1412 { 1255 /* Acquire current ly chosensnapshot item: */1413 /* Acquire current snapshot item: */ 1256 1414 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 1257 1415 AssertPtr(pSnapshotItem); … … 1322 1480 } 1323 1481 1324 void UISnapshotPane::showSnapshotDetails()1325 {1326 /* Acquire currently chosen snapshot item: */1327 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());1328 AssertReturnVoid(pSnapshotItem);1329 1330 /* Get corresponding snapshot: */1331 const CSnapshot comSnapshot = pSnapshotItem->snapshot();1332 AssertReturnVoid(!comSnapshot.isNull());1333 1334 /* Show Snapshot Details dialog: */1335 QPointer<VBoxSnapshotDetailsDlg> pDlg = new VBoxSnapshotDetailsDlg(this);1336 pDlg->setData(*pSnapshotItem, comSnapshot);1337 if (pDlg->exec() == QDialog::Accepted)1338 pDlg->saveData();1339 if (pDlg)1340 delete pDlg;1341 }1342 1343 1482 void UISnapshotPane::cloneSnapshot() 1344 1483 { 1345 /* Acquire current ly chosensnapshot item: */1484 /* Acquire current snapshot item: */ 1346 1485 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 1347 1486 AssertReturnVoid(pSnapshotItem); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r67147 r67160 32 32 class QTreeWidgetItem; 33 33 class QITreeWidgetItem; 34 class UISnapshotDetailsWidget; 35 class UISnapshotItem; 34 36 class UISnapshotTree; 35 class UISnapshotItem;36 37 class UIToolBar; 37 38 … … 91 92 /** @name Toolbar handlers. 92 93 * @{ */ 93 /** Proposesto take a snapshot. */94 /** Handles command to take a snapshot. */ 94 95 void sltTakeSnapshot() { takeSnapshot(); } 95 /** Proposesto restore the snapshot. */96 /** Handles command to restore the snapshot. */ 96 97 void sltRestoreSnapshot() { restoreSnapshot(); } 97 /** Proposesto delete the snapshot. */98 /** Handles command to delete the snapshot. */ 98 99 void sltDeleteSnapshot() { deleteSnapshot(); } 99 /** Displays the snapshot details dialog. */ 100 void sltShowSnapshotDetails() { showSnapshotDetails(); } 100 /** Handles command to make snapshot details @a fVisible. */ 101 void sltToggleSnapshotDetailsVisibility(bool fVisible); 102 /** Handles command to commit snapshot details changes. */ 103 void sltCommitSnapshotDetailsChanges(); 101 104 /** Proposes to clone the snapshot. */ 102 105 void sltCloneSnapshot() { cloneSnapshot(); } … … 127 130 /** Prepares tree-widget. */ 128 131 void prepareTreeWidget(); 132 /** Prepares details-widget. */ 133 void prepareDetailsWidget(); 129 134 130 135 /** Refreshes everything. */ … … 145 150 /** Proposes to restore the snapshot. */ 146 151 bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false); 147 /** Displays the snapshot details dialog. */148 void showSnapshotDetails();149 152 /** Proposes to clone the snapshot. */ 150 153 void cloneSnapshot(); … … 198 201 /** Holds the Show Snapshot Details action instance. */ 199 202 QAction *m_pActionShowSnapshotDetails; 203 /** Holds the Commit Snapshot Details action instance. */ 204 QAction *m_pActionCommitSnapshotDetails; 200 205 /** Holds the Clone Snapshot action instance. */ 201 206 QAction *m_pActionCloneSnapshot; … … 205 210 /** Holds the current snapshot item reference. */ 206 211 UISnapshotItem *m_pCurrentSnapshotItem; 212 213 /** Holds the details-widget instance. */ 214 UISnapshotDetailsWidget *m_pDetailsWidget; 207 215 /** @} */ 208 216 };
Note:
See TracChangeset
for help on using the changeset viewer.