feat: 增加主程序退出动画

This commit is contained in:
麻木 2022-12-10 23:05:59 +08:00
parent b63ae13a3e
commit 2d3366990a
2 changed files with 33 additions and 0 deletions

@ -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