mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-22 21:42:21 +08:00
feat: 增加主程序退出动画
This commit is contained in:
parent
b63ae13a3e
commit
2d3366990a
@ -292,3 +292,31 @@ 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();
|
||||
}
|
||||
}
|
@ -51,6 +51,11 @@ private slots:
|
||||
//接受来自dbus的url
|
||||
void onGetUrl(const QString &url);
|
||||
void on_pushButton_14_clicked();
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
bool closeWindowAnimation = false;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOWDTK_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user