VirtualBox

Changeset 88644 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 22, 2021 8:09:38 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9930. Populating the menu with selected items of the vm list

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r88634 r88644  
    3838#include "UIIconPool.h"
    3939#include "UIMessageCenter.h"
     40#include "UIVirtualMachineItem.h"
    4041#include "UIVMLogPage.h"
    4142#include "UIVMLogViewerWidget.h"
     
    5354/** Limit the read string size to avoid bloated log viewer pages. */
    5455const ULONG uAllowedLogSize = _256M;
     56
     57UIVMLogViewerWidget::Machine::Machine(const QUuid &id, const QString &strName)
     58    : m_id(id)
     59    , m_strName(strName)
     60{
     61}
     62
    5563UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding,
    5664                                         UIActionPool *pActionPool,
     
    121129}
    122130
     131void UIVMLogViewerWidget::setSelectedVMListItems(const QList<UIVirtualMachineItem*> &items)
     132{
     133    m_machines.clear();
     134    foreach (const UIVirtualMachineItem *item, items)
     135    {
     136        if (!item)
     137            continue;
     138        m_machines << Machine(item->id(), item->name());
     139    }
     140    updateMachineSelectionMenu();
     141}
     142
    123143QFont UIVMLogViewerWidget::currentFont() const
    124144{
     
    502522                m_pMachineSelectionMenu = new QMenu(this);
    503523                m_pCornerButton->setMenu(m_pMachineSelectionMenu);
     524                m_pCornerButton->setPopupMode(QToolButton::InstantPopup);
    504525            }
    505526        }
     
    688709        m_pToolBar->updateLayout();
    689710#endif
     711    m_pCornerButton->setToolTip(tr("Select machines to show their log"));
    690712}
    691713
     
    932954    m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));
    933955}
     956
     957void UIVMLogViewerWidget::updateMachineSelectionMenu()
     958{
     959    if (!m_pMachineSelectionMenu)
     960    {
     961        m_pMachineSelectionMenu = new QMenu(this);
     962        if (m_pCornerButton)
     963            m_pCornerButton->setMenu(m_pMachineSelectionMenu);
     964    }
     965    m_pMachineSelectionMenu->clear();
     966
     967    foreach (const Machine &machine, m_machines)
     968    {
     969        QAction *pAction = m_pMachineSelectionMenu->addAction(machine.m_strName);
     970        pAction->setCheckable(true);
     971        pAction->setData(machine.m_id);
     972    }
     973}
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r88634 r88644  
    4444class QIToolBar;
    4545class QIToolButton;
     46class UIVirtualMachineItem;
    4647class UIVMLogPage;
    4748class UIVMLogViewerBookmarksPanel;
     
    8687    /** Defines the @a comMachine whose logs to show. */
    8788    void setMachine(const CMachine &comMachine);
     89    void setSelectedVMListItems(const QList<UIVirtualMachineItem*> &items);
    8890    QFont currentFont() const;
    8991
     
    137139
    138140private:
    139 
     141        struct Machine
     142        {
     143            Machine(const QUuid &id, const QString &strName);
     144            QUuid   m_id;
     145            QString m_strName;
     146        };
    140147    /** @name Prepare/Cleanup
    141148      * @{ */
     
    184191    /** Resets document (of the curent tab) and scrollbar highligthing */
    185192    void resetHighlighthing();
    186 
    187193    void hidePanel(UIDialogPanel* panel);
    188194    void showPanel(UIDialogPanel* panel);
    189 
    190195    /** Make sure escape key is assigned to only a single widget. This is done by checking
    191196        several things in the following order:
     
    194199        - assigned it to the most recently "unhidden" panel */
    195200    void manageEscapeShortCut();
     201    void updateMachineSelectionMenu();
    196202
    197203    /** Holds the widget's embedding type. */
     
    203209    /** Holds the machine instance. */
    204210    CMachine      m_comMachine;
     211    QVector<Machine> m_machines;
    205212
    206213    /** Holds whether the dialog is polished. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.cpp

    r88071 r88644  
    279279        m_pPaneDetails->setItems(m_items);
    280280    }
     281    /* Update logs pane is it is open: */
     282    if (isToolOpened(UIToolType_Logs))
     283    {
     284        AssertPtrReturnVoid(m_pPaneLogViewer);
     285        m_pPaneLogViewer->setSelectedVMListItems(m_items);
     286    }
    281287}
    282288
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