VirtualBox

Changeset 89093 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 17, 2021 11:35:46 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9930. Working on toolbar actions of the activity widget

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

Legend:

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

    r89036 r89093  
    952952        src/manager/chooser/UIChooserAbstractModel.cpp \
    953953        src/activity/overview/UIVMActivityOverviewWidget.cpp \
    954         src/activity/overview/UIVMActivityToolWidget.cpp \
    955954        src/networkmanager/UINetworkManager.cpp \
    956955        src/snapshots/UISnapshotDetailsWidget.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityToolWidget.cpp

    r89080 r89093  
    6060
    6161
    62 class UIVMActivityListWidget : public QWidget
    63 {
    64 
    65     Q_OBJECT;
    66 public:
    67 
    68     UIVMActivityListWidget(QWidget *pParent = 0)
    69         : QWidget(pParent)
    70     {
    71     }
    72 };
    7362/*********************************************************************************************************************************
    7463*   Class UIVMActivityToolWidget implementation.                                                                             *
     
    8271    , m_fShowToolbar(fShowToolbar)
    8372    , m_pToolBar(0)
     73    , m_pExportToFileAction(0)
    8474{
    8575    prepare();
     76    prepareActions();
     77    prepareToolBar();
     78    sltCurrentTabChanged(0);
    8679}
    8780
     
    113106{
    114107    setTabBarAutoHide(true);
     108    setLayout(new QHBoxLayout);
     109
     110    connect(this, &UIVMActivityToolWidget::currentChanged,
     111            this, &UIVMActivityToolWidget::sltCurrentTabChanged);
    115112}
    116113
     
    148145}
    149146
    150 
    151147void UIVMActivityToolWidget::prepareActions()
    152148{
     
    156152        connect(pToResourcesAction, &QAction::triggered, this, &UIVMActivityToolWidget::sigSwitchToResourcesPane);
    157153
     154    m_pExportToFileAction =
     155        m_pActionPool->action(UIActionIndex_M_Activity_S_Export);
     156    if (m_pExportToFileAction)
     157        connect(m_pExportToFileAction, &QAction::triggered, this, &UIVMActivityToolWidget::sltExportToFile);
    158158}
    159159
     
    187187}
    188188
    189 void UIVMActivityToolWidget::showVMActivityMonitor(CMachine &comMachine)
    190 {
    191     if (comMachine.isNull())
    192         return;
    193     // if (!m_pActivityMonitor)
    194     // {
    195     //     m_pActivityMonitor = new UIVMActivityMonitor(m_enmEmbedding, this,
    196     //                                                  comMachine, m_pActionPool, false /* Show toolbar */);
    197     //     addWidget(m_pActivityMonitor);
    198     // }
    199     // else
    200     //     m_pActivityMonitor->setMachine(comMachine);
    201 
    202     // setCurrentWidget(m_pActivityMonitor);
    203 }
    204 
    205 void UIVMActivityToolWidget::showVMActivityList()
    206 {
    207     // if (!m_pActivityList)
    208     // {
    209     //     m_pActivityList = new UIVMActivityListWidget(this);
    210     //     addWidget(m_pActivityList);
    211     // }
    212     // setCurrentWidget(m_pActivityList);
    213 }
    214 
    215189void UIVMActivityToolWidget::removeTabs(const QVector<QUuid> &machineIdsToRemove)
    216190{
     
    241215        if (comMachine.isNull())
    242216            continue;
    243         addTab(new UIVMActivityMonitor(m_enmEmbedding, this, comMachine, m_pActionPool), comMachine.GetName());
    244     }
    245 }
    246 
    247 #include "UIVMActivityToolWidget.moc"
     217        addTab(new UIVMActivityMonitor(m_enmEmbedding, this, comMachine), comMachine.GetName());
     218    }
     219}
     220
     221void UIVMActivityToolWidget::sltExportToFile()
     222{
     223    UIVMActivityMonitor *pActivityMonitor = qobject_cast<UIVMActivityMonitor*>(currentWidget());
     224    if (pActivityMonitor)
     225        pActivityMonitor->sltExportMetricsToFile();
     226}
     227
     228void UIVMActivityToolWidget::sltCurrentTabChanged(int iIndex)
     229{
     230    Q_UNUSED(iIndex);
     231    UIVMActivityMonitor *pActivityMonitor = qobject_cast<UIVMActivityMonitor*>(currentWidget());
     232    if (pActivityMonitor)
     233    {
     234        CMachine comMachine = uiCommon().virtualBox().FindMachine(pActivityMonitor->machineId().toString());
     235        if (!comMachine.isNull())
     236        {
     237            setExportActionEnabled(comMachine.GetState() == KMachineState_Running);
     238        }
     239    }
     240}
     241
     242void UIVMActivityToolWidget::setExportActionEnabled(bool fEnabled)
     243{
     244    if (m_pExportToFileAction)
     245        m_pExportToFileAction->setEnabled(fEnabled);
     246}
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityToolWidget.h

    r89080 r89093  
    7272private slots:
    7373
     74    void sltExportToFile();
     75    void sltCurrentTabChanged(int iIndex);
    7476
    7577private:
     
    8688    /** @} */
    8789
    88     void showVMActivityMonitor(CMachine &comMachine);
    89     void showVMActivityList();
    9090    /** Remove tabs conaining machine monitors with ids @machineIdsToRemove. */
    9191    void removeTabs(const QVector<QUuid> &machineIdsToRemove);
    9292    /** Add new tabs for each QUuid in @machineIdsToAdd. Does not check for duplicates. */
    9393    void addTabs(const QVector<QUuid> &machineIdsToAdd);
    94 
     94    void setExportActionEnabled(bool fEnabled);
    9595
    9696    /** @name General variables.
     
    106106    bool    m_fIsCurrentTool;
    107107    QVector<QUuid> m_machineIds;
     108    QAction *m_pExportToFileAction;
    108109};
    109110
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp

    r89041 r89093  
    3030/* GUI includes: */
    3131#include "QIFileDialog.h"
    32 #include "UIActionPool.h"
    3332#include "UICommon.h"
    3433#include "UIIconPool.h"
     
    880879
    881880UIVMActivityMonitor::UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent,
    882                                            const CMachine &machine, UIActionPool *pActionPool)
     881                                           const CMachine &machine)
    883882    : QIWithRetranslateUI<QWidget>(pParent)
    884883    , m_fGuestAdditionsAvailable(false)
     
    893892    , m_iTimeStep(0)
    894893    , m_enmEmbedding(enmEmbedding)
    895     , m_pActionPool(pActionPool)
    896894{
    897895    prepareMetrics();
     
    12671265void UIVMActivityMonitor::prepareActions()
    12681266{
    1269     QAction *pExportAction =
    1270         m_pActionPool->action(UIActionIndex_M_Activity_S_Export);
    1271     if (pExportAction)
    1272         connect(pExportAction, &QAction::triggered, this, &UIVMActivityMonitor::sltExportMetricsToFile);
    12731267}
    12741268
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h

    r89041 r89093  
    4545class QVBoxLayout;
    4646class QLabel;
    47 class UIActionPool;
    4847class UIChart;
    4948class UISession;
     
    127126    /** Constructs information-tab passing @a pParent to the QWidget base-class constructor.
    128127      * @param machine is machine reference. */
    129     UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine,
    130                         UIActionPool *pActionPool);
     128    UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine);
    131129    ~UIVMActivityMonitor();
    132130    void setMachine(const CMachine &machine);
     
    140138        void sltGuestAdditionsStateChange();
    141139    /** @} */
     140        void sltExportMetricsToFile();
    142141
    143142protected:
     
    152151    /** Stop updating the charts if/when the machine state changes something other than KMachineState_Running. */
    153152    void sltMachineStateChange(const QUuid &uId);
    154     void sltExportMetricsToFile();
    155153    void sltCreateContextMenu(const QPoint &point);
    156154    void sltClearCOMData();
     
    251249    quint64 m_iTimeStep;
    252250    EmbedTo m_enmEmbedding;
    253     UIActionPool *m_pActionPool;
    254251};
    255252
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r88834 r89093  
    23112311};
    23122312
    2313 /** Simple action extension, used as 'To VM Activity Oveview' action class. */
     2313/** Simple action extension, used as 'To VM Activity Overview' action class. */
    23142314class UIActionMenuSelectorActivityToVMActivityOverview : public UIActionSimple
    23152315{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp

    r89046 r89093  
    228228        /* Create Performance Monitor tab: */
    229229        UIVMActivityMonitor *pVMActivityMonitorWidget =
    230             new UIVMActivityMonitor(EmbedTo_Dialog, this, m_pMachineWindow->machine(),
    231                                      m_pMachineWindow->uisession()->actionPool());
     230            new UIVMActivityMonitor(EmbedTo_Dialog, this, m_pMachineWindow->machine());
    232231        if (pVMActivityMonitorWidget)
    233232        {
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