Changeset 67517 in vbox
- Timestamp:
- Jun 20, 2017 5:52:13 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp
r67409 r67517 37 37 38 38 /* GUI includes: */ 39 # include "QIDialogButtonBox.h" 39 40 # include "QIFlowLayout.h" 40 41 # include "UIConverter.h" … … 524 525 , m_pLabelName(0), m_pEditorName(0), m_pErrorPaneName(0) 525 526 , m_pLabelDescription(0), m_pBrowserDescription(0), m_pErrorPaneDescription(0) 527 , m_pButtonBox(0) 526 528 , m_pLayoutDetails(0) 527 529 , m_pScrollAreaDetails(0) … … 563 565 "Press <b>Take</b> button if you wish to take a new snapshot.</p>"); 564 566 m_pTabWidget->setTabText(0, tr("&Attributes")); 565 m_pTabWidget->setTabText(1, tr(" D&etails"));567 m_pTabWidget->setTabText(1, tr("&Information")); 566 568 m_pLabelName->setText(tr("&Name:")); 567 569 m_pLabelDescription->setText(tr("&Description:")); 570 m_pEditorName->setToolTip(tr("Holds the snapshot name.")); 571 m_pBrowserDescription->setToolTip(tr("Holds the snapshot description.")); 572 m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Apply")); 573 m_pButtonBox->button(QDialogButtonBox::Cancel)->setText(tr("Discard")); 574 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 575 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 576 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current snapshot details")); 577 m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Discard changes in current snapshot details")); 578 m_pButtonBox->button(QDialogButtonBox::Ok)-> 579 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 580 m_pButtonBox->button(QDialogButtonBox::Cancel)-> 581 setToolTip(tr("Discard Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Cancel)->shortcut().toString())); 568 582 569 583 /* And if snapshot is valid: */ … … 609 623 m_newData.m_strName = m_pEditorName->text(); 610 624 revalidate(m_pErrorPaneName); 611 notify();625 updateButtonStates(); 612 626 } 613 627 … … 616 630 m_newData.m_strDescription = m_pBrowserDescription->toPlainText(); 617 631 revalidate(m_pErrorPaneDescription); 618 notify();632 updateButtonStates(); 619 633 } 620 634 … … 633 647 pViewer->activateWindow(); 634 648 } 649 } 650 651 void UISnapshotDetailsWidget::sltHandleChangeAccepted() 652 { 653 /* Disable buttons first of all: */ 654 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 655 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); 656 657 /* Notify listeners: */ 658 emit sigDataChangeAccepted(); 659 } 660 661 void UISnapshotDetailsWidget::sltHandleChangeRejected() 662 { 663 /* Reset new data to old: */ 664 m_newData = m_oldData; 665 666 /* Load snapshot data: */ 667 loadSnapshotData(); 635 668 } 636 669 … … 799 832 m_pLayoutOptions->addLayout(pLayoutDescription, 1, 1); 800 833 } 834 835 /* Create button-box: */ 836 m_pButtonBox = new QIDialogButtonBox; 837 AssertPtrReturnVoid(m_pButtonBox); 838 { 839 /* Configure button-box: */ 840 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 841 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UISnapshotDetailsWidget::sltHandleChangeAccepted); 842 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISnapshotDetailsWidget::sltHandleChangeRejected); 843 844 /* Add into layout: */ 845 m_pLayoutOptions->addWidget(m_pButtonBox, 2, 0, 1, 2); 846 } 801 847 } 802 848 … … 1016 1062 /* Retranslate: */ 1017 1063 retranslateUi(); 1064 1065 /* Update button states finally: */ 1066 updateButtonStates(); 1018 1067 } 1019 1068 … … 1041 1090 } 1042 1091 1043 void UISnapshotDetailsWidget:: notify()1092 void UISnapshotDetailsWidget::updateButtonStates() 1044 1093 { 1045 1094 // if (m_oldData != m_newData) … … 1048 1097 // m_newData.m_strDescription.toUtf8().constData()); 1049 1098 1050 emit sigDataChanged(m_oldData != m_newData); 1099 /* Update 'Apply' / 'Discard' button states: */ 1100 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 1101 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 1051 1102 } 1052 1103 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.h
r67409 r67517 39 39 class QVBoxLayout; 40 40 class QWidget; 41 class QIDialogButtonBox; 41 42 class UISnapshotDetailsElement; 42 43 … … 79 80 signals: 80 81 81 /** Notifies listeners about data change d and whether it @a fDiffers. */82 void sigDataChange d(bool fDiffers);82 /** Notifies listeners about data change accepted and should be applied. */ 83 void sigDataChangeAccepted(); 83 84 84 85 public: … … 109 110 void sltHandleAnchorClicked(const QUrl &link); 110 111 112 /** Handles snapshot details change accepting. */ 113 void sltHandleChangeAccepted(); 114 /** Handles snapshot details change rejecting. */ 115 void sltHandleChangeRejected(); 116 111 117 private: 112 118 … … 132 138 /** Retranslates validation for passed @a pWidget. */ 133 139 void retranslateValidation(QWidget *pWidget = 0); 134 /** Notifies listeners about data changed or not. */135 void notify();140 /** Updates button states. */ 141 void updateButtonStates(); 136 142 137 143 /** Returns a details report on a given @a comMachine. */ … … 177 183 QLabel *m_pErrorPaneDescription; 178 184 185 /** Holds the button-box instance. */ 186 QIDialogButtonBox *m_pButtonBox; 187 179 188 /** Holds the 'Details' layout instance. */ 180 189 QVBoxLayout *m_pLayoutDetails; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r67509 r67517 467 467 , m_pActionRestoreSnapshot(0) 468 468 , m_pActionShowSnapshotDetails(0) 469 , m_pActionCommitSnapshotDetails(0)470 469 , m_pActionCloneSnapshot(0) 471 470 , m_pSnapshotTree(0) … … 522 521 m_pActionRestoreSnapshot->setText(tr("&Restore")); 523 522 m_pActionShowSnapshotDetails->setText(tr("D&etails...")); 524 m_pActionCommitSnapshotDetails->setText(tr("&Apply..."));525 523 m_pActionCloneSnapshot->setText(tr("&Clone...")); 526 524 /* Translate actions tool-tips: */ … … 533 531 m_pActionShowSnapshotDetails->setToolTip(tr("Open Snapshot Details (%1)") 534 532 .arg(m_pActionShowSnapshotDetails->shortcut().toString())); 535 m_pActionCommitSnapshotDetails->setToolTip(tr("Apply Changes in Snapshot Details (%1)")536 .arg(m_pActionCommitSnapshotDetails->shortcut().toString()));537 533 m_pActionCloneSnapshot->setToolTip(tr("Clone Virtual Machine (%1)") 538 534 .arg(m_pActionCloneSnapshot->shortcut().toString())); … … 542 538 m_pActionRestoreSnapshot->setStatusTip(tr("Restore selected snapshot of the virtual machine")); 543 539 m_pActionShowSnapshotDetails->setStatusTip(tr("Open pane with the selected snapshot details")); 544 m_pActionCommitSnapshotDetails->setStatusTip(tr("Apply changes in snapshot details pane"));545 540 m_pActionCloneSnapshot->setStatusTip(tr("Clone selected virtual machine")); 546 541 … … 914 909 { 915 910 /* Show/hide commit action and details-widget: */ 916 m_pActionCommitSnapshotDetails->setVisible(fVisible);917 911 m_pDetailsWidget->setVisible(fVisible); 918 912 /* If details-widget is visible: */ … … 926 920 } 927 921 928 void UISnapshotPane::slt CommitSnapshotDetailsChanges()922 void UISnapshotPane::sltApplySnapshotDetailsChanges() 929 923 { 930 924 /* Make sure nothing being edited in the meantime: */ 931 925 if (!m_pLockReadWrite->tryLockForWrite()) 932 926 return; 933 934 /* Disable button first of all: */935 m_pActionCommitSnapshotDetails->setEnabled(false);936 927 937 928 /* Acquire "current snapshot" item: */ … … 1019 1010 menu.addAction(m_pActionRestoreSnapshot); 1020 1011 menu.addAction(m_pActionShowSnapshotDetails); 1021 menu.addAction(m_pActionCommitSnapshotDetails);1022 1012 menu.addSeparator(); 1023 1013 menu.addAction(m_pActionCloneSnapshot); … … 1221 1211 } 1222 1212 1223 /* Add Commit Snapshot Details action: */1224 m_pActionCommitSnapshotDetails = m_pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_commit_details_22px.png",1225 ":/snapshot_commit_details_16px.png",1226 ":/snapshot_commit_details_disabled_22px.png",1227 ":/snapshot_commit_details_disabled_16px.png"),1228 QString(), this, &UISnapshotPane::sltCommitSnapshotDetailsChanges);1229 {1230 connect(m_pActionShowSnapshotDetails, &QAction::toggled,1231 m_pActionCommitSnapshotDetails, &QAction::setVisible);1232 m_pActionCommitSnapshotDetails->setShortcut(QString("Ctrl+Return"));1233 m_pActionCommitSnapshotDetails->setVisible(false);1234 }1235 1236 1213 m_pToolBar->addSeparator(); 1237 1214 … … 1280 1257 /* Configure details-widget: */ 1281 1258 m_pDetailsWidget->setVisible(false); 1282 connect(m_pDetailsWidget, &UISnapshotDetailsWidget::sigDataChange d,1283 m_pActionCommitSnapshotDetails, &QAction::setEnabled);1259 connect(m_pDetailsWidget, &UISnapshotDetailsWidget::sigDataChangeAccepted, 1260 this, &UISnapshotPane::sltApplySnapshotDetailsChanges); 1284 1261 1285 1262 /* Add into layout: */ … … 1460 1437 m_pActionShowSnapshotDetails->setEnabled( 1461 1438 pSnapshotItem 1462 );1463 1464 /* Update 'Commit Details' action: */1465 m_pActionCommitSnapshotDetails->setEnabled(1466 false1467 1439 ); 1468 1440 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r67509 r67517 119 119 /** Handles command to make snapshot details @a fVisible. */ 120 120 void sltToggleSnapshotDetailsVisibility(bool fVisible); 121 /** Handles command to commitsnapshot details changes. */122 void slt CommitSnapshotDetailsChanges();121 /** Handles command to apply snapshot details changes. */ 122 void sltApplySnapshotDetailsChanges(); 123 123 /** Proposes to clone the snapshot. */ 124 124 void sltCloneSnapshot() { cloneSnapshot(); } … … 227 227 /** Holds the Show Snapshot Details action instance. */ 228 228 QAction *m_pActionShowSnapshotDetails; 229 /** Holds the Commit Snapshot Details action instance. */230 QAction *m_pActionCommitSnapshotDetails;231 229 /** Holds the Clone Snapshot action instance. */ 232 230 QAction *m_pActionCloneSnapshot;
Note:
See TracChangeset
for help on using the changeset viewer.