VirtualBox

Changeset 80525 in vbox


Ignore:
Timestamp:
Sep 1, 2019 1:39:49 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133032
Message:

FE/Qt: bugref:9510: Updating GAs and VRDE fields.

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

Legend:

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

    r80523 r80525  
    5252const int iDecimalCount = 2;
    5353
    54 enum InfoLine
    55 {
    56     InfoLine_Title = 0,
    57     InfoLine_Resolution,
    58     InfoLine_Uptime,
    59     InfoLine_ClipboardMode,
    60     InfoLine_DnDMode,
    61     InfoLine_ExecutionEngine,
    62     InfoLine_NestedPaging,
    63     InfoLine_UnrestrictedExecution,
    64     InfoLine_Paravirtualization,
    65     InfoLine_GuestAdditions,
    66     InfoLine_GuestOSType,
    67     InfoLine_RemoteDesktop,
    68     InfoLine_Max
     54enum InfoRow
     55{
     56    InfoRow_Title = 0,
     57    InfoRow_Resolution,
     58    InfoRow_Uptime,
     59    InfoRow_ClipboardMode,
     60    InfoRow_DnDMode,
     61    InfoRow_ExecutionEngine,
     62    InfoRow_NestedPaging,
     63    InfoRow_UnrestrictedExecution,
     64    InfoRow_Paravirtualization,
     65    InfoRow_GuestAdditions,
     66    InfoRow_GuestOSType,
     67    InfoRow_RemoteDesktop,
     68    InfoRow_Max
    6969};
    7070
     
    8181    UIRuntimeInfoWidget(QWidget *pParent, const CMachine &machine, const CConsole &console);
    8282    void guestMonitorChange(ulong uScreenId);
     83    void guestAdditionStateChange();
     84    void VRDEChange();
    8385
    8486protected:
     
    9496private:
    9597
    96     void runTimeAttributes();
     98    void createInfoRows();
    9799    void updateScreenInfo(int iScreenId = -1);
    98100    void updateUpTime();
     101    void updateGAsVersion();
     102    void updateVRDE();
     103    /** Searches the table for the @p item of enmLine and replaces its text. if not found inserts a new
     104      * row to the end of the table. Assumes only one line of the @p enmLine exists. */
     105    void updateInfoRow(InfoRow enmLine, const QString &strColumn0, const QString &strColumn1);
    99106    QString screenResolution(int iScreenId);
    100     /** Creates to QTableWidgetItems of tye @enmInfoLine using the @p strLabel and @p strInfo and inserts it
     107    /** Creates to QTableWidgetItems of tye @enmInfoRow using the @p strLabel and @p strInfo and inserts it
    101108     * to the row @p iRow. If @p iRow is -1 then the items inserted to the end of the table. */
    102     void insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo, int iRow = -1);
     109    void insertInfoRow(InfoRow enmInfoRow, const QString& strLabel, const QString &strInfo, int iRow = -1);
    103110    void computeMinimumWidth();
    104111
     
    249256    retranslateUi();
    250257    /* Add the title row: */
    251     QTableWidgetItem *pTitleItem = new QTableWidgetItem(UIIconPool::iconSet(":/state_running_16px.png"), m_strTableTitle, InfoLine_Title);
     258    QTableWidgetItem *pTitleItem = new QTableWidgetItem(UIIconPool::iconSet(":/state_running_16px.png"), m_strTableTitle, InfoRow_Title);
    252259    QFont titleFont(font());
    253260    titleFont.setBold(true);
     
    256263    setItem(0, 0, pTitleItem);
    257264    /* Make the API calls and populate the table: */
    258     runTimeAttributes();
     265    createInfoRows();
    259266    computeMinimumWidth();
    260267}
     
    264271    updateScreenInfo(uScreenId);
    265272}
     273
     274void UIRuntimeInfoWidget::guestAdditionStateChange()
     275{
     276    updateGAsVersion();
     277}
     278
     279void UIRuntimeInfoWidget::VRDEChange()
     280{
     281    updateVRDE();
     282}
     283
    266284
    267285void UIRuntimeInfoWidget::retranslateUi()
     
    297315}
    298316
    299 void UIRuntimeInfoWidget::insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo, int iRow /* = -1 */)
     317void UIRuntimeInfoWidget::insertInfoRow(InfoRow enmInfoRow, const QString& strLabel, const QString &strInfo, int iRow /* = -1 */)
    300318{
    301319    int iMargin = 0.2 * qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin);
     
    304322        iNewRow = iRow;
    305323    insertRow(iNewRow);
    306     setItem(iNewRow, 0, new QTableWidgetItem(strLabel, enmInfoLine));
    307     setItem(iNewRow, 1, new QTableWidgetItem(strInfo, enmInfoLine));
     324    setItem(iNewRow, 0, new QTableWidgetItem(strLabel, enmInfoRow));
     325    setItem(iNewRow, 1, new QTableWidgetItem(strInfo, enmInfoRow));
    308326    setRowHeight(iNewRow, 2 * iMargin + m_iFontHeight);
    309327}
     
    356374    {
    357375        QTableWidgetItem *pItem = item(i, 0);
    358         if (pItem && pItem->type() == InfoLine_Resolution)
     376        if (pItem && pItem->type() == InfoRow_Resolution)
    359377            removeRow(i);
    360378    }
     
    366384            QString("%1:").arg(m_strScreenResolutionLabel);
    367385        /* Insert the screen resolution row at the top of the table. Row 0 is the title row: */
    368         insertInfoLine(InfoLine_Resolution, strLabel, m_screenResolutions[iScreen], iScreen + 1);
     386        insertInfoRow(InfoRow_Resolution, strLabel, m_screenResolutions[iScreen], iScreen + 1);
    369387    }
    370388    resizeColumnToContents(1);
     
    385403                uUpDays, uUpHours, uUpMins, uUpSecs);
    386404    QString strUptime = QString(szUptime);
    387 
     405    updateInfoRow(InfoRow_Uptime, QString("%1:").arg(m_strUptimeLabel), strUptime);
     406}
     407
     408void UIRuntimeInfoWidget::updateGAsVersion()
     409{
     410    CGuest guest = m_console.GetGuest();
     411    QString strGAVersion = guest.GetAdditionsVersion();
     412    if (strGAVersion.isEmpty())
     413        strGAVersion = m_strNotDetected;
     414    else
     415    {
     416        ULONG uRevision = guest.GetAdditionsRevision();
     417        if (uRevision != 0)
     418            strGAVersion += QString(" r%1").arg(uRevision);
     419    }
     420   updateInfoRow(InfoRow_GuestAdditions, QString("%1:").arg(m_strGuestAdditionsLabel), strGAVersion);
     421}
     422
     423void UIRuntimeInfoWidget::updateVRDE()
     424{
     425    /* VRDE information: */
     426    int iVRDEPort = m_console.GetVRDEServerInfo().GetPort();
     427    QString strVRDEInfo = (iVRDEPort == 0 || iVRDEPort == -1) ?
     428        m_strNotAvailable : QString("%1").arg(iVRDEPort);
     429   updateInfoRow(InfoRow_RemoteDesktop, QString("%1:").arg(m_strRemoteDesktopLabel), strVRDEInfo);
     430}
     431
     432void UIRuntimeInfoWidget::updateInfoRow(InfoRow enmLine, const QString &strColumn0, const QString &strColumn1)
     433{
    388434    QTableWidgetItem *pItem = 0;
    389435    for (int i = 0; i < rowCount() && !pItem; ++i)
     
    392438        if (!pItem)
    393439            continue;
    394         if (pItem->type() != InfoLine_Uptime)
     440        if (pItem->type() != enmLine)
    395441            pItem = 0;
    396442    }
    397443    if (!pItem)
    398         insertInfoLine(InfoLine_Uptime, QString("%1:").arg(m_strUptimeLabel), strUptime);
     444        insertInfoRow(enmLine, strColumn0, strColumn1);
    399445    else
    400         pItem->setText(strUptime);
    401 }
    402 
    403 void UIRuntimeInfoWidget::runTimeAttributes()
     446        pItem->setText(strColumn1);
     447}
     448
     449void UIRuntimeInfoWidget::createInfoRows()
    404450{
    405451    updateScreenInfo();
     
    444490    QString strParavirtProvider = gpConverter->toString(m_machine.GetEffectiveParavirtProvider());
    445491
    446     /* Guest information: */
    447     CGuest guest = m_console.GetGuest();
    448     QString strGAVersion = guest.GetAdditionsVersion();
    449     if (strGAVersion.isEmpty())
    450         strGAVersion = m_strNotDetected;
    451     else
    452     {
    453         ULONG uRevision = guest.GetAdditionsRevision();
    454         if (uRevision != 0)
    455             strGAVersion += QString(" r%1").arg(uRevision);
    456     }
    457     QString strOSType = guest.GetOSTypeId();
     492    QString strOSType = m_console.GetGuest().GetOSTypeId();
    458493    if (strOSType.isEmpty())
    459494        strOSType = m_strNotDetected;
     
    461496        strOSType = uiCommon().vmGuestOSTypeDescription(strOSType);
    462497
    463     /* VRDE information: */
    464     int iVRDEPort = m_console.GetVRDEServerInfo().GetPort();
    465     QString strVRDEInfo = (iVRDEPort == 0 || iVRDEPort == -1)?
    466         m_strNotAvailable : QString("%1").arg(iVRDEPort);
    467 
    468 
    469     insertInfoLine(InfoLine_ClipboardMode, QString("%1:").arg(m_strClipboardModeLabel), strClipboardMode);
    470     insertInfoLine(InfoLine_DnDMode, QString("%1:").arg(m_strDragAndDropLabel), strDnDMode);
    471     insertInfoLine(InfoLine_ExecutionEngine, QString("%1:").arg(m_strExcutionEngineLabel), strExecutionEngine);
    472     insertInfoLine(InfoLine_NestedPaging, QString("%1:").arg(m_strNestedPagingLabel), strNestedPaging);
    473     insertInfoLine(InfoLine_UnrestrictedExecution, QString("%1:").arg(m_strUnrestrictedExecutionLabel), strUnrestrictedExecution);
    474     insertInfoLine(InfoLine_Paravirtualization, QString("%1:").arg(m_strParavirtualizationLabel), strParavirtProvider);
    475     insertInfoLine(InfoLine_GuestAdditions, QString("%1:").arg(m_strGuestAdditionsLabel), strGAVersion);
    476     insertInfoLine(InfoLine_GuestOSType, QString("%1:").arg(m_strGuestOSTypeLabel), strOSType);
    477     insertInfoLine(InfoLine_RemoteDesktop, QString("%1:").arg(m_strRemoteDesktopLabel), strVRDEInfo);
     498
     499    insertInfoRow(InfoRow_ClipboardMode, QString("%1:").arg(m_strClipboardModeLabel), strClipboardMode);
     500    insertInfoRow(InfoRow_DnDMode, QString("%1:").arg(m_strDragAndDropLabel), strDnDMode);
     501    insertInfoRow(InfoRow_ExecutionEngine, QString("%1:").arg(m_strExcutionEngineLabel), strExecutionEngine);
     502    insertInfoRow(InfoRow_NestedPaging, QString("%1:").arg(m_strNestedPagingLabel), strNestedPaging);
     503    insertInfoRow(InfoRow_UnrestrictedExecution, QString("%1:").arg(m_strUnrestrictedExecutionLabel), strUnrestrictedExecution);
     504    insertInfoRow(InfoRow_Paravirtualization, QString("%1:").arg(m_strParavirtualizationLabel), strParavirtProvider);
     505    updateGAsVersion();
     506    insertInfoRow(InfoRow_GuestOSType, QString("%1:").arg(m_strGuestOSTypeLabel), strOSType);
     507    updateVRDE();
     508
    478509
    479510    resizeColumnToContents(0);
     
    10871118    connect(pSession, &UISession::sigAdditionsStateChange, this, &UIInformationRuntime::sltGuestAdditionsStateChange);
    10881119    connect(pSession, &UISession::sigGuestMonitorChange, this, &UIInformationRuntime::sltGuestMonitorChange);
     1120    connect(pSession, &UISession::sigVRDEChange, this, &UIInformationRuntime::sltVRDEChange);
    10891121
    10901122    prepareMetrics();
     
    13381370void UIInformationRuntime::sltGuestAdditionsStateChange()
    13391371{
     1372    if (m_pRuntimeInfoWidget)
     1373        m_pRuntimeInfoWidget->guestAdditionStateChange();
    13401374    bool fGuestAdditionsAvailable = guestAdditionsAvailable(6 /* minimum major version */);
    13411375    if (m_fGuestAdditionsAvailable == fGuestAdditionsAvailable)
     
    13491383    Q_UNUSED(changeType);
    13501384    Q_UNUSED(screenGeo);
    1351     printf("%lu\n", uScreenId);
    13521385    if (m_pRuntimeInfoWidget)
    13531386        m_pRuntimeInfoWidget->guestMonitorChange(uScreenId);
     1387}
     1388
     1389void UIInformationRuntime::sltVRDEChange()
     1390{
     1391    if (m_pRuntimeInfoWidget)
     1392        m_pRuntimeInfoWidget->VRDEChange();
    13541393}
    13551394
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h

    r80523 r80525  
    3838/* GUI includes: */
    3939#include "QIWithRetranslateUI.h"
    40 #include "UITextTable.h"
     40#include "UIMainEventListener.h"
     41
    4142
    4243/* Forward declarations: */
     
    155156    void sltGuestAdditionsStateChange();
    156157    void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
     158    void sltVRDEChange();
    157159
    158160private:
     
    192194    QMap<QString,UIChart*>  m_charts;
    193195    QMap<QString,QLabel*>  m_infoLabels;
     196    ComObjPtr<UIMainEventListenerImpl> m_pQtGuestListener;
    194197
    195198    /** @name These metric names are used for map keys to identify metrics.
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