Skip to content

Commit 1777769

Browse files
committedOct 30, 2018
selectAll if requested on mouse release
because otherwise the mouse event makes the selectAll useless if it's done on focusEvent cherry-picked from d3c861e
1 parent a5981f3 commit 1777769

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
 

‎python/gui/auto_generated/qgsfilterlineedit.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ Will select all text when this widget receives the focus.
268268
protected:
269269
virtual void focusInEvent( QFocusEvent *e );
270270

271+
virtual void mouseReleaseEvent( QMouseEvent *e );
272+
271273

272274
};
273275

‎src/gui/qgsfilterlineedit.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ void QgsFilterLineEdit::focusInEvent( QFocusEvent *e )
9090
if ( e->reason() == Qt::MouseFocusReason && ( isNull() || mSelectOnFocus ) )
9191
{
9292
mFocusInEvent = true;
93+
mWaitingForMouseRelease = true;
94+
}
95+
}
96+
97+
void QgsFilterLineEdit::mouseReleaseEvent( QMouseEvent *e )
98+
{
99+
QLineEdit::mouseReleaseEvent( e );
100+
if ( mWaitingForMouseRelease )
101+
{
102+
mWaitingForMouseRelease = false;
93103
selectAll();
94104
}
95105
}

‎src/gui/qgsfilterlineedit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
265265

266266
protected:
267267
void focusInEvent( QFocusEvent *e ) override;
268+
void mouseReleaseEvent( QMouseEvent *e ) override;
268269

269270
private slots:
270271
void onTextChanged( const QString &text );
@@ -286,6 +287,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
286287
QString mDefaultValue;
287288
QString mStyleSheet;
288289
bool mFocusInEvent = false;
290+
bool mWaitingForMouseRelease = false;
289291
bool mSelectOnFocus = false;
290292

291293
QgsAnimatedIcon *mBusySpinnerAnimatedIcon = nullptr;

0 commit comments

Comments
 (0)
Please sign in to comment.