Changeset 104449 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 28, 2024 8:59:22 AM (10 months ago)
- svn:sync-xref-src-repo-rev:
- 162958
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/activity
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityToolWidget.cpp
r104445 r104449 63 63 , m_pTabWidget(0) 64 64 { 65 m_dataSeriesColor[0] = QApplication::palette().color(QPalette::LinkVisited); 66 m_dataSeriesColor[1] = QApplication::palette().color(QPalette::Link); 65 67 prepare(); 66 68 prepareActions(); … … 96 98 97 99 m_pPaneContainer = new UIVMActivityMonitorPaneContainer(this, m_enmEmbedding); 100 for (int i = 0; i < 2; ++i) 101 m_pPaneContainer->setDataSeriesColor(i, m_dataSeriesColor[i]); 98 102 m_pPaneContainer->hide(); 99 103 pMainLayout->addWidget(m_pPaneContainer); 100 104 connect(m_pTabWidget, &QTabWidget::currentChanged, 101 105 this, &UIVMActivityToolWidget::sltCurrentTabChanged); 106 connect(m_pPaneContainer, &UIVMActivityMonitorPaneContainer::sigColorChanged, 107 this, &UIVMActivityToolWidget::sltDataSeriesColorChanged); 102 108 } 103 109 … … 209 215 { 210 216 CMachine comMachine = pMachine->toLocal()->machine(); 211 m_pTabWidget->addTab(new UIVMActivityMonitorLocal(m_enmEmbedding, this, comMachine), comMachine.GetName()); 217 UIVMActivityMonitorLocal *pActivityMonitor = new UIVMActivityMonitorLocal(m_enmEmbedding, this, comMachine); 218 pActivityMonitor->setDataSeriesColor(0, m_dataSeriesColor[0]); 219 pActivityMonitor->setDataSeriesColor(1, m_dataSeriesColor[1]); 220 m_pTabWidget->addTab(pActivityMonitor, comMachine.GetName()); 212 221 continue; 213 222 } … … 217 226 if (!comMachine.isOk()) 218 227 continue; 219 m_pTabWidget->addTab(new UIVMActivityMonitorCloud(m_enmEmbedding, this, comMachine), comMachine.GetName()); 228 UIVMActivityMonitorCloud *pActivityMonitor = new UIVMActivityMonitorCloud(m_enmEmbedding, this, comMachine); 229 pActivityMonitor->setDataSeriesColor(0, m_dataSeriesColor[0]); 230 pActivityMonitor->setDataSeriesColor(1, m_dataSeriesColor[1]); 231 m_pTabWidget->addTab(pActivityMonitor, comMachine.GetName()); 220 232 continue; 221 233 } … … 252 264 } 253 265 266 void UIVMActivityToolWidget::sltDataSeriesColorChanged(int iIndex, const QColor &color) 267 { 268 for (int i = m_pTabWidget->count() - 1; i >= 0; --i) 269 { 270 UIVMActivityMonitor *pMonitor = qobject_cast<UIVMActivityMonitor*>(m_pTabWidget->widget(i)); 271 if (!pMonitor) 272 continue; 273 pMonitor->setDataSeriesColor(iIndex, color); 274 if (iIndex >= 0 && iIndex < 2) 275 m_dataSeriesColor[iIndex] = color; 276 } 277 } 278 254 279 void UIVMActivityToolWidget::setExportActionEnabled(bool fEnabled) 255 280 { -
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityToolWidget.h
r104445 r104449 33 33 34 34 /* Qt includes: */ 35 #include <QColor> 35 36 #include <QWidget> 36 37 #include <QUuid> … … 77 78 void sltCurrentTabChanged(int iIndex); 78 79 void sltTogglePreferencesPane(bool fChecked); 80 void sltDataSeriesColorChanged(int iIndex, const QColor &color); 79 81 80 82 private: … … 111 113 UIVMActivityMonitorPaneContainer *m_pPaneContainer; 112 114 QTabWidget *m_pTabWidget; 115 QColor m_dataSeriesColor[2]; 113 116 }; 114 117 -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r104445 r104449 130 130 void sltSetShowPieChart(bool fShowPieChart); 131 131 void sltSetUseAreaChart(bool fUseAreaChart); 132 void sltSelectDataSeriesColor();133 132 void sltRetranslateUI(); 134 133 … … 227 226 connect(this, &UIChart::customContextMenuRequested, 228 227 this, &UIChart::sltCreateContextMenu); 229 230 setDataSeriesColor(0, QApplication::palette().color(QPalette::LinkVisited));231 setDataSeriesColor(1, QApplication::palette().color(QPalette::Link));232 228 233 229 m_iMarginLeft = 3 * QFontMetricsF(m_axisFont).averageCharWidth(); … … 849 845 connect(pAreaChartToggle, &QAction::toggled, this, &UIChart::sltSetUseAreaChart); 850 846 } 851 QAction *pSelectColor0 = menu.addAction(m_strSelectChartColor0);852 pSelectColor0->setData(0);853 connect(pSelectColor0, &QAction::triggered, this, &UIChart::sltSelectDataSeriesColor);854 855 QAction *pSelectColor1 = menu.addAction(m_strSelectChartColor1);856 pSelectColor1->setData(1);857 connect(pSelectColor1, &QAction::triggered, this, &UIChart::sltSelectDataSeriesColor);858 859 847 menu.exec(mapToGlobal(point)); 860 848 } … … 874 862 { 875 863 setUseAreaChart(fUseAreaChart); 876 }877 878 void UIChart::sltSelectDataSeriesColor()879 {880 QAction *pSenderAction = qobject_cast<QAction*>(sender());881 if (!pSenderAction)882 return;883 int iIndex = pSenderAction->data().toInt();884 if (iIndex < 0 || iIndex >= DATA_SERIES_SIZE)885 return;886 887 QColorDialog colorDialog(m_dataSeriesColor[iIndex], this);888 if (colorDialog.exec() == QDialog::Rejected)889 return;890 QColor newColor = colorDialog.selectedColor();891 if (m_dataSeriesColor[iIndex] == newColor)892 return;893 m_dataSeriesColor[iIndex] = newColor;894 update();895 864 } 896 865 … … 1266 1235 } 1267 1236 1237 void UIVMActivityMonitor::setDataSeriesColor(int iIndex, const QColor &color) 1238 { 1239 if (iIndex < 0 || iIndex >= DATA_SERIES_SIZE) 1240 return; 1241 m_dataSeriesColor[iIndex] = color; 1242 1243 foreach (UIChart *pChart, m_charts) 1244 if (pChart) 1245 pChart->setDataSeriesColor(iIndex, color); 1246 } 1247 1268 1248 /********************************************************************************************************************************* 1269 1249 * UIVMActivityMonitorLocal definition. * -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h
r104445 r104449 33 33 34 34 /* Qt includes: */ 35 #include <QColor> 35 36 #include <QWidget> 36 37 #include <QMap> … … 157 158 virtual QUuid machineId() const = 0; 158 159 virtual QString machineName() const = 0; 160 void setDataSeriesColor(int iIndex, const QColor &color); 159 161 160 162 public slots: … … 184 186 void prepareActions(); 185 187 void setInfoLabelWidth(); 188 186 189 QGridLayout *m_pContainerLayout; 187 190 QTimer *m_pTimer; … … 222 225 int m_iMaximumLabelLength; 223 226 int m_iMaximumQueueSize; 227 QColor m_dataSeriesColor[DATA_SERIES_SIZE]; 224 228 225 229 private slots: -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitorPaneContainer.cpp
r104448 r104449 28 28 /* Qt includes: */ 29 29 #include <QApplication> 30 #include <QColor> 31 #include <QColorDialog> 30 32 #include <QHBoxLayout> 31 33 #include <QLabel> 34 #include <QPainter> 35 #include <QPixmap> 32 36 #include <QPlainTextEdit> 33 37 #include <QPushButton> 38 #include <QStyle> 34 39 35 40 /* GUI includes: */ … … 37 42 #include "UIVMActivityMonitorPaneContainer.h" 38 43 44 /* Other includes: */ 45 #include "iprt/assert.h" 46 39 47 UIVMActivityMonitorPaneContainer::UIVMActivityMonitorPaneContainer(QWidget *pParent, 40 48 EmbedTo enmEmbedTo /* = EmbedTo_Stack */) 41 49 : UIPaneContainer(pParent, enmEmbedTo, false /* detach not allowed */) 42 , m_pColorLabel0(0) 43 , m_pColorLabel1(0) 44 , m_pColorChangeButton0(0) 45 , m_pColorChangeButton1(0) 50 , m_pColorLabel{0, 0} 51 , m_pColorChangeButton{0, 0} 46 52 { 47 53 prepare(); … … 50 56 void UIVMActivityMonitorPaneContainer::prepare() 51 57 { 52 sltRetranslateUI();53 54 58 QWidget *pContainerWidget = new QWidget(this); 55 59 QVBoxLayout *pContainerLayout = new QVBoxLayout(pContainerWidget); 56 insertTab( 0, pContainerWidget, m_strTabText);60 insertTab(Tab_Preferences, pContainerWidget, ""); 57 61 58 QHBoxLayout *pColorLayout0 = new QHBoxLayout(this); 59 m_pColorLabel0 = new QLabel(this); 60 m_pColorChangeButton0 = new QPushButton(this); 61 pColorLayout0->addWidget(m_pColorLabel0); 62 pColorLayout0->addWidget(m_pColorChangeButton0); 62 for (int i = 0; i < 2; ++i) 63 { 64 QHBoxLayout *pColorLayout = new QHBoxLayout; 65 m_pColorLabel[i] = new QLabel(this); 66 m_pColorChangeButton[i] = new QPushButton(this); 67 pColorLayout->addWidget(m_pColorLabel[i]); 68 pColorLayout->addWidget(m_pColorChangeButton[i]); 69 pColorLayout->addStretch(); 70 pContainerLayout->addLayout(pColorLayout); 71 connect(m_pColorChangeButton[i], &QPushButton::pressed, 72 this, &UIVMActivityMonitorPaneContainer::sltColorChangeButtonPressed); 73 } 63 74 64 QHBoxLayout *pColorLayout1 = new QHBoxLayout(this); 65 m_pColorLabel1 = new QLabel(this); 66 m_pColorChangeButton1 = new QPushButton(this); 67 pColorLayout1->addWidget(m_pColorLabel1); 68 pColorLayout1->addWidget(m_pColorChangeButton1); 75 pContainerLayout->addStretch(); 69 76 70 pContainerLayout->addLayout(pColorLayout0); 71 pContainerLayout->addLayout(pColorLayout1); 72 73 77 sltRetranslateUI(); 74 78 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI, 75 79 this, &UIVMActivityMonitorPaneContainer::sltRetranslateUI); … … 78 82 void UIVMActivityMonitorPaneContainer::sltRetranslateUI() 79 83 { 80 m_strTabText = QApplication::translate("UIVMActivityMonitorPaneContainer", "Preferences");84 setTabText(Tab_Preferences, QApplication::translate("UIVMActivityMonitorPaneContainer", "Preferences")); 81 85 82 if (m_pColorLabel 0)83 m_pColorLabel 0->setText(QApplication::translate("UIVMActivityMonitorPaneContainer", "Data Series 1 Color"));84 if (m_pColorLabel 1)85 m_pColorLabel 1->setText(QApplication::translate("UIVMActivityMonitorPaneContainer", "Data Series 1Color"));86 if (m_pColorLabel[0]) 87 m_pColorLabel[0]->setText(QApplication::translate("UIVMActivityMonitorPaneContainer", "Data Series 1 Color")); 88 if (m_pColorLabel[1]) 89 m_pColorLabel[1]->setText(QApplication::translate("UIVMActivityMonitorPaneContainer", "Data Series 2 Color")); 86 90 } 91 92 void UIVMActivityMonitorPaneContainer::colorPushButtons(QPushButton *pButton, const QColor &color) 93 { 94 AssertReturnVoid(pButton); 95 int iSize = qApp->style()->pixelMetric(QStyle::PM_ButtonIconSize); 96 QPixmap iconPixmap(iSize, iSize); 97 QPainter painter(&iconPixmap); 98 painter.setBrush(color); 99 painter.drawRect(iconPixmap.rect()); 100 pButton->setIcon(QIcon(iconPixmap)); 101 } 102 103 void UIVMActivityMonitorPaneContainer::setDataSeriesColor(int iIndex, const QColor &color) 104 { 105 if (iIndex == 0 || iIndex == 1) 106 { 107 m_color[iIndex] = color; 108 colorPushButtons(m_pColorChangeButton[iIndex], color); 109 } 110 } 111 112 void UIVMActivityMonitorPaneContainer::sltColorChangeButtonPressed() 113 { 114 int iIndex = -1; 115 if (sender() == m_pColorChangeButton[0]) 116 iIndex = 0; 117 else if (sender() == m_pColorChangeButton[1]) 118 iIndex = 1; 119 else 120 return; 121 122 QColorDialog colorDialog(m_color[iIndex], this); 123 if (colorDialog.exec() == QDialog::Rejected) 124 return; 125 QColor newColor = colorDialog.selectedColor(); 126 if (m_color[iIndex] == newColor) 127 return; 128 m_color[iIndex] = newColor; 129 colorPushButtons(m_pColorChangeButton[iIndex], newColor); 130 emit sigColorChanged(iIndex, newColor); 131 } -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitorPaneContainer.h
r104448 r104449 36 36 #include "UIPaneContainer.h" 37 37 38 class QColor; 38 39 class QLabel; 39 40 class QPushButton; … … 44 45 Q_OBJECT; 45 46 47 signals: 48 49 void sigColorChanged(int iIndex, const QColor &color); 50 46 51 public: 47 52 48 53 UIVMActivityMonitorPaneContainer(QWidget *pParent, EmbedTo enmEmbedTo = EmbedTo_Stack); 54 void setDataSeriesColor(int iIndex, const QColor &color); 49 55 50 56 private slots: 51 57 52 58 void sltRetranslateUI(); 59 void sltColorChangeButtonPressed(); 53 60 54 61 private: 62 enum Tab 63 { 64 Tab_Preferences = 0 65 }; 55 66 56 67 void prepare(); 68 void colorPushButtons(QPushButton *pButton, const QColor &color); 57 69 QString m_strTabText; 58 70 59 71 60 QLabel *m_pColorLabel 0;61 Q Label *m_pColorLabel1;72 QLabel *m_pColorLabel[2]; 73 QPushButton *m_pColorChangeButton[2]; 62 74 63 QPushButton *m_pColorChangeButton0;64 QPushButton *m_pColorChangeButton1;65 75 76 QColor m_color[2]; 66 77 67 78 };
Note:
See TracChangeset
for help on using the changeset viewer.