Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d60cdef637
|
|||
|
97c9ba30f0
|
|||
|
6e94484fac
|
|||
|
1d87abd5af
|
@@ -136,6 +136,7 @@ Rectangle
|
|||||||
viewMoreWallpaperPopup.authorId = packsModel.data(packsModel.index(index,0), NewestPacksModel.AuthorIdRole)
|
viewMoreWallpaperPopup.authorId = packsModel.data(packsModel.index(index,0), NewestPacksModel.AuthorIdRole)
|
||||||
viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole)
|
viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole)
|
||||||
viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole)
|
viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole)
|
||||||
|
viewMoreWallpaperPopup.uuid = packsModel.data(packsModel.index(index,0), NewestPacksModel.UuidRole)
|
||||||
viewMoreWallpaperPopup.opacity = 1
|
viewMoreWallpaperPopup.opacity = 1
|
||||||
popupContainer.opacity = 1
|
popupContainer.opacity = 1
|
||||||
resultsLayout.opacity = 0
|
resultsLayout.opacity = 0
|
||||||
|
|||||||
@@ -702,6 +702,7 @@ Item
|
|||||||
viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole)
|
viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole)
|
||||||
viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole)
|
viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole)
|
||||||
viewMoreWallpaperPopup.name = packsModel.data(packsModel.index(index,0), NewestPacksModel.NameRole)
|
viewMoreWallpaperPopup.name = packsModel.data(packsModel.index(index,0), NewestPacksModel.NameRole)
|
||||||
|
viewMoreWallpaperPopup.uuid = packsModel.data(packsModel.index(index,0), NewestPacksModel.UuidRole)
|
||||||
viewMoreWallpaperPopup.opacity = 1
|
viewMoreWallpaperPopup.opacity = 1
|
||||||
popupContainer.opacity = 1
|
popupContainer.opacity = 1
|
||||||
pageArea.opacity = 0
|
pageArea.opacity = 0
|
||||||
|
|||||||
@@ -51,12 +51,6 @@ Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SquareButton
|
|
||||||
{
|
|
||||||
Layout.preferredWidth: 186
|
|
||||||
Layout.fillHeight: true
|
|
||||||
text: qsTr("Set Wallpaper")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VerticalSpacer {}
|
VerticalSpacer {}
|
||||||
|
|||||||
@@ -304,4 +304,6 @@ Item
|
|||||||
{
|
{
|
||||||
downloadManager.downloadPack(uuid)
|
downloadManager.downloadPack(uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: () => downloadManager.reset()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import KomplexHub
|
|||||||
Item {
|
Item {
|
||||||
property string title: qsTr("Warning")
|
property string title: qsTr("Warning")
|
||||||
property string description: qsTr("Kero noticed there might be an issue")
|
property string description: qsTr("Kero noticed there might be an issue")
|
||||||
property color color: palette.window
|
property color color: "transparent"
|
||||||
|
|
||||||
id: keroWarningAvatarRoot
|
id: keroWarningAvatarRoot
|
||||||
|
|
||||||
|
|||||||
@@ -350,8 +350,9 @@ auto DownloadManager::downloadPack(const QString &id) -> void
|
|||||||
|
|
||||||
QNetworkRequest request(downloadUrl);
|
QNetworkRequest request(downloadUrl);
|
||||||
request.setRawHeader(QByteArray("uuid"), id.toUtf8());
|
request.setRawHeader(QByteArray("uuid"), id.toUtf8());
|
||||||
|
QString tempFile(QString("%1.tar.gz").arg(id));
|
||||||
|
|
||||||
QFuture<QUrl> downloadUri = download(request, id, Post);
|
QFuture<QUrl> downloadUri = download(request, id, Post, tempFile);
|
||||||
|
|
||||||
downloadUri
|
downloadUri
|
||||||
.then
|
.then
|
||||||
@@ -378,31 +379,35 @@ auto DownloadManager::downloadPack(const QString &id) -> void
|
|||||||
)
|
)
|
||||||
.onCanceled
|
.onCanceled
|
||||||
(
|
(
|
||||||
[this]()
|
[this, tempFile]()
|
||||||
{
|
{
|
||||||
|
QFile::remove(QStringLiteral("/tmp/") + tempFile);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.onFailed
|
.onFailed
|
||||||
(
|
(
|
||||||
[this] (const NetworkException &e)
|
[this, tempFile] (const NetworkException &e)
|
||||||
{
|
{
|
||||||
|
QFile::remove(QStringLiteral("/tmp/") + tempFile);
|
||||||
reset();
|
reset();
|
||||||
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
|
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.onFailed
|
.onFailed
|
||||||
(
|
(
|
||||||
[this] (const FileException &e)
|
[this, tempFile] (const FileException &e)
|
||||||
{
|
{
|
||||||
|
QFile::remove(QStringLiteral("/tmp/") + tempFile);
|
||||||
reset();
|
reset();
|
||||||
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
|
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.onFailed
|
.onFailed
|
||||||
(
|
(
|
||||||
[this] ()
|
[this, tempFile] ()
|
||||||
{
|
{
|
||||||
|
QFile::remove(QStringLiteral("/tmp/") + tempFile);
|
||||||
reset();
|
reset();
|
||||||
setError(QStringLiteral("Unknown Exception"), QString());
|
setError(QStringLiteral("Unknown Exception"), QString());
|
||||||
}
|
}
|
||||||
@@ -503,7 +508,7 @@ auto DownloadManager::install(const QUrl &uri) noexcept(false) -> QUrl
|
|||||||
|
|
||||||
QDir tempDirectory(uri.toLocalFile());
|
QDir tempDirectory(uri.toLocalFile());
|
||||||
|
|
||||||
QUrl installLocation = QStringLiteral("%1/.local/share/komplex/packs/%2").arg
|
QUrl installLocation = QStringLiteral("file://%1/.local/share/komplex/packs/%2").arg
|
||||||
(
|
(
|
||||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation),
|
QStandardPaths::writableLocation(QStandardPaths::HomeLocation),
|
||||||
tempDirectory.dirName()
|
tempDirectory.dirName()
|
||||||
@@ -537,24 +542,28 @@ auto DownloadManager::install(const QUrl &uri) noexcept(false) -> QUrl
|
|||||||
return installLocation;
|
return installLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DownloadManager::download(const QNetworkRequest &request, const QString &id, RequestType type) -> QFuture<QUrl>
|
auto DownloadManager::download(const QNetworkRequest &request, const QString &id, RequestType type, const QString &filename) -> QFuture<QUrl>
|
||||||
{
|
{
|
||||||
return QtConcurrent::run
|
return QtConcurrent::run
|
||||||
(
|
(
|
||||||
[this, request, id, type]() -> QUrl
|
[this, request, id, type, _filename = filename]() -> QUrl
|
||||||
{
|
{
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QString filename = id;
|
QString filename = _filename;
|
||||||
|
|
||||||
if(filename.isEmpty())
|
if(filename.isEmpty() && !request.url().fileName().isEmpty())
|
||||||
{
|
{
|
||||||
filename = QUuid::createUuidV7().toString();
|
filename = request.url().fileName();
|
||||||
|
}
|
||||||
|
else if(filename.isEmpty())
|
||||||
|
{
|
||||||
|
filename = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl downloadUri = QStringLiteral("file://%1/%2").arg
|
QUrl downloadUri = QStringLiteral("file://%1/%2").arg
|
||||||
(
|
(
|
||||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
|
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
|
||||||
request.url().fileName()
|
filename
|
||||||
);
|
);
|
||||||
|
|
||||||
auto manager = CoreServices::networkAccessManager().toStrongRef();
|
auto manager = CoreServices::networkAccessManager().toStrongRef();
|
||||||
@@ -624,8 +633,9 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
|
|||||||
reply,
|
reply,
|
||||||
&QNetworkReply::readyRead,
|
&QNetworkReply::readyRead,
|
||||||
this,
|
this,
|
||||||
[this, downloadUri, reply]()
|
[this, downloadUri/*, reply, &downloadFile*/]()
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker(&m_fileMutex);
|
||||||
QFile downloadFile(downloadUri.toLocalFile());
|
QFile downloadFile(downloadUri.toLocalFile());
|
||||||
|
|
||||||
if(!downloadFile.open(QFile::ReadWrite | QFile::Append))
|
if(!downloadFile.open(QFile::ReadWrite | QFile::Append))
|
||||||
@@ -633,8 +643,19 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
|
|||||||
throw FileException(QStringLiteral("Could not open temp file location"));
|
throw FileException(QStringLiteral("Could not open temp file location"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
|
if(reply == nullptr)
|
||||||
|
{
|
||||||
|
throw NetworkException
|
||||||
|
{
|
||||||
|
QStringLiteral("Reply is not a qobject")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
quint64 bytes = reply->bytesAvailable();
|
quint64 bytes = reply->bytesAvailable();
|
||||||
quint64 bytesWritten = downloadFile.write(reply->readAll()/*bytes)*/);
|
QByteArray data = reply->readAll();
|
||||||
|
quint64 bytesWritten = downloadFile.write(data/*bytes)*/);
|
||||||
|
|
||||||
downloadFile.close();
|
downloadFile.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
auto compile(const QUrl &uri) noexcept(false) -> QUrl;
|
auto compile(const QUrl &uri) noexcept(false) -> QUrl;
|
||||||
auto install(const QUrl &uri) noexcept(false) -> QUrl;
|
auto install(const QUrl &uri) noexcept(false) -> QUrl;
|
||||||
auto download(const QNetworkRequest &request, const QString &id, RequestType type = Get) -> QFuture<QUrl>;
|
auto download(const QNetworkRequest &request, const QString &id, RequestType type = Get, const QString &filename = QString()) -> QFuture<QUrl>;
|
||||||
auto readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry;
|
auto readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry;
|
||||||
|
|
||||||
QString m_lastInstalledFile;
|
QString m_lastInstalledFile;
|
||||||
@@ -159,6 +159,7 @@ private:
|
|||||||
State m_state;
|
State m_state;
|
||||||
|
|
||||||
QMutex m_downloadMutex;
|
QMutex m_downloadMutex;
|
||||||
|
QMutex m_fileMutex;
|
||||||
|
|
||||||
PackCompiler *m_compiler = nullptr;
|
PackCompiler *m_compiler = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -60,29 +60,22 @@ auto PackCompiler::process(const QUrl &uri) -> QFuture<QUrl>
|
|||||||
setStatus(QStringLiteral("Compiling %1").arg(uri.fileName()));
|
setStatus(QStringLiteral("Compiling %1").arg(uri.fileName()));
|
||||||
setState(Compiling);
|
setState(Compiling);
|
||||||
|
|
||||||
if(!validateDirectory(uri))
|
// this was a leftover from ThumbnailGenerator
|
||||||
{
|
// if(!validateDirectory(uri))
|
||||||
throw FileException
|
// {
|
||||||
(
|
// throw FileException
|
||||||
QStringLiteral("Source directory is invalid")
|
// (
|
||||||
);
|
// QStringLiteral("Source directory is invalid")
|
||||||
}
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
QUrl buildUri
|
QFileInfo info(uri.toLocalFile());
|
||||||
(
|
|
||||||
QStringLiteral("file://%1/komplex/build/%2").arg
|
QUrl buildUri;
|
||||||
(
|
|
||||||
QStandardPaths::writableLocation
|
|
||||||
(
|
|
||||||
QStandardPaths::TempLocation
|
|
||||||
),
|
|
||||||
uri.fileName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
extract(uri, buildUri);
|
buildUri = extract(uri);
|
||||||
prepareShaders(buildUri);
|
prepareShaders(buildUri);
|
||||||
compile(buildUri);
|
compile(buildUri);
|
||||||
}
|
}
|
||||||
@@ -98,6 +91,10 @@ auto PackCompiler::process(const QUrl &uri) -> QFuture<QUrl>
|
|||||||
setError(QStringLiteral("Compiler Error"), e.message);
|
setError(QStringLiteral("Compiler Error"), e.message);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
removeDirectory(buildUri);
|
||||||
|
}
|
||||||
|
|
||||||
return buildUri;
|
return buildUri;
|
||||||
}
|
}
|
||||||
@@ -457,18 +454,89 @@ auto PackCompiler::validateDirectory(const QUrl &uri) -> bool
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PackCompiler::extract(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void
|
auto PackCompiler::createDirectory(const QUrl &uri) -> void
|
||||||
|
{
|
||||||
|
if(!uri.isLocalFile() || !uri.isValid())
|
||||||
|
{
|
||||||
|
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList arguments =
|
||||||
|
{
|
||||||
|
QStringLiteral("-p"),
|
||||||
|
uri.toLocalFile()
|
||||||
|
};
|
||||||
|
|
||||||
|
QProcess *process = new QProcess(this);
|
||||||
|
|
||||||
|
QObject::connect
|
||||||
|
(
|
||||||
|
process,
|
||||||
|
&QProcess::readyReadStandardOutput,
|
||||||
|
this,
|
||||||
|
[this, process]()
|
||||||
|
{
|
||||||
|
QByteArray processData = process->readAllStandardOutput();
|
||||||
|
setCompilerOutput(m_compilerOutput + processData);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect
|
||||||
|
(
|
||||||
|
process,
|
||||||
|
&QProcess::readyReadStandardError,
|
||||||
|
this,
|
||||||
|
[this, process]()
|
||||||
|
{
|
||||||
|
QByteArray processData = process->readAllStandardError();
|
||||||
|
|
||||||
|
if(!processData.isValidUtf8())
|
||||||
|
{
|
||||||
|
qWarning() << QStringLiteral("Process output not valid UTF8 data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCompilerOutput(m_compilerOutput + processData);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
process->start(QStringLiteral("mkdir"), arguments);
|
||||||
|
|
||||||
|
if(!process->waitForStarted(3000))
|
||||||
|
{
|
||||||
|
process->deleteLater();
|
||||||
|
throw FileException(QStringLiteral("Could not start preprocessor"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!process->waitForFinished())
|
||||||
|
{
|
||||||
|
process->deleteLater();
|
||||||
|
throw FileException(QStringLiteral("Preprocessor timeout"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(process->exitCode() != 0)
|
||||||
|
{
|
||||||
|
process->deleteLater();
|
||||||
|
throw ShaderCompilerException(m_compilerOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
process->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto PackCompiler::extract(const QUrl &sourceUri) noexcept(false) -> QUrl
|
||||||
{
|
{
|
||||||
if(!sourceUri.isLocalFile() || !sourceUri.isValid())
|
if(!sourceUri.isLocalFile() || !sourceUri.isValid())
|
||||||
{
|
{
|
||||||
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
|
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFileInfo info(sourceUri.toLocalFile());
|
||||||
|
|
||||||
QUrl outputUri
|
QUrl outputUri
|
||||||
(
|
(
|
||||||
QStringLiteral("file://%1_proc").arg
|
QStringLiteral("file:///tmp/%1").arg
|
||||||
(
|
(
|
||||||
sourceUri.toLocalFile()
|
info.baseName()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -480,6 +548,13 @@ auto PackCompiler::extract(const QUrl &sourceUri, const QUrl &destinationUri) no
|
|||||||
outputUri.toLocalFile()
|
outputUri.toLocalFile()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QDir outputDir(outputUri.toLocalFile());
|
||||||
|
|
||||||
|
if(!outputDir.exists())
|
||||||
|
{
|
||||||
|
createDirectory(outputUri);
|
||||||
|
}
|
||||||
|
|
||||||
QProcess *process = new QProcess(this);
|
QProcess *process = new QProcess(this);
|
||||||
|
|
||||||
QObject::connect
|
QObject::connect
|
||||||
@@ -534,6 +609,10 @@ auto PackCompiler::extract(const QUrl &sourceUri, const QUrl &destinationUri) no
|
|||||||
}
|
}
|
||||||
|
|
||||||
process->deleteLater();
|
process->deleteLater();
|
||||||
|
|
||||||
|
QFile::remove(sourceUri.toLocalFile());
|
||||||
|
|
||||||
|
return outputUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PackCompiler::copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void
|
auto PackCompiler::copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ protected:
|
|||||||
*/
|
*/
|
||||||
auto validateDirectory(const QUrl &uri) -> bool;
|
auto validateDirectory(const QUrl &uri) -> bool;
|
||||||
|
|
||||||
auto extract(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void;
|
auto createDirectory(const QUrl &uri) -> void;
|
||||||
|
|
||||||
|
auto extract(const QUrl &sourceUri) noexcept(false) -> QUrl;
|
||||||
auto copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void;
|
auto copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void;
|
||||||
auto compile(const QUrl &uri) noexcept(false) -> void;
|
auto compile(const QUrl &uri) noexcept(false) -> void;
|
||||||
auto preprocess(const QUrl &uri) noexcept(false) -> void;
|
auto preprocess(const QUrl &uri) noexcept(false) -> void;
|
||||||
|
|||||||
Reference in New Issue
Block a user