VirtualBox

Ignore:
Timestamp:
Sep 13, 2019 10:25:13 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9510: Adding an option to show/hide pie charts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp

    r80766 r80771  
    161161    const QStringList &textList() const;
    162162
    163     bool withPieChart() const;
    164     void setWithPieChart(bool fWithPieChart);
     163    bool isPieChartAllowed() const;
     164    void setIsPieChartAllowed(bool fWithPieChart);
     165
     166    bool drawPieChart() const;
     167    void setDrawPieChart(bool fDrawPieChart);
    165168
    166169    bool useGradientLineColor() const;
     
    184187    void sltCreateContextMenu(const QPoint &point);
    185188    void sltResetMetric();
     189    void sltSetDrawPieChart(bool fDrawPieChart);
    186190
    187191private:
     
    217221    int m_iPieChartRadius;
    218222    int m_iPieChartSpacing;
    219     bool m_fWithPieChart;
     223    /** For some chart it is not possible to have a pie chart, Then We dont present the
     224      * option to show it to user. see m_fIsPieChartAllowed. */
     225    bool m_fIsPieChartAllowed;
     226    /**  m_fDrawPieChart is considered only if m_fIsPieChartAllowed is true. */
     227    bool m_fDrawPieChart;
    220228    bool m_fUseGradientLineColor;
    221229    QColor m_dataSeriesColor[DATA_SERIES_SIZE];
     
    223231    QString m_strGAWarning;
    224232    QString m_strResetActionLabel;
     233    QString m_strPieChartToggleActionLabel;
    225234};
    226235
     
    524533    , m_size(QSize(50, 50))
    525534    , m_iOverlayAlpha(80)
    526     , m_fWithPieChart(false)
     535    , m_fIsPieChartAllowed(false)
     536    , m_fDrawPieChart(true)
    527537    , m_fUseGradientLineColor(false)
    528538{
     
    557567}
    558568
    559 bool UIChart::withPieChart() const
    560 {
    561     return m_fWithPieChart;
    562 }
    563 
    564 void UIChart::setWithPieChart(bool fWithPieChart)
    565 {
    566     if (m_fWithPieChart == fWithPieChart)
    567         return;
    568     m_fWithPieChart = fWithPieChart;
     569bool UIChart::isPieChartAllowed() const
     570{
     571    return m_fIsPieChartAllowed;
     572}
     573
     574void UIChart::setIsPieChartAllowed(bool fWithPieChart)
     575{
     576    if (m_fIsPieChartAllowed == fWithPieChart)
     577        return;
     578    m_fIsPieChartAllowed = fWithPieChart;
     579    update();
     580}
     581
     582bool UIChart::drawPieChart() const
     583{
     584    return m_fDrawPieChart;
     585}
     586
     587void UIChart::setDrawPieChart(bool fDrawChart)
     588{
     589    if (m_fDrawPieChart == fDrawChart)
     590        return;
     591    m_fDrawPieChart = fDrawChart;
    569592    update();
    570593}
     
    625648    m_strGAWarning = QApplication::translate("UIVMInformationDialog", "No guest additions! This metric requires guest additions to work properly.");
    626649    m_strResetActionLabel = QApplication::translate("UIVMInformationDialog", "Reset");
     650    m_strPieChartToggleActionLabel = QApplication::translate("UIVMInformationDialog", "Show Pie Chart");
    627651}
    628652
     
    668692    painter.setPen(mainAxisColor);
    669693    drawXAxisLabels(painter, iXSubAxisCount);
    670 
    671694
    672695    /* Draw a half-transparent rectangle over the whole widget to indicate the it is disabled: */
     
    731754    }
    732755
    733     if (m_fWithPieChart)
     756    if (m_fIsPieChartAllowed && m_fDrawPieChart)
    734757        drawCombinedPieCharts(painter, iMaximum);
    735758}
     
    853876    QPainterPath arc;
    854877    QPointF center(rectangle.center());
    855 
    856     // arc.moveTo(center);
    857     // arc.arcTo(rectangle, 90/*startAngle*/,
    858     //                -1 * 360 /*sweepLength*/);
    859 
    860878    arc.addEllipse(rectangle);
    861879    return arc;
     
    938956    QAction *pResetAction = menu.addAction(m_strResetActionLabel);
    939957    connect(pResetAction, &QAction::triggered, this, &UIChart::sltResetMetric);
     958    if (m_fIsPieChartAllowed)
     959    {
     960        QAction *pPieChartToggle = menu.addAction(m_strPieChartToggleActionLabel);
     961        pPieChartToggle->setCheckable(true);
     962        pPieChartToggle->setChecked(m_fDrawPieChart);
     963        connect(pPieChartToggle, &QAction::toggled, this, &UIChart::sltSetDrawPieChart);
     964    }
    940965    menu.exec(mapToGlobal(point));
    941966}
     
    945970    if (m_pMetric)
    946971        m_pMetric->reset();
     972}
     973
     974void UIChart::sltSetDrawPieChart(bool fDrawPieChart)
     975{
     976    setDrawPieChart(fDrawPieChart);
    947977}
    948978
     
    12571287    /* Configure charts: */
    12581288    if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])
    1259         m_charts[m_strCPUMetricName]->setWithPieChart(true);
     1289        m_charts[m_strCPUMetricName]->setIsPieChartAllowed(true);
    12601290
    12611291    m_pRuntimeInfoWidget = new UIRuntimeInfoWidget(0, m_machine, m_console);
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