VirtualBox

Changeset 80243 in vbox


Ignore:
Timestamp:
Aug 13, 2019 6:39:03 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132693
Message:

FE/Qt: bugref:9510: Caching translated strings

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
Files:
2 edited

Legend:

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

    r80203 r80243  
    299299            QLinearGradient gradient(0, 0, 0, iChartHeight);
    300300            gradient.setColorAt(1.0, Qt::green);
     301            gradient.setColorAt(0.5, Qt::yellow);
    301302            gradient.setColorAt(0.0, Qt::red);
    302303            painter.setPen(QPen(gradient, 2.5));
     
    335336                 m_pSubMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0)
    336337            strValue = uiCommon().formatSize(iValue);
    337 
    338         // QString strCurentSec = QString::number(iTotalSeconds - i * iTotalSeconds / (float)(iXSubAxisCount + 1));
    339         // int iTextWidth = fontMetrics.width(strCurentSec);
    340         // if (i == 0)
    341         // {
    342         //     strCurentSec += " seconds";
    343         //     painter.drawText(iTextX, height() - m_iMarginBottom + iFontHeight, strCurentSec);
    344         // }
    345         // else
    346         //     painter.drawText(iTextX - 0.5 * iTextWidth, height() - m_iMarginBottom + iFontHeight, strCurentSec);
    347338        painter.drawText(width() - 0.9 * m_iMarginRight, iTextY, strValue);
    348339    }
     
    357348        QPainterPath fillPath;
    358349        fillPath.moveTo(center);
    359 
    360350        fillPath.arcTo(m_pieChartRect, 90/*startAngle*/,
    361351                       -1 * 360 /*sweepLength*/);
    362352
    363353        /* First draw a white filled circle and that the arc for data: */
     354        painter.setPen(Qt::NoPen);
     355        painter.setBrush(QColor(255, 255, 255, 175));
     356        painter.drawPath(fillPath);
     357
     358        /* Prepare the gradient for the pie chart: */
    364359        QConicalGradient pieGradient;
    365360        pieGradient.setCenter(m_pieChartRect.center());
    366361        pieGradient.setAngle(90);
    367362        pieGradient.setColorAt(0, Qt::red);
     363        pieGradient.setColorAt(0.5, Qt::yellow);
    368364        pieGradient.setColorAt(1, Qt::green);
    369 
    370         painter.setPen(Qt::NoPen);
    371         painter.setBrush(Qt::white);
    372         painter.drawPath(fillPath);
    373365
    374366        if (isEnabled())
     
    466458
    467459UIPerformanceMonitor::UIPerformanceMonitor(QWidget *pParent, const CMachine &machine, const CConsole &console, const UISession *pSession)
    468     : QWidget(pParent)
     460    : QIWithRetranslateUI<QWidget>(pParent)
    469461    , m_fGuestAdditionsAvailable(false)
    470462    , m_machine(machine)
     
    485477    prepareObjects();
    486478    enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable);
     479    retranslateUi();
    487480}
    488481
    489482UIPerformanceMonitor::~UIPerformanceMonitor()
    490483{
     484}
     485
     486void UIPerformanceMonitor::retranslateUi()
     487{
     488    m_strCPUInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "CPU Load");
     489    m_strRAMInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "RAM Usage");
     490    m_strRAMInfoLabelTotal = QApplication::translate("UIVMInformationDialog", "Total");
     491    m_strRAMInfoLabelFree = QApplication::translate("UIVMInformationDialog", "Free");
     492    m_strRAMInfoLabelUsed = QApplication::translate("UIVMInformationDialog", "Used");
     493    m_strNetInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network");
     494    m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Received");
     495    m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Trasmitted");
     496    m_strNetInfoLabelMaximum = QApplication::translate("UIVMInformationDialog", "Maximum");
    491497}
    492498
     
    531537        m_charts[m_strNetMetricName]->setUseGradientLineColor(false);
    532538    }
     539    // if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])
     540    //     m_charts[m_strCPUMetricName]->setUseGradientLineColor(false);
     541
    533542    QWidget *bottomSpacerWidget = new QWidget(this);
    534543    bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
     
    605614        ULONG aPctOther;
    606615        m_machineDebugger.GetCPULoad(0x7fffffff, aPctExecuting, aPctHalted, aPctOther);
    607         updateCPUGraphsAndMetric(aPctExecuting);
     616        updateCPUGraphsAndMetric(aPctExecuting, aPctOther);
    608617    }
    609618
     
    703712}
    704713
    705 void UIPerformanceMonitor::updateCPUGraphsAndMetric(ULONG iLoadPercentage)
    706 {
     714void UIPerformanceMonitor::updateCPUGraphsAndMetric(ULONG iExecutingPercentage, ULONG iOtherPercentage)
     715{
     716    Q_UNUSED(iOtherPercentage);
    707717    UISubMetric &CPUMetric = m_subMetrics[m_strCPUMetricName];
    708     CPUMetric.addData(0, iLoadPercentage);
     718    CPUMetric.addData(0, iExecutingPercentage);
     719    //CPUMetric.addData(1, iOtherPercentage);
    709720    CPUMetric.setMaximum(100);
    710721    if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName])
     
    712723        QString strInfo;
    713724        if (m_infoLabels[m_strCPUMetricName]->isEnabled())
    714             strInfo = QString("<b>%1</b><br/>%2%3").arg("CPU Load").arg(QString::number(iLoadPercentage)).arg("%");
     725            strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg(QString::number(iExecutingPercentage)).arg("%");
    715726        else
    716             strInfo = QString("<b>%1</b><br/>%2%3").arg("CPU Load").arg("--").arg("%");
     727            strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg("--").arg("%");
    717728        m_infoLabels[m_strCPUMetricName]->setText(strInfo);
    718729    }
     
    730741        QString strInfo;
    731742        if (m_infoLabels[m_strRAMMetricName]->isEnabled())
    732             strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg("RAM Usage").arg("Total").arg(uiCommon().formatSize(_1K * iTotalRAM))
    733                 .arg("Free:").arg(uiCommon().formatSize(_1K * (iFreeRAM)))
    734                 .arg("Used:").arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM)));
     743            strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg(uiCommon().formatSize(_1K * iTotalRAM))
     744                .arg(m_strRAMInfoLabelFree).arg(uiCommon().formatSize(_1K * (iFreeRAM)))
     745                .arg(m_strRAMInfoLabelUsed).arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM)));
    735746        else
    736             strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg("RAM Usage").arg("Total").arg("---").arg("Free").arg("---").arg("Used").arg("---");
     747            strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg("---").arg(m_strRAMInfoLabelFree).arg("---").arg(m_strRAMInfoLabelUsed).arg("---");
    737748        m_infoLabels[m_strRAMMetricName]->setText(strInfo);
    738749    }
     
    755766        QString strInfo;
    756767        if (m_infoLabels[m_strNetMetricName]->isEnabled())
    757             strInfo = QString("<b>%1</b></b><br/><font color=\"#FF0000\">%2: %3</font><br/><font color=\"#0000FF\">%4: %5</font><br/>%6: %7").arg("Network")
    758                 .arg("Receive").arg(uiCommon().formatSize((quint64)iReceiveRate))
    759                 .arg("Transmit:").arg(uiCommon().formatSize((quint64)iTransmitRate))
    760                 .arg("Maximum:").arg(uiCommon().formatSize((quint64)iMaximum));
     768            strInfo = QString("<b>%1</b></b><br/><font color=\"#FF0000\">%2: %3</font><br/><font color=\"#0000FF\">%4: %5</font><br/>%6: %7").arg(m_strNetInfoLabelTitle)
     769                .arg(m_strNetInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate))
     770                .arg(m_strNetInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate))
     771                .arg(m_strNetInfoLabelMaximum).arg(uiCommon().formatSize((quint64)iMaximum));
    761772        else
    762             strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg("Network").arg("Receieve").arg("---").arg("Transmit").arg("---");
     773            strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strNetInfoLabelTitle).arg(m_strNetInfoLabelReceived).arg("---").arg(m_strNetInfoLabelTransmitted).arg("---");
    763774        m_infoLabels[m_strNetMetricName]->setText(strInfo);
    764775    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.h

    r80203 r80243  
    3737
    3838/* GUI includes: */
     39#include "QIWithRetranslateUI.h"
    3940#include "UIMainEventListener.h"
    4041
     
    7677};
    7778
    78 class UIPerformanceMonitor : public QWidget
     79/** UIPerformanceMonitor class displays some high level performance metric of the guest system.
     80  * The values are read in certain periods and cached in the GUI side. Currently we draw some line charts
     81  * and pie charts (where applicable) alongside with some text. */
     82class UIPerformanceMonitor : public QIWithRetranslateUI<QWidget>
    7983{
    8084    Q_OBJECT;
     
    8791    UIPerformanceMonitor(QWidget *pParent, const CMachine &machine, const CConsole &console, const UISession *pSession);
    8892    ~UIPerformanceMonitor();
     93
     94protected:
     95    void retranslateUi();
    8996
    9097private slots:
     
    100107    bool guestAdditionsAvailable(int iMinimumMajorVersion);
    101108    void enableDisableGuestAdditionDependedWidgets(bool fEnable);
    102     void updateCPUGraphsAndMetric(ULONG iLoadPercentage);
     109    void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage);
    103110    void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM);
    104111    void updateNewGraphsAndMetric(ULONG iReceiveRate, ULONG iTransmitRate);
     
    124131    QMap<QString,QLabel*>  m_infoLabels;
    125132
    126     QString m_strCPUMetricName;
    127     QString m_strRAMMetricName;
    128     QString m_strDiskMetricName;
    129     QString m_strNetMetricName;
     133    /** @name These metric names are used for map keys to identify metrics.
     134      * @{ */
     135        QString m_strCPUMetricName;
     136        QString m_strRAMMetricName;
     137        QString m_strDiskMetricName;
     138        QString m_strNetMetricName;
     139    /** @} */
     140
     141    /** @name These metric names are used for map keys to identify metrics.
     142      * @{ */
     143        /** CPU info label strings. */
     144        QString m_strCPUInfoLabelTitle;
     145        /** RAM usage info label strings. */
     146        QString m_strRAMInfoLabelTitle;
     147        QString m_strRAMInfoLabelTotal;
     148        QString m_strRAMInfoLabelFree;
     149        QString m_strRAMInfoLabelUsed;
     150        /** Net traffic info label strings. */
     151        QString m_strNetInfoLabelTitle;
     152        QString m_strNetInfoLabelReceived;
     153        QString m_strNetInfoLabelTransmitted;
     154        QString m_strNetInfoLabelMaximum;
     155    /** @} */
     156
     157
    130158};
    131159
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