mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-16 10:32:21 +08:00
fix: ISSUE #I6CU7C 下载完成时,即使主窗口被遮挡,下载列表按钮动画效果仍显示在最上层
动画效果 WaterDrop widget 未设置父对象,使用全局坐标映射显示在按钮位置 Log: 对 WaterDrop 添加父对象,与下载列表按钮同级,为标题栏布局子控件,以此限制动画显示范围仅在标题栏内
This commit is contained in:
parent
48d551424a
commit
da03261cbb
src/widgets/common
@ -9,7 +9,7 @@ ProgressButton::ProgressButton(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
{
|
||||
// this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
setMinimumWidth(36);
|
||||
setMinimumHeight(36);
|
||||
svgPath = "";
|
||||
@ -99,8 +99,8 @@ void ProgressButton::setProgress(int progress)
|
||||
{
|
||||
buttonState = state::closeProgress;
|
||||
update();
|
||||
auto waterDrop = new WaterDrop();
|
||||
waterDrop->move(this->mapToGlobal(this->rect().center()));
|
||||
WaterDrop *waterDrop = new WaterDrop(parentWidget());
|
||||
waterDrop->move(geometry().center());
|
||||
waterDrop->show();
|
||||
}
|
||||
repaint();
|
||||
@ -159,11 +159,13 @@ WaterDrop::WaterDrop(QWidget *parent)
|
||||
: QWidget(parent), m_waterDropAnimation(nullptr), m_animationRadius(0)
|
||||
{
|
||||
this->setFixedSize(QSize(RADIUS * 2, RADIUS * 2));
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
// this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_waterDropAnimation = new QVariantAnimation(this);
|
||||
// m_waterDropAnimation->setEasingCurve(QEasingCurve(static_cast<QEasingCurve::Type>(QRandomGenerator::global()->bounded(40))));
|
||||
// m_waterDropAnimation->setEasingCurve(QEasingCurve(static_cast<QEasingCurve::Type>(QRandomGenerator::global()->bounded(40))));
|
||||
|
||||
connect(m_waterDropAnimation, &QVariantAnimation::finished, this, &WaterDrop::deleteLater);
|
||||
}
|
||||
|
||||
// 把鼠标点击的点转换为圆心点坐标
|
||||
@ -179,9 +181,9 @@ void WaterDrop::show()
|
||||
m_waterDropAnimation->setEndValue(RADIUS);
|
||||
m_waterDropAnimation->setDuration(350);
|
||||
|
||||
connect(m_waterDropAnimation, &QVariantAnimation::valueChanged, this, &WaterDrop::onRaduisChanged);
|
||||
connect(m_waterDropAnimation, &QVariantAnimation::valueChanged, this, &WaterDrop::onRadiusChanged);
|
||||
connect(m_waterDropAnimation, &QVariantAnimation::finished, this, &WaterDrop::close);
|
||||
m_waterDropAnimation->start();
|
||||
m_waterDropAnimation->start(QVariantAnimation::DeleteWhenStopped);
|
||||
QWidget::show();
|
||||
}
|
||||
|
||||
@ -194,9 +196,11 @@ void WaterDrop::paintEvent(QPaintEvent *event)
|
||||
pen.setWidth(5);
|
||||
painter.setPen(pen);
|
||||
painter.drawEllipse(event->rect().center(), m_animationRadius, m_animationRadius);
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void WaterDrop::onRaduisChanged(QVariant value)
|
||||
void WaterDrop::onRadiusChanged(QVariant value)
|
||||
{
|
||||
m_animationRadius = value.toInt();
|
||||
update();
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void onRaduisChanged(QVariant value);
|
||||
void onRadiusChanged(QVariant value);
|
||||
|
||||
private:
|
||||
class QVariantAnimation* m_waterDropAnimation;
|
||||
|
Loading…
x
Reference in New Issue
Block a user