Changeset 88972 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 11, 2021 10:20:30 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144309
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r88970 r88972 61 61 const ULONG uAllowedLogSize = _256M; 62 62 63 class UILabelTab : public QWidget 64 { 65 Q_OBJECT; 66 67 public: 68 69 UILabelTab(QWidget *pParent, const QUuid &uMachineId) 70 : QWidget(pParent) 71 , m_uMachineId(uMachineId) 72 { 73 } 74 75 private: 76 77 QUuid m_uMachineId; 78 79 }; 80 63 81 /********************************************************************************************************************************* 64 82 * UITabBar definition. * … … 110 128 m_selectedTabColor = opt.palette.color(QPalette::Button).lighter(300); 111 129 112 QStyle *pFusionStyle = QStyleFactory::create("Fusion");113 if (pFusionStyle)114 setStyle(pFusionStyle);130 // QStyle *pFusionStyle = QStyleFactory::create("Fusion"); 131 // if (pFusionStyle) 132 // setStyle(pFusionStyle); 115 133 } 116 134 … … 125 143 QStyleOptionTab opt; 126 144 initStyleOption(&opt, i); 127 128 if (i == currentIndex()) 129 opt.palette.setColor(QPalette::Button, m_selectedTabColor); 130 else 131 { 132 int iColorIndex = tabData(i).toInt(); 133 if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size()) 134 opt.palette.setColor(QPalette::Button, m_alternateColors[iColorIndex]); 135 } 136 painter.drawControl(QStyle::CE_TabBarTab, opt); 145 bool fLabelTab = tabData(i).toBool(); 146 // if (i == currentIndex()) 147 // opt.palette.setColor(QPalette::Button, m_selectedTabColor); 148 // else 149 // { 150 // int iColorIndex = tabData(i).toInt(); 151 // if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size()) 152 // opt.palette.setColor(QPalette::Button, m_alternateColors[iColorIndex]); 153 // } 154 if (!fLabelTab) 155 painter.drawControl(QStyle::CE_TabBarTabShape, opt); 156 painter.drawControl(QStyle::CE_TabBarTabLabel, opt); 137 157 } 138 158 } … … 255 275 return; 256 276 QTabBar *pTabBar = m_pTabWidget->tabBar(); 257 int iColorIndex = 0; 258 pTabBar->setTabData(0, iColorIndex); 259 260 for (int i = 1; i < pTabBar->count(); ++i) 261 { 262 UIVMLogPage *pLogPage = logPage(i); 263 UIVMLogPage *pLogPagePrev = logPage(i - 1); 264 if (!pLogPage || !pLogPagePrev) 265 continue; 266 /* We the machine if the tab is different than that of previous alternate the color index. */ 267 if (pLogPage->machineId() != pLogPagePrev->machineId()) 268 ++iColorIndex; 269 pTabBar->setTabData(i, iColorIndex % 2); 277 //int iColorIndex = 0; 278 279 for (int i = 0; i < pTabBar->count(); ++i) 280 { 281 // UIVMLogPage *pLogPage = logPage(i); 282 // UIVMLogPage *pLogPagePrev = logPage(i - 1); 283 // if (!pLogPage || !pLogPagePrev) 284 // continue; 285 286 // /* We the machine if the tab is different than that of previous alternate the color index. */ 287 // if (i > 0 && pLogPage->machineId() != pLogPagePrev->machineId()) 288 // ++iColorIndex; 289 if (qobject_cast<UILabelTab*>(m_pTabWidget->widget(i))) 290 pTabBar->setTabData(i, true); 291 else 292 pTabBar->setTabData(i, false); 270 293 } 271 294 } … … 482 505 { 483 506 Q_UNUSED(tabIndex); 484 507 if (labelTabHandler()) 508 return; 485 509 /* Dont refresh the search here as it is refreshed by the filtering mechanism 486 510 which is updated as tab current index changes (see sltFilterApplied): */ … … 884 908 } 885 909 886 QPlainTextEdit* UIVMLogViewerWidget::logPage(int pIndex) const887 {888 if (m_pTabWidget)889 return 0;890 QWidget* pContainer = m_pTabWidget->widget(pIndex);891 if (!pContainer)892 return 0;893 QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>();894 return pBrowser;895 }896 897 910 QVector<UIVMLogPage*> UIVMLogViewerWidget::logPages() 898 911 { … … 933 946 934 947 /* Add page-container to viewer-container in stacked mode (manager UI case): */ 935 bool fTitleWithMachineName = m_enmEmbedding == EmbedTo_Stack;948 bool fTitleWithMachineName = false;//m_enmEmbedding == EmbedTo_Stack; 936 949 QString strTabTitle; 937 950 if (fTitleWithMachineName) … … 942 955 strTabTitle.append(QFileInfo(strFileName).fileName()); 943 956 944 945 m_pTabWidget->blockSignals(true);946 957 int iIndex = m_pTabWidget->addTab(pLogPage, strTabTitle); 947 958 /* !!Hack alert. Setting html to text edit while th tab is not current ends up in an empty text edit: */ 948 959 if (noLogsToShow) 949 960 m_pTabWidget->setCurrentIndex(iIndex); 950 m_pTabWidget->blockSignals(false);951 961 952 962 pLogPage->setLogContent(strLogContent, noLogsToShow); 953 963 pLogPage->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector()); 954 955 964 } 956 965 } … … 979 988 void UIVMLogViewerWidget::createLogViewerPages(const QVector<QUuid> &machineList) 980 989 { 990 if (!m_pTabWidget) 991 return; 992 m_pTabWidget->blockSignals(true); 993 981 994 const CSystemProperties &sys = uiCommon().virtualBox().GetSystemProperties(); 982 995 unsigned cMaxLogs = sys.GetLogHistoryCount() + 1 /*VBox.log*/ + 1 /*VBoxHardening.log*/; /** @todo Add api for getting total possible log count! */ … … 986 999 if (comMachine.isNull()) 987 1000 continue; 988 bool fNoLogFileForMachine = true;989 1001 990 1002 QUuid uMachineId = comMachine.GetId(); 991 1003 QString strMachineName = comMachine.GetName(); 1004 1005 m_pTabWidget->addTab(new UILabelTab(this, uMachineId), strMachineName); 1006 1007 bool fNoLogFileForMachine = true; 992 1008 for (unsigned iLogFileId = 0; iLogFileId < cMaxLogs; ++iLogFileId) 993 1009 { … … 1010 1026 } 1011 1027 } 1028 m_pTabWidget->blockSignals(false); 1029 labelTabHandler(); 1012 1030 } 1013 1031 … … 1118 1136 } 1119 1137 1138 bool UIVMLogViewerWidget::labelTabHandler() 1139 { 1140 if (!m_pTabWidget || !qobject_cast<UILabelTab*>(m_pTabWidget->currentWidget())) 1141 return false; 1142 if (m_pTabWidget->currentIndex() < m_pTabWidget->count() - 1) 1143 m_pTabWidget->setCurrentIndex(m_pTabWidget->currentIndex() + 1); 1144 return true; 1145 } 1146 1120 1147 #include "UIVMLogViewerWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r88903 r88972 171 171 /** @} */ 172 172 173 174 /** Returns the log-page from the tab with index @a pIndex. */175 QPlainTextEdit* logPage(int pIndex) const;176 173 /** Returns the newly created log-page using @a strPage filename. */ 177 174 void createLogPage(const QString &strFileName, const QString &strMachineName, … … 207 204 /** Returns the content of the ith log file of @comMachine or possibly an empty string */ 208 205 QString readLogFile(CMachine &comMachine, int iLogFileId); 206 /** If the current tab is a label tab then switch to the next tab and return true. Returns false otherwise. */ 207 bool labelTabHandler(); 209 208 210 209 /** Holds the widget's embedding type. */
Note:
See TracChangeset
for help on using the changeset viewer.