VirtualBox

Changeset 88131 in vbox


Ignore:
Timestamp:
Mar 16, 2021 9:46:13 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9510. Marking non-running vms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp

    r88123 r88131  
    223223    bool operator==(const UIActivityOverviewItem& other) const;
    224224    bool isWithGuestAdditions();
     225    void resetDebugger();
    225226
    226227    QUuid         m_VMuid;
     
    312313    /* Return the state of the machine represented by the item at @rowIndex. */
    313314    KMachineState machineState(int rowIndex) const;
     315    void setDefaultViewFont(const QFont &font);
     316    void setDefaultViewFontColor(const QColor &color);
    314317
    315318private slots:
     
    342345    bool m_fShouldUpdate;
    343346    UIVMActivityOverviewHostStats m_hostStats;
     347    QFont m_defaultViewFont;
     348    QColor m_defaultViewFontColor;
    344349    /** Maximum length of string length of data displayed in column. Updated in UIActivityOverviewModel::data(..). */
    345350    mutable QMap<int, int> m_columnDataMaxLength;
     
    777782    , m_uVMExitTotal(0)
    778783{
    779     m_comSession = uiCommon().openSession(uid, KLockType_Shared);
    780     if (!m_comSession.isNull())
    781     {
    782         CConsole comConsole = m_comSession.GetConsole();
    783         if (!comConsole.isNull())
    784         {
    785             m_comGuest = comConsole.GetGuest();
    786             m_comDebugger = comConsole.GetDebugger();
    787         }
    788     }
     784    resetDebugger();
    789785}
    790786
     
    809805}
    810806
    811 // UIActivityOverviewItem::UIActivityOverviewItem(const QUuid &uid)
    812 //     : m_VMuid(uid)
    813 //     , m_uCPUGuestLoad(0)
    814 //     , m_uCPUVMMLoad(0)
    815 //     , m_uTotalRAM(0)
    816 //     , m_uUsedRAM(0)
    817 //     , m_fRAMUsagePercentage(0)
    818 //     , m_uNetworkDownRate(0)
    819 //     , m_uNetworkUpRate(0)
    820 //     , m_uNetworkDownTotal(0)
    821 //     , m_uNetworkUpTotal(0)
    822 //     , m_uDiskWriteRate(0)
    823 //     , m_uDiskReadRate(0)
    824 //     , m_uDiskWriteTotal(0)
    825 //     , m_uDiskReadTotal(0)
    826 //     , m_uVMExitRate(0)
    827 //     , m_uVMExitTotal(0)
    828 // {
    829 // }
     807void UIActivityOverviewItem::resetDebugger()
     808{
     809    m_comSession = uiCommon().openSession(m_VMuid, KLockType_Shared);
     810    if (!m_comSession.isNull())
     811    {
     812        CConsole comConsole = m_comSession.GetConsole();
     813        if (!comConsole.isNull())
     814        {
     815            m_comGuest = comConsole.GetGuest();
     816            m_comDebugger = comConsole.GetDebugger();
     817        }
     818    }
     819}
    830820
    831821UIActivityOverviewItem::~UIActivityOverviewItem()
     
    981971}
    982972
     973void UIActivityOverviewModel::setDefaultViewFont(const QFont &font)
     974{
     975    m_defaultViewFont = font;
     976}
     977
     978void UIActivityOverviewModel::setDefaultViewFontColor(const QColor &color)
     979{
     980    m_defaultViewFontColor = color;
     981}
     982
    983983QVariant UIActivityOverviewModel::data(const QModelIndex &index, int role) const
    984984{
    985     if (role == Qt::FontRole && machineState(index.row()) != KMachineState_Running)
    986     {
    987         QFont font;
    988         font.setItalic(true);
    989         return font;
    990 
     985    if (machineState(index.row()) != KMachineState_Running)
     986    {
     987        if (role == Qt::FontRole)
     988        {
     989            QFont font(m_defaultViewFont);
     990            font.setItalic(true);
     991            return font;
     992        }
     993        if (role == Qt::ForegroundRole || role == Qt::TextColorRole)
     994            return m_defaultViewFontColor.lighter(250);
    991995    }
    992996    if (!index.isValid() || role != Qt::DisplayRole || index.row() >= rowCount())
     
    10251029    int iIndex = itemIndex(uId);
    10261030    if (iIndex != -1 && iIndex < m_itemList.size())
     1031    {
    10271032        m_itemList[iIndex].m_enmMachineState = state;
     1033        if (state == KMachineState_Running)
     1034            m_itemList[iIndex].resetDebugger();
     1035    }
    10281036    //
    10291037    // /* Remove the machine in case machine is no longer working. */
     
    14591467        m_pTableView->setSortingEnabled(true);
    14601468        m_pTableView->sortByColumn(0, Qt::AscendingOrder);
     1469        /* Store the default font and its color of the table on the view. They are used in ::data(..): */
     1470        m_pModel->setDefaultViewFont(m_pTableView->font());
     1471        m_pModel->setDefaultViewFontColor(m_pTableView->palette().color(QPalette::WindowText));
     1472
    14611473        connect(m_pModel, &UIActivityOverviewModel::sigDataUpdate,
    14621474                this, &UIVMActivityOverviewWidget::sltHandleDataUpdate);
     
    15791591void UIVMActivityOverviewWidget::sltHandleTableContextMenuRequest(const QPoint &pos)
    15801592{
    1581     if (!m_pTableView || !m_pTableView->hasSelection())
     1593    if (!m_pTableView)
    15821594        return;
    15831595
     
    15921604{
    15931605    Q_UNUSED(deselected);
    1594     if (m_pVMActivityMonitorAction)
    1595         m_pVMActivityMonitorAction->setEnabled(!selected.isEmpty());
     1606    if (!m_pVMActivityMonitorAction || !m_pModel || !m_pProxyModel)
     1607        return;
     1608
     1609    if (selected.indexes().empty())
     1610    {
     1611        m_pVMActivityMonitorAction->setEnabled(false);
     1612        return;
     1613    }
     1614    int iMachineIndex = m_pProxyModel->mapToSource(selected.indexes()[0]).row();
     1615    if (m_pModel->machineState(iMachineIndex) != KMachineState_Running)
     1616    {
     1617        m_pVMActivityMonitorAction->setEnabled(false);
     1618        return;
     1619    }
     1620    m_pVMActivityMonitorAction->setEnabled(true);
    15961621}
    15971622
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