Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add a selectOnFocus property to QgsFilterLineEdit
- Loading branch information
|
@@ -177,6 +177,21 @@ class QgsFilterLineEdit : QLineEdit |
|
|
Show a spinner icon. This can be used for search boxes to indicate that |
|
|
something is going on in the background. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
%End |
|
|
|
|
|
bool selectOnFocus() const; |
|
|
%Docstring |
|
|
Will select all text when this widget receives the focus. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
:rtype: bool |
|
|
%End |
|
|
|
|
|
void setSelectOnFocus( bool selectOnFocus ); |
|
|
%Docstring |
|
|
Will select all text when this widget receives the focus. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
%End |
|
|
|
|
@@ -209,6 +224,14 @@ class QgsFilterLineEdit : QLineEdit |
|
|
Show a spinner icon. This can be used for search boxes to indicate that |
|
|
something is going on in the background. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
%End |
|
|
|
|
|
|
|
|
void selectOnFocusChanged(); |
|
|
%Docstring |
|
|
Will select all text when this widget receives the focus. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
%End |
|
|
|
|
|
|
@@ -102,7 +102,7 @@ void QgsFilterLineEdit::mouseMoveEvent( QMouseEvent *e ) |
|
|
void QgsFilterLineEdit::focusInEvent( QFocusEvent *e ) |
|
|
{ |
|
|
QLineEdit::focusInEvent( e ); |
|
|
if ( e->reason() == Qt::MouseFocusReason && isNull() ) |
|
|
if ( e->reason() == Qt::MouseFocusReason && ( isNull() || mSelectOnFocus ) ) |
|
|
{ |
|
|
mFocusInEvent = true; |
|
|
selectAll(); |
|
@@ -197,6 +197,20 @@ void QgsFilterLineEdit::updateBusySpinner() |
|
|
update(); |
|
|
} |
|
|
|
|
|
bool QgsFilterLineEdit::selectOnFocus() const |
|
|
{ |
|
|
return mSelectOnFocus; |
|
|
} |
|
|
|
|
|
void QgsFilterLineEdit::setSelectOnFocus( bool selectOnFocus ) |
|
|
{ |
|
|
if ( mSelectOnFocus == selectOnFocus ) |
|
|
return; |
|
|
|
|
|
mSelectOnFocus = selectOnFocus; |
|
|
emit selectOnFocusChanged(); |
|
|
} |
|
|
|
|
|
bool QgsFilterLineEdit::showSpinner() const |
|
|
{ |
|
|
return mShowSpinner; |
|
|
|
@@ -199,6 +199,20 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit |
|
|
*/ |
|
|
void setShowSpinner( bool showSpinner ); |
|
|
|
|
|
/** |
|
|
* Will select all text when this widget receives the focus. |
|
|
* |
|
|
* \since QGIS 3.0 |
|
|
*/ |
|
|
bool selectOnFocus() const; |
|
|
|
|
|
/** |
|
|
* Will select all text when this widget receives the focus. |
|
|
* |
|
|
* \since QGIS 3.0 |
|
|
*/ |
|
|
void setSelectOnFocus( bool selectOnFocus ); |
|
|
|
|
|
public slots: |
|
|
|
|
|
/** |
|
@@ -231,6 +245,14 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit |
|
|
*/ |
|
|
void showSpinnerChanged(); |
|
|
|
|
|
|
|
|
/** |
|
|
* Will select all text when this widget receives the focus. |
|
|
* |
|
|
* \since QGIS 3.0 |
|
|
*/ |
|
|
void selectOnFocusChanged(); |
|
|
|
|
|
protected: |
|
|
void mousePressEvent( QMouseEvent *e ) override; |
|
|
void mouseMoveEvent( QMouseEvent *e ) override; |
|
@@ -255,6 +277,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit |
|
|
QString mStyleSheet; |
|
|
bool mFocusInEvent = false; |
|
|
bool mClearHover = false; |
|
|
bool mSelectOnFocus = false; |
|
|
|
|
|
QSize mClearIconSize; |
|
|
QPixmap mClearIconPixmap; |
|
|