Changeset 70272 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 21, 2017 12:35:24 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r69933 r70272 545 545 src/globals/UIMainEventListener.cpp \ 546 546 src/globals/UIThreadPool.cpp \ 547 src/logviewer/UIVMLogViewerWidget.cpp \ 547 548 src/medium/UIMediumEnumerator.cpp \ 548 549 src/runtime/UIActionPoolRuntime.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp
r70242 r70272 21 21 22 22 /* Qt includes: */ 23 # include <QAction> 23 24 # include <QCheckBox> 24 25 # include <QComboBox> … … 29 30 # include <QLabel> 30 31 # include <QPlainTextEdit> 32 # include <QTextBlock> 31 33 32 34 /* GUI includes: */ … … 75 77 } 76 78 79 const QVector<float> &UIVMLogViewerSearchPanel::getMatchLocationVector() const 80 { 81 return m_matchLocationVector; 82 } 83 77 84 void UIVMLogViewerSearchPanel::hideEvent(QHideEvent *pEvent) 78 85 { … … 146 153 if (m_iMatchCount != 0) 147 154 m_iMatchCount = -1; 155 156 m_matchLocationVector.clear(); 148 157 pDocument->undo(); 149 158 } 150 159 configureInfoLabels(); 160 emit sigHighlightingUpdated(); 151 161 } 152 162 … … 473 483 } 474 484 else 485 { 475 486 m_iMatchCount = -1; 487 m_matchLocationVector.clear(); 488 } 476 489 477 490 QTextCursor resultCursor(pDocument); … … 513 526 m_iSearchPosition = resultCursor.position(); 514 527 configureInfoLabels(); 528 emit sigHighlightingUpdated(); 515 529 } 516 530 … … 529 543 { 530 544 m_iMatchCount = 0; 545 m_matchLocationVector.clear(); 531 546 if (!pDocument) 532 547 return; … … 540 555 cursor.beginEditBlock(); 541 556 colorFormat.setBackground(Qt::yellow); 542 557 int lineCount = pDocument->lineCount(); 543 558 while (!highlightCursor.isNull() && !highlightCursor.atEnd()) 544 559 { 545 560 /* Hightlighting searches is always from the top of the document forward: */ 546 561 highlightCursor = pDocument->find(searchString, highlightCursor, constructFindFlags(ForwardSearch)); 547 548 562 if (!highlightCursor.isNull()) 549 563 { 550 564 highlightCursor.mergeCharFormat(colorFormat); 551 565 ++m_iMatchCount; 566 /* The following assumes we have single line blocks only: */ 567 int cursorLine = pDocument->findBlock(highlightCursor.position()).firstLineNumber(); 568 if (lineCount != 0) 569 m_matchLocationVector.push_back(cursorLine / static_cast<float>(lineCount)); 552 570 } 553 571 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h
r70242 r70272 42 42 Q_OBJECT; 43 43 44 signals: 45 void sigHighlightingUpdated(); 46 44 47 public: 45 48 … … 50 53 void refresh(); 51 54 void reset(); 55 const QVector<float> &getMatchLocationVector() const; 52 56 53 57 protected: … … 63 67 * @param strSearchString Specifies search-string. */ 64 68 void findCurrent(const QString &strSearchString); 69 void sltHighlightAllCheckBox(); 65 70 66 void sltHighlightAllCheckBox();67 71 private: 68 72 enum SearchDirection { ForwardSearch, BackwardSearch }; … … 131 135 n > 0: n matches found. */ 132 136 int m_iMatchCount; 137 /** Stores relative positions of the lines of the matches. The values are [0,1] 0 being the first line 1 being the last. */ 138 QVector<float> m_matchLocationVector; 133 139 }; 134 140 135 141 136 142 #endif /* !___UIVMLogViewerSearchPanel_h___ */ 143 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70242 r70272 27 27 # include <QFontDatabase> 28 28 # endif 29 # include <QPainter> 29 30 # include <QPlainTextEdit> 30 31 # include <QScrollBar> … … 48 49 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 49 50 51 /** We use a modified scrollbar style for our QPlainTextEdits to get the 52 markings on the scrollbars correctly. The default scrollbarstyle does not 53 reveal the height of the pushbuttons on the scrollbar to compute the marking 54 locations correctlt. so we turn them off: */ 55 const QString verticalScrollBarStyle("QScrollBar:vertical {" 56 "border: 1px ridge grey; " 57 "margin: 0px 0px 0 0px;}" 58 "QScrollBar::handle:vertical {" 59 "min-height: 10px;" 60 "background: grey;}" 61 "QScrollBar::add-line:vertical {" 62 "width: 0px;}" 63 "QScrollBar::sub-line:vertical {" 64 "width: 0px;}"); 65 66 const QString horizontalScrollBarStyle("QScrollBar:horizontal {" 67 "border: 1px ridge grey; " 68 "margin: 0px 0px 0 0px;}" 69 "QScrollBar::handle:horizontal {" 70 "min-height: 10px;" 71 "background: grey;}" 72 "QScrollBar::add-line:horizontal {" 73 "height: 0px;}" 74 "QScrollBar::sub-line:horizontal {" 75 "height: 0px;}"); 76 77 class UIIndicatorScrollBar : public QScrollBar 78 { 79 Q_OBJECT; 80 81 public: 82 83 UIIndicatorScrollBar(QWidget *parent = 0) 84 :QScrollBar(parent) 85 { 86 setStyleSheet(verticalScrollBarStyle); 87 } 88 89 void setMarkingsVector(const QVector<float> &vector) 90 { 91 m_markingsVector = vector; 92 } 93 94 protected: 95 96 virtual void paintEvent(QPaintEvent *pEvent) /* override */ 97 { 98 QScrollBar::paintEvent(pEvent); 99 /* Put a red line to marking position: */ 100 for (int i = 0; i < m_markingsVector.size(); ++i) 101 { 102 QPointF p1 = QPointF(0, m_markingsVector[i] * height()); 103 QPointF p2 = QPointF(width(), m_markingsVector[i] * height()); 104 105 QPainter painter(this); 106 painter.setRenderHint(QPainter::Antialiasing, true); 107 painter.setPen(QPen(QColor(255, 0, 0, 255), 1.2f)); 108 painter.drawLine(p1, p2); 109 } 110 } 111 112 private: 113 /* Stores the relative (to scrollbar's height) positions of markings, 114 where we draw a horizontal line. */ 115 QVector<float> m_markingsVector; 116 }; 50 117 UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */, const CMachine &machine /* = CMachine() */) 51 118 : QIWithRetranslateUI<QWidget>(pParent) … … 205 272 } 206 273 274 void UIVMLogViewerWidget::sltSearchResultHighLigting() 275 { 276 if (!m_pSearchPanel) 277 return; 278 279 if (!currentLogPage()) 280 return; 281 UIIndicatorScrollBar* scrollBar = qobject_cast<UIIndicatorScrollBar*>(currentLogPage()->verticalScrollBar()); 282 if (scrollBar) 283 scrollBar->setMarkingsVector(m_pSearchPanel->getMatchLocationVector()); 284 285 m_markingsVector = m_pSearchPanel->getMatchLocationVector(); 286 currentLogPage()->repaint(); 287 } 288 207 289 void UIVMLogViewerWidget::setMachine(const CMachine &machine) 208 290 { … … 260 342 /* Add VM Log-Viewer search-panel to main-layout: */ 261 343 m_pMainLayout->insertWidget(2, m_pSearchPanel); 344 connect(m_pSearchPanel, &UIVMLogViewerSearchPanel::sigHighlightingUpdated, 345 this, &UIVMLogViewerWidget::sltSearchResultHighLigting); 262 346 } 263 347 … … 579 663 { 580 664 /* Configure Log-Viewer: */ 665 pLogViewer->setVerticalScrollBar(new UIIndicatorScrollBar()); 666 pLogViewer->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); 667 QScrollBar *pHorizontalScrollBar = pLogViewer->horizontalScrollBar(); 668 if (pHorizontalScrollBar) 669 { 670 pHorizontalScrollBar->setStyleSheet(horizontalScrollBarStyle); 671 } 581 672 #if defined(RT_OS_SOLARIS) 582 673 /* Use system fixed-width font on Solaris hosts as the Courier family fonts don't render well. */ … … 588 679 pLogViewer->setFont(font); 589 680 pLogViewer->setWordWrapMode(QTextOption::NoWrap); 590 pLogViewer->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);591 681 pLogViewer->setReadOnly(true); 592 682 /* Add Log-Viewer to page-layout: */ … … 603 693 return m_logMap[currentLogPage()]; 604 694 } 695 696 #include "UIVMLogViewerWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70185 r70272 73 73 protected: 74 74 75 76 75 /** Returns whether the window should be maximized when geometry being restored. */ 77 76 virtual bool shouldBeMaximized() const /* override */; … … 87 86 /** Handles filter action triggering. */ 88 87 void sltFilter(); 88 89 /** Handles the search result highlight changes. */ 90 void sltSearchResultHighLigting(); 89 91 90 92 private: … … 168 170 /** @} */ 169 171 172 QVector<float> m_markingsVector; 173 170 174 friend class UIVMLogViewerSearchPanel; 171 175 friend class UIVMLogViewerFilterPanel;
Note:
See TracChangeset
for help on using the changeset viewer.