VirtualBox

Ignore:
Timestamp:
Jun 28, 2018 10:59:17 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: Small improvements to logviewer filter panel buttons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp

    r72706 r72716  
    7979    virtual void        mouseReleaseEvent(QMouseEvent *){}
    8080    virtual void        paintEvent(QPaintEvent *event) /* override */;
     81    virtual void        resizeEvent(QResizeEvent *event) /* override */;                                                                     
    8182
    8283private slots:
     
    143144}
    144145
    145 void UIVMFilterLineEdit::paintEvent(QPaintEvent *event)
    146 {
    147     QLineEdit::paintEvent(event);
    148 
     146void UIVMFilterLineEdit::resizeEvent(QResizeEvent *event)
     147{
     148    QLineEdit::resizeEvent(event);
     149   
    149150    if (!m_pClearAllButton || !m_pRemoveTermButton)
    150151        createButtons();
    151152    int clearButtonSize = height();
    152 
    153     int deltaY = 0.5 * (height() - m_pClearAllButton->height());
    154     m_pClearAllButton->setGeometry(width() - clearButtonSize, deltaY, clearButtonSize, clearButtonSize);
     153   
     154    int deltaHeight = 0.5 * (height() - m_pClearAllButton->height());
     155    m_pClearAllButton->setGeometry(width() - clearButtonSize, deltaHeight, clearButtonSize, clearButtonSize);
     156}
     157
     158void UIVMFilterLineEdit::paintEvent(QPaintEvent *event)
     159{
     160    QLineEdit::paintEvent(event);
     161    int clearButtonSize = height();
    155162    /* If we have a selected term move the m_pRemoveTermButton to the end of the
    156163       or start of the word (depending on the location of the word within line edit itself: */
    157164    if (hasSelectedText())
    158165    {
     166        int deltaHeight = 0.5 * (height() - m_pClearAllButton->height());       
    159167        m_pRemoveTermButton->show();
    160         int buttonY = 0.5 * (height() - 16);
    161168        int buttonSize = m_iRemoveTermButtonSize;
    162169        int charWidth = fontMetrics().width('x');
    163170        int buttonLeft = cursorRect().right() - 0.5 * charWidth;
    164         /* If buttonLeft is in far left of the line edit, move the
     171        /* If buttonLeft is in far right of the line edit, move the
    165172           button to left side of the selected word: */
    166173        if (buttonLeft + buttonSize  >=  width() - clearButtonSize)
     
    169176            buttonLeft -= (selectionWidth + buttonSize);
    170177        }
    171         m_pRemoveTermButton->setGeometry(buttonLeft, buttonY, buttonSize, buttonSize);
     178        m_pRemoveTermButton->setGeometry(buttonLeft, deltaHeight, buttonSize, buttonSize);
    172179    }
    173180    else
Note: See TracChangeset for help on using the changeset viewer.

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