Changeset 89607 in vbox
- Timestamp:
- Jun 10, 2021 4:04:00 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r89606 r89607 155 155 :QTabBar(pParent) 156 156 { 157 setContextMenuPolicy(Qt::CustomContextMenu);158 157 } 159 158 … … 312 311 { 313 312 pTabBar->setTabData(i, true); 314 UIVMLogTab *pTab = logTab(i);315 if ( pTab)313 /* Add close button only for manager UI. */ 314 if (uiCommon().uiType() == UICommon::UIType_SelectorUI) 316 315 { 317 UILogTabCloseButton *pCloseButton = new UILogTabCloseButton(0, pTab->machineId()); 318 pCloseButton->setIcon(UIIconPool::iconSet(":/close_16px.png")); 319 pTabBar->setTabButton(i, QTabBar::RightSide, pCloseButton); 320 connect(pCloseButton, &UILogTabCloseButton::clicked, this, &UIVMLogViewerWidget::sltTabCloseButtonClick); 316 UIVMLogTab *pTab = logTab(i); 317 if (pTab) 318 { 319 UILogTabCloseButton *pCloseButton = new UILogTabCloseButton(0, pTab->machineId()); 320 pCloseButton->setIcon(UIIconPool::iconSet(":/close_16px.png")); 321 pTabBar->setTabButton(i, QTabBar::RightSide, pCloseButton); 322 connect(pCloseButton, &UILogTabCloseButton::clicked, this, &UIVMLogViewerWidget::sltTabCloseButtonClick); 323 } 321 324 } 322 325 } … … 650 653 } 651 654 saveOptions(); 652 }653 654 void UIVMLogViewerWidget::sltShowTabBarContextMenu(const QPoint &pos)655 {656 if (m_pTabWidget && m_pTabWidget->tabBar())657 {658 int iIndex = m_pTabWidget->tabBar()->tabAt(pos);659 if (iIndex == -1)660 return;661 UIVMLogTab *pTab = qobject_cast<UIVMLogTab*>(m_pTabWidget->widget(iIndex));662 if (!pTab)663 return;664 QMenu menu;665 666 QAction *pCloseAction = menu.addAction(QString("%1 %2").arg(tr("Close Logs of")).arg(pTab->machineName()));667 pCloseAction->setData(pTab->machineId());668 connect(pCloseAction, &QAction::triggered, this, &UIVMLogViewerWidget::sltCloseMachineLogs);669 menu.exec(m_pTabWidget->tabBar()->mapToGlobal(pos));670 }671 655 } 672 656 … … 766 750 m_pMainLayout->addWidget(m_pTabWidget); 767 751 connect(m_pTabWidget, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltCurrentTabChanged); 768 connect(m_pTabWidget->tabBar(), &QTabBar::customContextMenuRequested,769 this, &UIVMLogViewerWidget::sltShowTabBarContextMenu);770 752 } 771 753 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r89605 r89607 142 142 void sltResetOptionsToDefault(); 143 143 /** @} */ 144 void sltShowTabBarContextMenu(const QPoint &pos);145 144 void sltCloseMachineLogs(); 146 145 void sltTabCloseButtonClick();
Note:
See TracChangeset
for help on using the changeset viewer.