Changeset 70655 in vbox
- Timestamp:
- Jan 20, 2018 9:41:31 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120387
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70647 r70655 28 28 # include <QPlainTextEdit> 29 29 # include <QScrollBar> 30 # include <QStyle> 30 31 # include <QTextBlock> 31 32 32 33 /* GUI includes: */ 33 34 # include "UIVMLogViewerTextEdit.h" 35 # include "UIVMLogViewerWidget.h" 34 36 35 37 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 152 154 153 155 UIVMLogViewerTextEdit::UIVMLogViewerTextEdit(QWidget* parent /* = 0 */) 154 : QPlainTextEdit(parent)156 : QIWithRetranslateUI<QPlainTextEdit>(parent) 155 157 , m_pLineNumberArea(0) 156 158 , m_mouseCursorLine(-1) … … 169 171 { 170 172 prepareWidgets(); 173 retranslateUi(); 171 174 } 172 175 … … 191 194 setReadOnly(true); 192 195 193 /* Set colors to have a selection with bluebackground and white foreground: */194 QPalette mPalette = palette();195 mPalette.setColor(QPalette::Highlight, QColor(48, 140, 198, 255));196 mPalette.setColor(QPalette::HighlightedText, QColor(255, 255, 255, 255));197 mPalette.setColor(QPalette::Text, QColor(0, 0, 0, 255));198 setPalette(mPalette);199 196 200 197 #if defined(RT_OS_SOLARIS) … … 206 203 #endif 207 204 setFont(font); 205 208 206 if (m_pLineNumberArea) 209 207 m_pLineNumberArea->setFont(font); 210 211 208 } 212 209 … … 266 263 } 267 264 265 void UIVMLogViewerTextEdit::retranslateUi() 266 { 267 m_strBackgroungText = QString(UIVMLogViewerWidget::tr("Filtered")); 268 } 269 270 void UIVMLogViewerTextEdit::setBackground() 271 { 272 QPalette mPalette = palette(); 273 /* When the text is marked as filtered blend a background indicating that */ 274 if (m_bShownTextIsFiltered) 275 { 276 QImage image(300, 100, QImage::Format_ARGB32_Premultiplied); 277 QColor fillColor(QPalette::Light); 278 fillColor.setAlpha(0); 279 image.fill(fillColor); 280 QPainter painter(&image); 281 282 /* Configure the font size and color. */ 283 QFont pfont = painter.font(); 284 QColor fontColor(QPalette::Dark); 285 fontColor.setAlpha(22); 286 painter.setPen(fontColor); 287 pfont.setBold(true); 288 pfont.setPixelSize(40); 289 painter.setFont(pfont); 290 291 painter.drawText(image.rect(), Qt::AlignCenter | Qt::AlignVCenter, m_strBackgroungText); 292 293 mPalette.setBrush(QPalette::Base, QBrush(image)); 294 setPalette(mPalette); 295 } 296 else 297 { 298 /* Reset this->palette back to standard one. */ 299 if (style()) 300 setPalette(style()->standardPalette()); 301 } 302 } 303 268 304 void UIVMLogViewerTextEdit::contextMenuEvent(QContextMenuEvent *pEvent) 269 305 { … … 288 324 289 325 delete menu; 290 }291 292 void UIVMLogViewerTextEdit::paintEvent(QPaintEvent *pEvent)293 {294 QPlainTextEdit::paintEvent(pEvent);295 if (m_bShownTextIsFiltered && viewport())296 {297 int rectHeight = 24;298 int rectWidth = 84;299 int rectX = viewport()->width() - rectWidth;300 int rectMargin = 4;301 if (verticalScrollBar())302 rectX -= verticalScrollBar()->width();303 QPainter painter(viewport());304 painter.fillRect(rectX, 0, rectWidth, rectHeight, QColor(125, 125, 125, 100));305 QFont nFont(painter.font());306 nFont.setPixelSize(rectHeight- 2 * rectMargin) ;307 painter.setFont(nFont);308 painter.setPen(QPen(QColor(255, 0, 0, 175), 1.8f));309 painter.drawText(rectX + rectMargin, rectMargin, rectWidth, rectHeight,310 Qt::AlignLeft, "Filtered");311 viewport()->update();312 }313 326 } 314 327 … … 442 455 return; 443 456 m_bShownTextIsFiltered = warning; 457 setBackground(); 444 458 } 445 459 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h
r70645 r70655 19 19 #define ___UIVMLogViewerTextEdit_h___ 20 20 21 /* GUI includes: */ 22 #include "QIWithRetranslateUI.h" 23 21 24 /* Qt includes: */ 22 25 #include <QPlainTextEdit> … … 26 29 /* QPlainTextEdit extension for some addtional context menu items, 27 30 a special scrollbar, line number area, and bookmarking support: */ 28 class UIVMLogViewerTextEdit : public Q PlainTextEdit31 class UIVMLogViewerTextEdit : public QIWithRetranslateUI<QPlainTextEdit> 29 32 { 30 33 Q_OBJECT; … … 60 63 protected: 61 64 62 virtual void paintEvent(QPaintEvent *pEvent) /* override */;63 65 virtual void contextMenuEvent(QContextMenuEvent *pEvent) /* override */; 64 66 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 65 67 virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */; 66 68 virtual void leaveEvent(QEvent * pEvent) /* override */; 69 virtual void retranslateUi() /* override */; 67 70 68 71 private slots: … … 82 85 /** If bookmark exists this function removes it, if not it adds the bookmark. */ 83 86 void toggleBookmark(const QPair<int, QString>& bookmark); 87 void setBackground(); 84 88 /** Line number and text at the context menu position */ 85 89 QPair<int, QString> m_iContextMenuBookmark; … … 96 100 bool m_bShowLineNumbers; 97 101 bool m_bWrapLines; 98 102 QString m_strBackgroungText; 99 103 friend class UILineNumberArea; 100 104 };
Note:
See TracChangeset
for help on using the changeset viewer.