Changeset 88131 in vbox
- Timestamp:
- Mar 16, 2021 9:46:13 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp
r88123 r88131 223 223 bool operator==(const UIActivityOverviewItem& other) const; 224 224 bool isWithGuestAdditions(); 225 void resetDebugger(); 225 226 226 227 QUuid m_VMuid; … … 312 313 /* Return the state of the machine represented by the item at @rowIndex. */ 313 314 KMachineState machineState(int rowIndex) const; 315 void setDefaultViewFont(const QFont &font); 316 void setDefaultViewFontColor(const QColor &color); 314 317 315 318 private slots: … … 342 345 bool m_fShouldUpdate; 343 346 UIVMActivityOverviewHostStats m_hostStats; 347 QFont m_defaultViewFont; 348 QColor m_defaultViewFontColor; 344 349 /** Maximum length of string length of data displayed in column. Updated in UIActivityOverviewModel::data(..). */ 345 350 mutable QMap<int, int> m_columnDataMaxLength; … … 777 782 , m_uVMExitTotal(0) 778 783 { 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(); 789 785 } 790 786 … … 809 805 } 810 806 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 // } 807 void 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 } 830 820 831 821 UIActivityOverviewItem::~UIActivityOverviewItem() … … 981 971 } 982 972 973 void UIActivityOverviewModel::setDefaultViewFont(const QFont &font) 974 { 975 m_defaultViewFont = font; 976 } 977 978 void UIActivityOverviewModel::setDefaultViewFontColor(const QColor &color) 979 { 980 m_defaultViewFontColor = color; 981 } 982 983 983 QVariant UIActivityOverviewModel::data(const QModelIndex &index, int role) const 984 984 { 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); 991 995 } 992 996 if (!index.isValid() || role != Qt::DisplayRole || index.row() >= rowCount()) … … 1025 1029 int iIndex = itemIndex(uId); 1026 1030 if (iIndex != -1 && iIndex < m_itemList.size()) 1031 { 1027 1032 m_itemList[iIndex].m_enmMachineState = state; 1033 if (state == KMachineState_Running) 1034 m_itemList[iIndex].resetDebugger(); 1035 } 1028 1036 // 1029 1037 // /* Remove the machine in case machine is no longer working. */ … … 1459 1467 m_pTableView->setSortingEnabled(true); 1460 1468 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 1461 1473 connect(m_pModel, &UIActivityOverviewModel::sigDataUpdate, 1462 1474 this, &UIVMActivityOverviewWidget::sltHandleDataUpdate); … … 1579 1591 void UIVMActivityOverviewWidget::sltHandleTableContextMenuRequest(const QPoint &pos) 1580 1592 { 1581 if (!m_pTableView || !m_pTableView->hasSelection())1593 if (!m_pTableView) 1582 1594 return; 1583 1595 … … 1592 1604 { 1593 1605 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); 1596 1621 } 1597 1622
Note:
See TracChangeset
for help on using the changeset viewer.