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

cherry-picked from d3c861e
  • Loading branch information
signedav committed Oct 30, 2018
1 parent a5981f3 commit 1777769
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1777769

Please sign in to comment.