VirtualBox

Changeset 70655 in vbox


Ignore:
Timestamp:
Jan 20, 2018 9:41:31 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120387
Message:

FE/Qt bugref:9072 Mark the filtered log viewer by blending a background

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  
    2828# include <QPlainTextEdit>
    2929# include <QScrollBar>
     30# include <QStyle>
    3031# include <QTextBlock>
    3132
    3233/* GUI includes: */
    3334# include "UIVMLogViewerTextEdit.h"
     35# include "UIVMLogViewerWidget.h"
    3436
    3537#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    152154
    153155UIVMLogViewerTextEdit::UIVMLogViewerTextEdit(QWidget* parent /* = 0 */)
    154     :QPlainTextEdit(parent)
     156    : QIWithRetranslateUI<QPlainTextEdit>(parent)
    155157    , m_pLineNumberArea(0)
    156158    , m_mouseCursorLine(-1)
     
    169171{
    170172    prepareWidgets();
     173    retranslateUi();
    171174}
    172175
     
    191194    setReadOnly(true);
    192195
    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);
    199196
    200197#if defined(RT_OS_SOLARIS)
     
    206203#endif
    207204    setFont(font);
     205
    208206    if (m_pLineNumberArea)
    209207        m_pLineNumberArea->setFont(font);
    210 
    211208}
    212209
     
    266263}
    267264
     265void UIVMLogViewerTextEdit::retranslateUi()
     266{
     267    m_strBackgroungText = QString(UIVMLogViewerWidget::tr("Filtered"));
     268}
     269
     270void 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
    268304void UIVMLogViewerTextEdit::contextMenuEvent(QContextMenuEvent *pEvent)
    269305{
     
    288324
    289325    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     }
    313326}
    314327
     
    442455        return;
    443456    m_bShownTextIsFiltered = warning;
     457    setBackground();
    444458}
    445459
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h

    r70645 r70655  
    1919#define ___UIVMLogViewerTextEdit_h___
    2020
     21/* GUI includes: */
     22#include "QIWithRetranslateUI.h"
     23
    2124/* Qt includes: */
    2225#include <QPlainTextEdit>
     
    2629/* QPlainTextEdit extension for some addtional context menu items,
    2730   a special scrollbar, line number area, and bookmarking support: */
    28 class UIVMLogViewerTextEdit : public QPlainTextEdit
     31class UIVMLogViewerTextEdit : public QIWithRetranslateUI<QPlainTextEdit>
    2932{
    3033    Q_OBJECT;
     
    6063protected:
    6164
    62     virtual void paintEvent(QPaintEvent *pEvent) /* override */;
    6365    virtual void contextMenuEvent(QContextMenuEvent *pEvent) /* override */;
    6466    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
    6567    virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */;
    6668    virtual void leaveEvent(QEvent * pEvent) /* override */;
     69    virtual void retranslateUi() /* override */;
    6770
    6871private slots:
     
    8285    /** If bookmark exists this function removes it, if not it adds the bookmark. */
    8386    void toggleBookmark(const QPair<int, QString>& bookmark);
     87    void setBackground();
    8488    /** Line number and text at the context menu position */
    8589    QPair<int, QString>  m_iContextMenuBookmark;
     
    96100    bool                 m_bShowLineNumbers;
    97101    bool                 m_bWrapLines;
    98 
     102    QString              m_strBackgroungText;
    99103    friend class UILineNumberArea;
    100104};
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette