Changeset 67044 in vbox for trunk/src/VBox
- Timestamp:
- May 23, 2017 2:17:18 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r66730 r67044 5 5 6 6 /* 7 * Copyright (C) 2006-201 6Oracle Corporation7 * Copyright (C) 2006-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 508 508 /* Our own context menu: */ 509 509 setContextMenuPolicy(Qt::CustomContextMenu); 510 511 #if QT_VERSION < 0x050000512 // WORKAROUND:513 // The snapshots widget is not very useful if there are a lot514 // of snapshots in a tree and the current Qt style decides not515 // to draw lines (branches) between the snapshot nodes; it is516 // then often unclear which snapshot is a child of another.517 // So on platforms whose styles do not normally draw branches,518 // we use QWindowsStyle which is present on every platform and519 // draws required thing like we want. */520 // #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)521 QWindowsStyle *pTreeWidgetStyle = new QWindowsStyle;522 setStyle(pTreeWidgetStyle);523 connect(this, SIGNAL(destroyed(QObject *)), pTreeWidgetStyle, SLOT(deleteLater()));524 // #endif525 #endif /* QT_VERSION < 0x050000 */526 510 } 527 511 … … 531 515 *********************************************************************************************************************************/ 532 516 533 UISnapshotPane::UISnapshotPane(QWidget *pParent )517 UISnapshotPane::UISnapshotPane(QWidget *pParent /* = 0 */) 534 518 : QIWithRetranslateUI<QWidget>(pParent) 535 519 , m_pCurrentSnapshotItem(0) 536 , m_pSnapshotItemActionGroup(new QActionGroup(this)) 537 , m_pCurrentStateItemActionGroup(new QActionGroup(this)) 538 , m_pActionTakeSnapshot(new QAction(m_pCurrentStateItemActionGroup)) 539 , m_pActionRestoreSnapshot(new QAction(m_pSnapshotItemActionGroup)) 540 , m_pActionDeleteSnapshot(new QAction(m_pSnapshotItemActionGroup)) 541 , m_pActionShowSnapshotDetails(new QAction(m_pSnapshotItemActionGroup)) 542 , m_pActionCloneSnapshot(new QAction(m_pCurrentStateItemActionGroup)) 520 , m_pActionTakeSnapshot(0) 521 , m_pActionRestoreSnapshot(0) 522 , m_pActionDeleteSnapshot(0) 523 , m_pActionShowSnapshotDetails(0) 524 , m_pActionCloneSnapshot(0) 543 525 , m_fShapshotOperationsAllowed(false) 544 526 , m_pSnapshotTree(0) 545 527 { 546 /* Set contents margins: */547 #if defined(VBOX_WS_MAC)548 setContentsMargins(4, 5, 5, 5);549 #elif defined(VBOX_WS_WIN)550 setContentsMargins(3, 5, 5, 0);551 #elif defined(VBOX_WS_X11)552 setContentsMargins(0, 5, 5, 5);553 #endif554 555 528 /* Cache pixmaps: */ 556 529 m_snapshotIconOffline = UIIconPool::iconSet(":/snapshot_offline_16px.png"); 557 530 m_snapshotIconOnline = UIIconPool::iconSet(":/snapshot_online_16px.png"); 558 531 559 /* Create VBoxlayout: */532 /* Create layout: */ 560 533 QVBoxLayout *pLayout = new QVBoxLayout(this); 561 pLayout->setContentsMargins(0, 0, 0, 0); 562 563 /* Determine icon metric: */ 564 const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375); 565 566 /* Create tool-bar: */ 567 UIToolBar *pToolBar = new UIToolBar(this); 568 pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 569 pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 570 pToolBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 571 /* Add actions into tool-bar: */ 572 pToolBar->addAction(m_pActionTakeSnapshot); 573 pToolBar->addSeparator(); 574 pToolBar->addAction(m_pActionRestoreSnapshot); 575 pToolBar->addAction(m_pActionDeleteSnapshot); 576 pToolBar->addAction(m_pActionShowSnapshotDetails); 577 pToolBar->addSeparator(); 578 pToolBar->addAction(m_pActionCloneSnapshot); 579 /* Add tool-bar into layout: */ 580 pLayout->addWidget(pToolBar); 581 582 /* Setup action icons: */ 583 m_pActionTakeSnapshot->setIcon(UIIconPool::iconSetFull( 584 ":/snapshot_take_22px.png", ":/snapshot_take_16px.png", 585 ":/snapshot_take_disabled_22px.png", ":/snapshot_take_disabled_16px.png")); 586 m_pActionRestoreSnapshot->setIcon(UIIconPool::iconSetFull( 587 ":/snapshot_restore_22px.png", ":/snapshot_restore_16px.png", 588 ":/snapshot_restore_disabled_22px.png", ":/snapshot_restore_disabled_16px.png")); 589 m_pActionDeleteSnapshot->setIcon(UIIconPool::iconSetFull( 590 ":/snapshot_delete_22px.png", ":/snapshot_delete_16px.png", 591 ":/snapshot_delete_disabled_22px.png", ":/snapshot_delete_disabled_16px.png")); 592 m_pActionShowSnapshotDetails->setIcon(UIIconPool::iconSetFull( 593 ":/snapshot_show_details_22px.png", ":/snapshot_show_details_16px.png", 594 ":/snapshot_show_details_disabled_22px.png", ":/snapshot_details_show_disabled_16px.png")); 595 m_pActionCloneSnapshot->setIcon(UIIconPool::iconSetFull( 596 ":/vm_clone_22px.png", ":/vm_clone_16px.png", 597 ":/vm_clone_disabled_22px.png", ":/vm_clone_disabled_16px.png")); 598 /* Setup action shortcuts: */ 599 m_pActionTakeSnapshot->setShortcut(QString("Ctrl+Shift+S")); 600 m_pActionRestoreSnapshot->setShortcut(QString("Ctrl+Shift+R")); 601 m_pActionDeleteSnapshot->setShortcut(QString("Ctrl+Shift+D")); 602 m_pActionShowSnapshotDetails->setShortcut(QString("Ctrl+Space")); 603 m_pActionCloneSnapshot->setShortcut(QString("Ctrl+Shift+C")); 604 605 /* Create snapshot tree: */ 606 m_pSnapshotTree = new UISnapshotTree(this); 607 /* Add snapshot tree into layout: */ 608 pLayout->addWidget(m_pSnapshotTree); 534 { 535 /* Configure layout: */ 536 pLayout->setContentsMargins(0, 0, 0, 0); 537 #ifdef VBOX_WS_MAC 538 pLayout->setSpacing(10); 539 #else 540 pLayout->setSpacing(4); 541 #endif 542 543 /* Create snapshot toolbar: */ 544 UIToolBar *pToolBar = new UIToolBar(this); 545 { 546 /* Configure toolbar: */ 547 const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375); 548 pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 549 pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 550 pToolBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 551 552 /* Add Take Snapshot action: */ 553 m_pActionTakeSnapshot = pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_take_22px.png", 554 ":/snapshot_take_16px.png", 555 ":/snapshot_take_disabled_22px.png", 556 ":/snapshot_take_disabled_16px.png"), 557 QString(), this, &UISnapshotPane::sltTakeSnapshot); 558 { 559 m_pActionTakeSnapshot->setShortcut(QString("Ctrl+Shift+S")); 560 } 561 562 pToolBar->addSeparator(); 563 564 /* Add Restore Snapshot action: */ 565 m_pActionRestoreSnapshot = pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_restore_22px.png", 566 ":/snapshot_restore_16px.png", 567 ":/snapshot_restore_disabled_22px.png", 568 ":/snapshot_restore_disabled_16px.png"), 569 QString(), this, &UISnapshotPane::sltRestoreSnapshot); 570 { 571 m_pActionRestoreSnapshot->setShortcut(QString("Ctrl+Shift+R")); 572 } 573 574 /* Add Delete Snapshot action: */ 575 m_pActionDeleteSnapshot = pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_delete_22px.png", 576 ":/snapshot_delete_16px.png", 577 ":/snapshot_delete_disabled_22px.png", 578 ":/snapshot_delete_disabled_16px.png"), 579 QString(), this, &UISnapshotPane::sltDeleteSnapshot); 580 { 581 m_pActionDeleteSnapshot->setShortcut(QString("Ctrl+Shift+D")); 582 } 583 584 /* Add Show Snapshot Details action: */ 585 m_pActionShowSnapshotDetails = pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_show_details_22px.png", 586 ":/snapshot_show_details_16px.png", 587 ":/snapshot_show_details_disabled_22px.png", 588 ":/snapshot_details_show_disabled_16px.png"), 589 QString(), this, &UISnapshotPane::sltShowSnapshotDetails); 590 { 591 m_pActionShowSnapshotDetails->setShortcut(QString("Ctrl+Space")); 592 } 593 594 pToolBar->addSeparator(); 595 596 /* Add Clone Snapshot action: */ 597 m_pActionCloneSnapshot = pToolBar->addAction(UIIconPool::iconSetFull(":/vm_clone_22px.png", 598 ":/vm_clone_16px.png", 599 ":/vm_clone_disabled_22px.png", 600 ":/vm_clone_disabled_16px.png"), 601 QString(), this, &UISnapshotPane::sltCloneSnapshot); 602 { 603 m_pActionCloneSnapshot->setShortcut(QString("Ctrl+Shift+C")); 604 } 605 606 /* Add into layout: */ 607 pLayout->addWidget(pToolBar); 608 } 609 610 /* Create snapshot tree: */ 611 m_pSnapshotTree = new UISnapshotTree(this); 612 { 613 /* Configure snapshot tree: */ 614 connect(m_pSnapshotTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), 615 this, SLOT(sltCurrentItemChanged(QTreeWidgetItem *))); 616 connect(m_pSnapshotTree, SIGNAL(customContextMenuRequested(const QPoint &)), 617 this, SLOT(sltContextMenuRequested(const QPoint &))); 618 connect(m_pSnapshotTree, SIGNAL(itemChanged(QTreeWidgetItem *, int)), 619 this, SLOT(sltItemChanged(QTreeWidgetItem *))); 620 connect(m_pSnapshotTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), 621 this, SLOT(sltItemDoubleClicked(QTreeWidgetItem *))); 622 623 /* Add into layout: */ 624 pLayout->addWidget(m_pSnapshotTree); 625 } 626 } 609 627 610 628 /* Setup timer: */ 611 629 m_ageUpdateTimer.setSingleShot(true); 612 613 /* Setup snapshot tree connections: */ 614 connect(m_pSnapshotTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), 615 this, SLOT(sltCurrentItemChanged(QTreeWidgetItem *))); 616 connect(m_pSnapshotTree, SIGNAL(customContextMenuRequested(const QPoint &)), 617 this, SLOT(sltContextMenuRequested(const QPoint &))); 618 connect(m_pSnapshotTree, SIGNAL(itemChanged(QTreeWidgetItem *, int)), 619 this, SLOT(sltItemChanged(QTreeWidgetItem *))); 620 connect(m_pSnapshotTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), 621 this, SLOT(sltItemDoubleClicked(QTreeWidgetItem *))); 622 /* Setup snapshot operation connections: */ 623 connect(m_pActionTakeSnapshot, SIGNAL(triggered()), this, SLOT(sltTakeSnapshot())); 624 connect(m_pActionRestoreSnapshot, SIGNAL(triggered()), this, SLOT(sltRestoreSnapshot())); 625 connect(m_pActionDeleteSnapshot, SIGNAL(triggered()), this, SLOT(sltDeleteSnapshot())); 626 connect(m_pActionShowSnapshotDetails, SIGNAL(triggered()), this, SLOT(sltShowSnapshotDetails())); 627 connect(m_pActionCloneSnapshot, SIGNAL(triggered()), this, SLOT(sltCloneSnapshot())); 630 connect(&m_ageUpdateTimer, SIGNAL(timeout()), this, SLOT(sltUpdateSnapshotsAge())); 631 628 632 /* Setup Main event connections: */ 629 633 connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), … … 633 637 connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), 634 638 this, SLOT(sltSessionStateChange(QString, KSessionState))); 635 /* Setup timer event connections: */636 connect(&m_ageUpdateTimer, SIGNAL(timeout()), this, SLOT(sltUpdateSnapshotsAge()));637 639 638 640 /* Translate finally: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r64495 r67044 5 5 6 6 /* 7 * Copyright (C) 2006-201 6Oracle Corporation7 * Copyright (C) 2006-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 57 57 58 58 /** Constructs snapshot pane passing @a pParent to the base-class. */ 59 UISnapshotPane(QWidget *pParent );59 UISnapshotPane(QWidget *pParent = 0); 60 60 61 61 /** Defines the @a comMachine to be parsed. */ … … 154 154 QReadWriteLock m_lockReadWrite; 155 155 156 /** Holds the snapshot item action group instance. */157 QActionGroup *m_pSnapshotItemActionGroup;158 /** Holds the current item action group instance. */159 QActionGroup *m_pCurrentStateItemActionGroup;160 161 156 /** Holds the snapshot take action instance. */ 162 157 QAction *m_pActionTakeSnapshot;
Note:
See TracChangeset
for help on using the changeset viewer.