Show current value on mouse over

Integrate the changes of commit fcdf4c0568 into `FloatModelEditorBase`. This commit lets users show the current value of a float model when the mouse is moved over the control.
This commit is contained in:
Michael Gregorius
2023-09-23 10:48:08 +02:00
parent e4934132d9
commit 8593f78a2c
2 changed files with 23 additions and 0 deletions

View File

@@ -87,6 +87,9 @@ protected:
void paintEvent( QPaintEvent * _me ) override;
void wheelEvent( QWheelEvent * _me ) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
virtual float getValue( const QPoint & _p );
private slots:
@@ -99,6 +102,7 @@ private:
void doConnections() override;
void showTextFloat(int msecBeforeDisplay, int msecDisplayTime);
void setPosition( const QPoint & _p );
inline float pageSize() const

View File

@@ -77,6 +77,12 @@ void FloatModelEditorBase::initUi( const QString & _name )
}
void FloatModelEditorBase::showTextFloat(int msecBeforeDisplay, int msecDisplayTime)
{
s_textFloat->setText(displayValue());
s_textFloat->moveGlobal(this, QPoint(width() + 2, 0));
s_textFloat->showWithDelay(msecBeforeDisplay, msecDisplayTime);
}
float FloatModelEditorBase::getValue( const QPoint & _p )
@@ -176,6 +182,8 @@ void FloatModelEditorBase::mousePressEvent( QMouseEvent * _me )
emit sliderPressed();
showTextFloat(0, 0);
s_textFloat->setText( displayValue() );
s_textFloat->moveGlobal( this,
QPoint( width() + 2, 0 ) );
@@ -209,6 +217,7 @@ void FloatModelEditorBase::mouseMoveEvent( QMouseEvent * _me )
m_lastMousePos = _me->pos();
}
s_textFloat->setText( displayValue() );
s_textFloat->show();
}
@@ -235,6 +244,16 @@ void FloatModelEditorBase::mouseReleaseEvent( QMouseEvent* event )
}
void FloatModelEditorBase::enterEvent(QEvent *event)
{
showTextFloat(700, 2000);
}
void FloatModelEditorBase::leaveEvent(QEvent *event)
{
s_textFloat->hide();
}
void FloatModelEditorBase::focusOutEvent( QFocusEvent * _fe )