VirtualBox

Changeset 101159 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Sep 18, 2023 3:45:32 PM (15 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: UIAdvancedSettingsDialog: Extending filter editor with filter clear button.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp

    r101147 r101159  
    115115    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
    116116
     117private slots:
     118
     119    /** Handles editor @a strText change. */
     120    void sltHandleEditorTextChanged(const QString &strText);
     121    /** Handles button click. */
     122    void sltHandleButtonClicked();
     123
    117124private:
    118125
     
    136143    /** Holds the filter editor instance. */
    137144    QILineEdit   *m_pLineEdit;
    138 #if 0
    139145    /** Holds the filter reset button instance. */
    140146    QIToolButton *m_pToolButton;
    141 #endif
    142147
    143148    /** Holds whether filter editor focused. */
     
    179184    : QWidget(pParent)
    180185    , m_pLineEdit(0)
    181 #if 0
    182186    , m_pToolButton(0)
    183 #endif
    184187    , m_fFocused(false)
    185188    , m_iUnfocusedEditorWidth(0)
     
    242245}
    243246
     247void UIFilterEditor::sltHandleEditorTextChanged(const QString &strText)
     248{
     249    m_pToolButton->setHidden(m_pLineEdit->text().isEmpty());
     250    emit sigTextChanged(strText);
     251}
     252
     253void UIFilterEditor::sltHandleButtonClicked()
     254{
     255    m_pLineEdit->clear();
     256}
     257
    244258void UIFilterEditor::prepare()
    245259{
     
    250264        m_pLineEdit->installEventFilter(this);
    251265        connect(m_pLineEdit, &QILineEdit::textChanged,
    252                 this, &UIFilterEditor::sigTextChanged);
    253     }
    254 
    255 #if 0
     266                this, &UIFilterEditor::sltHandleEditorTextChanged);
     267    }
     268
    256269    /* Prepare filter reset button: */
    257270    m_pToolButton = new QIToolButton(this);
    258271    if (m_pToolButton)
    259         m_pToolButton->setIcon(UIIconPool::iconSet(":/search_16px.png"));
    260 #endif
     272    {
     273        m_pToolButton->hide();
     274        m_pToolButton->setIconSize(QSize(10, 10));
     275        m_pToolButton->setIcon(UIIconPool::iconSet(":/close_16px.png"));
     276        connect(m_pToolButton, &QIToolButton::clicked,
     277                this, &UIFilterEditor::sltHandleButtonClicked);
     278    }
    261279
    262280    /* Install 'unfocus/focus' animation to 'editorWidth' property: */
     
    279297void UIFilterEditor::adjustEditorGeometry()
    280298{
     299    /* Acquire maximum widget width: */
     300    const int iWidth = width();
     301
     302    /* Update filter editor geometry: */
     303    const QSize esh = m_pLineEdit->minimumSizeHint();
     304    const int iMinimumEditorWidth = esh.width();
     305    const int iMinimumEditorHeight = esh.height();
    281306    /* Update minimum/maximum filter editor width: */
    282     const int iWidth = width();
    283     const int iMinimumWidth = m_pLineEdit->minimumSizeHint().width();
    284     m_iUnfocusedEditorWidth = qMax(iWidth / 2, iMinimumWidth);
    285     m_iFocusedEditorWidth = qMax(iWidth, iMinimumWidth);;
     307    m_iUnfocusedEditorWidth = qMax(iWidth / 2, iMinimumEditorWidth);
     308    m_iFocusedEditorWidth = qMax(iWidth, iMinimumEditorWidth);
    286309    m_pAnimation->update();
    287 
    288     /* Update filter editor geometry: */
    289310    setEditorWidth(m_fFocused ? m_iFocusedEditorWidth : m_iUnfocusedEditorWidth);
     311
     312    /* Update filter button geometry: */
     313    const QSize bsh = m_pToolButton->minimumSizeHint();
     314    const int iMinimumButtonWidth = bsh.width();
     315    const int iMinimumButtonHeight = bsh.height();
     316    const int iButtonY = iMinimumEditorHeight > iMinimumButtonHeight
     317                       ? (iMinimumEditorHeight - iMinimumButtonHeight) / 2
     318                       : 0;
     319    m_pToolButton->setGeometry(iWidth - iMinimumButtonWidth, iButtonY, iMinimumButtonWidth, iMinimumButtonHeight);
    290320}
    291321
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