Skip to content

Commit

Permalink
fix: 修复退出时音量未保存问题 (#428)
Browse files Browse the repository at this point in the history
退出时等待文件写入完成后再退出

Bug: https://pms.uniontech.com/bug-view-242507.html
Log: 修复部分已知问题
  • Loading branch information
pengfeixx authored Mar 8, 2024
1 parent 3d142f6 commit 9cd707e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
16 changes: 14 additions & 2 deletions src/common/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <X11/Xlib.h>
#include "moviewidget.h"
#include <QtConcurrent>
#include <QFileSystemWatcher>

#include "../accessibility/ac-deepin-movie-define.h"

Expand Down Expand Up @@ -3357,8 +3358,19 @@ void MainWindow::closeEvent(QCloseEvent *pEvent)
Settings::get().setInternalOption("playlist_pos", nCur);
}
}
//关闭窗口时保存音量值
Settings::get().setInternalOption("global_volume", m_nDisplayVolume > 100 ? 100 : m_nDisplayVolume);

int volume = Settings::get().internalOption("global_volume").toInt();
if (m_nDisplayVolume != volume) {
static QEventLoop loop;
QFileSystemWatcher fileWatcher;
fileWatcher.addPath(Settings::get().configPath());
connect(&fileWatcher, &QFileSystemWatcher::fileChanged, this, [=](){
loop.quit();
});
//关闭窗口时保存音量值
Settings::get().setInternalOption("global_volume", m_nDisplayVolume > 100 ? 100 : m_nDisplayVolume);
loop.exec();
}
m_pEngine->savePlaybackPosition();

pEvent->accept();
Expand Down
15 changes: 13 additions & 2 deletions src/common/platform/platform_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <X11/Xlib.h>
#include "moviewidget.h"
#include <QJsonObject>
#include <QFileSystemWatcher>

#include "../accessibility/ac-deepin-movie-define.h"

Expand Down Expand Up @@ -3340,8 +3341,18 @@ void Platform_MainWindow::closeEvent(QCloseEvent *pEvent)
Settings::get().setInternalOption("playlist_pos", nCur);
}
}
//关闭窗口时保存音量值
Settings::get().setInternalOption("global_volume", m_nDisplayVolume > 100 ? 100 : m_nDisplayVolume);
int volume = Settings::get().internalOption("global_volume").toInt();
if (m_nDisplayVolume != volume) {
static QEventLoop loop;
QFileSystemWatcher fileWatcher;
fileWatcher.addPath(Settings::get().configPath());
connect(&fileWatcher, &QFileSystemWatcher::fileChanged, this, [=](){
loop.quit();
});
//关闭窗口时保存音量值
Settings::get().setInternalOption("global_volume", m_nDisplayVolume > 100 ? 100 : m_nDisplayVolume);
loop.exec();
}
m_pEngine->savePlaybackPosition();

pEvent->accept();
Expand Down

0 comments on commit 9cd707e

Please sign in to comment.