1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-02 08:39:49 +02:00

Workaround for working wallpaper two times

This commit is contained in:
Elias 2019-03-14 18:56:55 +01:00
parent 1fe810befd
commit 2dcb49366b
2 changed files with 29 additions and 2 deletions

View File

@ -10,7 +10,6 @@ InstalledListModel::InstalledListModel(QObject* parent)
QObject::connect(&m_loadScreenWatcher, &QFutureWatcher<void>::progressValueChanged, [](int progressValue) {
qDebug() << progressValue;
});
}
int InstalledListModel::rowCount(const QModelIndex& parent) const
@ -95,9 +94,17 @@ void InstalledListModel::loadInstalledContent()
{
if (m_loadScreenWatcher.isRunning())
qDebug() << "allready running";
qDebug() << QThread::currentThreadId();
if (m_isLoadingContent) {
qDebug() << "Called loading installed files twice! Aborting";
return;
}
m_loadScreenFuture = QtConcurrent::run([this]() {
auto cleanup = qScopeGuard([this] { setIsLoadingContent(false); });
setIsLoadingContent(true);
qDebug() << QThread::currentThreadId();
QJsonDocument jsonProject;
QJsonParseError parseError;
@ -138,7 +145,7 @@ void InstalledListModel::loadInstalledContent()
obj.insert("type", "video");
}
if (fileEnding.endsWith(".webm") || (obj.value("type").toString() == "qmlScene" || fileEnding.endsWith(".html")))
if (fileEnding.endsWith(".webm") || (obj.value("type").toString() == "qmlScene" || fileEnding.endsWith(".html")))
emit addInstalledItem(obj, item.baseName());
if (obj.value("type") == "qmlWidget" || obj.value("type") == "standalonewidget")

View File

@ -40,6 +40,7 @@ public:
bool getProjectByAbsoluteStoragePath(QUrl* path, ProjectFile* spf);
Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged)
Q_PROPERTY(bool isLoadingContent READ isLoadingContent WRITE setIsLoadingContent NOTIFY isLoadingContentChanged)
enum InstalledRole {
TitleRole,
@ -58,6 +59,11 @@ public:
return m_absoluteStoragePath;
}
bool isLoadingContent() const
{
return m_isLoadingContent;
}
public slots:
void loadInstalledContent();
QVariantMap get(QString folderId);
@ -73,6 +79,15 @@ public slots:
int getAmountItemLoaded();
void reset();
void setIsLoadingContent(bool isLoadingContent)
{
if (m_isLoadingContent == isLoadingContent)
return;
m_isLoadingContent = isLoadingContent;
emit isLoadingContentChanged(m_isLoadingContent);
}
signals:
void setScreenVisible(bool visible);
void setScreenToVideo(QString absolutePath);
@ -80,9 +95,14 @@ signals:
void addInstalledItem(const QJsonObject, const QString);
void installedLoadingFinished();
void isLoadingContentChanged(bool isLoadingContent);
private:
QVector<ProjectFile> m_screenPlayFiles;
QUrl m_absoluteStoragePath;
QFuture<void> m_loadScreenFuture;
QFutureWatcher<void> m_loadScreenWatcher;
bool m_isLoadingContent = false;
};