chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -5,62 +5,42 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "ElaToolTip.h"
|
||||
ElaToolTipPrivate::ElaToolTipPrivate(QObject* parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
_pOpacity = 1;
|
||||
}
|
||||
ElaToolTipPrivate::ElaToolTipPrivate(QObject *parent) : QObject{parent} { _pOpacity = 1; }
|
||||
|
||||
ElaToolTipPrivate::~ElaToolTipPrivate()
|
||||
{
|
||||
}
|
||||
ElaToolTipPrivate::~ElaToolTipPrivate() {}
|
||||
|
||||
bool ElaToolTipPrivate::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
bool ElaToolTipPrivate::eventFilter(QObject *watched, QEvent *event) {
|
||||
Q_Q(ElaToolTip);
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::Enter:
|
||||
{
|
||||
QTimer::singleShot(_pShowDelayMsec, this, [=]() {
|
||||
_doShowAnimation();
|
||||
});
|
||||
if (_pDisplayMsec > -1)
|
||||
{
|
||||
QTimer::singleShot(_pDisplayMsec, this, [=]() {
|
||||
q->hide();
|
||||
});
|
||||
switch (event->type()) {
|
||||
case QEvent::Enter: {
|
||||
QTimer::singleShot(_pShowDelayMsec, this, [=]() { _doShowAnimation(); });
|
||||
if (_pDisplayMsec > -1) {
|
||||
QTimer::singleShot(_pDisplayMsec, this, [=]() { q->hide(); });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QEvent::Leave:
|
||||
{
|
||||
QTimer::singleShot(_pHideDelayMsec, this, [=]() {
|
||||
q->hide();
|
||||
});
|
||||
case QEvent::Leave: {
|
||||
QTimer::singleShot(_pHideDelayMsec, this, [=]() { q->hide(); });
|
||||
break;
|
||||
}
|
||||
case QEvent::HoverMove:
|
||||
case QEvent::MouseMove:
|
||||
{
|
||||
case QEvent::MouseMove: {
|
||||
_updatePos();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void ElaToolTipPrivate::_doShowAnimation()
|
||||
{
|
||||
void ElaToolTipPrivate::_doShowAnimation() {
|
||||
Q_Q(ElaToolTip);
|
||||
QPoint cursorPoint = QCursor::pos();
|
||||
q->move(cursorPoint.x() + 10, cursorPoint.y());
|
||||
q->show();
|
||||
QPropertyAnimation* showAnimation = new QPropertyAnimation(q, "windowOpacity");
|
||||
QPropertyAnimation *showAnimation = new QPropertyAnimation(q, "windowOpacity");
|
||||
showAnimation->setEasingCurve(QEasingCurve::InOutSine);
|
||||
showAnimation->setDuration(250);
|
||||
showAnimation->setStartValue(0);
|
||||
@@ -68,11 +48,9 @@ void ElaToolTipPrivate::_doShowAnimation()
|
||||
showAnimation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
void ElaToolTipPrivate::_updatePos()
|
||||
{
|
||||
void ElaToolTipPrivate::_updatePos() {
|
||||
Q_Q(ElaToolTip);
|
||||
if (q->isVisible())
|
||||
{
|
||||
if (q->isVisible()) {
|
||||
QPoint cursorPoint = QCursor::pos();
|
||||
q->move(cursorPoint.x() + 10, cursorPoint.y());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user