diff --git a/ScreenPlay/src/installedlistmodel.cpp b/ScreenPlay/src/installedlistmodel.cpp index 23044795..dea707bf 100644 --- a/ScreenPlay/src/installedlistmodel.cpp +++ b/ScreenPlay/src/installedlistmodel.cpp @@ -5,15 +5,11 @@ InstalledListModel::InstalledListModel(QObject* parent) { QObject::connect(this, &InstalledListModel::addInstalledItem, this, &InstalledListModel::append, Qt::QueuedConnection); - m_loadScreenWatcher.setFuture(m_loadScreenFuture); - - QObject::connect(&m_loadScreenWatcher, &QFutureWatcher::progressValueChanged, [](int progressValue) { - qDebug() << progressValue; - }); } int InstalledListModel::rowCount(const QModelIndex& parent) const { + Q_UNUSED(parent) return m_screenPlayFiles.count(); } @@ -81,7 +77,7 @@ bool InstalledListModel::getProjectByAbsoluteStoragePath(QUrl* path, ProjectFile void InstalledListModel::append(const QJsonObject obj, const QString folderName) { - //qDebug() << QThread::currentThreadId(); + beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size()); ProjectFile tmpFile(obj, folderName, m_absoluteStoragePath); @@ -92,19 +88,8 @@ void InstalledListModel::append(const QJsonObject obj, const QString folderName) void InstalledListModel::loadInstalledContent() { - if (m_loadScreenWatcher.isRunning()) - qDebug() << "allready running"; - - - if (m_isLoadingContent) { - qDebug() << "Called loading installed files twice! Aborting"; - return; - } - - m_loadScreenFuture = QtConcurrent::run([this]() { - auto cleanup = qScopeGuard([this] { setIsLoadingContent(false); }); - setIsLoadingContent(true); + QtConcurrent::run([this]() { QJsonDocument jsonProject; QJsonParseError parseError; @@ -154,6 +139,7 @@ void InstalledListModel::loadInstalledContent() emit installedLoadingFinished(); }); + } QVariantMap InstalledListModel::get(QString folderId) diff --git a/ScreenPlay/src/installedlistmodel.h b/ScreenPlay/src/installedlistmodel.h index 76185d43..8bfe27bc 100644 --- a/ScreenPlay/src/installedlistmodel.h +++ b/ScreenPlay/src/installedlistmodel.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -16,9 +18,6 @@ #include #include #include -#include -#include - /*! \class Installed List Model @@ -29,21 +28,19 @@ class InstalledListModel : public QAbstractListModel { Q_OBJECT -public: - explicit InstalledListModel(QObject* parent = 0); + Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged) + +public: + explicit InstalledListModel(QObject* parent = nullptr); - // Basic functionality: int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; 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, + TitleRole = Qt::UserRole, TypeRole, PreviewRole, PreviewGIFRole, @@ -59,15 +56,15 @@ public: return m_absoluteStoragePath; } - bool isLoadingContent() const - { - return m_isLoadingContent; - } - public slots: void loadInstalledContent(); - QVariantMap get(QString folderId); void append(const QJsonObject, const QString); + void reset(); + + int getAmountItemLoaded(); + + QVariantMap get(QString folderId); + void setabsoluteStoragePath(QUrl absoluteStoragePath) { if (m_absoluteStoragePath == absoluteStoragePath) @@ -76,33 +73,15 @@ public slots: m_absoluteStoragePath = absoluteStoragePath; emit absoluteStoragePathChanged(m_absoluteStoragePath); } - 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); void absoluteStoragePathChanged(QUrl absoluteStoragePath); void addInstalledItem(const QJsonObject, const QString); void installedLoadingFinished(); - void isLoadingContentChanged(bool isLoadingContent); private: QVector m_screenPlayFiles; QUrl m_absoluteStoragePath; - QFuture m_loadScreenFuture; - QFutureWatcher m_loadScreenWatcher; - - - bool m_isLoadingContent = false; }; diff --git a/ScreenPlay/src/profilelistmodel.h b/ScreenPlay/src/profilelistmodel.h index 87e56ae1..7aa29563 100644 --- a/ScreenPlay/src/profilelistmodel.h +++ b/ScreenPlay/src/profilelistmodel.h @@ -2,13 +2,13 @@ #include "profile.h" #include +#include #include #include #include #include -#include #include -#include +#include /*! \class Profile List Model @@ -25,14 +25,13 @@ class ProfileListModel : public QAbstractListModel { Q_OBJECT public: - explicit ProfileListModel(QObject* parent = 0); + explicit ProfileListModel(QObject* parent = nullptr); enum RoleNames { NameRole = Qt::UserRole, - NumberRole = Qt::UserRole + 2 + NumberRole }; - int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; virtual QHash roleNames() const override; @@ -43,7 +42,4 @@ public: private: QHash m_roleNames; QVector m_profileList; - }; - - diff --git a/ScreenPlay/src/projectsettingslistmodel.h b/ScreenPlay/src/projectsettingslistmodel.h index e49408c1..332c3a9c 100644 --- a/ScreenPlay/src/projectsettingslistmodel.h +++ b/ScreenPlay/src/projectsettingslistmodel.h @@ -1,14 +1,15 @@ #pragma once #include -#include -#include #include #include +#include #include #include #include +#include #include + #include "projectsettingslistitem.h" /*! @@ -17,16 +18,14 @@ */ -class ProjectSettingsListModel : public QAbstractListModel -{ +class ProjectSettingsListModel : public QAbstractListModel { Q_OBJECT - public: - explicit ProjectSettingsListModel(QString file, QObject *parent = nullptr); + explicit ProjectSettingsListModel(QString file, QObject* parent = nullptr); ProjectSettingsListModel(); - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; enum ProjectSettingsRole { @@ -38,7 +37,6 @@ public: void init(QString file); - public slots: void append(QString name, bool isHeadline, QVariant value); diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 4c3e3b2f..d0144adc 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -50,10 +50,6 @@ class ActiveProfile; class Settings : public QObject { Q_OBJECT -public: - explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QObject* parent = nullptr); - ~Settings(); - Q_PROPERTY(QVersionNumber version READ version) Q_PROPERTY(bool hasWorkshopBannerSeen READ hasWorkshopBannerSeen WRITE setHasWorkshopBannerSeen NOTIFY hasWorkshopBannerSeenChanged) Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) @@ -65,7 +61,9 @@ public: Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged) Q_PROPERTY(int activeWallpaperCounter READ activeWallpaperCounter WRITE setActiveWallpaperCounter NOTIFY activeWallpaperCounterChanged) - void loadActiveProfiles(); +public: + explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QObject* parent = nullptr); + ~Settings(); enum LocalCopyResult { NoError,