File indexing completed on 2024-12-15 04:00:58
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #ifndef GLAXNIMATE_ANDROID_ANDROIDFILEPICKER_HPP 0008 #define GLAXNIMATE_ANDROID_ANDROIDFILEPICKER_HPP 0009 0010 #include <memory> 0011 #include <QUrl> 0012 #include <QObject> 0013 0014 namespace glaxnimate::android { 0015 0016 class AndroidFilePicker : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 AndroidFilePicker(QObject *parent = nullptr); 0021 ~AndroidFilePicker(); 0022 0023 bool select_open(bool is_import); 0024 bool select_save(const QString& suggested_name, bool is_export, const QString &mime = "*/*"); 0025 bool open_external(const QUrl& uri, const QString& mime); 0026 0027 static QByteArray read_content_uri(const QUrl& url); 0028 static bool write_content_uri(const QUrl& url, const QByteArray& data); 0029 static std::vector<QString> list_assets(const QString& path = ""); 0030 0031 bool get_permissions(const QStringList & perms = { 0032 "android.permission.WRITE_EXTERNAL_STORAGE", 0033 "android.permission.READ_EXTERNAL_STORAGE" 0034 }); 0035 0036 Q_SIGNALS: 0037 void open_selected(const QUrl& path, bool is_import); 0038 void save_selected(const QUrl& path, bool is_export); 0039 0040 private: 0041 class Private; 0042 std::unique_ptr<Private> d; 0043 }; 0044 0045 } // namespace glaxnimate::android 0046 0047 #endif // GLAXNIMATE_ANDROID_ANDROIDFILEPICKER_HPP