1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01: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") { if (name === "Installed") {
stackView.replace("qrc:/ScreenPlay/qml/" + name + "/" + name + ".qml", { stackView.replace("qrc:/ScreenPlay/qml/Installed/Installed.qml", {
"sidebar": sidebar "sidebar": sidebar
}) })
return return
@ -71,7 +71,9 @@ ApplicationWindow {
} }
Component.onCompleted: { Component.onCompleted: {
setTheme(ScreenPlay.settings.theme); setTheme(ScreenPlay.settings.theme);
switchPage("Installed"); stackView.push("qrc:/ScreenPlay/qml/Installed/Installed.qml", {
"sidebar": sidebar
})
if (!ScreenPlay.settings.silentStart) if (!ScreenPlay.settings.silentStart)
root.show(); root.show();

View File

@ -12,7 +12,7 @@ import "../Common"
Rectangle { Rectangle {
id: root id: root
property string currentNavigationName: "" property string currentNavigationName: "Installed"
property var navArray: [navCreate, navWorkshop, navInstalled, navSettings, navCommunity] property var navArray: [navCreate, navWorkshop, navInstalled, navSettings, navCommunity]
property bool navActive: true property bool navActive: true
property ApplicationWindow window 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::directoryChanged, this, reloadLambda);
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, 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() void InstalledListModel::loadInstalledContent()
{ {
if (m_loadContentFuture.isRunning()) { if (m_isLoading) {
qInfo() << "loadInstalledContent is already running. Skip."; qInfo() << "loadInstalledContent is already running. Skip.";
return; return;
} }
m_isLoading = true;
m_loadContentFuture = QtConcurrent::run([this]() { auto unused = QtConcurrent::run([this]() {
QFileInfoList list = QDir(m_globalVariables->localStoragePath().toLocalFile()).entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs); QFileInfoList list = QDir(m_globalVariables->localStoragePath().toLocalFile()).entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs);
int counter = 0; int counter = 0;
@ -240,6 +239,7 @@ void InstalledListModel::loadInstalledContent()
} }
setCount(counter); setCount(counter);
emit installedLoadingFinished(); emit installedLoadingFinished();
m_isLoading = false;
}); });
} }

View File

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