Changeset 89011 in vbox
- Timestamp:
- May 12, 2021 12:53:25 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r88877 r89011 31 31 #include "UIVMLogViewerTextEdit.h" 32 32 33 34 UIVMLogPage::UIVMLogPage(QWidget *pParent /* = 0 */) 33 /********************************************************************************************************************************* 34 * UIVMLogTab implementation. * 35 *********************************************************************************************************************************/ 36 37 UIVMLogTab::UIVMLogTab(QWidget *pParent, const QUuid &uMachineId) 35 38 : QIWithRetranslateUI<QWidget>(pParent) 39 , m_uMachineId(uMachineId) 40 { 41 } 42 const QUuid &UIVMLogTab::machineId() const 43 { 44 return m_uMachineId; 45 } 46 47 /********************************************************************************************************************************* 48 * UIVMLogPage implementation. * 49 *********************************************************************************************************************************/ 50 51 UIVMLogPage::UIVMLogPage(QWidget *pParent, const QUuid &uMachineId) 52 : UIVMLogTab(pParent, uMachineId) 36 53 , m_pMainLayout(0) 37 54 , m_pTextEdit(0) … … 310 327 } 311 328 312 const QUuid &UIVMLogPage::machineId() const313 {314 return m_machineId;315 }316 317 void UIVMLogPage::setMachineId(const QUuid &machineId)318 {319 m_machineId = machineId;320 }321 322 329 void UIVMLogPage::setLogFileId(int iLogFileId) 323 330 { -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r88734 r89011 41 41 typedef QPair<int, QString> LogBookmark; 42 42 43 44 class UIVMLogTab : public QIWithRetranslateUI<QWidget> 45 { 46 47 Q_OBJECT; 48 49 public: 50 51 UIVMLogTab(QWidget *pParent, const QUuid &uMachineId); 52 const QUuid &machineId() const; 53 54 private: 55 56 QUuid m_uMachineId; 57 }; 58 43 59 /** UIVMLogPage defines data and functionalities of the each tab page of a UIVMLogViewerWidget. 44 60 * It stores the original log file content , a list of bookmarks, etc */ 45 class UIVMLogPage : public QIWithRetranslateUI<QWidget>61 class UIVMLogPage : public UIVMLogTab 46 62 { 47 63 Q_OBJECT; … … 54 70 public: 55 71 56 UIVMLogPage(QWidget *pParent = 0);72 UIVMLogPage(QWidget *pParent, const QUuid &uMachineId); 57 73 ~UIVMLogPage(); 58 74 … … 95 111 QFont currentFont() const; 96 112 void setCurrentFont(QFont font); 97 98 const QUuid &machineId() const;99 void setMachineId(const QUuid &machineId);100 113 101 114 void setLogFileId(int iLogFileId); … … 142 155 bool m_bFiltered; 143 156 /** @} */ 144 /** Id of the machine the log shown in this page belongs to. */145 QUuid m_machineId;146 157 /** The id we pass to CMachine::ReadLog. Used while refreshing and saving page content. */ 147 158 int m_iLogFileId; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r88972 r89011 61 61 const ULONG uAllowedLogSize = _256M; 62 62 63 class UILabelTab : public QWidget 64 { 63 class UILabelTab : public UIVMLogPage 64 { 65 65 66 Q_OBJECT; 66 67 … … 68 69 69 70 UILabelTab(QWidget *pParent, const QUuid &uMachineId) 70 : QWidget(pParent) 71 , m_uMachineId(uMachineId) 72 { 73 } 74 75 private: 76 77 QUuid m_uMachineId; 78 71 : UIVMLogPage(pParent, uMachineId) 72 { 73 } 79 74 }; 80 75 … … 91 86 92 87 UITabBar(QWidget *pParent = 0); 88 93 89 protected: 94 90 95 91 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 96 97 private:98 99 QVector<QColor> m_alternateColors;100 QColor m_selectedTabColor;101 92 }; 102 93 … … 123 114 :QTabBar(pParent) 124 115 { 125 QStyleOptionTab opt;126 m_alternateColors << opt.palette.color(QPalette::Button).darker(180);127 m_alternateColors << opt.palette.color(QPalette::Button).darker(120);128 m_selectedTabColor = opt.palette.color(QPalette::Button).lighter(300);129 130 // QStyle *pFusionStyle = QStyleFactory::create("Fusion");131 // if (pFusionStyle)132 // setStyle(pFusionStyle);133 116 } 134 117 … … 144 127 initStyleOption(&opt, i); 145 128 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 // } 129 154 130 if (!fLabelTab) 155 131 painter.drawControl(QStyle::CE_TabBarTabShape, opt); … … 266 242 removeLogViewerPages(unselectedMachines); 267 243 /* Assign color indexes to tabs based on machines. We use two alternating colors to indicate different machine logs. */ 268 setTabColorPerMachine(); 244 markLabelTabs(); 245 labelTabHandler(); 269 246 m_pTabWidget->show(); 270 247 } 271 248 272 void UIVMLogViewerWidget:: setTabColorPerMachine()249 void UIVMLogViewerWidget::markLabelTabs() 273 250 { 274 251 if (!m_pTabWidget || !m_pTabWidget->tabBar() || m_pTabWidget->tabBar()->count() == 0) 275 252 return; 276 253 QTabBar *pTabBar = m_pTabWidget->tabBar(); 277 //int iColorIndex = 0;278 254 279 255 for (int i = 0; i < pTabBar->count(); ++i) 280 256 { 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 257 if (qobject_cast<UILabelTab*>(m_pTabWidget->widget(i))) 290 258 pTabBar->setTabData(i, true); … … 390 358 391 359 m_pTabWidget->blockSignals(false); 392 setTabColorPerMachine();360 markLabelTabs(); 393 361 m_pTabWidget->show(); 394 362 } … … 922 890 } 923 891 924 void UIVMLogViewerWidget::createLogPage(const QString &strFileName, const QString &strMachineName,892 void UIVMLogViewerWidget::createLogPage(const QString &strFileName, 925 893 const QUuid &machineId, int iLogFileId, 926 894 const QString &strLogContent, bool noLogsToShow) … … 930 898 931 899 /* Create page-container: */ 932 UIVMLogPage* pLogPage = new UIVMLogPage(this );900 UIVMLogPage* pLogPage = new UIVMLogPage(this, machineId); 933 901 if (pLogPage) 934 902 { … … 939 907 pLogPage->setWrapLines(m_bWrapLines); 940 908 pLogPage->setCurrentFont(m_font); 941 pLogPage->setMachineId(machineId);942 909 pLogPage->setLogFileId(iLogFileId); 943 910 /* Set the file name only if we really have log file to read. */ … … 945 912 pLogPage->setLogFileName(strFileName); 946 913 947 /* Add page-container to viewer-container in stacked mode (manager UI case): */ 948 bool fTitleWithMachineName = false;//m_enmEmbedding == EmbedTo_Stack; 949 QString strTabTitle; 950 if (fTitleWithMachineName) 951 { 952 strTabTitle.append(strMachineName); 953 strTabTitle.append(" - "); 954 } 955 strTabTitle.append(QFileInfo(strFileName).fileName()); 956 957 int iIndex = m_pTabWidget->addTab(pLogPage, strTabTitle); 914 int iIndex = m_pTabWidget->addTab(pLogPage, QFileInfo(strFileName).fileName()); 958 915 /* !!Hack alert. Setting html to text edit while th tab is not current ends up in an empty text edit: */ 959 916 if (noLogsToShow) … … 1003 960 QString strMachineName = comMachine.GetName(); 1004 961 1005 m_pTabWidget->addTab(new UILabelTab(this, uMachineId), strMachineName); 962 if (m_enmEmbedding == EmbedTo_Stack) 963 m_pTabWidget->addTab(new UILabelTab(this, uMachineId), strMachineName); 1006 964 1007 965 bool fNoLogFileForMachine = true; … … 1013 971 fNoLogFileForMachine = false; 1014 972 createLogPage(comMachine.QueryLogFilename(iLogFileId), 1015 strMachineName,uMachineId, iLogFileId,973 uMachineId, iLogFileId, 1016 974 strLogContent, false); 1017 975 } … … 1023 981 "<nobr><b>%2</b></nobr>.</p>") 1024 982 .arg(strMachineName).arg(comMachine.GetLogFolder())); 1025 createLogPage(tr("NoLogFile"), strMachineName,uMachineId, -1 /* iLogFileId */, strDummyTabText, true);983 createLogPage(tr("NoLogFile"), uMachineId, -1 /* iLogFileId */, strDummyTabText, true); 1026 984 } 1027 985 } … … 1037 995 m_pTabWidget->blockSignals(true); 1038 996 /* Cache log page pointers and tab titles: */ 1039 QVector<QPair<UIVMLog Page*, QString> > logPages;997 QVector<QPair<UIVMLogTab*, QString> > logTabs; 1040 998 for (int i = 0; i < m_pTabWidget->count(); ++i) 1041 999 { 1042 UIVMLog Page*pTab = logPage(i);1000 UIVMLogTab *pTab = logPage(i); 1043 1001 if (pTab) 1044 log Pages << QPair<UIVMLogPage*, QString>(pTab, m_pTabWidget->tabText(i));1002 logTabs << QPair<UIVMLogTab*, QString>(pTab, m_pTabWidget->tabText(i)); 1045 1003 } 1046 1004 /* Remove all the tabs from tab widget, note that this does not delete tab widgets: */ 1047 1005 m_pTabWidget->clear(); 1048 QVector<UIVMLog Page*> pagesToRemove;1006 QVector<UIVMLogTab*> pagesToRemove; 1049 1007 /* Add tab widgets (log pages) back as long as machine id is not in machineList: */ 1050 for (int i = 0; i < log Pages.size(); ++i)1051 { 1052 if (!log Pages[i].first)1008 for (int i = 0; i < logTabs.size(); ++i) 1009 { 1010 if (!logTabs[i].first) 1053 1011 continue; 1054 const QUuid &id = log Pages[i].first->machineId();1012 const QUuid &id = logTabs[i].first->machineId(); 1055 1013 1056 1014 if (machineList.contains(id)) 1057 pagesToRemove << log Pages[i].first;1015 pagesToRemove << logTabs[i].first; 1058 1016 else 1059 m_pTabWidget->addTab(log Pages[i].first, logPages[i].second);1017 m_pTabWidget->addTab(logTabs[i].first, logTabs[i].second); 1060 1018 } 1061 1019 /* Delete all the other pages: */ … … 1069 1027 return; 1070 1028 1071 QVector<UIVMLogPage*> pagesToRemove = logPages(); 1029 QVector<QWidget*> pagesToRemove; 1030 for (int i = 0; i < m_pTabWidget->count(); ++i) 1031 pagesToRemove << m_pTabWidget->widget(i); 1072 1032 m_pTabWidget->clear(); 1073 1033 qDeleteAll(pagesToRemove.begin(), pagesToRemove.end()); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r88972 r89011 172 172 173 173 /** Returns the newly created log-page using @a strPage filename. */ 174 void createLogPage(const QString &strFileName, const QString &strMachineName,174 void createLogPage(const QString &strFileName, 175 175 const QUuid &machineId, int iLogFileId, 176 176 const QString &strLogContent, bool noLogsToShow); … … 187 187 void removeLogViewerPages(const QVector<QUuid> &machineList); 188 188 void removeAllLogPages(); 189 /** We alternate tab colors between two `darker and lighter` one per machine. This function goes over tabs and 190 * sets tab data so tab our QTabBar extension can color tabs correctly. */ 191 void setTabColorPerMachine(); 189 void markLabelTabs(); 192 190 193 191 /** Resets document (of the curent tab) and scrollbar highligthing */
Note:
See TracChangeset
for help on using the changeset viewer.