fix: refine playback shutdown and danmaku sizing
This commit is contained in:
+47
-27
@@ -101,23 +101,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
});
|
||||
}
|
||||
});
|
||||
connect(m_trayManager, &TrayManager::quitRequested, this, [this]() {
|
||||
m_realQuit = true;
|
||||
|
||||
if (auto *player = m_homeView->activePlayerView()) {
|
||||
player->stopAndReport();
|
||||
|
||||
QElapsedTimer wait;
|
||||
wait.start();
|
||||
while (wait.elapsed() < 500) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
|
||||
}
|
||||
}
|
||||
if(m_core && m_core->authService()) {
|
||||
m_core->authService()->logout();
|
||||
}
|
||||
qApp->quit();
|
||||
});
|
||||
connect(m_trayManager, &TrayManager::quitRequested, this,
|
||||
&MainWindow::requestApplicationQuit);
|
||||
|
||||
|
||||
|
||||
@@ -1045,6 +1030,46 @@ void MainWindow::navigateToLogin() {
|
||||
fadeIn->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
void MainWindow::requestApplicationQuit()
|
||||
{
|
||||
if (m_quitPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_quitPending = true;
|
||||
m_realQuit = true;
|
||||
const bool stoppedPlayback = stopActivePlaybackForQuit();
|
||||
if (stoppedPlayback) {
|
||||
QTimer::singleShot(500, this, &MainWindow::finishApplicationQuit);
|
||||
return;
|
||||
}
|
||||
|
||||
finishApplicationQuit();
|
||||
}
|
||||
|
||||
bool MainWindow::stopActivePlaybackForQuit()
|
||||
{
|
||||
if (!m_homeView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto *player = m_homeView->activePlayerView();
|
||||
if (!player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
player->stopAndReport();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::finishApplicationQuit()
|
||||
{
|
||||
if (m_core && m_core->authService()) {
|
||||
m_core->authService()->logout();
|
||||
}
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == qApp && event->type() == QEvent::ApplicationStateChange) {
|
||||
@@ -1172,16 +1197,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
hide();
|
||||
event->ignore();
|
||||
} else {
|
||||
|
||||
if (auto *player = m_homeView->activePlayerView()) {
|
||||
player->stopAndReport();
|
||||
|
||||
QElapsedTimer wait;
|
||||
wait.start();
|
||||
while (wait.elapsed() < 500) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
|
||||
}
|
||||
if (!m_quitPending) {
|
||||
requestApplicationQuit();
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
event->accept();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user