VirtualBox

Changeset 6719 in vbox


Ignore:
Timestamp:
Feb 1, 2008 1:20:51 PM (17 years ago)
Author:
vboxsync
Message:

1761: “Create VM session information dialog”:

  1. The margins around the HTML widget made as thick as on the Details page of the main (VM Selector) window.
  2. "Basic" page renamed to "Details" (gear icon used for it).
  3. "Runtime" page made the default visible.
  4. "Green arrow" icon used for the "Runtime Attributes header".
  5. To avoid large dialog width "one column mode" is used: extended margin and large attributes values leads to enlarging dialog to annoying width in case of two columns.
  6. Disabled adapters are marked "Disabled" now and not attached Hard Disks are marked "Not attached".
  7. HTML widget have the initial focus now. Moreover, switching between pages enables focus to switched page.
  8. Session Info Dialog is now centered relative to it's VM window, not the desktop.
Location:
trunk/src/VBox/Frontends/VirtualBox/ui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMInformationDlg.ui

    r6630 r6719  
    141141    <slot access="protected">updateDetails()</slot>
    142142    <slot access="protected">processStatistics()</slot>
     143    <slot access="protected">onPageChanged( QWidget* )</slot>
    143144</slots>
    144145<functions>
     
    156157    <function returnType="QString" access="pritave">parseStatistics( const QString &amp; )</function>
    157158    <function access="pritave">refreshStatistics()</function>
    158     <function returnType="QString" access="pritave">composeArticle( const QString &amp;, int, int, int, int )</function>
     159    <function returnType="QString" access="pritave">formatHardDisk( const QString &amp;, CEnums::DiskControllerType, LONG, int, int )</function>
     160    <function returnType="QString" access="pritave">formatAdapter( const QString &amp;, ULONG, int, int )</function>
     161    <function returnType="QString" access="pritave">composeArticle( const QString &amp;, int, int )</function>
    159162</functions>
    160163<pixmapinproject/>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMInformationDlg.ui.h

    r6652 r6719  
    3636    {
    3737        /* creating new information dialog if there is no one existing */
    38         mSelfArray [machine.GetName()] = new VBoxVMInformationDlg (0,
     38        mSelfArray [machine.GetName()] = new VBoxVMInformationDlg (
     39            aConsole->topLevelWidget(),
    3940            "VBoxVMInformationDlg", WType_TopLevel | WDestructiveClose);
    4041        /* read new machine data for this information dialog */
     
    7273    /* logs list creation */
    7374    mInfoStack = new QTabWidget (mInfoFrame, "mInfoStack");
     75    mInfoStack->setMargin (10);
    7476    QVBoxLayout *infoFrameLayout = new QVBoxLayout (mInfoFrame);
    7577    infoFrameLayout->addWidget (mInfoStack);
     
    7779    /* details view creation */
    7880    mDetailsText = new QTextBrowser();
    79         mDetailsText->setFrameShape (QFrame::NoFrame);
    80     mDetailsText->setMargin (3);
     81    mDetailsText->setFrameShape (QFrame::NoFrame);
    8182    mDetailsText->setPaper (backgroundBrush());
    8283    mInfoStack->addTab (mDetailsText,
    83                         VBoxGlobal::iconSet ("help_16px.png"),
     84                        VBoxGlobal::iconSet ("settings_16px.png"),
    8485                        QString::null);
    8586
    8687    /* statistic view creation */
    8788    mStatisticText = new QTextBrowser();
    88         mStatisticText->setFrameShape (QFrame::NoFrame);
    89     mStatisticText->setMargin (3);
     89    mStatisticText->setFrameShape (QFrame::NoFrame);
    9090    mStatisticText->setPaper (backgroundBrush());
    9191    mInfoStack->addTab (mStatisticText,
     
    9595    /* full list of statistics counters to get total info */
    9696    // mDefStatText = new QTextBrowser();
    97         // mDefStatText->setFrameShape (QFrame::NoFrame);
    98     // mDefStatText->setMargin (3);
     97    // mDefStatText->setFrameShape (QFrame::NoFrame);
    9998    // mDefStatText->setPaper (backgroundBrush());
    10099    // mInfoStack->addTab (mDefStatText,
     
    105104    languageChangeImp();
    106105
    107     resize (800, 550);
     106    /* make initial resize */
     107    resize (600, 450);
     108
     109    /* show statistics page and make it focused */
     110    connect (mInfoStack, SIGNAL (currentChanged (QWidget*)),
     111             this, SLOT (onPageChanged (QWidget*)));
     112    mInfoStack->showPage (mStatisticText);
    108113}
    109114
     
    111116void VBoxVMInformationDlg::destroy()
    112117{
    113     mSelfArray.erase (mSession.GetMachine().GetName());
     118    if (!mSession.isNull() && !mSession.GetMachine().isNull())
     119        mSelfArray.erase (mSession.GetMachine().GetName());
    114120}
    115121
     
    153159
    154160    /* Setup a tabwidget page names. */
    155     mInfoStack->changeTab (mDetailsText, tr ("&Basic"));
     161    mInfoStack->changeTab (mDetailsText, tr ("&Details"));
    156162    mInfoStack->changeTab (mStatisticText, tr ("&Runtime"));
    157     // mInfoStack->changeTab (mDefStatText, tr ("&Default Stat"));
     163    // mInfoStack->changeTab (mDefStatText, tr ("De&fault Stat"));
    158164
    159165    /* Clear counter names initially. */
     
    183189    mNamesMap ["/Devices/PCNet0/TransmitBytes"] = tr ("Amount of bytes transmitted");
    184190    mNamesMap ["/Devices/PCNet0/ReceiveBytes"] = tr ("Amount of bytes received");
     191
    185192    mNamesMap ["/Devices/PCNet1/TransmitBytes"] = tr ("Amount of bytes transmitted");
    186193    mNamesMap ["/Devices/PCNet1/ReceiveBytes"] = tr ("Amount of bytes received");
     194
     195    mNamesMap ["/Devices/PCNet2/TransmitBytes"] = tr ("Amount of bytes transmitted");
     196    mNamesMap ["/Devices/PCNet2/ReceiveBytes"] = tr ("Amount of bytes received");
     197
     198    mNamesMap ["/Devices/PCNet3/TransmitBytes"] = tr ("Amount of bytes transmitted");
     199    mNamesMap ["/Devices/PCNet3/ReceiveBytes"] = tr ("Amount of bytes received");
    187200
    188201    /* Statistics page update. */
     
    324337
    325338
     339void VBoxVMInformationDlg::onPageChanged (QWidget *aPage)
     340{
     341    /* focusing the browser on shown page */
     342    aPage->setFocus();
     343}
     344
     345
    326346void VBoxVMInformationDlg::processStatistics()
    327347{
     
    345365}
    346366
     367
    347368QString VBoxVMInformationDlg::parseStatistics (const QString &aText)
    348369{
     
    350371    QRegExp query ("^.+<Statistics>\n(.+)\n</Statistics>.*$");
    351372    if (query.search (aText) == -1)
    352     {
    353             AssertMsgFailed (("Statistics format doesn't match.\n"));
    354373        return QString::null;
    355     }
     374
    356375    QStringList wholeList = QStringList::split ("\n", query.cap (1));
    357376
     
    386405}
    387406
     407
     408void VBoxVMInformationDlg::refreshStatistics()
     409{
     410    if (mSession.isNull())
     411        return;
     412
     413    QString table = "<p><table border=0 cellspacing=0 cellpadding=0 width=100%>%1</table></p>";
     414    QString hdrRow = "<tr><td align=left><img src='%1'></td><td colspan=2><b>%2</b></td></tr>";
     415    QString bdyRow = "<tr><td></td><td><nobr>%1</nobr></td><td width=100%><nobr>%2</nobr></td></tr>";
     416    QString paragraph = "<tr><td colspan=3></td></tr>";
     417    QString interline = "<tr><td colspan=3><font size=1>&nbsp;</font></td></tr>";
     418    QString result;
     419
     420    /* Screen & VT-X Runtime Parameters */
     421    {
     422        CConsole console = mSession.GetConsole();
     423        ULONG bpp = console.GetDisplay().GetBitsPerPixel();
     424        QString resolution = QString ("%1x%2")
     425            .arg (console.GetDisplay().GetWidth())
     426            .arg (console.GetDisplay().GetHeight());
     427        if (bpp)
     428            resolution += QString ("x%1").arg (bpp);
     429        QString virt = console.GetDebugger().GetHWVirtExEnabled() ?
     430            tr ("Enabled") : tr ("Disabled");
     431
     432        result += hdrRow.arg ("state_running_16px.png").arg (tr ("Runtime Attributes"));
     433        result += bdyRow.arg (tr ("Screen Resolution")).arg (resolution) +
     434                  bdyRow.arg (tr ("Hardware Virtualization")).arg (virt);
     435        result += paragraph;
     436    }
     437
     438    /* Hard Disk Statistics. */
     439    result += hdrRow.arg ("hd_16px.png").arg (tr ("Hard Disks Statistics"));
     440    result += formatHardDisk (tr ("Primary Master"), CEnums::IDE0Controller, 0, 0, 1);
     441    result += interline;
     442    result += formatHardDisk (tr ("Primary Slave"), CEnums::IDE0Controller, 1, 4, 5);
     443    result += interline;
     444    result += formatHardDisk (tr ("Secondary Master"), CEnums::IDE1Controller, 0, 8, 9);
     445    result += interline;
     446    result += formatHardDisk (tr ("Secondary Slave"), CEnums::IDE1Controller, 1, 12, 13);
     447    result += paragraph;
     448
     449    /* Network Adapters Statistics. */
     450    result += hdrRow.arg ("nw_16px.png").arg (tr ("Network Adapters Statistics"));
     451    result += formatAdapter (tr ("Adapter 1"), 0, 16, 17);
     452    result += interline;
     453    result += formatAdapter (tr ("Adapter 2"), 1, 18, 19);
     454    result += interline;
     455    result += formatAdapter (tr ("Adapter 3"), 2, 20, 21);
     456    result += interline;
     457    result += formatAdapter (tr ("Adapter 4"), 3, 22, 23);
     458
     459    /* Show full composed page. */
     460    mStatisticText->setText (table.arg (result));
     461}
     462
     463
     464QString VBoxVMInformationDlg::formatHardDisk (const QString &aName,
     465                                              CEnums::DiskControllerType aType,
     466                                              LONG aSlot, int aStart, int aFinish)
     467{
     468    if (mSession.isNull())
     469        return QString::null;
     470
     471    QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>";
     472    CMachine machine = mSession.GetMachine();
     473
     474    QString result = header.arg (aName);
     475    CHardDisk hd = machine.GetHardDisk (aType, aSlot);
     476    if (!hd.isNull() || (aType == CEnums::IDE1Controller && aSlot == 0))
     477    {
     478        result += composeArticle (QString::null, aStart, aFinish);
     479        result += composeArticle ("B", aStart + 2, aFinish + 2);
     480    }
     481    else
     482        result += composeArticle (tr ("Not attached"), -1, -1);
     483    return result;
     484}
     485
     486QString VBoxVMInformationDlg::formatAdapter (const QString &aName,
     487                                             ULONG aSlot,
     488                                             int aStart, int aFinish)
     489
     490{
     491    if (mSession.isNull())
     492        return QString::null;
     493
     494    QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>";
     495    CMachine machine = mSession.GetMachine();
     496
     497    QString result = header.arg (aName);
     498    CNetworkAdapter na = machine.GetNetworkAdapter (aSlot);
     499    result += na.GetEnabled() ?
     500        composeArticle ("B", aStart, aFinish) :
     501        composeArticle (tr ("Disabled"), -1, -1);
     502    return result;
     503}
     504
     505
     506QString VBoxVMInformationDlg::composeArticle (const QString &aUnits,
     507                                              int aStart, int aFinish)
     508{
     509    QString body = "<tr><td></td><td><nobr>%1</nobr></td><td width=100%><nobr>%2</nobr></td></tr>";
     510
     511    QString result;
     512
     513    if (aStart == -1 && aFinish == -1)
     514        result += body.arg (aUnits).arg (QString::null);
     515    else for (int id = aStart; id <= aFinish; ++ id)
     516    {
     517        QString line = body;
     518        if (mValuesMap.contains (mNamesMap.keys() [id]))
     519        {
     520            line = line.arg (mNamesMap.values() [id]);
     521            ULONG64 value = mValuesMap.values() [id].toULongLong();
     522            line = aUnits.isNull() ?
     523                line.arg (QString ("%L1").arg (value)) :
     524                line.arg (QString ("%L1 %2").arg (value).arg (aUnits));
     525        }
     526        result += line;
     527    }
     528
     529    return result;
     530}
     531
     532
     533/* Old code for two columns support */
     534#if 0
    388535void VBoxVMInformationDlg::refreshStatistics()
    389536{
     
    411558            tr ("Enabled") : tr ("Disabled");
    412559
    413         result += hdrRow.arg ("settings_16px.png").arg (tr ("Runtime Attributes"));
     560        result += hdrRow.arg ("state_running_16px.png").arg (tr ("Runtime Attributes"));
    414561        result += bdyRow.arg (tr ("Screen Resolution")) .arg (resolution)
    415562                        .arg (tr ("Hardware Virtualization")).arg (virt);
     
    439586}
    440587
     588
    441589QString VBoxVMInformationDlg::composeArticle (const QString &aUnits,
    442590                                              int aStart1, int aFinish1,
     
    452600    {
    453601        QString line = bdyRow;
     602        /* Processing first column */
    454603        if (id1 > aFinish1)
    455604        {
    456             line = line.arg (QString::null).arg (QString::null).arg (QString::null);
     605            line = line.arg (QString::null).arg (QString::null)
     606                       .arg (QString::null).arg (QString::null);
    457607        }
    458608        else if (mValuesMap.contains (mNamesMap.keys() [id1]))
     
    464614                line.arg (QString ("%L1 %2").arg (value).arg (aUnits));
    465615        }
     616        /* Processing second column */
    466617        if (id2 > aFinish2)
    467618        {
    468             line = line.arg (QString::null).arg (QString::null).arg (QString::null);
     619            line = line.arg (QString::null).arg (QString::null)
     620                       .arg (QString::null).arg (QString::null);
    469621        }
    470622        else if (mValuesMap.contains (mNamesMap.keys() [id2]))
     
    482634    return result;
    483635}
    484 
     636#endif
     637
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