Changeset 85406 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 22, 2020 8:29:51 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r82968 r85406 2253 2253 2254 2254 2255 2255 /** Simple action extension, used as 'Export' action class. */ 2256 class UIActionMenuPerformanceMonitorExport : public UIActionSimple 2257 { 2258 Q_OBJECT; 2259 2260 public: 2261 2262 /** Constructs action passing @a pParent to the base-class. */ 2263 UIActionMenuPerformanceMonitorExport(UIActionPool *pParent) 2264 : UIActionSimple(pParent, 2265 ":/log_viewer_save_32px.png", ":/log_viewer_save_16px.png", 2266 ":/log_viewer_save_disabled_32px.png", ":/log_viewer_save_disabled_16px.png") 2267 { 2268 setShortcutContext(Qt::WidgetWithChildrenShortcut); 2269 } 2270 2271 protected: 2272 2273 /** Returns shortcut extra-data ID. */ 2274 virtual QString shortcutExtraDataID() const /* override */ 2275 { 2276 return QString("ExportCharts"); 2277 } 2278 2279 /** Returns default shortcut. */ 2280 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */ 2281 { 2282 return QKeySequence(); 2283 } 2284 2285 /** Handles translation event. */ 2286 virtual void retranslateUi() /* override */ 2287 { 2288 setName(QApplication::translate("UIActionPool", "Export...")); 2289 setShortcutScope(QApplication::translate("UIActionPool", "Performance Monitor")); 2290 setStatusTip(QApplication::translate("UIActionPool", "Export the chart data into a text file")); 2291 setToolTip( QApplication::translate("UIActionPool", "Export the chart data into a text file") 2292 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 2293 } 2294 }; 2256 2295 2257 2296 … … 2504 2543 m_pool[UIActionIndex_M_FileManager_S_Guest_ShowProperties] = new UIActionMenuFileManagerShowProperties(this); 2505 2544 2545 /* Create 'Performance Monitor' actions: */ 2546 m_pool[UIActionIndex_M_PerformanceMonitor_S_Export] = new UIActionMenuPerformanceMonitorExport(this); 2547 2506 2548 2507 2549 /* Prepare update-handlers for known menus: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r82968 r85406 136 136 UIActionIndex_M_FileManager_S_Guest_ShowProperties, 137 137 138 /* Machine performance monitor actions. */ 139 UIActionIndex_M_PerformanceMonitor_S_Export, 138 140 139 141 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.cpp
r85398 r85406 193 193 case UIToolType_Performance: 194 194 { 195 m_pPanePerformanceMonitor = new UIPerformanceMonitor( 0, m_comMachine);195 m_pPanePerformanceMonitor = new UIPerformanceMonitor(EmbedTo_Stack, 0, m_comMachine, false /* Show toolbar */); 196 196 AssertPtrReturnVoid(m_pPanePerformanceMonitor); 197 197 #ifndef VBOX_WS_MAC … … 298 298 if (isToolOpened(UIToolType_Performance)) 299 299 { 300 // AssertPtrReturnVoid(m_pPanePerformanceMonitor); 301 // // CSession comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared); 302 // // AssertReturnVoid(!comSession.isNull()); 303 // // CConsole comConsole = comSession.GetConsole(); 304 // AssertReturnVoid(!comConsole.isNull()); 305 306 //m_pPaneLogViewer->setMachine(m_comMachine); 300 AssertPtrReturnVoid(m_pPanePerformanceMonitor); 301 m_pPanePerformanceMonitor->setMachine(m_comMachine); 307 302 } 308 303 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r85398 r85406 830 830 case UIToolType_Performance: 831 831 { 832 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_PerformanceMonitor_S_Export)); 832 833 break; 833 834 } -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.cpp
r85396 r85406 30 30 #include "UICommon.h" 31 31 #include "UIPerformanceMonitor.h" 32 #include "UIToolBar.h" 33 #include "UIVirtualBoxEventHandler.h" 32 34 33 35 /* COM includes: */ … … 539 541 } 540 542 541 542 543 void UIChart::sltCreateContextMenu(const QPoint &point) 543 544 { … … 699 700 *********************************************************************************************************************************/ 700 701 701 UIPerformanceMonitor::UIPerformanceMonitor(QWidget *pParent, const CMachine &machine) 702 UIPerformanceMonitor::UIPerformanceMonitor(EmbedTo enmEmbedding, QWidget *pParent, 703 const CMachine &machine, bool fShowToolbar /* = false */) 702 704 : QIWithRetranslateUI<QWidget>(pParent) 703 705 , m_fGuestAdditionsAvailable(false) 704 706 , m_pMainLayout(0) 705 707 , m_pTimer(0) 708 , m_pToolBar(0) 706 709 , m_strCPUMetricName("CPU Load") 707 710 , m_strRAMMetricName("RAM Usage") … … 711 714 , m_strVMExitMetricName("VMExits") 712 715 , m_iTimeStep(0) 713 { 714 setMachine(machine); 715 m_fGuestAdditionsAvailable = guestAdditionsAvailable(6 /* minimum major version */); 716 716 , m_enmEmbedding(enmEmbedding) 717 , m_fShowToolbar(fShowToolbar) 718 { 717 719 prepareMetrics(); 718 720 prepareObjects(); 719 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); 721 if (fShowToolbar) 722 prepareToolBar(); 720 723 retranslateUi(); 724 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, this, &UIPerformanceMonitor::sltMachineStateChange); 725 setMachine(machine); 721 726 } 722 727 … … 727 732 void UIPerformanceMonitor::setMachine(const CMachine &comMachine) 728 733 { 734 reset(); 729 735 if (comMachine.isNull()) 730 736 return; … … 734 740 735 741 m_comMachine = comMachine; 742 743 if (m_comMachine.GetState() == KMachineState_Running) 744 { 745 openSession(); 746 start(); 747 } 748 } 749 750 void UIPerformanceMonitor::openSession() 751 { 736 752 m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared); 737 753 AssertReturnVoid(!m_comSession.isNull()); … … 806 822 } 807 823 } 808 sltTimeout();809 824 } 810 825 … … 818 833 m_pTimer = new QTimer(this); 819 834 if (m_pTimer) 820 {821 835 connect(m_pTimer, &QTimer::timeout, this, &UIPerformanceMonitor::sltTimeout); 822 m_pTimer->start(1000 * g_iPeriod);823 }824 836 825 837 QScrollArea *pScrollArea = new QScrollArea(this); … … 920 932 UIMonitorCommon::getVMMExitCount(m_comMachineDebugger, cTotalVMExits); 921 933 updateVMExitMetric(cTotalVMExits); 934 } 935 } 936 937 void UIPerformanceMonitor::sltMachineStateChange(const QUuid &uId) 938 { 939 if (m_comMachine.isNull()) 940 return; 941 if (m_comMachine.GetId() != uId) 942 return; 943 reset(); 944 if (m_comMachine.GetState() == KMachineState_Running) 945 { 946 openSession(); 947 start(); 922 948 } 923 949 } … … 978 1004 } 979 1005 1006 void UIPerformanceMonitor::prepareToolBar() 1007 { 1008 /* Create toolbar: */ 1009 m_pToolBar = new UIToolBar(parentWidget()); 1010 AssertPtrReturnVoid(m_pToolBar); 1011 { 1012 /* Configure toolbar: */ 1013 const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize)); 1014 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 1015 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 1016 1017 #ifdef VBOX_WS_MAC 1018 /* Check whether we are embedded into a stack: */ 1019 if (m_enmEmbedding == EmbedTo_Stack) 1020 { 1021 /* Add into layout: */ 1022 layout()->addWidget(m_pToolBar); 1023 } 1024 #else 1025 /* Add into layout: */ 1026 layout()->addWidget(m_pToolBar); 1027 #endif 1028 } 1029 } 1030 980 1031 bool UIPerformanceMonitor::guestAdditionsAvailable(int iMinimumMajorVersion) 981 1032 { … … 1191 1242 } 1192 1243 1244 void UIPerformanceMonitor::reset() 1245 { 1246 m_fGuestAdditionsAvailable = false; 1247 if (m_pTimer) 1248 m_pTimer->stop(); 1249 for (QMap<QString, UIMetric>::iterator iterator = m_metrics.begin(); 1250 iterator != m_metrics.end(); ++iterator) 1251 iterator.value().reset(); 1252 for (QMap<QString, UIChart*>::iterator iterator = m_charts.begin(); 1253 iterator != m_charts.end(); ++iterator) 1254 iterator.value()->update(); 1255 } 1256 1257 void UIPerformanceMonitor::start() 1258 { 1259 if (m_comMachine.isNull() || m_comMachine.GetState() != KMachineState_Running) 1260 return; 1261 1262 m_fGuestAdditionsAvailable = guestAdditionsAvailable(6 /* minimum major version */); 1263 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); 1264 if (m_pTimer) 1265 m_pTimer->start(1000 * g_iPeriod); 1266 } 1267 1268 1193 1269 #include "UIPerformanceMonitor.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.h
r85396 r85406 36 36 37 37 /* GUI includes: */ 38 #include "QIManagerDialog.h" 38 39 #include "QIWithRetranslateUI.h" 39 40 #include "UIMonitorCommon.h" … … 46 47 class UISession; 47 48 class UIRuntimeInfoWidget; 49 class UIToolBar; 48 50 49 51 #define DATA_SERIES_SIZE 2 … … 110 112 /** Constructs information-tab passing @a pParent to the QWidget base-class constructor. 111 113 * @param machine is machine reference. */ 112 UIPerformanceMonitor( QWidget *pParent, const CMachine &machine);114 UIPerformanceMonitor(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine, bool fShowToolbar = false); 113 115 ~UIPerformanceMonitor(); 114 116 void setMachine(const CMachine &machine); 115 117 118 #ifdef VBOX_WS_MAC 119 UIToolBar *toolbar() const { return m_pToolBar; } 120 #endif 121 116 122 public slots: 117 123 … … 129 135 /** Reads the metric values for several sources and calls corresponding update functions. */ 130 136 void sltTimeout(); 137 /** Stop updating the charts if/when the machine state changes something other than KMachineState_Running. */ 138 void sltMachineStateChange(const QUuid &uId); 131 139 132 140 private: … … 134 142 void prepareObjects(); 135 143 void prepareMetrics(); 144 void prepareToolBar(); 136 145 bool guestAdditionsAvailable(int iMinimumMajorVersion); 137 146 void enableDisableGuestAdditionDependedWidgets(bool fEnable); … … 148 157 /** Returns a QColor for the chart with @p strChartName and data series with @p iDataIndex. */ 149 158 QString dataColorString(const QString &strChartName, int iDataIndex); 159 /* Starts the timer which in return collects data and updates charts/graphs. */ 160 void start(); 161 void reset(); 162 void openSession(); 150 163 151 164 bool m_fGuestAdditionsAvailable; … … 158 171 /** Holds the instance of layout we create. */ 159 172 QVBoxLayout *m_pMainLayout; 160 QTimer *m_pTimer; 173 QTimer *m_pTimer; 174 UIToolBar *m_pToolBar; 161 175 162 176 /** @name The following are used during UIPerformanceCollector::QueryMetricsData(..) … … 210 224 /** @} */ 211 225 quint64 m_iTimeStep; 226 EmbedTo m_enmEmbedding; 227 bool m_fShowToolbar; 212 228 }; 213 229 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp
r85396 r85406 200 200 /* Create Performance Monitor tab: */ 201 201 UIPerformanceMonitor *pPerformanceMonitorWidget = 202 new UIPerformanceMonitor( this, m_pMachineWindow->machine());202 new UIPerformanceMonitor(EmbedTo_Dialog, this, m_pMachineWindow->machine()); 203 203 if (pPerformanceMonitorWidget) 204 204 {
Note:
See TracChangeset
for help on using the changeset viewer.