mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-29 15:12:21 +08:00
动画效果 WaterDrop widget 未设置父对象,使用全局坐标映射显示在按钮位置 Log: 对 WaterDrop 添加父对象,与下载列表按钮同级,为标题栏布局子控件,以此限制动画显示范围仅在标题栏内
74 lines
1.4 KiB
C++
74 lines
1.4 KiB
C++
#ifndef PROGRESSBUTTON_H
|
|
#define PROGRESSBUTTON_H
|
|
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QTimer>
|
|
#include <QTimerEvent>
|
|
#include<QColor>
|
|
#include <QList>
|
|
#include <QMouseEvent>
|
|
|
|
|
|
class ProgressButton : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ProgressButton(QWidget *parent = nullptr);
|
|
void setIcon(QString svgPATH);
|
|
void setBackgroundColor(QColor color);
|
|
void setColor(QColor color);
|
|
void setProgress(int progress);
|
|
~ProgressButton();
|
|
signals:
|
|
void startProcessing();
|
|
void clicked();
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event)override;
|
|
void leaveEvent(QEvent *event)override;
|
|
void mousePressEvent(QMouseEvent *event)override;
|
|
|
|
private:
|
|
enum class state
|
|
{
|
|
normal,
|
|
hover,
|
|
openProgress,
|
|
closeProgress,
|
|
recovery
|
|
}
|
|
buttonState{state::normal};
|
|
QColor backColor;
|
|
QColor color;
|
|
QString svgPath;
|
|
int widthChangeValue{0};
|
|
void operationProcessing();
|
|
int progress{0};//处理百分比
|
|
};
|
|
|
|
class WaterDrop : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
WaterDrop(QWidget *parent = Q_NULLPTR);
|
|
void show();
|
|
void move(const QPoint &point);
|
|
|
|
private:
|
|
void paintEvent(QPaintEvent *event);
|
|
void onRadiusChanged(QVariant value);
|
|
|
|
private:
|
|
class QVariantAnimation* m_waterDropAnimation;
|
|
int m_animationRadius;
|
|
};
|
|
|
|
|
|
|
|
#endif // PROGRESSBUTTON_H
|