VirtualBox

Changeset 39261 in vbox


Ignore:
Timestamp:
Nov 10, 2011 12:01:01 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74796
Message:

FE/Qt: 5804: Allow one operation on several VMs: VM details support for choosing several VMs, step 2 (support for inaccessible VMs).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp

    r39225 r39261  
    224224        /* Assign corresponding vector values: */
    225225        m_machines[i] = machine;
    226         m_changeable[i] = machine.isNull() ? false :
     226        m_changeable[i] = machine.isNull() || !machine.GetAccessible() ? false :
    227227                          machine.GetState() != KMachineState_Stuck &&
    228228                          machine.GetState() != KMachineState_Saved /* for now! */;
     
    370370        if (!machine.isNull())
    371371        {
    372             QString item = sSectionItemTpl2.arg(tr("Name", "details report"), machine.GetName())
    373                          + sSectionItemTpl2.arg(tr("OS Type", "details report"), vboxGlobal().vmGuestOSTypeDescription(machine.GetOSTypeId()));
     372            QString item;
     373            if (machine.GetAccessible())
     374            {
     375                item = sSectionItemTpl2.arg(tr("Name", "details report"), machine.GetName())
     376                     + sSectionItemTpl2.arg(tr("OS Type", "details report"), vboxGlobal().vmGuestOSTypeDescription(machine.GetOSTypeId()));
     377            }
     378            else
     379            {
     380                item = QString(sSectionItemTpl1).arg(tr("Information inaccessible", "details report"));
     381            }
    374382            pLabel->setText(sTableTpl.arg(item));
    375383        }
     
    403411        if (!machine.isNull())
    404412        {
    405             QString item = sSectionItemTpl2.arg(tr("Base Memory", "details report"), tr("<nobr>%1 MB</nobr>", "details report"))
    406                                            .arg(machine.GetMemorySize());
    407 
    408             int cCPU = machine.GetCPUCount();
    409             if (cCPU > 1)
    410                 item += sSectionItemTpl2.arg(tr("Processors", "details report"), tr("<nobr>%1</nobr>", "details report"))
    411                                         .arg(cCPU);
    412 
    413             int iCPUExecCap = machine.GetCPUExecutionCap();
    414             if (iCPUExecCap < 100)
    415                 item += sSectionItemTpl2.arg(tr("Execution Cap", "details report"), tr("<nobr>%1%</nobr>", "details report"))
    416                                         .arg(iCPUExecCap);
    417 
    418             /* Boot order: */
    419             QStringList bootOrder;
    420             for (ulong i = 1; i <= m_vbox.GetSystemProperties().GetMaxBootPosition(); ++i)
     413            QString item;
     414            if (machine.GetAccessible())
    421415            {
    422                 KDeviceType device = machine.GetBootOrder(i);
    423                 if (device == KDeviceType_Null)
    424                     continue;
    425                 bootOrder << vboxGlobal().toString(device);
     416                item = sSectionItemTpl2.arg(tr("Base Memory", "details report"), tr("<nobr>%1 MB</nobr>", "details report"))
     417                                       .arg(machine.GetMemorySize());
     418
     419                int cCPU = machine.GetCPUCount();
     420                if (cCPU > 1)
     421                    item += sSectionItemTpl2.arg(tr("Processors", "details report"), tr("<nobr>%1</nobr>", "details report"))
     422                                            .arg(cCPU);
     423
     424                int iCPUExecCap = machine.GetCPUExecutionCap();
     425                if (iCPUExecCap < 100)
     426                    item += sSectionItemTpl2.arg(tr("Execution Cap", "details report"), tr("<nobr>%1%</nobr>", "details report"))
     427                                            .arg(iCPUExecCap);
     428
     429                /* Boot order: */
     430                QStringList bootOrder;
     431                for (ulong i = 1; i <= m_vbox.GetSystemProperties().GetMaxBootPosition(); ++i)
     432                {
     433                    KDeviceType device = machine.GetBootOrder(i);
     434                    if (device == KDeviceType_Null)
     435                        continue;
     436                    bootOrder << vboxGlobal().toString(device);
     437                }
     438                if (bootOrder.isEmpty())
     439                    bootOrder << vboxGlobal().toString(KDeviceType_Null);
     440
     441                item += sSectionItemTpl2.arg(tr("Boot Order", "details report"), bootOrder.join(", "));
     442
     443#ifdef VBOX_WITH_FULL_DETAILS_REPORT
     444                /* BIOS Settings holder: */
     445                const CBIOSSettings &biosSettings = machine.GetBIOSSettings();
     446                QStringList bios;
     447
     448                /* ACPI: */
     449                if (biosSettings.GetACPIEnabled())
     450                    bios << tr("ACPI", "details report");
     451
     452                /* IO APIC: */
     453                if (biosSettings.GetIOAPICEnabled())
     454                    bios << tr("IO APIC", "details report");
     455
     456                if (!bios.isEmpty())
     457                    item += sSectionItemTpl2.arg(tr("BIOS", "details report"), bios.join(", "));
     458#endif /* VBOX_WITH_FULL_DETAILS_REPORT */
     459
     460                QStringList accel;
     461                if (m_vbox.GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx))
     462                {
     463                    /* VT-x/AMD-V: */
     464                    if (machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled))
     465                    {
     466                        accel << tr("VT-x/AMD-V", "details report");
     467
     468                        /* Nested Paging (only when hw virt is enabled): */
     469                        if (machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging))
     470                            accel << tr("Nested Paging", "details report");
     471                    }
     472                }
     473
     474                /* PAE/NX: */
     475                if (machine.GetCPUProperty(KCPUPropertyType_PAE))
     476                    accel << tr("PAE/NX", "details report");
     477
     478                if (!accel.isEmpty())
     479                    item += sSectionItemTpl2.arg(tr("Acceleration", "details report"), accel.join(", "));
    426480            }
    427             if (bootOrder.isEmpty())
    428                 bootOrder << vboxGlobal().toString(KDeviceType_Null);
    429 
    430             item += sSectionItemTpl2.arg(tr("Boot Order", "details report"), bootOrder.join(", "));
    431 
    432 #ifdef VBOX_WITH_FULL_DETAILS_REPORT
    433             /* BIOS Settings holder: */
    434             const CBIOSSettings &biosSettings = machine.GetBIOSSettings();
    435             QStringList bios;
    436 
    437             /* ACPI: */
    438             if (biosSettings.GetACPIEnabled())
    439                 bios << tr("ACPI", "details report");
    440 
    441             /* IO APIC: */
    442             if (biosSettings.GetIOAPICEnabled())
    443                 bios << tr("IO APIC", "details report");
    444 
    445             if (!bios.isEmpty())
    446                 item += sSectionItemTpl2.arg(tr("BIOS", "details report"), bios.join(", "));
    447 #endif /* VBOX_WITH_FULL_DETAILS_REPORT */
    448 
    449             QStringList accel;
    450             if (m_vbox.GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx))
     481            else
    451482            {
    452                 /* VT-x/AMD-V: */
    453                 if (machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled))
    454                 {
    455                     accel << tr("VT-x/AMD-V", "details report");
    456 
    457                     /* Nested Paging (only when hw virt is enabled): */
    458                     if (machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging))
    459                         accel << tr("Nested Paging", "details report");
    460                 }
     483                item = QString(sSectionItemTpl1).arg(tr("Information inaccessible", "details report"));
    461484            }
    462 
    463             /* PAE/NX: */
    464             if (machine.GetCPUProperty(KCPUPropertyType_PAE))
    465                 accel << tr("PAE/NX", "details report");
    466 
    467             if (!accel.isEmpty())
    468                 item += sSectionItemTpl2.arg(tr("Acceleration", "details report"), accel.join(", "));
    469 
    470485            pLabel->setText(sTableTpl.arg(item));
    471486        }
     
    11501165    pPopup->setProperty("block-number", iBlockNumber);
    11511166    pPopup->setProperty("section-type", static_cast<int>(section));
     1167    if (!m_machines[iBlockNumber].GetAccessible())
     1168        pPopup->setWarningIcon(UIIconPool::iconSet(":/state_aborted_16px.png"));
    11521169
    11531170    /* Configure the popup box: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp

    r39225 r39261  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Local includes */
     20/* Global includes: */
     21#include <QContextMenuEvent>
     22#include <QMenu>
     23#include <QPainter>
     24#include <QTimer>
     25
     26/* Local includes: */
    2127#include "UIVMPreviewWindow.h"
    2228#include "UIVirtualBoxEventHandler.h"
     
    2430#include "VBoxGlobal.h"
    2531
    26 /* Global includes */
    27 #include <QContextMenuEvent>
    28 #include <QMenu>
    29 #include <QPainter>
    30 #include <QTimer>
    31 
     32/* Initialize map: */
     33UpdateIntervalMap UpdateIntervalMapConstructor()
     34{
     35    UpdateIntervalMap map;
     36    map[UpdateInterval_Disabled] = "disabled";
     37    map[UpdateInterval_500ms]    = "500";
     38    map[UpdateInterval_1000ms]   = "1000";
     39    map[UpdateInterval_2000ms]   = "2000";
     40    map[UpdateInterval_5000ms]   = "5000";
     41    map[UpdateInterval_10000ms]  = "10000";
     42    return map;
     43}
     44UpdateIntervalMap UIVMPreviewWindow::m_intervals = UpdateIntervalMapConstructor();
     45
     46/* Constructor: */
    3247UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent)
    3348  : QIWithRetranslateUI<QWidget>(pParent)
     
    3954  , m_pGlossyImg(0)
    4055{
    41     m_session.createInstance(CLSID_Session);
    42 
     56    /* Setup contents: */
    4357    setContentsMargins(0, 5, 0, 5);
    4458    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    45     /* Connect the update timer */
    46     connect(m_pUpdateTimer, SIGNAL(timeout()),
    47             this, SLOT(sltRecreatePreview()));
    48     /* Connect the machine state event */
    49     connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    50             this, SLOT(sltMachineStateChange(QString, KMachineState)));
    51     /* Create the context menu */
     59
     60    /* Create session instance: */
     61    m_session.createInstance(CLSID_Session);
     62
     63    /* Create the context menu: */
    5264    setContextMenuPolicy(Qt::DefaultContextMenu);
    5365    m_pUpdateTimerMenu = new QMenu(this);
    5466    QActionGroup *pUpdateTimeG = new QActionGroup(this);
    5567    pUpdateTimeG->setExclusive(true);
    56     for(int i = 0; i < UpdateEnd; ++i)
     68    for(int i = 0; i < UpdateInterval_Max; ++i)
    5769    {
    5870        QAction *pUpdateTime = new QAction(pUpdateTimeG);
     
    6375        m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime;
    6476    }
    65     m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(Update500ms)]);
    66     /* Default value */
    67     UpdateInterval interval = Update1000ms;
     77    m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(UpdateInterval_500ms)]);
     78
     79    /* Load preview update interval: */
    6880    QString strInterval = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_PreviewUpdate);
    69     if (strInterval == "disabled")
    70         interval = UpdateDisabled;
    71     else if (strInterval == "500")
    72         interval = Update500ms;
    73     else if (strInterval == "1000")
    74         interval = Update1000ms;
    75     else if (strInterval == "2000")
    76         interval = Update2000ms;
    77     else if (strInterval == "5000")
    78         interval = Update5000ms;
    79     else if (strInterval == "10000")
    80         interval = Update10000ms;
    81     /* Initialize with the new update interval */
     81    /* Parse loaded value: */
     82    UpdateInterval interval = m_intervals.key(strInterval, UpdateInterval_1000ms);
     83    /* Initialize with the new update interval: */
    8284    setUpdateInterval(interval, false);
     85
     86    /* Setup connections: */
     87    connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview()));
     88    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
     89            this, SLOT(sltMachineStateChange(QString, KMachineState)));
    8390
    8491    /* Retranslate the UI */
     
    8895UIVMPreviewWindow::~UIVMPreviewWindow()
    8996{
    90     /* Close any open session */
     97    /* Close any open session: */
    9198    if (m_session.GetState() == KSessionState_Locked)
    9299        m_session.UnlockMachine();
     
    101108void UIVMPreviewWindow::setMachine(const CMachine& machine)
    102109{
    103     m_pUpdateTimer->stop();
     110    stop();
    104111    m_machine = machine;
    105112    restart();
     
    118125void UIVMPreviewWindow::retranslateUi()
    119126{
    120     m_actions.value(UpdateDisabled)->setText(tr("Update Disabled"));
    121     m_actions.value(Update500ms)->setText(tr("Every 0.5 s"));
    122     m_actions.value(Update1000ms)->setText(tr("Every 1 s"));
    123     m_actions.value(Update2000ms)->setText(tr("Every 2 s"));
    124     m_actions.value(Update5000ms)->setText(tr("Every 5 s"));
    125     m_actions.value(Update10000ms)->setText(tr("Every 10 s"));
     127    m_actions.value(UpdateInterval_Disabled)->setText(tr("Update Disabled"));
     128    m_actions.value(UpdateInterval_500ms)->setText(tr("Every 0.5 s"));
     129    m_actions.value(UpdateInterval_1000ms)->setText(tr("Every 1 s"));
     130    m_actions.value(UpdateInterval_2000ms)->setText(tr("Every 2 s"));
     131    m_actions.value(UpdateInterval_5000ms)->setText(tr("Every 5 s"));
     132    m_actions.value(UpdateInterval_10000ms)->setText(tr("Every 10 s"));
    126133}
    127134
     
    135142void UIVMPreviewWindow::showEvent(QShowEvent *pEvent)
    136143{
    137     /* Make sure there is some valid preview image when shown. */
     144    /* Make sure there is some valid preview image when shown: */
    138145    restart();
    139146    QWidget::showEvent(pEvent);
     
    142149void UIVMPreviewWindow::hideEvent(QHideEvent *pEvent)
    143150{
    144     /* Stop the update time when we aren't visible */
    145     m_pUpdateTimer->stop();
     151    /* Stop the update time when we aren't visible: */
     152    stop();
    146153    QWidget::hideEvent(pEvent);
    147154}
     
    171178        /* Fill rectangle with black color: */
    172179        painter.fillRect(m_vRect, Qt::black);
    173     }
    174 
    175     /* Compose name: */
    176     QString strName = tr("No Preview");
    177     if (!m_machine.isNull())
    178         strName = m_machine.GetName();
    179     /* Paint that name: */
    180     QFont font = painter.font();
    181     font.setBold(true);
    182     int fFlags = Qt::AlignCenter | Qt::TextWordWrap;
    183     float h = m_vRect.size().height() * .2;
    184     QRect r;
    185     /* Make a little magic to find out if the given text fits into our rectangle.
    186      * Decrease the font pixel size as long as it doesn't fit. */
    187     int cMax = 30;
    188     do
    189     {
    190         h = h * .8;
    191         font.setPixelSize((int)h);
    192         painter.setFont(font);
    193         r = painter.boundingRect(m_vRect, fFlags, strName);
    194     }
    195     while ((r.height() > m_vRect.height() || r.width() > m_vRect.width()) && cMax-- != 0);
    196     painter.setPen(Qt::white);
    197     painter.drawText(m_vRect, fFlags, strName);
     180
     181        /* Compose name: */
     182        QString strName = tr("No Preview");
     183        if (!m_machine.isNull())
     184            strName = m_machine.GetAccessible() ? m_machine.GetName() :
     185                      QApplication::translate("UIVMListView", "Inaccessible");
     186        /* Paint that name: */
     187        QFont font = painter.font();
     188        font.setBold(true);
     189        int fFlags = Qt::AlignCenter | Qt::TextWordWrap;
     190        float h = m_vRect.size().height() * .2;
     191        QRect r;
     192        /* Make a little magic to find out if the given text fits into our rectangle.
     193         * Decrease the font pixel size as long as it doesn't fit. */
     194        int cMax = 30;
     195        do
     196        {
     197            h = h * .8;
     198            font.setPixelSize((int)h);
     199            painter.setFont(font);
     200            r = painter.boundingRect(m_vRect, fFlags, strName);
     201        }
     202        while ((r.height() > m_vRect.height() || r.width() > m_vRect.width()) && cMax-- != 0);
     203        painter.setPen(Qt::white);
     204        painter.drawText(m_vRect, fFlags, strName);
     205    }
    198206
    199207    /* Draw the glossy overlay last: */
     
    215223void UIVMPreviewWindow::sltMachineStateChange(QString strId, KMachineState state)
    216224{
    217     if (   !m_machine.isNull()
    218         && m_machine.GetId() == strId)
    219     {
    220         /* Cache the machine state */
     225    if (!m_machine.isNull() && m_machine.GetId() == strId)
     226    {
     227        /* Cache the machine state: */
    221228        m_machineState = state;
    222229        restart();
     
    226233void UIVMPreviewWindow::sltRecreatePreview()
    227234{
    228     /* Only do this if we are visible */
     235    /* Only do this if we are visible: */
    229236    if (!isVisible())
    230237        return;
    231238
     239    /* Remove preview if any: */
    232240    if (m_pPreviewImg)
    233241    {
     
    236244    }
    237245
    238     if (   !m_machine.isNull()
    239         && m_vRect.width() > 0
    240         && m_vRect.height() > 0)
    241     {
    242         Assert(m_machineState != KMachineState_Null);
     246    /* We are not creating preview for inaccessible VMs: */
     247    if (m_machineState == KMachineState_Null)
     248        return;
     249
     250    if (!m_machine.isNull() && m_vRect.width() > 0 && m_vRect.height() > 0)
     251    {
    243252        QImage image(size(), QImage::Format_ARGB32);
    244253        image.fill(Qt::transparent);
     
    322331    switch (interval)
    323332    {
    324         case UpdateDisabled:
    325         {
    326             if (fSave)
    327                 vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "disabled");
     333        case UpdateInterval_Disabled:
     334        {
    328335            m_pUpdateTimer->setInterval(0);
    329336            m_pUpdateTimer->stop();
     
    331338            break;
    332339        }
    333         case Update500ms:
    334         {
    335             if (fSave)
    336                 vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "500");
     340        case UpdateInterval_500ms:
     341        {
    337342            m_pUpdateTimer->setInterval(500);
    338343            m_actions[interval]->setChecked(true);
    339344            break;
    340345        }
    341         case Update1000ms:
    342         {
    343             if (fSave)
    344                 vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "1000");
     346        case UpdateInterval_1000ms:
     347        {
    345348            m_pUpdateTimer->setInterval(1000);
    346349            m_actions[interval]->setChecked(true);
    347350            break;
    348351        }
    349         case Update2000ms:
    350         {
    351             if (fSave)
    352                 vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "2000");
     352        case UpdateInterval_2000ms:
     353        {
    353354            m_pUpdateTimer->setInterval(2000);
    354355            m_actions[interval]->setChecked(true);
    355356            break;
    356357        }
    357         case Update5000ms:
    358         {
    359             if (fSave)
    360                 vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "5000");
     358        case UpdateInterval_5000ms:
     359        {
    361360            m_pUpdateTimer->setInterval(5000);
    362361            m_actions[interval]->setChecked(true);
    363362            break;
    364363        }
    365         case Update10000ms:
    366         {
    367             if (fSave)
    368                 vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "10000");
     364        case UpdateInterval_10000ms:
     365        {
    369366            m_pUpdateTimer->setInterval(10000);
    370367            m_actions[interval]->setChecked(true);
    371368            break;
    372369        }
    373         case UpdateEnd: break;
    374     }
     370        case UpdateInterval_Max: break;
     371    }
     372    if (fSave && m_intervals.contains(interval))
     373        vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, m_intervals[interval]);
    375374}
    376375
    377376void UIVMPreviewWindow::restart()
    378377{
    379     /* Close any open session */
     378    /* Reopen session if necessary: */
    380379    if (m_session.GetState() == KSessionState_Locked)
    381380        m_session.UnlockMachine();
    382381    if (!m_machine.isNull())
    383382    {
    384         /* Fetch the latest machine state */
     383        /* Fetch the latest machine state: */
    385384        m_machineState = m_machine.GetState();
    386         /* Lock the session for the current machine */
    387         if (   m_machineState == KMachineState_Running
    388 //            || m_machineState == KMachineState_Saving /* Not sure if this is valid */
     385        /* Lock the session for the current machine: */
     386        if (m_machineState == KMachineState_Running
     387//          || m_machineState == KMachineState_Saving /* Not sure if this is valid */
    389388            || m_machineState == KMachineState_Paused)
    390389            m_machine.LockMachine(m_session, KLockType_Shared);
    391390    }
    392391
    393     /* Recreate the preview image */
     392    /* Recreate the preview image: */
    394393    sltRecreatePreview();
    395     /* Start the timer */
     394
     395    /* Start the timer if necessary: */
    396396    if (!m_machine.isNull())
    397397    {
    398         if (   m_pUpdateTimer->interval() > 0
    399             && m_machineState == KMachineState_Running)
     398        if (m_pUpdateTimer->interval() > 0 && m_machineState == KMachineState_Running)
    400399            m_pUpdateTimer->start();
    401400    }
    402401}
    403402
     403void UIVMPreviewWindow::stop()
     404{
     405    /* Stop the timer: */
     406    m_pUpdateTimer->stop();
     407}
     408
    404409void UIVMPreviewWindow::repaintBGImages()
    405410{
    406     /* Delete the old images */
     411    /* Delete the old images: */
    407412    if (m_pbgImage)
    408413    {
     
    416421    }
    417422
    418     /* Check that there is enough room for our fancy stuff. If not we just
    419      * draw nothing (the border and the blur radius). */
     423    /* Check that there is enough room for our fancy stuff.
     424     * If not we just draw nothing (the border and the blur radius). */
    420425    QRect cr = contentsRect();
    421     if (   cr.width()  < 41
    422         || cr.height() < 41)
     426    if (cr.width()  < 41 || cr.height() < 41)
    423427        return;
    424428
     
    427431    m_vRect = m_wRect.adjusted(m_vMargin, m_vMargin, -m_vMargin, -m_vMargin).adjusted(-3, -3, 3, 3);
    428432
    429     /* First draw the shadow. Its a rounded rectangle which get blurred. */
     433    /* First draw the shadow. Its a rounded rectangle which get blurred: */
    430434    QImage imageW(cr.size(), QImage::Format_ARGB32);
    431435    QColor bg = pal.color(QPalette::Base);
     
    442446    QPainter pO(&imageO);
    443447
    444 #if 1
    445     /* Now paint the border with a gradient to get a look of a monitor. */
     448    /* Now paint the border with a gradient to get a look of a monitor: */
    446449    QRect rr = QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10);
    447450    QLinearGradient lg(0, rr.y(), 0, rr.height());
    448451    QColor base(200, 200, 200); /* light variant */
    449     //        QColor base(80, 80, 80); /* Dark variant */
     452    // QColor base(80, 80, 80); /* Dark variant */
    450453    lg.setColorAt(0, base);
    451454    lg.setColorAt(0.4, base.darker(300));
     
    457460    pO.drawRoundedRect(rr, m_vMargin, m_vMargin);
    458461    pO.end();
    459 #endif
    460     /* Make a copy of the new bg image */
     462
     463    /* Make a copy of the new bg image: */
    461464    m_pbgImage = new QImage(imageO);
    462465
    463     /* Now the glossy overlay has to be created. Start with defining a nice
    464      * looking painter path. */
     466    /* Now the glossy overlay has to be created.
     467     * Start with defining a nice looking painter path. */
    465468    QRect gRect = QRect(QPoint(0, 0), m_vRect.size());
    466469    QPainterPath glossyPath(QPointF(gRect.x(), gRect.y()));
     
    472475    glossyPath.closeSubpath();
    473476
    474     /* Paint the glossy path on a QImage */
     477    /* Paint the glossy path on a QImage: */
    475478    QImage image(m_vRect.size(), QImage::Format_ARGB32);
    476479    QColor bg1(Qt::white); /* We want blur to transparent _and_ white. */
     
    485488    m_pGlossyImg = new QImage(image1);
    486489
    487     /* Repaint */
     490    /* Repaint: */
    488491    update();
    489492}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h

    r31056 r39261  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#include "COMDefs.h"
    2525
    26 /* Global includes */
     26/* Global includes: */
    2727#include <QWidget>
    2828#include <QHash>
    2929
    30 /* Global forward declarations */
     30/* Forward declarations: */
    3131class QAction;
    3232class QImage;
     
    3434class QTimer;
    3535
     36/* Update interval type: */
     37enum UpdateInterval
     38{
     39    UpdateInterval_Disabled,
     40    UpdateInterval_500ms,
     41    UpdateInterval_1000ms,
     42    UpdateInterval_2000ms,
     43    UpdateInterval_5000ms,
     44    UpdateInterval_10000ms,
     45    UpdateInterval_Max
     46};
     47typedef QMap<UpdateInterval, QString> UpdateIntervalMap;
     48
     49/* Preview window class: */
    3650class UIVMPreviewWindow : public QIWithRetranslateUI<QWidget>
    3751{
    3852    Q_OBJECT;
    39 
    40     enum UpdateInterval
    41     {
    42         UpdateDisabled,
    43         Update500ms,
    44         Update1000ms,
    45         Update2000ms,
    46         Update5000ms,
    47         Update10000ms,
    48         UpdateEnd
    49     };
    5053
    5154public:
     
    7780
    7881    void setUpdateInterval(UpdateInterval interval, bool fSave);
    79     void restart();
    8082    void repaintBGImages();
    8183
    82     /* Private member vars */
     84    void restart();
     85    void stop();
     86
     87    /* Variables: */
    8388    CSession m_session;
    8489    CMachine m_machine;
     
    9398    QImage *m_pPreviewImg;
    9499    QImage *m_pGlossyImg;
     100
     101    static UpdateIntervalMap m_intervals;
    95102};
    96103
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp

    r39225 r39261  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040  , m_fHeaderHover(false)
    4141{
     42    /* Placing content: */
    4243    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    4344    pMainLayout->setContentsMargins(10, 5, 5, 5);
    4445    QHBoxLayout *pTitleLayout = new QHBoxLayout();
    4546    m_pTitleIcon = new QLabel(this);
     47    m_pWarningIcon = new QLabel(this);
    4648    m_pTitleLabel = new QLabel(this);
    47     connect(m_pTitleLabel, SIGNAL(linkActivated(const QString)),
    48             this, SIGNAL(titleClicked(const QString)));
    4949    pTitleLayout->addWidget(m_pTitleIcon);
     50    pTitleLayout->addWidget(m_pWarningIcon);
    5051    pTitleLayout->addWidget(m_pTitleLabel, Qt::AlignLeft);
    5152    pMainLayout->addLayout(pTitleLayout);
    5253
     54    /* Configure widgets: */
     55    m_pWarningIcon->setHidden(true);
    5356    m_arrowPath.lineTo(m_aw / 2.0, m_aw / 2.0);
    5457    m_arrowPath.lineTo(m_aw, 0);
    5558
    56 //    setMouseTracking(true);
     59    /* Setup connections: */
     60    connect(m_pTitleLabel, SIGNAL(linkActivated(const QString)), this, SIGNAL(titleClicked(const QString)));
     61
     62    /* Install event-filter: */
    5763    qApp->installEventFilter(this);
    5864}
     
    7884void UIPopupBox::setTitleIcon(const QIcon& icon)
    7985{
    80     m_icon = icon;
     86    m_titleIcon = icon;
    8187    updateHover(true);
    8288    recalc();
     
    8591QIcon UIPopupBox::titleIcon() const
    8692{
    87     return m_icon;
     93    return m_titleIcon;
     94}
     95
     96void UIPopupBox::setWarningIcon(const QIcon& icon)
     97{
     98    m_warningIcon = icon;
     99    m_pWarningIcon->setHidden(m_warningIcon.isNull());
     100    updateHover(true);
     101    recalc();
     102}
     103
     104QIcon UIPopupBox::warningIcon() const
     105{
     106    return m_warningIcon;
    88107}
    89108
     
    277296                               .arg(m_strTitle));
    278297
    279         QPixmap i = m_icon.pixmap(16, 16);
     298        QPixmap titleIcon = m_titleIcon.pixmap(16, 16);
     299        QPixmap warningIcon = m_warningIcon.pixmap(16, 16);
    280300#ifdef Q_WS_MAC
    281         /* todo: fix this */
     301        /* TODO: Fix this! */
    282302//        if (!m_fHeaderHover)
    283 //            i = QPixmap::fromImage(toGray(i.toImage()));
     303//            titleIcon = QPixmap::fromImage(toGray(titleIcon.toImage()));
     304//        if (!m_fHeaderHover)
     305//            warningIcon = QPixmap::fromImage(toGray(warningIcon.toImage()));
    284306#endif /* Q_WS_MAC */
    285         m_pTitleIcon->setPixmap(i);
     307        m_pTitleIcon->setPixmap(titleIcon);
     308        m_pWarningIcon->setPixmap(warningIcon);
    286309        update();
    287310    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h

    r39225 r39261  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4141    void setTitleIcon(const QIcon& icon);
    4242    QIcon titleIcon() const;
     43
     44    void setWarningIcon(const QIcon& icon);
     45    QIcon warningIcon() const;
    4346
    4447    void setTitleLink(const QString& strLink);
     
    8487    QString m_strTitle;
    8588    QLabel *m_pTitleIcon;
    86     QIcon m_icon;
     89    QLabel *m_pWarningIcon;
     90    QIcon m_titleIcon;
     91    QIcon m_warningIcon;
    8792    QString m_strLink;
    8893    bool m_fLinkEnabled;
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