VirtualBox

Ignore:
Timestamp:
Apr 22, 2021 8:51:50 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143961
Message:

FE/Qt: bugref:9830. Not using QMenu

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r88602 r88647  
    10091009        src/logviewer/UIVMLogViewerFilterPanel.cpp \
    10101010        src/logviewer/UIVMLogViewerTextEdit.cpp \
     1011        src/logviewer/UIVMLogViewerWidget.cpp \
    10111012        src/activity/vmactivity/UIVMActivityMonitor.cpp \
    10121013        src/medium/UIMediumEnumerator.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r88644 r88647  
    5555const ULONG uAllowedLogSize = _256M;
    5656
     57class UIMachineListMenu : public QWidget
     58{
     59
     60    Q_OBJECT;
     61
     62public:
     63
     64    UIMachineListMenu(QWidget *pParent = 0);
     65    /** Removes the actions and deletes them. */
     66    void clear();
     67    QAction *addAction(const QString &strText);
     68};
     69
     70UIMachineListMenu::UIMachineListMenu(QWidget *pParent /* = 0 */)
     71    :QWidget(pParent)
     72{
     73}
     74
     75void UIMachineListMenu::clear()
     76{
     77    QList<QAction*> actionList = actions();
     78    for (int i = 0; i < actionList.size(); ++i)
     79    {
     80        removeAction(actionList[i]);
     81        delete actionList[i];
     82    }
     83}
     84
     85QAction *UIMachineListMenu::addAction(const QString &strText)
     86{
     87    QAction *pAction = new QAction(strText, this);
     88    QWidget::addAction(pAction);
     89    return pAction;
     90}
     91
    5792UIVMLogViewerWidget::Machine::Machine(const QUuid &id, const QString &strName)
    5893    : m_id(id)
     
    6095{
    6196}
     97
     98UIVMLogViewerWidget::Machine::Machine()
     99{}
    62100
    63101UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding,
     
    446484}
    447485
     486void UIVMLogViewerWidget::sltCornerButtonToggled(bool fToggle)
     487{
     488    printf("%d\n", fToggle);
     489}
     490
    448491void UIVMLogViewerWidget::prepare()
    449492{
     
    520563                m_pTabWidget->setCornerWidget(m_pCornerButton, Qt::TopLeftCorner);
    521564                m_pCornerButton->setIcon(UIIconPool::iconSet(":/machine_16px.png"));
    522                 m_pMachineSelectionMenu = new QMenu(this);
    523                 m_pCornerButton->setMenu(m_pMachineSelectionMenu);
    524                 m_pCornerButton->setPopupMode(QToolButton::InstantPopup);
     565                m_pCornerButton->setCheckable(true);
     566                m_pMachineSelectionMenu = new UIMachineListMenu(this);
     567                connect(m_pCornerButton, &QIToolButton::toggled, this, &UIVMLogViewerWidget::sltCornerButtonToggled);
     568                //m_pCornerButton->setMenu(m_pMachineSelectionMenu);
     569                //m_pCornerButton->setPopupMode(QToolButton::InstantPopup);
    525570            }
    526571        }
     
    9581003{
    9591004    if (!m_pMachineSelectionMenu)
    960     {
    961         m_pMachineSelectionMenu = new QMenu(this);
    962         if (m_pCornerButton)
    963             m_pCornerButton->setMenu(m_pMachineSelectionMenu);
    964     }
     1005        return;
    9651006    m_pMachineSelectionMenu->clear();
    9661007
     
    9721013    }
    9731014}
     1015
     1016#include "UIVMLogViewerWidget.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r88644 r88647  
    4444class QIToolBar;
    4545class QIToolButton;
     46class UIMachineListMenu;
    4647class UIVirtualMachineItem;
    4748class UIVMLogPage;
     
    137138        void sltResetOptionsToDefault();
    138139    /** @} */
    139 
     140    void sltCornerButtonToggled(bool fToggle);
    140141private:
    141142        struct Machine
    142143        {
    143144            Machine(const QUuid &id, const QString &strName);
     145            Machine();
    144146            QUuid   m_id;
    145147            QString m_strName;
     
    245247    /** @} */
    246248    QIToolButton *m_pCornerButton;
    247     QMenu *m_pMachineSelectionMenu;
     249    UIMachineListMenu *m_pMachineSelectionMenu;
    248250    friend class UIVMLogViewerFilterPanel;
    249251    friend class UIVMLogViewerPanel;
Note: See TracChangeset for help on using the changeset viewer.

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