Debian Codegraph @

src/assets/downloader/assetdownloader.h

raw
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
23 QT_BEGIN_NAMESPACE
24
25 namespace Assets::Downloader {
26
27 class AssetDownloaderPrivate;
28
29 class 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
68 public:
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
89 Q_INVOKABLE QStringList networkErrors() const;
90 Q_INVOKABLE QStringList sslErrors() const;
91
92 public Q_SLOTS:
93 void start();
94
95 protected:
96 virtual QUrl resolvedUrl(const QUrl &url) const;
97
98 Q_SIGNALS:
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);
106 void offlineAssetsFilePathChanged(const QUrl &);
107 void jsonFileNameChanged(const QString &);
108 void zipFileNameChanged(const QString &);
109
110 private:
111 std::unique_ptr<AssetDownloaderPrivate> d;
112 };
113
114 } // namespace Assets::Downloader
115
116 QT_END_NAMESPACE
117
118 #endif // ASSETDOWNLOADER_H