Changeset 88815 in vbox for trunk/src/VBox
- Timestamp:
- May 3, 2021 8:56:02 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r88766 r88815 22 22 #include <QFont> 23 23 #include <QMenu> 24 #include <QPalette> 24 25 #include <QPainter> 25 26 #include <QPlainTextEdit> 26 27 #include <QScrollBar> 27 28 #include <QStyle> 29 #include <QStylePainter> 30 #include <QStyleOptionTab> 31 #include <QTabBar> 28 32 #include <QTextBlock> 29 33 #include <QVBoxLayout> … … 55 59 /** Limit the read string size to avoid bloated log viewer pages. */ 56 60 const ULONG uAllowedLogSize = _256M; 61 62 class UITabBar : public QTabBar 63 { 64 Q_OBJECT; 65 public: 66 UITabBar(QWidget *pParent = 0) 67 :QTabBar(pParent) 68 { 69 QStyleOptionTab opt; 70 m_alternateColors << opt.palette.color(QPalette::Button).lighter(125); 71 m_alternateColors << opt.palette.color(QPalette::Button).darker(125); 72 } 73 74 void paintEvent(QPaintEvent * /*event*/) { 75 76 QStylePainter painter(this); 77 QStyleOptionTab opt; 78 79 for (int i = 0; i < count(); i++) { 80 initStyleOption(&opt, i); 81 int iColorIndex = tabData(i).toInt(); 82 if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size()) 83 { 84 opt.palette.setColor(QPalette::Button, m_alternateColors[iColorIndex]); 85 } 86 87 painter.drawControl(QStyle::CE_TabBarTabShape, opt); 88 painter.drawControl(QStyle::CE_TabBarTabLabel, opt); 89 } 90 } 91 private: 92 QVector<QColor> m_alternateColors; 93 }; 94 95 class UITabWidget : public QTabWidget 96 { 97 Q_OBJECT; 98 public: 99 UITabWidget(QWidget *pParent = 0) 100 :QTabWidget(pParent) 101 { 102 setTabBar(new UITabBar(this)); 103 } 104 }; 57 105 58 106 class UIMachineListCheckBox : public QCheckBox … … 229 277 /* Remove the log pages/tabs of unselected machines from the tab widget: */ 230 278 removeLogViewerPages(unselectedMachines); 279 setTabColorPerMachine(); 231 280 m_pTabWidget->show(); 281 } 282 283 void UIVMLogViewerWidget::setTabColorPerMachine() 284 { 285 if (!m_pTabWidget || !m_pTabWidget->tabBar() || m_pTabWidget->tabBar()->count() == 0) 286 return; 287 QTabBar *pTabBar = m_pTabWidget->tabBar(); 288 int iColorIndex = 0; 289 pTabBar->setTabData(0, iColorIndex); 290 291 for (int i = 1; i < pTabBar->count(); ++i) 292 { 293 UIVMLogPage *pLogPage = logPage(i); 294 UIVMLogPage *pLogPagePrev = logPage(i - 1); 295 if (!pLogPage || !pLogPagePrev) 296 continue; 297 if (pLogPage->machineId() != pLogPagePrev->machineId()) 298 ++iColorIndex; 299 pTabBar->setTabData(i, iColorIndex % 2); 300 } 232 301 } 233 302 … … 589 658 590 659 /* Create VM Log-Viewer container: */ 591 m_pTabWidget = new QITabWidget;660 m_pTabWidget = new UITabWidget; 592 661 if (m_pTabWidget) 593 662 { … … 873 942 } 874 943 strTabTitle.append(QFileInfo(strFileName).fileName()); 875 m_pTabWidget-> insertTab(m_pTabWidget->count(),pLogPage, strTabTitle);944 m_pTabWidget->addTab(pLogPage, strTabTitle); 876 945 877 946 pLogPage->setLogContent(strLogContent, noLogsToShow); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r88766 r88815 38 38 /* Forward declarations: */ 39 39 class QITabWidget; 40 class UITabWidget; 40 41 class QPlainTextEdit; 41 42 class QVBoxLayout; … … 182 183 /** Removes the log pages/tabs that shows logs of the machines from @p machineList. */ 183 184 void removeLogViewerPages(const QVector<QUuid> &machineList); 185 void setTabColorPerMachine(); 184 186 185 187 /** Resets document (of the curent tab) and scrollbar highligthing */ … … 210 212 211 213 /** Holds container for log-pages. */ 212 QITabWidget *m_pTabWidget;214 UITabWidget *m_pTabWidget; 213 215 214 216 /** @name Panel instances and a QMap for mapping panel instances to related actions.
Note:
See TracChangeset
for help on using the changeset viewer.