1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-14 22:42:34 +02:00

Fix installed loading being empty and loading twice

This commit is contained in:
Elias Steurer 2021-12-12 21:54:53 +01:00
parent c3da8e1b95
commit d370a78913
4 changed files with 10 additions and 8 deletions

View File

@ -38,7 +38,7 @@ ApplicationWindow {
}
if (name === "Installed") {
stackView.replace("qrc:/ScreenPlay/qml/" + name + "/" + name + ".qml", {
stackView.replace("qrc:/ScreenPlay/qml/Installed/Installed.qml", {
"sidebar": sidebar
})
return
@ -71,7 +71,9 @@ ApplicationWindow {
}
Component.onCompleted: {
setTheme(ScreenPlay.settings.theme);
switchPage("Installed");
stackView.push("qrc:/ScreenPlay/qml/Installed/Installed.qml", {
"sidebar": sidebar
})
if (!ScreenPlay.settings.silentStart)
root.show();

View File

@ -12,7 +12,7 @@ import "../Common"
Rectangle {
id: root
property string currentNavigationName: ""
property string currentNavigationName: "Installed"
property var navArray: [navCreate, navWorkshop, navInstalled, navSettings, navCommunity]
property bool navActive: true
property ApplicationWindow window

View File

@ -41,7 +41,6 @@ void InstalledListModel::init()
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, reloadLambda);
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadLambda);
loadInstalledContent();
}
/*!
@ -201,12 +200,12 @@ void InstalledListModel::append(const QJsonObject& obj, const QString& folderNam
*/
void InstalledListModel::loadInstalledContent()
{
if (m_loadContentFuture.isRunning()) {
if (m_isLoading) {
qInfo() << "loadInstalledContent is already running. Skip.";
return;
}
m_loadContentFuture = QtConcurrent::run([this]() {
m_isLoading = true;
auto unused = QtConcurrent::run([this]() {
QFileInfoList list = QDir(m_globalVariables->localStoragePath().toLocalFile()).entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs);
int counter = 0;
@ -240,6 +239,7 @@ void InstalledListModel::loadInstalledContent()
}
setCount(counter);
emit installedLoadingFinished();
m_isLoading = false;
});
}

View File

@ -124,7 +124,7 @@ private:
QFileSystemWatcher m_fileSystemWatcher;
QVector<ProjectFile> m_screenPlayFiles;
int m_count { 0 };
QFuture<void> m_loadContentFuture;
std::atomic_bool m_isLoading { false };
const std::shared_ptr<GlobalVariables>& m_globalVariables;
};