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
27class AssetDownloaderPrivate;
28
29class AssetDownloader : public QObject
30{
31 Q_OBJECT
32
33 Q_PROPERTY(
34 QUrl downloadBase
35 READ downloadBase
36 WRITE setDownloadBase
37 NOTIFY downloadBaseChanged)
38
39 Q_PROPERTY(
40 QUrl preferredLocalDownloadDir
41 READ preferredLocalDownloadDir
42 WRITE setPreferredLocalDownloadDir
43 NOTIFY preferredLocalDownloadDirChanged)
44
45 Q_PROPERTY(
46 QUrl offlineAssetsFilePath
47 READ offlineAssetsFilePath
48 WRITE setOfflineAssetsFilePath
49 NOTIFY offlineAssetsFilePathChanged)
50
51 Q_PROPERTY(
52 QString jsonFileName
53 READ jsonFileName
54 WRITE setJsonFileName
55 NOTIFY jsonFileNameChanged)
56
57 Q_PROPERTY(
58 QString zipFileName
59 READ zipFileName
60 WRITE setZipFileName
61 NOTIFY zipFileNameChanged)
62
63 Q_PROPERTY(
64 QUrl localDownloadDir
65 READ localDownloadDir
66 NOTIFY localDownloadDirChanged)
67
68public:
69 AssetDownloader(QObject *parent = nullptr);
70 ~AssetDownloader();
71
72 QUrl downloadBase() const;
73 void setDownloadBase(const QUrl &downloadBase);
74
75 QUrl preferredLocalDownloadDir() const;
76 void setPreferredLocalDownloadDir(const QUrl &localDir);
77
78 QUrl offlineAssetsFilePath() const;
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
89public Q_SLOTS:
90 void start();
91
92protected:
93 virtual QUrl resolvedUrl(const QUrl &url) const;
94
95Q_SIGNALS:
96 void started();
97 void finished(bool success);
98 void progressChanged(int progressValue, int progressMaximum, const QString &progressText);
99 void localDownloadDirChanged(const QUrl &url);
100
101 void downloadBaseChanged(const QUrl &);
102 void preferredLocalDownloadDirChanged(const QUrl &url);
103 void offlineAssetsFilePathChanged(const QUrl &);
104 void jsonFileNameChanged(const QString &);
105 void zipFileNameChanged(const QString &);
106
107private:
108 std::unique_ptr<AssetDownloaderPrivate> d;
109};
110
111} // namespace Assets::Downloader
112
113QT_END_NAMESPACE
114
115#endif // ASSETDOWNLOADER_H
116

source code of qtbase/src/assets/downloader/assetdownloader.h