File indexing completed on 2025-09-21 05:08:09
0001 // SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org> 0002 // SPDX-FileCopyrightText: 2021 Guo Yunhe <i@guoyunhe.me> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #pragma once 0006 0007 #include <QImage> 0008 #include <QUrl> 0009 #include <QVariantList> 0010 0011 #include <KPluginMetaData> 0012 0013 #include "plasma_potd_export.h" 0014 0015 class QDate; 0016 0017 class PotdProviderPrivate; 0018 0019 /** 0020 * This class is an interface for PoTD providers. 0021 */ 0022 class PLASMA_POTD_EXPORT PotdProvider : public QObject 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /** 0028 * Creates a new PoTD provider. 0029 * 0030 * @param parent The parent object. 0031 * @param data The metadata of the plugin 0032 * @param args The arguments. 0033 * @since 5.25 0034 */ 0035 explicit PotdProvider(QObject *parent, const KPluginMetaData &data, const QVariantList &args); 0036 0037 /** 0038 * Destroys the PoTD provider. 0039 */ 0040 virtual ~PotdProvider() override; 0041 0042 /** 0043 * Returns the local path of the requested image. 0044 * 0045 * Note: This method returns only a valid path after the 0046 * finished() signal has been emitted. 0047 */ 0048 virtual QString localPath() const; 0049 0050 /** 0051 * Returns the identifier of the PoTD request (name + date). 0052 */ 0053 virtual QString identifier() const; 0054 0055 /** 0056 * Returns the remote URL of the image from the provider 0057 * 0058 * @note No @c virtual to keep binary compatibility. 0059 * @return the remote URL of the image, if any 0060 * @since 5.25 0061 */ 0062 QUrl remoteUrl() const; 0063 0064 /** 0065 * Returns the information URL of the image from the provider 0066 * 0067 * @return the information URL of the image, if any 0068 * @since 5.25 0069 */ 0070 QUrl infoUrl() const; 0071 0072 /** 0073 * Returns the title of the image from the provider, if any. 0074 * 0075 * @return the title of the image, if any 0076 * @since 5.25 0077 */ 0078 QString title() const; 0079 0080 /** 0081 * Returns the author of the image from the provider 0082 * 0083 * @return the title of the image, if any 0084 * @since 5.25 0085 */ 0086 QString author() const; 0087 0088 /** 0089 * @return the name of this provider (equiv to X-KDE-PlasmaPoTDProvider-Identifier) 0090 */ 0091 QString name() const; 0092 0093 Q_SIGNALS: 0094 /** 0095 * This signal is emitted whenever a request has been finished 0096 * successfully. 0097 * 0098 * @param provider The provider which emitted the signal. 0099 * @param image The image from the provider. 0100 */ 0101 void finished(PotdProvider *provider, const QImage &image); 0102 0103 /** 0104 * This signal is emitted whenever an error has occurred. 0105 * 0106 * @param provider The provider which emitted the signal. 0107 */ 0108 void error(PotdProvider *provider); 0109 0110 protected: 0111 QUrl m_remoteUrl; 0112 QUrl m_infoUrl; 0113 QString m_title; 0114 QString m_author; 0115 0116 private: 0117 std::unique_ptr<PotdProviderPrivate> d; 0118 };