Changeset View
Changeset View
Standalone View
Standalone View
dataengines/potd/unsplashbaseprovider.h
- This file was copied from dataengines/potd/unsplashprovider.h.
Show All 11 Lines | |||||
12 | * GNU General Public License for more details | 12 | * GNU General Public License for more details | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef UNSPLASHPROVIDER_H | 20 | #ifndef UNSPLASHBASEPROVIDER_H | ||
21 | #define UNSPLASHPROVIDER_H | 21 | #define UNSPLASHBASEPROVIDER_H | ||
22 | 22 | | |||
23 | #include "potdprovider.h" | 23 | #include "potdprovider.h" | ||
24 | // Qt | 24 | // Qt | ||
25 | #include <QImage> | 25 | #include <QImage> | ||
26 | 26 | | |||
27 | class KJob; | 27 | class KJob; | ||
28 | 28 | | |||
29 | /** | 29 | /** | ||
30 | * This class provides random wallpapers from Unsplash Wallpapers | 30 | * This class provides random wallpapers from Unsplash Wallpapers Desktop Collection | ||
31 | * Image urls are parsed from https://unsplash.com/wallpaper/1065396/desktop-wallpapers | 31 | * https://unsplash.com/wallpaper/1065396/desktop-wallpapers | ||
32 | * | ||||
33 | * By extending this class and modify mCollection (the number in url), | ||||
34 | * we can get photo wallpaper from any collections | ||||
32 | */ | 35 | */ | ||
33 | class UnsplashProvider : public PotdProvider | 36 | class UnsplashBaseProvider : public PotdProvider | ||
34 | { | 37 | { | ||
35 | Q_OBJECT | 38 | Q_OBJECT | ||
36 | 39 | | |||
37 | public: | 40 | public: | ||
38 | /** | 41 | /** | ||
39 | * Creates a new Unsplash provider. | 42 | * Creates a new Unsplash provider. | ||
40 | * | 43 | * | ||
41 | * @param parent The parent object. | 44 | * @param parent The parent object. | ||
42 | * @param args The arguments. | 45 | * @param args The arguments. | ||
43 | */ | 46 | */ | ||
44 | UnsplashProvider( QObject *parent, const QVariantList &args ); | 47 | UnsplashBaseProvider( const int collectionId, QObject *parent, const QVariantList &args ); | ||
45 | 48 | | |||
46 | /** | 49 | /** | ||
47 | * Destroys the Unsplash provider. | 50 | * Destroys the Unsplash provider. | ||
48 | */ | 51 | */ | ||
49 | ~UnsplashProvider() override; | 52 | ~UnsplashBaseProvider() override; | ||
50 | 53 | | |||
51 | /** | 54 | /** | ||
52 | * Returns the requested image. | 55 | * Returns the requested image. | ||
53 | * | 56 | * | ||
54 | * Note: This method returns only a valid image after the | 57 | * Note: This method returns only a valid image after the | ||
55 | * finished() signal has been emitted. | 58 | * finished() signal has been emitted. | ||
56 | */ | 59 | */ | ||
57 | QImage image() const override; | 60 | QImage image() const override; | ||
58 | 61 | | |||
59 | private: | 62 | private: | ||
60 | void pageRequestFinished(KJob *job); | | |||
61 | void imageRequestFinished(KJob *job); | 63 | void imageRequestFinished(KJob *job); | ||
62 | 64 | | |||
63 | private: | 65 | private: | ||
64 | QImage mImage; | 66 | QImage mImage; | ||
65 | }; | 67 | }; | ||
66 | 68 | | |||
67 | #endif | 69 | #endif |