mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 11:32:42 +01:00
Move Q_PROPERTY to the top
Remove explicit enum value Replace 0 with nullptr Remove QFuture and QFuturewatcher for now
This commit is contained in:
parent
7e28cff32e
commit
b961769fad
@ -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<void>::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)
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
@ -16,9 +18,6 @@
|
||||
#include <QUrl>
|
||||
#include <QVector>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <QFutureWatcher>
|
||||
#include <QFuture>
|
||||
|
||||
|
||||
/*!
|
||||
\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<int, QByteArray> 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<ProjectFile> m_screenPlayFiles;
|
||||
QUrl m_absoluteStoragePath;
|
||||
QFuture<void> m_loadScreenFuture;
|
||||
QFutureWatcher<void> m_loadScreenWatcher;
|
||||
|
||||
|
||||
bool m_isLoadingContent = false;
|
||||
};
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
#include "profile.h"
|
||||
#include <QAbstractListModel>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
#include <QVector>
|
||||
|
||||
/*!
|
||||
\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<int, QByteArray> roleNames() const override;
|
||||
@ -43,7 +42,4 @@ public:
|
||||
private:
|
||||
QHash<int, QByteArray> m_roleNames;
|
||||
QVector<Profile> m_profileList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QFile>
|
||||
#include <QQmlContext>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QQmlContext>
|
||||
#include <QVector>
|
||||
|
||||
#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<int, QByteArray> roleNames() const override;
|
||||
|
||||
enum ProjectSettingsRole {
|
||||
@ -38,7 +37,6 @@ public:
|
||||
|
||||
void init(QString file);
|
||||
|
||||
|
||||
public slots:
|
||||
void append(QString name, bool isHeadline, QVariant value);
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user