Changeset 88660 in vbox for trunk/src/VBox
- Timestamp:
- Apr 22, 2021 4:24:51 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
r88659 r88660 105 105 106 106 UIMachineListMenu::UIMachineListMenu(QWidget *pParent /* = 0 */) 107 :QWidget(pParent )107 :QWidget(pParent, Qt::Popup) 108 108 , m_pLayout(0) 109 109 { 110 110 m_pLayout = new QVBoxLayout(this); 111 if (m_pLayout) 112 { 113 /* Configure layout: */ 114 const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2; 115 const int iT = qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin) / 2; 116 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 2; 117 const int iB = qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) / 2; 118 m_pLayout->setContentsMargins(iL, iT, iR, iB); 119 } 111 120 } 112 121 … … 123 132 pCheckBox->setId(id); 124 133 m_pLayout->addWidget(pCheckBox); 125 computeMinimumSize();126 }127 128 void UIMachineListMenu::computeMinimumSize()129 {130 int iMaxTextLen = 0;131 foreach(const UIMachineListCheckBox *pCheckBox, m_checkboxes)132 {133 if (!pCheckBox)134 continue;135 //iMaxTextLen = qMax(iMaxTextLen, fontMetrics().horizontalAdvance(pCheckBox->text()));136 iMaxTextLen = qMax(iMaxTextLen, pCheckBox->width());137 }138 int iWidth = iMaxTextLen + 2 * qApp->style()->pixelMetric(QStyle::PM_ButtonIconSize);139 int iHeight = m_checkboxes.size() * fontMetrics().height() +140 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) +141 qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin);142 //printf("%d %d\n", iWidth, iHeight);143 setMinimumSize(iWidth, iHeight);144 update();145 134 } 146 135 … … 242 231 } 243 232 244 void UIVMLogViewerWidget::resizeEvent(QResizeEvent *pEvent)245 {246 QIWithRetranslateUI<QWidget>::resizeEvent(pEvent);247 if (m_pMachineSelectionMenu)248 m_pMachineSelectionMenu->move(0, 40);249 }250 251 233 void UIVMLogViewerWidget::sltSaveOptions() 252 234 { … … 551 533 } 552 534 553 void UIVMLogViewerWidget::sltCornerButtonToggled(bool fToggle) 554 { 555 if (m_pMachineSelectionMenu) 556 m_pMachineSelectionMenu->setVisible(fToggle); 535 void UIVMLogViewerWidget::sltCornerButtonClicked() 536 { 537 if (m_pMachineSelectionMenu && m_pCornerButton) 538 { 539 m_pMachineSelectionMenu->adjustSize(); 540 m_pMachineSelectionMenu->move(m_pCornerButton->mapToGlobal(QPoint(-m_pMachineSelectionMenu->width(), 0))); 541 m_pMachineSelectionMenu->show(); 542 } 557 543 } 558 544 … … 630 616 { 631 617 m_pTabWidget->setCornerWidget(m_pCornerButton);//, Qt::TopLeftCorner); 632 m_pCornerButton->setCheckable(true);633 618 m_pCornerButton->setIcon(UIIconPool::iconSet(":/machine_16px.png")); 634 m_pCornerButton->setCheckable(true);635 619 m_pMachineSelectionMenu = new UIMachineListMenu(this); 636 m_pMachineSelectionMenu->setAutoFillBackground(true); 637 m_pMachineSelectionMenu->setVisible(false); 638 connect(m_pCornerButton, &QIToolButton::toggled, this, &UIVMLogViewerWidget::sltCornerButtonToggled); 639 //m_pCornerButton->setMenu(m_pMachineSelectionMenu); 640 //m_pCornerButton->setPopupMode(QToolButton::InstantPopup); 620 connect(m_pCornerButton, &QIToolButton::clicked, this, &UIVMLogViewerWidget::sltCornerButtonClicked); 641 621 } 642 622 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r88659 r88660 93 93 /** Returns whether the window should be maximized when geometry being restored. */ 94 94 virtual bool shouldBeMaximized() const /* override */; 95 void resizeEvent(QResizeEvent *pEvent) /* override */;96 95 97 96 private slots: … … 140 139 void sltResetOptionsToDefault(); 141 140 /** @} */ 142 void sltCornerButton Toggled(bool fToggle);141 void sltCornerButtonClicked(); 143 142 private: 144 143 struct Machine
Note:
See TracChangeset
for help on using the changeset viewer.