Changeset 23924 in vbox
- Timestamp:
- Oct 20, 2009 6:56:51 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
- 4 moved
-
VirtualBox1.qrc (modified) (1 diff)
-
images/delete_snapshot_16px.png (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/images/discard_snapshot_16px.png )
-
images/delete_snapshot_22px.png (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/images/discard_snapshot_22px.png )
-
images/delete_snapshot_dis_16px.png (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/images/discard_snapshot_dis_16px.png )
-
images/delete_snapshot_dis_22px.png (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/images/discard_snapshot_dis_22px.png )
-
include/VBoxProblemReporter.h (modified) (1 diff)
-
include/VBoxSnapshotsWgt.h (modified) (5 diffs)
-
src/VBoxConsoleWnd.cpp (modified) (2 diffs)
-
src/VBoxProblemReporter.cpp (modified) (4 diffs)
-
src/VBoxSnapshotsWgt.cpp (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc
r23580 r23924 135 135 <file alias="discard_cur_state_snapshot_dis_16px.png">images/discard_cur_state_snapshot_dis_16px.png</file> 136 136 <file alias="discard_cur_state_snapshot_dis_22px.png">images/discard_cur_state_snapshot_dis_22px.png</file> 137 <file alias="d iscard_snapshot_16px.png">images/discard_snapshot_16px.png</file>138 <file alias="d iscard_snapshot_22px.png">images/discard_snapshot_22px.png</file>139 <file alias="d iscard_snapshot_dis_16px.png">images/discard_snapshot_dis_16px.png</file>140 <file alias="d iscard_snapshot_dis_22px.png">images/discard_snapshot_dis_22px.png</file>137 <file alias="delete_snapshot_16px.png">images/delete_snapshot_16px.png</file> 138 <file alias="delete_snapshot_22px.png">images/delete_snapshot_22px.png</file> 139 <file alias="delete_snapshot_dis_16px.png">images/delete_snapshot_dis_16px.png</file> 140 <file alias="delete_snapshot_dis_22px.png">images/delete_snapshot_dis_22px.png</file> 141 141 <file alias="take_snapshot_16px.png">images/take_snapshot_16px.png</file> 142 142 <file alias="take_snapshot_22px.png">images/take_snapshot_22px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r23585 r23924 209 209 210 210 void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath); 211 bool askAboutSnapshotAndStateDiscarding(); 212 bool askAboutSnapshotDiscarding(); 213 void cannotDiscardSnapshot (const CConsole &aConsole, 214 const QString &aSnapshotName); 215 void cannotDiscardSnapshot (const CProgress &aProgress, 216 const QString &aSnapshotName); 217 void cannotDiscardCurrentState (const CConsole &console); 218 void cannotDiscardCurrentState (const CProgress &progress); 219 void cannotDiscardCurrentSnapshotAndState (const CConsole &console); 220 void cannotDiscardCurrentSnapshotAndState (const CProgress &progress); 211 212 bool askAboutSnapshotRestoring (const QString &aSnapshotName); 213 bool askAboutSnapshotDeleting (const QString &aSnapshotName); 214 void cannotRestoreSnapshot (const CConsole &aConsole, const QString &aSnapshotName); 215 void cannotRestoreSnapshot (const CProgress &aProgress, const QString &aSnapshotName); 216 void cannotDeleteSnapshot (const CConsole &aConsole, const QString &aSnapshotName); 217 void cannotDeleteSnapshot (const CProgress &aProgress, const QString &aSnapshotName); 221 218 222 219 void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxSnapshotsWgt.h
r23879 r23924 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 #define __VBoxSnapshotsWgt_h__ 25 25 26 /* Local includes */ 26 27 #include "VBoxSnapshotsWgt.gen.h" 27 28 #include "VBoxGlobal.h" 28 29 #include "QIWithRetranslateUI.h" 29 30 30 /* Qt includes */ 31 #include <QUuid> 32 31 /* Local forwards */ 33 32 class SnapshotWgtItem; 34 33 35 class QMenu; 36 37 class VBoxSnapshotsWgt : public QIWithRetranslateUI<QWidget>, 38 public Ui::VBoxSnapshotsWgt 34 class VBoxSnapshotsWgt : public QIWithRetranslateUI <QWidget>, public Ui::VBoxSnapshotsWgt 39 35 { 40 36 Q_OBJECT; … … 52 48 private slots: 53 49 54 void onCurrentChanged (QTreeWidgetItem *aNewItem, 55 QTreeWidgetItem *aOldItem = 0); 50 void onCurrentChanged (QTreeWidgetItem *aItem = 0); 56 51 void onContextMenuRequested (const QPoint &aPoint); 57 void onItemChanged (QTreeWidgetItem *aItem , int aColumn);52 void onItemChanged (QTreeWidgetItem *aItem); 58 53 59 void discardSnapshot(); 54 void restoreSnapshot(); 55 void deleteSnapshot(); 56 void showSnapshotDetails(); 60 57 void takeSnapshot(); 61 void discardCurState();62 void showSnapshotDetails();63 58 64 void machineDataChanged (const VBoxMachineDataChangeEvent &aE); 65 void machineStateChanged (const VBoxMachineStateChangeEvent &aE); 66 void sessionStateChanged (const VBoxSessionStateChangeEvent &aE); 67 #if 0 68 void snapshotChanged (const VBoxSnapshotEvent &aE); 69 #endif 59 void machineDataChanged (const VBoxMachineDataChangeEvent &aEvent); 60 void machineStateChanged (const VBoxMachineStateChangeEvent &aEvent); 61 void sessionStateChanged (const VBoxSessionStateChangeEvent &aEvent); 70 62 71 63 private: 72 64 73 void refreshAll (bool aKeepSelected = true);65 void refreshAll(); 74 66 SnapshotWgtItem* findItem (const QString &aSnapshotId); 75 67 SnapshotWgtItem* curStateItem(); … … 80 72 KSessionState mSessionState; 81 73 SnapshotWgtItem *mCurSnapshotItem; 82 QMenu *mContextMenu;83 bool mContextMenuDirty;84 74 bool mEditProtector; 85 75 … … 87 77 QActionGroup *mCurStateActionGroup; 88 78 89 QAction *mDiscardSnapshotAction; 79 QAction *mRestoreSnapshotAction; 80 QAction *mDeleteSnapshotAction; 81 QAction *mShowSnapshotDetailsAction; 90 82 QAction *mTakeSnapshotAction; 91 QAction *mRevertToCurSnapAction;92 QAction *mShowSnapshotDetailsAction;93 83 }; 94 84 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r23879 r23924 1388 1388 if (dlg.mCbDiscardCurState->isChecked() && dlg.mCbDiscardCurState->isVisibleTo (&dlg)) 1389 1389 { 1390 CProgress progress = console.RestoreSnapshot(machine.GetCurrentSnapshot()); 1390 CSnapshot snapshot = machine.GetCurrentSnapshot(); 1391 CProgress progress = console.RestoreSnapshot (snapshot); 1391 1392 if (console.isOk()) 1392 1393 { … … 1394 1395 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this); 1395 1396 if (progress.GetResultCode() != 0) 1396 vboxProblem().cannot DiscardCurrentState (progress);1397 vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName()); 1397 1398 } 1398 1399 else 1399 vboxProblem().cannot DiscardCurrentState (console);1400 vboxProblem().cannotRestoreSnapshot (console, snapshot.GetName()); 1400 1401 } 1401 1402 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r23585 r23924 804 804 } 805 805 806 bool VBoxProblemReporter::askAboutSnapshot Discarding()806 bool VBoxProblemReporter::askAboutSnapshotRestoring (const QString &aSnapshotName) 807 807 { 808 808 return messageOkCancel (mainWindowShown(), Question, 809 tr ("<p>Are you sure you wish to merge the selected snapshot?</p>"), 810 "confirmSnapshotDiscarding" /* aAutoConfirmId */, 811 tr ("Discard"), tr ("Cancel")); 812 } 813 814 bool VBoxProblemReporter::askAboutSnapshotAndStateDiscarding() 809 tr ("<p>Are you sure you wish to restore the selected snapshot <b>%1</b>? " 810 "This will also cause you to lose your current machine state.</p>") 811 .arg (aSnapshotName), 812 "confirmSnapshotRestoring" /* aAutoConfirmId */, 813 tr ("Restore"), tr ("Cancel")); 814 } 815 816 bool VBoxProblemReporter::askAboutSnapshotDeleting (const QString &aSnapshotName) 815 817 { 816 818 return messageOkCancel (mainWindowShown(), Question, 817 tr ("<p>Are you sure you wish to delete the selected snapshot "818 "and saved state?</p>"),819 "confirmSnapshot AndStateDiscarding" /* aAutoConfirmId */,820 tr ("D iscard"), tr ("Cancel"));821 } 822 823 void VBoxProblemReporter::cannot DiscardSnapshot (const CConsole &aConsole,819 tr ("<p>Are you sure you wish to delete the selected snapshot <b>%1</b>?</p>") 820 .arg (aSnapshotName), 821 "confirmSnapshotDeleting" /* aAutoConfirmId */, 822 tr ("Delete"), tr ("Cancel")); 823 } 824 825 void VBoxProblemReporter::cannotRestoreSnapshot (const CConsole &aConsole, 824 826 const QString &aSnapshotName) 825 827 { 826 828 message (mainWindowShown(), Error, 827 tr ("Failed to discard the snapshot <b>%1</b> of the virtual " 828 "machine <b>%2</b>.") 829 tr ("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.") 829 830 .arg (aSnapshotName) 830 831 .arg (CConsole (aConsole).GetMachine().GetName()), … … 832 833 } 833 834 834 void VBoxProblemReporter::cannot DiscardSnapshot (const CProgress &aProgress,835 void VBoxProblemReporter::cannotRestoreSnapshot (const CProgress &aProgress, 835 836 const QString &aSnapshotName) 836 837 { … … 838 839 839 840 message (mainWindowShown(), Error, 840 tr ("Failed to discard the snapshot <b>%1</b> of the virtual " 841 "machine <b>%2</b>.") 841 tr ("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.") 842 842 .arg (aSnapshotName) 843 843 .arg (console.GetMachine().GetName()), … … 845 845 } 846 846 847 void VBoxProblemReporter::cannotDiscardCurrentState (const CConsole &console) 848 { 849 message ( 850 mainWindowShown(), 851 Error, 852 tr ("Failed to discard the current state of the virtual " 853 "machine <b>%1</b>.") 854 .arg (CConsole (console).GetMachine().GetName()), 855 formatErrorInfo (console)); 856 } 857 858 void VBoxProblemReporter::cannotDiscardCurrentState (const CProgress &progress) 859 { 860 CConsole console (CProgress (progress).GetInitiator()); 861 862 message ( 863 mainWindowShown(), 864 Error, 865 tr ("Failed to discard the current state of the virtual " 866 "machine <b>%1</b>.") 847 void VBoxProblemReporter::cannotDeleteSnapshot (const CConsole &aConsole, 848 const QString &aSnapshotName) 849 { 850 message (mainWindowShown(), Error, 851 tr ("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.") 852 .arg (aSnapshotName) 853 .arg (CConsole (aConsole).GetMachine().GetName()), 854 formatErrorInfo (aConsole)); 855 } 856 857 void VBoxProblemReporter::cannotDeleteSnapshot (const CProgress &aProgress, 858 const QString &aSnapshotName) 859 { 860 CConsole console (CProgress (aProgress).GetInitiator()); 861 862 message (mainWindowShown(), Error, 863 tr ("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.") 864 .arg (aSnapshotName) 867 865 .arg (console.GetMachine().GetName()), 868 formatErrorInfo (progress.GetErrorInfo())); 869 } 870 871 void VBoxProblemReporter::cannotDiscardCurrentSnapshotAndState (const CConsole &console) 872 { 873 message ( 874 mainWindowShown(), 875 Error, 876 tr ("Failed to discard the current snapshot and the current state " 877 "of the virtual machine <b>%1</b>.") 878 .arg (CConsole (console).GetMachine().GetName()), 879 formatErrorInfo (console)); 880 } 881 882 void VBoxProblemReporter::cannotDiscardCurrentSnapshotAndState (const CProgress &progress) 883 { 884 CConsole console (CProgress (progress).GetInitiator()); 885 886 message ( 887 mainWindowShown(), 888 Error, 889 tr ("Failed to discard the current snapshot and the current state " 890 "of the virtual machine <b>%1</b>.") 891 .arg (console.GetMachine().GetName()), 892 formatErrorInfo (progress.GetErrorInfo())); 866 formatErrorInfo (aProgress.GetErrorInfo())); 893 867 } 894 868 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.cpp
r23879 r23924 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 /* Global includes */ 24 #include <QDateTime> 25 #include <QHeaderView> 26 #include <QMenu> 27 #include <QScrollBar> 28 29 /* Local includes */ 23 30 #include <VBoxSnapshotsWgt.h> 24 31 #include <VBoxProblemReporter.h> … … 27 34 #include <VBoxToolBar.h> 28 35 29 /* Qt includes */ 30 #include <QMenu> 31 #include <QHeaderView> 32 #include <QScrollBar> 33 #include <QDateTime> 34 35 /** QListViewItem subclass for snapshots items */ 36 /** 37 * QTreeWidgetItem subclass for snapshots items 38 */ 36 39 class SnapshotWgtItem : public QTreeWidgetItem 37 40 { 38 41 public: 39 42 40 /* * Normal snapshot item*/43 /* Normal snapshot item (child of tree-widget) */ 41 44 SnapshotWgtItem (QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot) 42 45 : QTreeWidgetItem (aTreeWidget) … … 46 49 } 47 50 48 /* * Normal snapshot item*/51 /* Normal snapshot item (child of tree-widget-item) */ 49 52 SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot) 50 53 : QTreeWidgetItem (aRootItem) … … 54 57 } 55 58 56 /* * Current state item*/59 /* Current state item (child of tree-widget) */ 57 60 SnapshotWgtItem (QTreeWidget *aTreeWidget, const CMachine &aMachine) 58 61 : QTreeWidgetItem (aTreeWidget) … … 63 66 } 64 67 65 /* * Current state item*/68 /* Current state item (child of tree-widget-item) */ 66 69 SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CMachine &aMachine) 67 70 : QTreeWidgetItem (aRootItem) … … 70 73 updateCurrentState (mMachine.GetState()); 71 74 recache(); 75 } 76 77 bool isCurrentStateItem() const 78 { 79 return mSnapshot.isNull(); 72 80 } 73 81 … … 122 130 mCurStateModified = mMachine.GetCurrentStateModified(); 123 131 setText (0, mCurStateModified ? 124 VBoxSnapshotsWgt::tr ("Current State (changed)", 125 "Current State (Modified)") : 126 VBoxSnapshotsWgt::tr ("Current State", 127 "Current State (Unmodified)")); 132 VBoxSnapshotsWgt::tr ("Current State (changed)", "Current State (Modified)") : 133 VBoxSnapshotsWgt::tr ("Current State", "Current State (Unmodified)")); 128 134 mDesc = mCurStateModified ? 129 VBoxSnapshotsWgt::tr ("The current state differs from the state " 130 "stored in the current snapshot") : 131 parent() != 0 ? /* we're not the only item in the view */ 132 VBoxSnapshotsWgt::tr ("The current state is identical to the state " 133 "stored in the current snapshot") : 135 VBoxSnapshotsWgt::tr ("The current state differs from the state stored in the current snapshot") : 136 parent() != 0 ? 137 VBoxSnapshotsWgt::tr ("The current state is identical to the state stored in the current snapshot") : 134 138 QString::null; 135 139 } … … 175 179 if (!mSnapshot.isNull()) 176 180 { 177 /* the current snapshot is always bold */181 /* The current snapshot is always bold */ 178 182 if (bold()) 179 183 details = VBoxSnapshotsWgt::tr (" (current, ", "Snapshot details"); … … 184 188 185 189 if (dateTimeToday) 186 dateTime = VBoxSnapshotsWgt::tr ("Taken at %1", "Snapshot (time)") 187 .arg (dateTime); 190 dateTime = VBoxSnapshotsWgt::tr ("Taken at %1", "Snapshot (time)").arg (dateTime); 188 191 else 189 dateTime = VBoxSnapshotsWgt::tr ("Taken on %1", "Snapshot (date + time)") 190 .arg (dateTime); 192 dateTime = VBoxSnapshotsWgt::tr ("Taken on %1", "Snapshot (date + time)").arg (dateTime); 191 193 } 192 194 else 193 195 { 194 196 dateTime = VBoxSnapshotsWgt::tr ("%1 since %2", "Current State (time or date + time)") 195 .arg (vboxGlobal().toString (mMachineState)) 196 .arg (dateTime); 197 .arg (vboxGlobal().toString (mMachineState)).arg (dateTime); 197 198 } 198 199 199 200 QString toolTip = QString ("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>") 200 .arg (name) .arg (details) 201 .arg (dateTime); 201 .arg (name) .arg (details).arg (dateTime); 202 202 203 203 if (!mDesc.isEmpty()) … … 244 244 }; 245 245 246 247 246 VBoxSnapshotsWgt::VBoxSnapshotsWgt (QWidget *aParent) 248 : QIWithRetranslateUI <QWidget> (aParent)247 : QIWithRetranslateUI <QWidget> (aParent) 249 248 , mCurSnapshotItem (0) 250 , mContextMenu (new QMenu (this))251 , mContextMenuDirty (true)252 249 , mEditProtector (false) 253 250 , mSnapshotActionGroup (new QActionGroup (this)) 254 251 , mCurStateActionGroup (new QActionGroup (this)) 255 , m DiscardSnapshotAction (new QAction (mSnapshotActionGroup))256 , m TakeSnapshotAction (new QAction (this))257 , m RevertToCurSnapAction (new QAction (mCurStateActionGroup))258 , m ShowSnapshotDetailsAction (new QAction (this))252 , mRestoreSnapshotAction (new QAction (mSnapshotActionGroup)) 253 , mDeleteSnapshotAction (new QAction (mSnapshotActionGroup)) 254 , mShowSnapshotDetailsAction (new QAction (mSnapshotActionGroup)) 255 , mTakeSnapshotAction (new QAction (mCurStateActionGroup)) 259 256 { 260 257 /* Apply UI decorations */ … … 270 267 271 268 toolBar->addAction (mTakeSnapshotAction); 272 toolBar->addActions (mCurStateActionGroup->actions());273 269 toolBar->addSeparator(); 274 toolBar->addActions (mSnapshotActionGroup->actions()); 270 toolBar->addAction (mRestoreSnapshotAction); 271 toolBar->addAction (mDeleteSnapshotAction); 275 272 toolBar->addSeparator(); 276 273 toolBar->addAction (mShowSnapshotDetailsAction); … … 279 276 280 277 /* Setup actions */ 281 m DiscardSnapshotAction->setIcon (VBoxGlobal::iconSetFull (278 mRestoreSnapshotAction->setIcon (VBoxGlobal::iconSetFull ( 282 279 QSize (22, 22), QSize (16, 16), 283 ":/discard_snapshot_22px.png", ":/discard_snapshot_16px.png", 284 ":/discard_snapshot_dis_22px.png", ":/discard_snapshot_dis_16px.png")); 280 ":/discard_cur_state_22px.png", ":/discard_cur_state_16px.png", // TODO: Update Icons! 281 ":/discard_cur_state_dis_22px.png", ":/discard_cur_state_dis_16px.png")); // TODO: Update Icons! 282 mDeleteSnapshotAction->setIcon (VBoxGlobal::iconSetFull ( 283 QSize (22, 22), QSize (16, 16), 284 ":/delete_snapshot_22px.png", ":/delete_snapshot_16px.png", 285 ":/delete_snapshot_dis_22px.png", ":/delete_snapshot_dis_16px.png")); 286 mShowSnapshotDetailsAction->setIcon (VBoxGlobal::iconSetFull ( 287 QSize (22, 22), QSize (16, 16), 288 ":/show_snapshot_details_22px.png", ":/show_snapshot_details_16px.png", 289 ":/show_snapshot_details_dis_22px.png", ":/show_snapshot_details_dis_16px.png")); 285 290 mTakeSnapshotAction->setIcon (VBoxGlobal::iconSetFull ( 286 291 QSize (22, 22), QSize (16, 16), 287 292 ":/take_snapshot_22px.png", ":/take_snapshot_16px.png", 288 293 ":/take_snapshot_dis_22px.png", ":/take_snapshot_dis_16px.png")); 289 mRevertToCurSnapAction->setIcon (VBoxGlobal::iconSetFull ( 290 QSize (22, 22), QSize (16, 16), 291 ":/discard_cur_state_22px.png", ":/discard_cur_state_16px.png", 292 ":/discard_cur_state_dis_22px.png", ":/discard_cur_state_dis_16px.png")); 293 mShowSnapshotDetailsAction->setIcon (VBoxGlobal::iconSetFull ( 294 QSize (22, 22), QSize (16, 16), 295 ":/show_snapshot_details_22px.png", ":/show_snapshot_details_16px.png", 296 ":/show_snapshot_details_dis_22px.png", ":/show_snapshot_details_dis_16px.png")); 297 298 mDiscardSnapshotAction->setShortcut (QString ("Ctrl+Shift+D")); 294 295 mRestoreSnapshotAction->setShortcut (QString ("Ctrl+Shift+R")); 296 mDeleteSnapshotAction->setShortcut (QString ("Ctrl+Shift+D")); 297 mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space")); 299 298 mTakeSnapshotAction->setShortcut (QString ("Ctrl+Shift+S")); 300 mRevertToCurSnapAction->setShortcut (QString ("Ctrl+Shift+R"));301 mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space"));302 299 303 300 /* Setup connections */ 304 301 connect (mTreeWidget, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)), 305 this, SLOT (onCurrentChanged (QTreeWidgetItem* , QTreeWidgetItem*)));302 this, SLOT (onCurrentChanged (QTreeWidgetItem*))); 306 303 connect (mTreeWidget, SIGNAL (customContextMenuRequested (const QPoint&)), 307 304 this, SLOT (onContextMenuRequested (const QPoint&))); 308 305 connect (mTreeWidget, SIGNAL (itemChanged (QTreeWidgetItem*, int)), 309 this, SLOT (onItemChanged (QTreeWidgetItem*, int))); 310 311 connect (mDiscardSnapshotAction, SIGNAL (triggered()), 312 this, SLOT (discardSnapshot())); 313 connect (mTakeSnapshotAction, SIGNAL (triggered()), 314 this, SLOT (takeSnapshot())); 315 connect (mRevertToCurSnapAction, SIGNAL (triggered()), 316 this, SLOT (discardCurState())); 317 connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), 318 this, SLOT (showSnapshotDetails())); 306 this, SLOT (onItemChanged (QTreeWidgetItem*))); 307 308 connect (mRestoreSnapshotAction, SIGNAL (triggered()), this, SLOT (restoreSnapshot())); 309 connect (mDeleteSnapshotAction, SIGNAL (triggered()), this, SLOT (deleteSnapshot())); 310 connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), this, SLOT (showSnapshotDetails())); 311 connect (mTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (takeSnapshot())); 319 312 320 313 connect (&vboxGlobal(), SIGNAL (machineDataChanged (const VBoxMachineDataChangeEvent&)), … … 324 317 connect (&vboxGlobal(), SIGNAL (sessionStateChanged (const VBoxSessionStateChangeEvent&)), 325 318 this, SLOT (sessionStateChanged (const VBoxSessionStateChangeEvent&))); 326 #if 0327 connect (&vboxGlobal(), SIGNAL (snapshotChanged (const VBoxSnapshotEvent&)),328 this, SLOT (snapshotChanged (const VBoxSnapshotEvent&)));329 #endif330 319 331 320 retranslateUi(); … … 351 340 352 341 353 void VBoxSnapshotsWgt::onCurrentChanged (QTreeWidgetItem *aItem, 354 QTreeWidgetItem* /* old */) 342 void VBoxSnapshotsWgt::onCurrentChanged (QTreeWidgetItem *aItem) 355 343 { 356 344 /* Make the selected item visible */ 357 if (aItem)358 {359 SnapshotWgtItem *item = static_cast<SnapshotWgtItem*> (aItem);345 SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0; 346 if (item) 347 { 360 348 mTreeWidget->horizontalScrollBar()->setValue (0); 361 349 mTreeWidget->scrollToItem (item); 362 mTreeWidget->horizontalScrollBar()->setValue ( 363 mTreeWidget->indentation() * item->level()); 350 mTreeWidget->horizontalScrollBar()->setValue (mTreeWidget->indentation() * item->level()); 364 351 } 365 352 … … 368 355 369 356 /* Enable/disable snapshot actions */ 370 mSnapshotActionGroup->setEnabled (!busy && 371 aItem && mCurSnapshotItem && aItem != mCurSnapshotItem->child (0)); 357 mSnapshotActionGroup->setEnabled (!busy && mCurSnapshotItem && item && !item->isCurrentStateItem()); 372 358 373 359 /* Enable/disable the details action regardles of the session state */ 374 mShowSnapshotDetailsAction->setEnabled ( 375 aItem && mCurSnapshotItem && aItem != mCurSnapshotItem->child (0)); 360 mShowSnapshotDetailsAction->setEnabled (mCurSnapshotItem && item && !item->isCurrentStateItem()); 376 361 377 362 /* Enable/disable current state actions */ 378 mCurStateActionGroup->setEnabled (!busy && 379 aItem && mCurSnapshotItem && aItem == mCurSnapshotItem->child (0)); 380 381 /* The Take Snapshot action is always enabled for the current state */ 382 mTakeSnapshotAction->setEnabled ((!busy && mCurStateActionGroup->isEnabled()) || 383 (aItem && !mCurSnapshotItem)); 384 385 mContextMenuDirty = true; 363 mCurStateActionGroup->setEnabled (!busy && mCurSnapshotItem && item && item->isCurrentStateItem() || 364 item && !mCurSnapshotItem); 386 365 } 387 366 … … 389 368 { 390 369 QTreeWidgetItem *item = mTreeWidget->itemAt (aPoint); 391 if (!item) 392 return; 393 394 if (mContextMenuDirty) 395 { 396 mContextMenu->clear(); 397 398 if (!mCurSnapshotItem) 399 { 400 /* We have only one item -- current state */ 401 mContextMenu->addAction (mTakeSnapshotAction); 402 mContextMenu->addActions (mCurStateActionGroup->actions()); 403 } 404 else 405 { 406 if (item == mCurSnapshotItem->child (0)) 407 { 408 /* Current state is selected */ 409 mContextMenu->addAction (mTakeSnapshotAction); 410 mContextMenu->addActions (mCurStateActionGroup->actions()); 411 } 412 else 413 { 414 /* Snapshot is selected */ 415 mContextMenu->addActions (mSnapshotActionGroup->actions()); 416 mContextMenu->addSeparator(); 417 mContextMenu->addAction (mShowSnapshotDetailsAction); 418 } 419 } 420 421 mContextMenuDirty = false; 422 } 423 424 mContextMenu->exec (mTreeWidget->viewport()->mapToGlobal (aPoint)); 425 } 426 427 void VBoxSnapshotsWgt::onItemChanged (QTreeWidgetItem *aItem, int) 370 SnapshotWgtItem *snapshotItem = item ? static_cast <SnapshotWgtItem*> (item) : 0; 371 if (!snapshotItem) 372 return; 373 374 QMenu menu; 375 376 if (mCurSnapshotItem && !snapshotItem->isCurrentStateItem()) 377 { 378 menu.addAction (mRestoreSnapshotAction); 379 menu.addAction (mDeleteSnapshotAction); 380 menu.addSeparator(); 381 menu.addAction (mShowSnapshotDetailsAction); 382 } 383 else 384 menu.addAction (mTakeSnapshotAction); 385 386 menu.exec (mTreeWidget->viewport()->mapToGlobal (aPoint)); 387 } 388 389 void VBoxSnapshotsWgt::onItemChanged (QTreeWidgetItem *aItem) 428 390 { 429 391 if (mEditProtector) 430 392 return; 431 393 432 SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;394 SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0; 433 395 434 396 if (item) 435 397 { 436 398 CSnapshot snap = mMachine.GetSnapshot (item->snapshotId()); 437 if (!snap.isNull() && snap.isOk() && 438 snap.GetName() != item->text (0)) 399 if (!snap.isNull() && snap.isOk() && snap.GetName() != item->text (0)) 439 400 snap.SetName (item->text (0)); 440 401 } 441 402 } 442 403 443 444 void VBoxSnapshotsWgt::discardSnapshot() 445 { 446 SnapshotWgtItem *item = mTreeWidget->selectedItems().isEmpty() ? 0 : 447 static_cast<SnapshotWgtItem*> (mTreeWidget->selectedItems() [0]); 404 void VBoxSnapshotsWgt::restoreSnapshot() 405 { 406 SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 : 407 static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem()); 448 408 AssertReturn (item, (void) 0); 449 409 450 410 QString snapId = item->snapshotId(); 451 411 AssertReturn (!snapId.isNull(), (void) 0); 412 CSnapshot snapshot = mMachine.GetSnapshot (snapId); 413 414 if (!vboxProblem().askAboutSnapshotRestoring (snapshot.GetName())) 415 return; 452 416 453 417 /* Open a direct session (this call will handle all errors) */ … … 456 420 return; 457 421 458 QString snapName = mMachine.GetSnapshot (snapId).GetName();459 460 422 CConsole console = session.GetConsole(); 461 CProgress progress = console. DeleteSnapshot(snapId);423 CProgress progress = console.RestoreSnapshot (snapshot); 462 424 if (console.isOk()) 463 425 { … … 467 429 468 430 if (progress.GetResultCode() != 0) 469 vboxProblem().cannot DiscardSnapshot (progress, snapName);431 vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName()); 470 432 } 471 433 else 472 vboxProblem().cannot DiscardSnapshot (console, snapName);434 vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName()); 473 435 474 436 session.Close(); 475 437 } 476 438 439 void VBoxSnapshotsWgt::deleteSnapshot() 440 { 441 SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 : 442 static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem()); 443 AssertReturn (item, (void) 0); 444 445 QString snapId = item->snapshotId(); 446 AssertReturn (!snapId.isNull(), (void) 0); 447 CSnapshot snapshot = mMachine.GetSnapshot (snapId); 448 449 if (!vboxProblem().askAboutSnapshotDeleting (snapshot.GetName())) 450 return; 451 452 /* Open a direct session (this call will handle all errors) */ 453 CSession session = vboxGlobal().openSession (mMachineId); 454 if (session.isNull()) 455 return; 456 457 CConsole console = session.GetConsole(); 458 CProgress progress = console.DeleteSnapshot (snapId); 459 if (console.isOk()) 460 { 461 /* Show the progress dialog */ 462 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), 463 vboxProblem().mainWindowShown()); 464 465 if (progress.GetResultCode() != 0) 466 vboxProblem().cannotDeleteSnapshot (progress, snapshot.GetName()); 467 } 468 else 469 vboxProblem().cannotDeleteSnapshot (console, snapshot.GetName()); 470 471 session.Close(); 472 } 473 474 void VBoxSnapshotsWgt::showSnapshotDetails() 475 { 476 SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 : 477 static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem()); 478 AssertReturn (item, (void) 0); 479 480 CSnapshot snap = item->snapshot(); 481 AssertReturn (!snap.isNull(), (void) 0); 482 483 CMachine snapMachine = snap.GetMachine(); 484 485 VBoxSnapshotDetailsDlg dlg (this); 486 dlg.getFromSnapshot (snap); 487 488 if (dlg.exec() == QDialog::Accepted) 489 dlg.putBackToSnapshot(); 490 } 491 477 492 void VBoxSnapshotsWgt::takeSnapshot() 478 493 { 479 SnapshotWgtItem *item = mTreeWidget->selectedItems().isEmpty() ? 0 :480 static_cast <SnapshotWgtItem*> (mTreeWidget->selectedItems() [0]);494 SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 : 495 static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem()); 481 496 AssertReturn (item, (void) 0); 482 497 … … 510 525 511 526 CConsole console = session.GetConsole(); 512 CProgress progress = 513 console.TakeSnapshot (dlg.mLeName->text().trimmed(), 514 dlg.mTeDescription->toPlainText()); 527 CProgress progress = console.TakeSnapshot (dlg.mLeName->text().trimmed(), 528 dlg.mTeDescription->toPlainText()); 515 529 if (console.isOk()) 516 530 { … … 529 543 } 530 544 531 void VBoxSnapshotsWgt::discardCurState() 532 { 533 if (!vboxProblem().askAboutSnapshotDiscarding()) 534 return; 535 536 SnapshotWgtItem *item = mTreeWidget->selectedItems().isEmpty() ? 0 : 537 static_cast<SnapshotWgtItem*> (mTreeWidget->selectedItems() [0]); 538 AssertReturn (item, (void) 0); 539 540 /* Open a direct session (this call will handle all errors) */ 541 CSession session = vboxGlobal().openSession (mMachineId); 542 if (session.isNull()) 543 return; 544 545 CConsole console = session.GetConsole(); 546 CProgress progress = console.RestoreSnapshot(mMachine.GetCurrentSnapshot()); 547 if (console.isOk()) 548 { 549 /* show the progress dialog */ 550 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), 551 vboxProblem().mainWindowShown()); 552 553 if (progress.GetResultCode() != 0) 554 vboxProblem().cannotDiscardCurrentState (progress); 555 } 556 else 557 vboxProblem().cannotDiscardCurrentState (console); 558 559 session.Close(); 560 } 561 562 void VBoxSnapshotsWgt::showSnapshotDetails() 563 { 564 SnapshotWgtItem *item = mTreeWidget->selectedItems().isEmpty() ? 0 : 565 static_cast<SnapshotWgtItem*> (mTreeWidget->selectedItems() [0]); 566 AssertReturn (item, (void) 0); 567 568 CSnapshot snap = item->snapshot(); 569 AssertReturn (!snap.isNull(), (void) 0); 570 571 CMachine snapMachine = snap.GetMachine(); 572 573 VBoxSnapshotDetailsDlg dlg (this); 574 dlg.getFromSnapshot (snap); 575 576 if (dlg.exec() == QDialog::Accepted) 577 dlg.putBackToSnapshot(); 578 } 579 580 581 void VBoxSnapshotsWgt::machineDataChanged (const VBoxMachineDataChangeEvent &aE) 545 546 void VBoxSnapshotsWgt::machineDataChanged (const VBoxMachineDataChangeEvent &aEvent) 582 547 { 583 548 SnapshotEditBlocker guardBlock (mEditProtector); 584 549 585 if (aE .id != mMachineId)586 return; /* not interested in other machines */550 if (aEvent.id != mMachineId) 551 return; 587 552 588 553 curStateItem()->recache(); 589 554 } 590 555 591 void VBoxSnapshotsWgt::machineStateChanged (const VBoxMachineStateChangeEvent &aE )556 void VBoxSnapshotsWgt::machineStateChanged (const VBoxMachineStateChangeEvent &aEvent) 592 557 { 593 558 SnapshotEditBlocker guardBlock (mEditProtector); 594 559 595 if (aE .id != mMachineId)596 return; /* not interested in other machines */560 if (aEvent.id != mMachineId) 561 return; 597 562 598 563 curStateItem()->recache(); 599 curStateItem()->updateCurrentState (aE .state);600 } 601 602 void VBoxSnapshotsWgt::sessionStateChanged (const VBoxSessionStateChangeEvent &aE )564 curStateItem()->updateCurrentState (aEvent.state); 565 } 566 567 void VBoxSnapshotsWgt::sessionStateChanged (const VBoxSessionStateChangeEvent &aEvent) 603 568 { 604 569 SnapshotEditBlocker guardBlock (mEditProtector); 605 570 606 if (aE.id != mMachineId) 607 return; /* not interested in other machines */ 608 609 mSessionState = aE.state; 610 onCurrentChanged (mTreeWidget->selectedItems().isEmpty() ? 0 : 611 mTreeWidget->selectedItems() [0]); 612 } 613 614 #if 0 615 void VBoxSnapshotsWgt::snapshotChanged (const VBoxSnapshotEvent &aE) 616 { 617 SnapshotEditBlocker guardBlock (mEditProtector); 618 619 if (aE.machineId != mMachineId) 620 return; /* not interested in other machines */ 621 622 switch (aE.what) 623 { 624 case VBoxSnapshotEvent::Taken: 625 case VBoxSnapshotEvent::Discarded: 626 { 627 refreshAll(); 628 break; 629 } 630 case VBoxSnapshotEvent::Changed: 631 { 632 SnapshotWgtItem *lvi = findItem (aE.snapshotId); 633 if (!lvi) 634 refreshAll (false); 635 else 636 lvi->recache(); 637 break; 638 } 639 } 640 } 641 #endif 571 if (aEvent.id != mMachineId) 572 return; 573 574 mSessionState = aEvent.state; 575 onCurrentChanged (mTreeWidget->currentItem()); 576 } 642 577 643 578 void VBoxSnapshotsWgt::retranslateUi() … … 646 581 Ui::VBoxSnapshotsWgt::retranslateUi (this); 647 582 648 mDiscardSnapshotAction->setText (tr ("&Discard Snapshot")); 583 mRestoreSnapshotAction->setText (tr ("&Restore Snapshot")); 584 mDeleteSnapshotAction->setText (tr ("&Delete Snapshot")); 585 mShowSnapshotDetailsAction->setText (tr ("S&how Details")); 649 586 mTakeSnapshotAction->setText (tr ("Take &Snapshot")); 650 mRevertToCurSnapAction->setText (tr ("&Revert to Current Snapshot")); 651 m ShowSnapshotDetailsAction->setText (tr ("S&how Details"));652 653 m DiscardSnapshotAction->setStatusTip (tr ("Discard the selected snapshot of the virtual machine"));587 588 mRestoreSnapshotAction->setStatusTip (tr ("Restore the selected snapshot of the virtual machine")); 589 mDeleteSnapshotAction->setStatusTip (tr ("Delete the selected snapshot of the virtual machine")); 590 mShowSnapshotDetailsAction->setStatusTip (tr ("Show details of the selected snapshot")); 654 591 mTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the current virtual machine state")); 655 mRevertToCurSnapAction->setStatusTip (tr ("Restore the virtual machine state from the state stored in the current snapshot")); 656 mShowSnapshotDetailsAction->setStatusTip (tr ("Show details of the selected snapshot")); 657 658 mDiscardSnapshotAction->setToolTip (mDiscardSnapshotAction->text().remove ('&').remove ('.') + 659 QString (" (%1)").arg (mDiscardSnapshotAction->shortcut().toString())); 592 593 mRestoreSnapshotAction->setToolTip (mRestoreSnapshotAction->text().remove ('&').remove ('.') + 594 QString (" (%1)").arg (mRestoreSnapshotAction->shortcut().toString())); 595 mDeleteSnapshotAction->setToolTip (mDeleteSnapshotAction->text().remove ('&').remove ('.') + 596 QString (" (%1)").arg (mDeleteSnapshotAction->shortcut().toString())); 597 mShowSnapshotDetailsAction->setToolTip (mShowSnapshotDetailsAction->text().remove ('&').remove ('.') + 598 QString (" (%1)").arg (mShowSnapshotDetailsAction->shortcut().toString())); 660 599 mTakeSnapshotAction->setToolTip (mTakeSnapshotAction->text().remove ('&').remove ('.') + 661 600 QString (" (%1)").arg (mTakeSnapshotAction->shortcut().toString())); 662 mRevertToCurSnapAction->setToolTip (mRevertToCurSnapAction->text().remove ('&').remove ('.') + 663 QString (" (%1)").arg (mRevertToCurSnapAction->shortcut().toString())); 664 mShowSnapshotDetailsAction->setToolTip (mShowSnapshotDetailsAction->text().remove ('&').remove ('.') + 665 QString (" (%1)").arg (mShowSnapshotDetailsAction->shortcut().toString())); 666 } 667 668 void VBoxSnapshotsWgt::refreshAll (bool aKeepSelected /* = true */) 601 } 602 603 void VBoxSnapshotsWgt::refreshAll() 669 604 { 670 605 SnapshotEditBlocker guardBlock (mEditProtector); 671 606 672 QString selected, selectedFirstChild; 673 if (aKeepSelected) 674 { 675 SnapshotWgtItem *cur = mTreeWidget->selectedItems().isEmpty() ? 0 : 676 static_cast<SnapshotWgtItem*> (mTreeWidget->selectedItems() [0]); 677 if (cur) 678 { 679 selected = cur->snapshotId(); 680 if (cur->child (0)) 681 selectedFirstChild = 682 static_cast<SnapshotWgtItem*> (cur->child (0))->snapshotId(); 683 } 607 if (mMachine.isNull()) 608 { 609 onCurrentChanged(); 610 return; 611 } 612 613 QString selectedItem, firstChildOfSelectedItem; 614 SnapshotWgtItem *cur = !mTreeWidget->currentItem() ? 0 : 615 static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem()); 616 if (cur) 617 { 618 selectedItem = cur->snapshotId(); 619 if (cur->child (0)) 620 firstChildOfSelectedItem = static_cast <SnapshotWgtItem*> (cur->child (0))->snapshotId(); 684 621 } 685 622 686 623 mTreeWidget->clear(); 687 624 688 if (mMachine.isNull()) 689 { 690 onCurrentChanged (NULL); 691 return; 692 } 693 694 /* get the first snapshot */ 625 /* Get the first snapshot */ 695 626 if (mMachine.GetSnapshotCount() > 0) 696 627 { … … 700 631 Assert (mCurSnapshotItem); 701 632 702 /* add the "current state" item */633 /* Add the "current state" item */ 703 634 new SnapshotWgtItem (mCurSnapshotItem, mMachine); 704 635 705 SnapshotWgtItem *cur = 0; 706 if (aKeepSelected) 707 { 708 cur = findItem (selected); 709 if (cur == 0) 710 cur = findItem (selectedFirstChild); 711 } 636 SnapshotWgtItem *cur = findItem (selectedItem); 637 if (cur == 0) 638 cur = findItem (firstChildOfSelectedItem); 712 639 if (cur == 0) 713 640 cur = curStateItem(); 641 714 642 mTreeWidget->scrollToItem (cur); 715 643 mTreeWidget->setCurrentItem (cur); … … 720 648 mCurSnapshotItem = 0; 721 649 722 /* add the "current state" item */650 /* Add the "current state" item */ 723 651 SnapshotWgtItem *csi = new SnapshotWgtItem (mTreeWidget, mMachine); 652 724 653 mTreeWidget->setCurrentItem (csi); 725 654 onCurrentChanged (csi); … … 734 663 while (*it) 735 664 { 736 SnapshotWgtItem *lvi = static_cast <SnapshotWgtItem*> (*it);665 SnapshotWgtItem *lvi = static_cast <SnapshotWgtItem*> (*it); 737 666 if (lvi->snapshotId() == aSnapshotId) 738 667 return lvi; … … 745 674 SnapshotWgtItem *VBoxSnapshotsWgt::curStateItem() 746 675 { 747 QTreeWidgetItem *csi = mCurSnapshotItem ? mCurSnapshotItem->child (0) 748 : mTreeWidget->invisibleRootItem()->child (0); 676 QTreeWidgetItem *csi = mCurSnapshotItem ? 677 mCurSnapshotItem->child (mCurSnapshotItem->childCount() - 1) : 678 mTreeWidget->invisibleRootItem()->child (0); 749 679 Assert (csi); 750 return static_cast<SnapshotWgtItem*> (csi); 751 } 752 753 void VBoxSnapshotsWgt::populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *item) 754 { 755 SnapshotWgtItem *si = 0; 756 si = item ? new SnapshotWgtItem (item, aSnapshot) : 757 new SnapshotWgtItem (mTreeWidget, aSnapshot); 680 return static_cast <SnapshotWgtItem*> (csi); 681 } 682 683 void VBoxSnapshotsWgt::populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem) 684 { 685 SnapshotWgtItem *item = aItem ? new SnapshotWgtItem (aItem, aSnapshot) : 686 new SnapshotWgtItem (mTreeWidget, aSnapshot); 758 687 759 688 if (mMachine.GetCurrentSnapshot().GetId() == aSnapshot.GetId()) 760 689 { 761 si->setBold (true); 762 mCurSnapshotItem = si; 763 } 764 765 CSnapshotVector snapvec = aSnapshot.GetChildren(); 766 for (int i = 0; i < snapvec.size(); ++i) 767 { 768 CSnapshot sn = snapvec[i]; 769 populateSnapshots (sn, si); 770 } 771 772 si->setExpanded (true); 773 si->setFlags (si->flags() | Qt::ItemIsEditable); 774 } 775 690 item->setBold (true); 691 mCurSnapshotItem = item; 692 } 693 694 CSnapshotVector snapshots = aSnapshot.GetChildren(); 695 foreach (const CSnapshot &snapshot, snapshots) 696 populateSnapshots (snapshot, item); 697 698 item->setExpanded (true); 699 item->setFlags (item->flags() | Qt::ItemIsEditable); 700 } 701
Note:
See TracChangeset
for help on using the changeset viewer.

