mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Apply timer spinbox workaround to QgsDoubleSpinBox too
To prevent double changed event fired in case the slot takes too long to execute.
This commit is contained in:
parent
bd6ecba176
commit
60fb0cb47f
@ -145,6 +145,8 @@ is equal to minimum(). Typical use is to indicate that this choice has a special
|
||||
|
||||
virtual void wheelEvent( QWheelEvent *event );
|
||||
|
||||
virtual void timerEvent( QTimerEvent *event );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -93,6 +93,17 @@ void QgsDoubleSpinBox::wheelEvent( QWheelEvent *event )
|
||||
setSingleStep( step );
|
||||
}
|
||||
|
||||
void QgsDoubleSpinBox::timerEvent( QTimerEvent *event )
|
||||
{
|
||||
// Process all events, which may include a mouse release event
|
||||
// Only allow the timer to trigger additional value changes if the user
|
||||
// has in fact held the mouse button, rather than the timer expiry
|
||||
// simply appearing before the mouse release in the event queue
|
||||
qApp->processEvents();
|
||||
if ( QApplication::mouseButtons() & Qt::LeftButton )
|
||||
QDoubleSpinBox::timerEvent( event );
|
||||
}
|
||||
|
||||
void QgsDoubleSpinBox::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
mLineEdit->setShowClearButton( shouldShowClearForValue( value() ) );
|
||||
|
@ -146,6 +146,10 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
|
||||
protected:
|
||||
void changeEvent( QEvent *event ) override;
|
||||
void wheelEvent( QWheelEvent *event ) override;
|
||||
// This is required because private implementation of
|
||||
// QAbstractSpinBoxPrivate may trigger a second
|
||||
// undesired event from the auto-repeat mouse timer
|
||||
void timerEvent( QTimerEvent *event ) override;
|
||||
|
||||
private slots:
|
||||
void changed( double value );
|
||||
|
Loading…
x
Reference in New Issue
Block a user