Large update. Added Video, Image and Live item views. Added Live search
This commit is contained in:
@@ -50,3 +50,15 @@ auto CoreServices::sessionToken() -> QByteArray
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
auto CoreServices::screenSize() -> QSize
|
||||
{
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
|
||||
if(screen == nullptr)
|
||||
{
|
||||
return QSize(0,0);
|
||||
}
|
||||
|
||||
return screen->size();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QSharedPointer>
|
||||
#include <QWeakPointer>
|
||||
#include <QScreen>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
@@ -45,6 +46,8 @@ public:
|
||||
*/
|
||||
static auto sessionToken() -> QByteArray;
|
||||
|
||||
static auto screenSize() -> QSize;
|
||||
|
||||
private:
|
||||
|
||||
CoreServices() = default;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef EXCEPTIONS_H
|
||||
#define EXCEPTIONS_H
|
||||
#include <QString>
|
||||
#include <exception>
|
||||
#include "komplex_global.h"
|
||||
|
||||
struct KOMPLEX_EXPORT Exception : std::exception
|
||||
{
|
||||
explicit Exception(const QString &message, quint16 errorCode = 0)
|
||||
: std::exception(), message(message), errorCode(errorCode){}
|
||||
|
||||
const QString message;
|
||||
const quint16 errorCode;
|
||||
};
|
||||
|
||||
struct NetworkException : Exception
|
||||
{
|
||||
NetworkException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
|
||||
};
|
||||
struct FileException : Exception
|
||||
{
|
||||
FileException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
|
||||
};
|
||||
struct SqlException : Exception
|
||||
{
|
||||
SqlException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
|
||||
};
|
||||
#endif // EXCEPTIONS_H
|
||||
@@ -31,11 +31,12 @@
|
||||
#define SLIDING_CACHE_PREFETCH_THRESHOLD 20
|
||||
|
||||
#define NETWORK_TIMEOUT 10000
|
||||
#define NETWORK_RETRY_LIMIT 3
|
||||
|
||||
#ifdef KOMPLEX_LOCAL_DEV
|
||||
#define KOMPLEX_API_HOST "https://komplexapi.hlab"
|
||||
#else
|
||||
#define KOMPLEX_API_HOST "https://komplex.digitalartifex.dev"
|
||||
#define KOMPLEX_API_HOST "https://api.komplex.dev"
|
||||
#endif
|
||||
|
||||
#define KOMPLEX_API_VERSION "v2"
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <qdebug.h>
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
|
||||
#include "komplex_global.h"
|
||||
#include "slidingcachecontroller.h"
|
||||
@@ -47,6 +50,7 @@ signals:
|
||||
auto pageChanged() -> void;
|
||||
auto countChanged() -> void;
|
||||
auto queryChanged() -> void;
|
||||
auto uriChanged() -> void;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -168,6 +172,34 @@ public:
|
||||
setOffset(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief uri
|
||||
* URI of the API Endpoint. This is set by the child class
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto uri() const -> QString
|
||||
{
|
||||
return m_uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setUri
|
||||
* Sets the API Endpoint URI to fetch from
|
||||
* @param uri
|
||||
*/
|
||||
auto setUri(const QString &uri) -> void
|
||||
{
|
||||
if(uri == m_uri)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_uri = uri;
|
||||
|
||||
Q_EMIT uriChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief data
|
||||
* @return
|
||||
@@ -321,6 +353,31 @@ protected:
|
||||
controller()->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief getDocument
|
||||
* Extracts the JSON document from the server reply and deletes the reply
|
||||
* object.
|
||||
* @param reply
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto getDocument(QNetworkReply *reply) const -> QJsonDocument
|
||||
{
|
||||
QByteArray data = reply->readAll();
|
||||
QJsonParseError documentError;
|
||||
QJsonDocument document = QJsonDocument::fromJson(data, &documentError);
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
LOG_ERROR_X(documentError.error != QJsonParseError::NoError,
|
||||
"NewestPacksPaginator::getDocument",
|
||||
documentError.errorString().toStdString().c_str(),
|
||||
{}
|
||||
);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -377,6 +434,12 @@ private:
|
||||
* Controls the queryable state of the paginator
|
||||
*/
|
||||
bool m_queryable = false;
|
||||
|
||||
/**
|
||||
* @brief m_uri
|
||||
* API Endpoint URI
|
||||
*/
|
||||
QString m_uri;
|
||||
};
|
||||
|
||||
#endif // PAGINATOR_H
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
#ifndef SHADERPACKMETADATA
|
||||
#define SHADERPACKMETADATA
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QProcess>
|
||||
#include <QEventLoop>
|
||||
#include <QtQml/qqmlregistration.h>
|
||||
|
||||
#include "komplex_global.h"
|
||||
|
||||
class KOMPLEX_EXPORT ShaderPackMetadata : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
QString m_author;
|
||||
QString m_description;
|
||||
QString m_engine;
|
||||
QString m_file;
|
||||
QString m_id;
|
||||
QString m_license;
|
||||
QString m_name;
|
||||
QString m_version;
|
||||
|
||||
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
|
||||
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
|
||||
Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||
Q_PROPERTY(QString file READ file WRITE setFile NOTIFY fileChanged)
|
||||
Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
|
||||
Q_PROPERTY(QString license READ license WRITE setLicense NOTIFY licenseChanged)
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
Q_PROPERTY(QString version READ version WRITE setVersion NOTIFY versionChanged)
|
||||
|
||||
Q_SIGNALS:
|
||||
void authorChanged();
|
||||
void descriptionChanged();
|
||||
void engineChanged();
|
||||
void idChanged();
|
||||
void licenseChanged();
|
||||
void nameChanged();
|
||||
void versionChanged();
|
||||
void fileChanged();
|
||||
|
||||
public:
|
||||
|
||||
QString author() const { return m_author; }
|
||||
void setAuthor(const QString& author)
|
||||
{
|
||||
if(author != m_author)
|
||||
{
|
||||
m_author = author;
|
||||
Q_EMIT authorChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString description() const { return m_description; }
|
||||
void setDescription(const QString& description)
|
||||
{
|
||||
if(description != m_description)
|
||||
{
|
||||
m_description = description;
|
||||
Q_EMIT descriptionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString engine() const { return m_engine; }
|
||||
void setEngine(const QString& engine)
|
||||
{
|
||||
if(engine != m_engine)
|
||||
{
|
||||
m_engine = engine;
|
||||
Q_EMIT engineChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString file() const { return m_file; }
|
||||
void setFile(const QString& file)
|
||||
{
|
||||
if(file != m_file)
|
||||
{
|
||||
m_file = file;
|
||||
Q_EMIT fileChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString id() const { return m_id; }
|
||||
void setId(const QString& id)
|
||||
{
|
||||
if(id != m_id)
|
||||
{
|
||||
m_id = id;
|
||||
Q_EMIT idChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString license() const { return m_license; }
|
||||
void setLicense(const QString& license)
|
||||
{
|
||||
if(license != m_license)
|
||||
{
|
||||
m_license = license;
|
||||
Q_EMIT licenseChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString name() const { return m_name; }
|
||||
void setName(const QString& name)
|
||||
{
|
||||
if(name != m_name)
|
||||
{
|
||||
m_name = name;
|
||||
Q_EMIT nameChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString version() const { return m_version; }
|
||||
void setVersion(const QString& version)
|
||||
{
|
||||
if(version != m_version)
|
||||
{
|
||||
m_version = version;
|
||||
Q_EMIT versionChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ShaderPackMetadata)
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
#ifndef SHADERTOYMETADATA_H
|
||||
#define SHADERTOYMETADATA_H
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QStandardPaths>
|
||||
#include <QUuid>
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
#include <QDir>
|
||||
#include <QEventLoop>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QPixmap>
|
||||
#include <qqmlintegration.h>
|
||||
|
||||
#include "komplex_global.h"
|
||||
|
||||
struct KOMPLEX_EXPORT ShaderToyMetadata
|
||||
{
|
||||
QDateTime date;
|
||||
QString description;
|
||||
quint64 flags = 0;
|
||||
bool hasLiked = false;
|
||||
QString id;
|
||||
quint64 likes = 0;
|
||||
QString name;
|
||||
quint64 published = 0;
|
||||
QStringList tags;
|
||||
bool usePreview = false;
|
||||
QString username;
|
||||
QString version;
|
||||
quint64 views = 0;
|
||||
};
|
||||
|
||||
struct KOMPLEX_EXPORT ShaderToyRenderInput
|
||||
{
|
||||
quint8 channel = 0;
|
||||
QString ctype;
|
||||
QString filter;
|
||||
quint64 id = 0;
|
||||
QString internal;
|
||||
bool published = false;
|
||||
QString source;
|
||||
bool srgb = false;
|
||||
bool verticalFlip = false;
|
||||
QString wrap;
|
||||
};
|
||||
|
||||
struct KOMPLEX_EXPORT ShaderToyRenderOutput
|
||||
{
|
||||
const quint8 channel = 0;
|
||||
const quint64 id = 0;
|
||||
};
|
||||
|
||||
struct KOMPLEX_EXPORT ShaderToyRenderPass
|
||||
{
|
||||
QByteArray code;
|
||||
QString description;
|
||||
QList<ShaderToyRenderInput> inputs;
|
||||
QString name;
|
||||
QList<ShaderToyRenderOutput> outputs;
|
||||
QString type;
|
||||
};
|
||||
|
||||
enum KOMPLEX_EXPORT ShaderToyErrorCode
|
||||
{
|
||||
NoError = 0,
|
||||
NetworkError = (0x10 << 24),
|
||||
MediaError = (0x20 << 24),
|
||||
DiskError = (0x30 << 24),
|
||||
CompileError = (0x40 << 24)
|
||||
};
|
||||
|
||||
struct KOMPLEX_EXPORT ShaderToyError
|
||||
{
|
||||
QString message;
|
||||
ShaderToyErrorCode code;
|
||||
};
|
||||
|
||||
struct KOMPLEX_EXPORT ShaderToyEntry
|
||||
{
|
||||
enum Status
|
||||
{
|
||||
Idle,
|
||||
Loading,
|
||||
Compiling,
|
||||
Compiled,
|
||||
Error
|
||||
};
|
||||
|
||||
ShaderToyMetadata metadata;
|
||||
QList<ShaderToyRenderPass> renderPasses;
|
||||
QByteArray data;
|
||||
ShaderToyError error;
|
||||
QStringList videoSelections;
|
||||
Status status = Idle;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ShaderToyEntry)
|
||||
Q_DECLARE_METATYPE(ShaderToyError)
|
||||
#endif // SHADERTOYMETADATA_H
|
||||
@@ -96,7 +96,6 @@ public:
|
||||
auto at(qsizetype index) const -> const T&
|
||||
{
|
||||
QMutexLocker cacheLocker(&m_cacheMutex);
|
||||
T defaultValue;
|
||||
|
||||
if(!externalBoundaryCheck(index))
|
||||
{
|
||||
@@ -203,7 +202,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if(!externalBoundaryCheck(index + count))
|
||||
if(externalBoundaryCheck(index + count))
|
||||
{
|
||||
slideWindow(index);
|
||||
}
|
||||
@@ -589,6 +588,8 @@ private:
|
||||
* Override for window size
|
||||
*/
|
||||
qsizetype m_windowSize = nullsize;
|
||||
|
||||
T defaultValue;
|
||||
};
|
||||
|
||||
#endif // SLIDINGCACHECONTROLLER_H
|
||||
|
||||
Reference in New Issue
Block a user