Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
assetdownloader.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef ASSETDOWNLOADER_H
5#define ASSETDOWNLOADER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QObject>
19#include <QtCore/QUrl>
20
21#include <memory>
22
23QT_BEGIN_NAMESPACE
24
25namespace Assets::Downloader {
26
28
30{
31 Q_OBJECT
32
33 Q_PROPERTY(
34 QUrl downloadBase
35 READ downloadBase
36 WRITE setDownloadBase
37 NOTIFY downloadBaseChanged)
38
44
50
56
62
67
68public:
69 AssetDownloader(QObject *parent = nullptr);
71
72 QUrl downloadBase() const;
73 void setDownloadBase(const QUrl &downloadBase);
74
76 void setPreferredLocalDownloadDir(const QUrl &localDir);
77
79 void setOfflineAssetsFilePath(const QUrl &offlineAssetsFilePath);
80
81 QString jsonFileName() const;
82 void setJsonFileName(const QString &jsonFileName);
83
84 QString zipFileName() const;
85 void setZipFileName(const QString &zipFileName);
86
87 QUrl localDownloadDir() const;
88
89 Q_INVOKABLE QStringList networkErrors() const;
91
92public Q_SLOTS:
93 void start();
94
95protected:
96 virtual QUrl resolvedUrl(const QUrl &url) const;
97
99 void started();
100 void finished(bool success);
101 void progressChanged(int progressValue, int progressMaximum, const QString &progressText);
102 void localDownloadDirChanged(const QUrl &url);
103
104 void downloadBaseChanged(const QUrl &);
105 void preferredLocalDownloadDirChanged(const QUrl &url);
107 void jsonFileNameChanged(const QString &);
108 void zipFileNameChanged(const QString &);
109
110private:
111 std::unique_ptr<AssetDownloaderPrivate> d;
112};
113
114} // namespace Assets::Downloader
115
116QT_END_NAMESPACE
117
118#endif // ASSETDOWNLOADER_H
void setupDownload(NetworkQuery *query, const QString &progressText)
void setProgress(int progressValue, int progressMaximum, const QString &progressText)
void clearProgress(const QString &progressText)
void updateProgress(int progressValue, int progressMaximum)
std::unique_ptr< QNetworkAccessManager > m_manager
std::unique_ptr< QTemporaryDir > m_temporaryDir
void progressChanged(int progressValue, int progressMaximum, const QString &progressText)
void localDownloadDirChanged(const QUrl &url)
void setOfflineAssetsFilePath(const QUrl &offlineAssetsFilePath)
virtual QUrl resolvedUrl(const QUrl &url) const
void setJsonFileName(const QString &jsonFileName)
void jsonFileNameChanged(const QString &)
void downloadBaseChanged(const QUrl &)
void setPreferredLocalDownloadDir(const QUrl &localDir)
void offlineAssetsFilePathChanged(const QUrl &)
void setDownloadBase(const QUrl &downloadBase)
void setZipFileName(const QString &zipFileName)
void zipFileNameChanged(const QString &)
void preferredLocalDownloadDirChanged(const QUrl &url)
static void unzip(QPromise< void > &promise, const QByteArray &content, const QDir &directory, const QString &fileName)
static bool sameFileContent(const QFileInfo &first, const QFileInfo &second)
static void writeAsset(QPromise< void > &promise, const QByteArray &content, const QString &filePath)
static void precheckLocalFile(const QUrl &url)
static QDir baseLocalDir(const QDir &preferredLocalDir)
static QString pathFromUrl(const QUrl &url)
static bool allAssetsPresent(const QList< QUrl > &assetFiles, const QDir &expectedDir)
static void copyAndCheck(QPromise< void > &promise, const QString &sourcePath, const QString &destPath)
static bool canBeALocalBaseDir(const QDir &dir)
static QList< QUrl > filterDownloadableAssets(const QList< QUrl > &assetFiles, const QDir &expectedDir)
static void readAssetsFileContent(QPromise< DownloadableAssets > &promise, const QByteArray &content)
static bool createDirectory(const QDir &dir)
static bool isWritableDir(const QDir &dir)