Navigation Menu

Skip to content

Commit

Permalink
selectAll if requested on mouse release
Browse files Browse the repository at this point in the history
because otherwise the mouse event makes the selectAll useless if it's done on focusEvent
  • Loading branch information
signedav committed Oct 10, 2018
1 parent fbbb320 commit d3c861e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/gui/auto_generated/qgsfilterlineedit.sip.in
Expand Up @@ -268,6 +268,8 @@ Will select all text when this widget receives the focus.
protected:
virtual void focusInEvent( QFocusEvent *e );

virtual void mouseReleaseEvent( QMouseEvent *e );


};

Expand Down
10 changes: 10 additions & 0 deletions src/gui/qgsfilterlineedit.cpp
Expand Up @@ -90,6 +90,16 @@ void QgsFilterLineEdit::focusInEvent( QFocusEvent *e )
if ( e->reason() == Qt::MouseFocusReason && ( isNull() || mSelectOnFocus ) )
{
mFocusInEvent = true;
mWaitingForMouseRelease = true;
}
}

void QgsFilterLineEdit::mouseReleaseEvent( QMouseEvent *e )
{
QLineEdit::mouseReleaseEvent( e );
if ( mWaitingForMouseRelease )
{
mWaitingForMouseRelease = false;
selectAll();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsfilterlineedit.h
Expand Up @@ -265,6 +265,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit

protected:
void focusInEvent( QFocusEvent *e ) override;
void mouseReleaseEvent( QMouseEvent *e ) override;

private slots:
void onTextChanged( const QString &text );
Expand All @@ -286,6 +287,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
QString mDefaultValue;
QString mStyleSheet;
bool mFocusInEvent = false;
bool mWaitingForMouseRelease = false;
bool mSelectOnFocus = false;

QgsAnimatedIcon *mBusySpinnerAnimatedIcon = nullptr;
Expand Down

0 comments on commit d3c861e

Please sign in to comment.