VirtualBox

Ignore:
Timestamp:
Jul 31, 2020 7:22:55 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139640
Message:

FE/Qt: bugref:9686, bugref:9510. Exporting charts' data

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r85434 r85571  
    22482248        setStatusTip(QApplication::translate("UIActionPool", "Show the properties of currently selected file object(s)"));
    22492249        setToolTip(  QApplication::translate("UIActionPool", "Show Properties of Current Object(s)")
     2250                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
     2251    }
     2252};
     2253
     2254
     2255/** Menu action extension, used as 'Performance' menu class. */
     2256class UIActionMenuSelectorPerformance : public UIActionMenu
     2257{
     2258    Q_OBJECT;
     2259
     2260public:
     2261
     2262    /** Constructs action passing @a pParent to the base-class. */
     2263    UIActionMenuSelectorPerformance(UIActionPool *pParent)
     2264        : UIActionMenu(pParent)
     2265    {}
     2266
     2267protected:
     2268
     2269    /** Returns shortcut extra-data ID. */
     2270    virtual QString shortcutExtraDataID() const /* override */
     2271    {
     2272        return QString("PerformanceMenu");
     2273    }
     2274
     2275    /** Handles translation event. */
     2276    virtual void retranslateUi() /* override */
     2277    {
     2278        setName(QApplication::translate("UIActionPool", "&Performance"));
     2279    }
     2280};
     2281
     2282/** Simple action extension, used as 'Export' action class. */
     2283class UIActionMenuSelectorPerformanceExport : public UIActionSimple
     2284{
     2285    Q_OBJECT;
     2286
     2287public:
     2288
     2289    /** Constructs action passing @a pParent to the base-class. */
     2290    UIActionMenuSelectorPerformanceExport(UIActionPool *pParent)
     2291        : UIActionSimple(pParent,
     2292                         ":/log_viewer_save_32px.png", ":/log_viewer_save_16px.png",
     2293                         ":/log_viewer_save_disabled_32px.png", ":/log_viewer_save_disabled_16px.png")
     2294    {
     2295        setShortcutContext(Qt::WidgetWithChildrenShortcut);
     2296    }
     2297
     2298protected:
     2299
     2300    /** Returns shortcut extra-data ID. */
     2301    virtual QString shortcutExtraDataID() const /* override */
     2302    {
     2303        return QString("ExportCharts");
     2304    }
     2305
     2306    /** Handles translation event. */
     2307    virtual void retranslateUi() /* override */
     2308    {
     2309        setName(QApplication::translate("UIActionPool", "&Export..."));
     2310        setShortcutScope(QApplication::translate("UIActionPool", "Performance Monitor"));
     2311        setStatusTip(QApplication::translate("UIActionPool", "Export the chart data into a text file"));
     2312        setToolTip(  QApplication::translate("UIActionPool", "Export Data to File")
    22502313                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    22512314    }
     
    25012564    m_pool[UIActionIndex_M_FileManager_S_Guest_ShowProperties] = new UIActionMenuFileManagerShowProperties(this);
    25022565
     2566    /* Performance Monitor actions: */
     2567    m_pool[UIActionIndex_M_Performance] = new UIActionMenuSelectorPerformance(this);
     2568    m_pool[UIActionIndex_M_Performance_S_Export] = new UIActionMenuSelectorPerformanceExport(this);
     2569
    25032570    /* Prepare update-handlers for known menus: */
    25042571#ifdef VBOX_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r85434 r85571  
    136136    UIActionIndex_M_FileManager_S_Guest_ShowProperties,
    137137
     138    /* Performance Monitor actions: */
     139    UIActionIndex_M_Performance,
     140    UIActionIndex_M_Performance_S_Export,
     141
    138142    /* Maximum index: */
    139143    UIActionIndex_Max
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r85547 r85571  
    21452145        setStatusTip(QApplication::translate("UIActionPool", "Clone selected virtual machine"));
    21462146        setToolTip(  QApplication::translate("UIActionPool", "Clone Virtual Machine")
    2147                    + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    2148     }
    2149 };
    2150 
    2151 
    2152 /** Menu action extension, used as 'Performance' menu class. */
    2153 class UIActionMenuSelectorPerformance : public UIActionMenu
    2154 {
    2155     Q_OBJECT;
    2156 
    2157 public:
    2158 
    2159     /** Constructs action passing @a pParent to the base-class. */
    2160     UIActionMenuSelectorPerformance(UIActionPool *pParent)
    2161         : UIActionMenu(pParent)
    2162     {}
    2163 
    2164 protected:
    2165 
    2166     /** Returns shortcut extra-data ID. */
    2167     virtual QString shortcutExtraDataID() const /* override */
    2168     {
    2169         return QString("PerformanceMenu");
    2170     }
    2171 
    2172     /** Handles translation event. */
    2173     virtual void retranslateUi() /* override */
    2174     {
    2175         setName(QApplication::translate("UIActionPool", "&Performance"));
    2176     }
    2177 };
    2178 
    2179 /** Simple action extension, used as 'Export' action class. */
    2180 class UIActionMenuSelectorPerformanceExport : public UIActionSimple
    2181 {
    2182     Q_OBJECT;
    2183 
    2184 public:
    2185 
    2186     /** Constructs action passing @a pParent to the base-class. */
    2187     UIActionMenuSelectorPerformanceExport(UIActionPool *pParent)
    2188         : UIActionSimple(pParent,
    2189                          ":/log_viewer_save_32px.png", ":/log_viewer_save_16px.png",
    2190                          ":/log_viewer_save_disabled_32px.png", ":/log_viewer_save_disabled_16px.png")
    2191     {
    2192         setShortcutContext(Qt::WidgetWithChildrenShortcut);
    2193     }
    2194 
    2195 protected:
    2196 
    2197     /** Returns shortcut extra-data ID. */
    2198     virtual QString shortcutExtraDataID() const /* override */
    2199     {
    2200         return QString("ExportCharts");
    2201     }
    2202 
    2203     /** Handles translation event. */
    2204     virtual void retranslateUi() /* override */
    2205     {
    2206         setName(QApplication::translate("UIActionPool", "&Export..."));
    2207         setShortcutScope(QApplication::translate("UIActionPool", "Performance Monitor"));
    2208         setStatusTip(QApplication::translate("UIActionPool", "Export the chart data into a text file"));
    2209         setToolTip(  QApplication::translate("UIActionPool", "Export Data to File")
    22102147                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    22112148    }
     
    35383475    m_pool[UIActionIndexST_M_Snapshot_T_Properties] = new UIActionMenuSelectorSnapshotToggleProperties(this);
    35393476    m_pool[UIActionIndexST_M_Snapshot_S_Clone] = new UIActionMenuSelectorSnapshotPerformClone(this);
    3540 
    3541     /* Performance Monitor actions: */
    3542     m_pool[UIActionIndex_M_Performance] = new UIActionMenuSelectorPerformance(this);
    3543     m_pool[UIActionIndex_M_Performance_S_Export] = new UIActionMenuSelectorPerformanceExport(this);
    35443477
    35453478    /* Virtual Medium Manager actions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r85547 r85571  
    149149    UIActionIndexST_M_Snapshot_S_Clone,
    150150
    151     /* Performance Monitor actions: */
    152     UIActionIndex_M_Performance,
    153     UIActionIndex_M_Performance_S_Export,
    154 
    155151    /* Virtual Media Manager actions: */
    156152    UIActionIndexST_M_MediumWindow,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.cpp

    r85406 r85571  
    193193            case UIToolType_Performance:
    194194            {
    195                 m_pPanePerformanceMonitor = new UIPerformanceMonitor(EmbedTo_Stack, 0, m_comMachine, false /* Show toolbar */);
     195                m_pPanePerformanceMonitor = new UIPerformanceMonitor(EmbedTo_Stack, 0,
     196                                                                     m_comMachine, m_pActionPool, false /* Show toolbar */);
    196197                AssertPtrReturnVoid(m_pPanePerformanceMonitor);
    197198#ifndef VBOX_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.cpp

    r85568 r85571  
    2929/* GUI includes: */
    3030#include "QIFileDialog.h"
     31#include "UIActionPool.h"
    3132#include "UICommon.h"
    3233#include "UIPerformanceMonitor.h"
     
    722723}
    723724
    724 void UIMetric::toFile(QFile &file) const
    725 {
    726     QTextStream stream(&file);
    727     stream << m_strName << "\n";
     725void UIMetric::toFile(QTextStream &stream) const
     726{
     727    stream << "Metric Name: " << m_strName << "\n";
     728    stream << "Unit: " << m_strUnit << "\n";
     729    stream << "Maximum: " << m_iMaximum << "\n";
    728730    foreach (const quint64& data, m_data[0])
    729         stream << data;
     731        stream << data << " ";
     732    stream << "\n";
     733    foreach (const quint64& data, m_data[1])
     734        stream << data << " ";
     735    stream << "\n\n";
    730736}
    731737
     
    735741
    736742UIPerformanceMonitor::UIPerformanceMonitor(EmbedTo enmEmbedding, QWidget *pParent,
    737                                            const CMachine &machine, bool fShowToolbar /* = false */)
     743                                           const CMachine &machine, UIActionPool *pActionPool, bool fShowToolbar /* = false */)
    738744    : QIWithRetranslateUI<QWidget>(pParent)
    739745    , m_fGuestAdditionsAvailable(false)
     
    750756    , m_enmEmbedding(enmEmbedding)
    751757    , m_fShowToolbar(fShowToolbar)
     758    , m_pActionPool(pActionPool)
    752759{
    753760    prepareMetrics();
     
    755762    if (fShowToolbar)
    756763        prepareToolBar();
     764    prepareActions();
    757765    retranslateUi();
    758766    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, this, &UIPerformanceMonitor::sltMachineStateChange);
     
    991999    QString strFileName = QIFileDialog::getSaveFileName("","",this, "");
    9921000
    993     QFile data(strFileName);
    994     if (data.open(QFile::WriteOnly | QFile::Truncate)) {
    995 
     1001    QFile dataFile(strFileName);
     1002    if (dataFile.open(QFile::WriteOnly | QFile::Truncate)) {
     1003        QTextStream stream(&dataFile);
    9961004        for (QMap<QString, UIMetric>::const_iterator iterator =  m_metrics.begin();
    9971005             iterator != m_metrics.end(); ++iterator)
    9981006        {
    999             iterator.value().toFile(data);
     1007            iterator.value().toFile(stream);
    10001008        }
    1001         data.close();
    1002 
    1003       //   QTextStream out(&data);
    1004       // out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7;
    1005       // writes "Result: 3.14      2.7       "
     1009        dataFile.close();
    10061010  }
    1007 
    1008 
    10091011}
    10101012
     
    10881090#endif
    10891091    }
    1090     // QAction *pAction =
    1091     //     actionPool()->action(UIActionIndex_M_Performance_S_Export);
    1092     // if (pAction)
    1093     //     connect(pAction, &QAction::triggered, this, &UIPerformanceMonitor::sltExportMetricsToFile);
     1092}
     1093
     1094void UIPerformanceMonitor::prepareActions()
     1095{
     1096    QAction *pAction =
     1097        m_pActionPool->action(UIActionIndex_M_Performance_S_Export);
     1098    if (pAction)
     1099        connect(pAction, &QAction::triggered, this, &UIPerformanceMonitor::sltExportMetricsToFile);
    10941100}
    10951101
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.h

    r85568 r85571  
    4545class QVBoxLayout;
    4646class QLabel;
     47class UIActionPool;
    4748class UIChart;
    4849class UISession;
     
    8283    void reset();
    8384
    84     void toFile(QFile &file) const;
     85    void toFile(QTextStream &stream) const;
    8586
    8687private:
     
    115116    /** Constructs information-tab passing @a pParent to the QWidget base-class constructor.
    116117      * @param machine is machine reference. */
    117     UIPerformanceMonitor(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine, bool fShowToolbar = false);
     118    UIPerformanceMonitor(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine,
     119                         UIActionPool *pActionPool,bool fShowToolbar = false);
    118120    ~UIPerformanceMonitor();
    119121    void setMachine(const CMachine &machine);
     
    147149    void prepareMetrics();
    148150    void prepareToolBar();
     151    void prepareActions();
    149152    bool guestAdditionsAvailable(int iMinimumMajorVersion);
    150153    void enableDisableGuestAdditionDependedWidgets(bool fEnable);
     
    239242    EmbedTo m_enmEmbedding;
    240243    bool    m_fShowToolbar;
     244    UIActionPool *m_pActionPool;
    241245};
    242246
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp

    r85406 r85571  
    200200        /* Create Performance Monitor tab: */
    201201        UIPerformanceMonitor *pPerformanceMonitorWidget =
    202             new UIPerformanceMonitor(EmbedTo_Dialog, this, m_pMachineWindow->machine());
     202            new UIPerformanceMonitor(EmbedTo_Dialog, this, m_pMachineWindow->machine(),
     203                                     m_pMachineWindow->uisession()->actionPool());
    203204        if (pPerformanceMonitorWidget)
    204205        {
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