VirtualBox

Changeset 88660 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 22, 2021 4:24:51 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9930: A bit of fixes for r143972; Making that menu separate top-level popup widget, it doesn't need to be togglable, just should not disappear on any of check-boxes click; No need to to calculate/limit size manually, just use the one layout knows about.

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  
    105105
    106106UIMachineListMenu::UIMachineListMenu(QWidget *pParent /* = 0 */)
    107     :QWidget(pParent)
     107    :QWidget(pParent, Qt::Popup)
    108108    , m_pLayout(0)
    109109{
    110110    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    }
    111120}
    112121
     
    123132    pCheckBox->setId(id);
    124133    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();
    145134}
    146135
     
    242231}
    243232
    244 void UIVMLogViewerWidget::resizeEvent(QResizeEvent *pEvent)
    245 {
    246     QIWithRetranslateUI<QWidget>::resizeEvent(pEvent);
    247     if (m_pMachineSelectionMenu)
    248         m_pMachineSelectionMenu->move(0, 40);
    249 }
    250 
    251233void UIVMLogViewerWidget::sltSaveOptions()
    252234{
     
    551533}
    552534
    553 void UIVMLogViewerWidget::sltCornerButtonToggled(bool fToggle)
    554 {
    555     if (m_pMachineSelectionMenu)
    556         m_pMachineSelectionMenu->setVisible(fToggle);
     535void 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    }
    557543}
    558544
     
    630616            {
    631617                m_pTabWidget->setCornerWidget(m_pCornerButton);//, Qt::TopLeftCorner);
    632                 m_pCornerButton->setCheckable(true);
    633618                m_pCornerButton->setIcon(UIIconPool::iconSet(":/machine_16px.png"));
    634                 m_pCornerButton->setCheckable(true);
    635619                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);
    641621            }
    642622        }
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r88659 r88660  
    9393    /** Returns whether the window should be maximized when geometry being restored. */
    9494    virtual bool shouldBeMaximized() const /* override */;
    95     void resizeEvent(QResizeEvent *pEvent) /* override */;
    9695
    9796private slots:
     
    140139        void sltResetOptionsToDefault();
    141140    /** @} */
    142     void sltCornerButtonToggled(bool fToggle);
     141    void sltCornerButtonClicked();
    143142private:
    144143        struct Machine
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette