解决延时对动画产生干涉,窗口切换动画异常问题

This commit is contained in:
lixueman 2022-09-07 14:11:45 +08:00
parent ebdfe9b63e
commit 2ca68199f1
2 changed files with 20 additions and 16 deletions

View File

@ -62,8 +62,6 @@ MainWindow::MainWindow(QWidget *parent) :
m_softwareDbThread = new SoftwareDatabaseUpdateThread; m_softwareDbThread = new SoftwareDatabaseUpdateThread;
m_animationPage = new AnimationPage(); m_animationPage = new AnimationPage();
m_maxAnimation = new QPropertyAnimation(m_animationPage, "geometry", this);
m_minAnimation = new QPropertyAnimation(m_animationPage, "geometry", this);
m_searchAppThread = new SearchAppThread; m_searchAppThread = new SearchAppThread;
m_functionBtnWid = new FunctionButtonWidget(m_minFuncPage); m_functionBtnWid = new FunctionButtonWidget(m_minFuncPage);
m_functionBtnWid->hide(); m_functionBtnWid->hide();
@ -209,8 +207,6 @@ void MainWindow::initSignalConnect()
connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &MainWindow::recvFunctionBtnSignal); connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &MainWindow::recvFunctionBtnSignal);
connect(m_functionBtnWid, &FunctionButtonWidget::sendResetFunctionPage, this, &MainWindow::resetFunctionPage); connect(m_functionBtnWid, &FunctionButtonWidget::sendResetFunctionPage, this, &MainWindow::resetFunctionPage);
connect(m_letterBtnWid, &LetterButtonWidget::sendResetLetterPage, this, &MainWindow::resetLetterPage); connect(m_letterBtnWid, &LetterButtonWidget::sendResetLetterPage, this, &MainWindow::resetLetterPage);
connect(m_maxAnimation, &QPropertyAnimation::finished, this, &MainWindow::maxAnimationFinished);
connect(m_minAnimation, &QPropertyAnimation::finished, this, &MainWindow::minAnimationFinished);
connect(m_lineEdit, &QLineEdit::textChanged, this, &MainWindow::searchAppSlot); connect(m_lineEdit, &QLineEdit::textChanged, this, &MainWindow::searchAppSlot);
connect(this, &MainWindow::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); connect(this, &MainWindow::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword);
connect(m_searchAppThread, &SearchAppThread::sendSearchResult, this, &MainWindow::recvSearchResult); connect(m_searchAppThread, &SearchAppThread::sendSearchResult, this, &MainWindow::recvSearchResult);
@ -773,12 +769,13 @@ void MainWindow::minAnimationFinished()
m_viewWidget->setFocus(); m_viewWidget->setFocus();
// m_collectPushButton->clicked(true); // m_collectPushButton->clicked(true);
on_collectPushButton_clicked(); on_collectPushButton_clicked();
QEventLoop loop;
QTimer::singleShot(100, &loop, SLOT(quit())); QTimer::singleShot(200, [=]() {
loop.exec();
m_animationPage->hide(); m_animationPage->hide();
});
} }
void MainWindow::iconAnimationFinished() void MainWindow::iconAnimationFinished()
{ {
m_dropDownMenu->raise(); m_dropDownMenu->raise();
@ -792,11 +789,12 @@ void MainWindow::maxAnimationFinished()
m_fullWindow->showNormal(); m_fullWindow->showNormal();
setMaxWindowPos(); setMaxWindowPos();
m_fullWindow->activateWindow(); m_fullWindow->activateWindow();
QEventLoop loop;
QTimer::singleShot(100, &loop, SLOT(quit())); QTimer::singleShot(200, [=]() {
loop.exec();
m_animationPage->hide(); m_animationPage->hide();
});
} }
void MainWindow::resetLetterPage() void MainWindow::resetLetterPage()
{ {
m_minLetterListView->show(); m_minLetterListView->show();
@ -846,6 +844,7 @@ void MainWindow::primaryScreenChangeSlot()
{ {
repaintWidget(); repaintWidget();
} }
void MainWindow::appClassificationBtnClickedSlot() void MainWindow::appClassificationBtnClickedSlot()
{ {
m_leaveAnimation->setStartValue(QRect(0, 0, Style::leftPageWidth, Style::leftPageHeight)); m_leaveAnimation->setStartValue(QRect(0, 0, Style::leftPageWidth, Style::leftPageHeight));
@ -1271,6 +1270,8 @@ void MainWindow::on_minMaxChangeButton_clicked()
{ {
m_canHide = true; m_canHide = true;
m_isFullScreen = true; m_isFullScreen = true;
QPropertyAnimation *m_maxAnimation = new QPropertyAnimation(m_animationPage, "geometry", this);
connect(m_maxAnimation, &QPropertyAnimation::finished, this, &MainWindow::maxAnimationFinished);
if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
m_maxAnimation->setDuration(1); m_maxAnimation->setDuration(1);
@ -1290,9 +1291,10 @@ void MainWindow::on_minMaxChangeButton_clicked()
m_maxAnimation->setStartValue(QRect(this->x(), this->y(), Style::minw, Style::minh)); m_maxAnimation->setStartValue(QRect(this->x(), this->y(), Style::minw, Style::minh));
m_maxAnimation->setEndValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); m_maxAnimation->setEndValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight));
m_maxAnimation->start(); m_maxAnimation->start(QAbstractAnimation::DeleteWhenStopped);
this->hide(); this->hide();
} }
void MainWindow::showWindow() void MainWindow::showWindow()
{ {
Style::initWidStyle(); Style::initWidStyle();
@ -1389,6 +1391,9 @@ void MainWindow::showNormalWindowSlot()
{ {
myDebug() << "Style::m_availableScreenWidth" << Style::m_availableScreenWidth << "Style::m_availableScreenHeight" << Style::m_availableScreenHeight; myDebug() << "Style::m_availableScreenWidth" << Style::m_availableScreenWidth << "Style::m_availableScreenHeight" << Style::m_availableScreenHeight;
QPropertyAnimation *m_minAnimation = new QPropertyAnimation(m_animationPage, "geometry", this);
connect(m_minAnimation, &QPropertyAnimation::finished, this, &MainWindow::minAnimationFinished);
if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
m_minAnimation->setDuration(1); m_minAnimation->setDuration(1);
} else { } else {
@ -1408,7 +1413,7 @@ void MainWindow::showNormalWindowSlot()
m_minAnimation->setStartValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); m_minAnimation->setStartValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight));
m_minAnimation->setEndValue(QRect(this->x(), this->y(), Style::minw, Style::minh)); m_minAnimation->setEndValue(QRect(this->x(), this->y(), Style::minw, Style::minh));
m_minAnimation->start(); m_minAnimation->start(QAbstractAnimation::DeleteWhenStopped);
m_fullWindow->hide(); m_fullWindow->hide();
} }
void MainWindow::on_powerOffButton_clicked() void MainWindow::on_powerOffButton_clicked()

View File

@ -144,6 +144,7 @@ public Q_SLOTS:
void iconAnimationFinished(); void iconAnimationFinished();
void changeStyle(); void changeStyle();
void tabletModeChangeSlot(bool flag); void tabletModeChangeSlot(bool flag);
private Q_SLOTS: private Q_SLOTS:
void on_selectMenuButton_triggered(QAction *arg1); void on_selectMenuButton_triggered(QAction *arg1);
@ -236,8 +237,6 @@ private:
DesktopWatcher *m_desktopWatcher = nullptr; DesktopWatcher *m_desktopWatcher = nullptr;
QPropertyAnimation *m_enterAnimation = nullptr; QPropertyAnimation *m_enterAnimation = nullptr;
QPropertyAnimation *m_leaveAnimation = nullptr; QPropertyAnimation *m_leaveAnimation = nullptr;
QPropertyAnimation *m_minAnimation = nullptr;
QPropertyAnimation *m_maxAnimation = nullptr;
QPropertyAnimation *iconAnimation = nullptr; QPropertyAnimation *iconAnimation = nullptr;
int m_widgetState = -1; int m_widgetState = -1;
FunctionButtonWidget *m_functionBtnWid = nullptr; FunctionButtonWidget *m_functionBtnWid = nullptr;