Changeset 70589 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 15, 2018 1:00:21 PM (7 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
r70581 r70589 143 143 void UIVMLogPage::setTextEdit(const QString &strText) 144 144 { 145 if(!m_pTextEdit) 146 return; 147 145 148 m_pTextEdit->setPlainText(strText); 146 149 /* Move the cursor position to end: */ … … 151 154 } 152 155 156 void UIVMLogPage::setTextEditAsHtml(const QString &strText) 157 { 158 if(!m_pTextEdit) 159 return; 160 m_pTextEdit->appendHtml(strText); 161 repaint(); 162 } 163 153 164 void UIVMLogPage::markForError() 154 165 { 155 QPalette pal = m_pTextEdit->palette();156 pal.setColor(QPalette::Base, pal.color(QPalette::Window));157 m_pTextEdit->set Palette(pal);166 if(!m_pTextEdit) 167 return; 168 m_pTextEdit->setWrapLines(true); 158 169 } 159 170 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70581 r70589 72 72 m_strLog. For example during filtering. */ 73 73 void setTextEdit(const QString &strText); 74 void setTextEditAsHtml(const QString &strText); 74 75 75 76 /** Marks the plain text edit When we dont have a log content. */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70581 r70589 190 190 #endif 191 191 setFont(font); 192 setWordWrapMode(QTextOption::NoWrap); 192 193 setWordWrapMode(QTextOption::NoWrap); 193 194 setReadOnly(true); … … 389 390 int UIVMLogViewerTextEdit::lineNumberForPos(const QPoint &position) 390 391 { 392 QTextCursor cursor = cursorForPosition(position); 393 QTextBlock block = cursor.block(); 394 return block.blockNumber() + 1; 395 } 396 397 QPair<int, QString> UIVMLogViewerTextEdit::bookmarkForPos(const QPoint &position) 398 { 391 399 QTextBlock block = cursorForPosition(position).block(); 392 return block.firstLineNumber() + 1; 393 } 394 395 QPair<int, QString> UIVMLogViewerTextEdit::bookmarkForPos(const QPoint &position) 396 { 397 QTextBlock block = cursorForPosition(position).block(); 398 return QPair<int, QString>(block.firstLineNumber() + 1, block.text()); 400 return QPair<int, QString>(lineNumberForPos(position), block.text()); 399 401 } 400 402 … … 437 439 return; 438 440 m_bWrapLines = bWrapLines; 441 if(m_bWrapLines) 442 { 443 setLineWrapMode(QPlainTextEdit::WidgetWidth); 444 setWordWrapMode(QTextOption::WordWrap); 445 } 446 else 447 { 448 setWordWrapMode(QTextOption::NoWrap); 449 setWordWrapMode(QTextOption::NoWrap); 450 } 451 439 452 update(); 440 453 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70581 r70589 208 208 m_pActionSave->setEnabled(!noLogsToShow); 209 209 m_pActionBookmark->setEnabled(!noLogsToShow); 210 m_pTabWidget->setEnabled(!noLogsToShow); 210 //m_pTabWidget->setEnabled(!noLogsToShow); 211 m_pActionSettings->setEnabled(!noLogsToShow); 211 212 m_pTabWidget->show(); 212 213 if (m_pSearchPanel && m_pSearchPanel->isVisible()) … … 730 731 { 731 732 int currentTabIndex = m_pTabWidget->currentIndex(); 732 if (currentTabIndex >= m_logPageList.size() )733 if (currentTabIndex >= m_logPageList.size() || currentTabIndex == -1) 733 734 return 0; 735 734 736 return qobject_cast<UIVMLogPage*>(m_logPageList.at(currentTabIndex)); 735 737 } … … 779 781 { 780 782 noLogsToShow = true; 781 strDummyTabText = QString(tr("<p><b>No machine</b> is currently selected . Please select a"782 " Virtual Machine to see its logs"));783 strDummyTabText = QString(tr("<p><b>No machine</b> is currently selected or the selected machine is not valid. " 784 "Please select a Virtual Machine to see its logs")); 783 785 } 784 786 785 787 const CSystemProperties &sys = vboxGlobal().virtualBox().GetSystemProperties(); 786 788 unsigned cMaxLogs = sys.GetLogHistoryCount() + 1 /*VBox.log*/ + 1 /*VBoxHardening.log*/; /** @todo Add api for getting total possible log count! */ 787 788 /* If machine is valid then check if there are any log files and create viewer tabs: */ 789 if (cMaxLogs == 0) 789 bool logFileRead = false; 790 for (unsigned i = 0; i < cMaxLogs && !noLogsToShow; ++i) 791 { 792 /* Query the log file name for index i: */ 793 QString strFileName = m_comMachine.QueryLogFilename(i); 794 if (!strFileName.isEmpty()) 795 { 796 /* Try to read the log file with the index i: */ 797 ULONG uOffset = 0; 798 QString strText; 799 while (true) 800 { 801 QVector<BYTE> data = m_comMachine.ReadLog(i, uOffset, _1M); 802 if (data.size() == 0) 803 break; 804 strText.append(QString::fromUtf8((char*)data.data(), data.size())); 805 uOffset += data.size(); 806 } 807 /* Anything read at all? */ 808 if (uOffset > 0) 809 { 810 logFileRead = true; 811 createLogPage(strFileName, strText); 812 } 813 } 814 } 815 if (!noLogsToShow && !logFileRead) 790 816 { 791 817 noLogsToShow = true; … … 795 821 .arg(m_comMachine.GetLogFolder())); 796 822 } 797 else{ 798 for (unsigned i = 0; i < cMaxLogs; ++i) 799 { 800 /* Query the log file name for index i: */ 801 QString strFileName = m_comMachine.QueryLogFilename(i); 802 if (!strFileName.isEmpty()) 803 { 804 /* Try to read the log file with the index i: */ 805 ULONG uOffset = 0; 806 QString strText; 807 while (true) 808 { 809 QVector<BYTE> data = m_comMachine.ReadLog(i, uOffset, _1M); 810 if (data.size() == 0) 811 break; 812 strText.append(QString::fromUtf8((char*)data.data(), data.size())); 813 uOffset += data.size(); 814 } 815 /* Anything read at all? */ 816 if (uOffset > 0) 817 { 818 createLogPage(strFileName, strText); 819 } 820 } 821 } 822 } 823 823 824 /* if noLogsToShow then ceate a single log page with an error message: */ 824 825 if (noLogsToShow) … … 855 856 /* Set the log string of the UIVMLogPage: */ 856 857 pLogPage->setLogString(strLogContent); 857 /* Also set text edit since we want to display this text: */ 858 pLogPage->setTextEdit(strLogContent); 859 if (noLogsToShow) 858 /* Set text edit since we want to display this text: */ 859 if (!noLogsToShow) 860 pLogPage->setTextEdit(strLogContent); 861 /* In case there are some errors append the error text as html: */ 862 else 863 { 864 pLogPage->setTextEditAsHtml(strLogContent); 860 865 pLogPage->markForError(); 866 } 861 867 } 862 868
Note:
See TracChangeset
for help on using the changeset viewer.