mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 12:52:04 +08:00
repo: 添加 BaseWidgetOpacity 基础类来实现继承者的淡出动画来代替主窗口的实现
BaseWidgetOpacity 是一个提供了淡出/淡入动画的基础类
1. closeEvent 窗口关闭时进行淡出动画
此前在 MainWindow 中实现的淡出动画将由 BaseWidgetOpacity 来实现。
此前 MainWindow 原有的 DBlurEffectWidget 父类将移交至 BaseWidgetOpacity 继承。
注意:
如果 MainWindow 在未来重写 closeEvent 事件时将可能丢失 BaseWidgetOpacity 中的淡出效果
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#define AppPageSettings 3
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: DBlurEffectWidget(parent)
|
||||
: BaseWidgetOpacity(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -299,32 +299,3 @@ void MainWindow::on_pushButton_14_clicked()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @brief 窗口关闭事件
|
||||
/// @param event
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!closeWindowAnimation) {
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
|
||||
animation->setEasingCurve(QEasingCurve::OutQuart);
|
||||
animation->setDuration(500);
|
||||
animation->setStartValue(1.0);
|
||||
animation->setEndValue(0.0);
|
||||
|
||||
QObject::connect(animation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value){
|
||||
this->update();
|
||||
// setWindowTitle(QString("ヾ(⌒∇⌒*)See You♪ - %1%").arg(int(value.toFloat() * 100)));
|
||||
});
|
||||
|
||||
QObject::connect(animation, &QPropertyAnimation::finished, this, [=](){
|
||||
closeWindowAnimation = true;
|
||||
this->close();
|
||||
});
|
||||
|
||||
animation->start();
|
||||
event->ignore();
|
||||
} else {
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user