mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-07-03 07:05:26 +02:00
42 lines
1.4 KiB
C
42 lines
1.4 KiB
C
![]() |
/*
|
||
|
* Copyright (C) 2023 Savoir-faire Linux Inc.
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include "networkmanager.h"
|
||
|
#include "qtutils.h"
|
||
|
|
||
|
class ImageDownloader : public NetworkManager
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
QML_PROPERTY(QString, cachePath)
|
||
|
|
||
|
public:
|
||
|
explicit ImageDownloader(ConnectivityMonitor* cm, QObject* parent = nullptr);
|
||
|
|
||
|
// Download an image and call onDownloadImageFinished when done
|
||
|
Q_INVOKABLE void downloadImage(const QUrl& url, const QString& localPath);
|
||
|
|
||
|
Q_SIGNALS:
|
||
|
void downloadImageSuccessful(const QString& localPath);
|
||
|
void downloadImageFailed(const QString& localPath);
|
||
|
|
||
|
private Q_SLOTS:
|
||
|
// Saves the image to the localPath and emits the appropriate signal
|
||
|
void onDownloadImageFinished(const QByteArray& reply, const QString& localPath);
|
||
|
};
|