Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/image.h
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright 2007 Paolo Capriotti <p.capriotti@gmail.com> * | 2 | * Copyright 2007 Paolo Capriotti <p.capriotti@gmail.com> * | ||
3 | * Copyright 2008 by Petri Damsten <damu@iki.fi> * | 3 | * Copyright 2008 by Petri Damsten <damu@iki.fi> * | ||
4 | * Copyright 2014 Sebastian Kügler <sebas@kde.org> * | 4 | * Copyright 2014 Sebastian Kügler <sebas@kde.org> * | ||
5 | * Copyright 2015 Kai Uwe Broulik <kde@privat.broulik.de> * | 5 | * Copyright 2015 Kai Uwe Broulik <kde@privat.broulik.de> * | ||
6 | * Copyright 2019 David Redondo <kde@david-redondo.de> * | ||||
6 | * * | 7 | * * | ||
7 | * This program is free software; you can redistribute it and/or modify * | 8 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | 9 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | 10 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | 11 | * (at your option) any later version. * | ||
11 | * * | 12 | * * | ||
12 | * This program is distributed in the hope that it will be useful, * | 13 | * This program is distributed in the hope that it will be useful, * | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
15 | * GNU General Public License for more details. * | 16 | * GNU General Public License for more details. * | ||
16 | * * | 17 | * * | ||
17 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
18 | * along with this program; if not, write to the * | 19 | * along with this program; if not, write to the * | ||
19 | * Free Software Foundation, Inc., * | 20 | * Free Software Foundation, Inc., * | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
21 | ***************************************************************************/ | 22 | ***************************************************************************/ | ||
22 | 23 | | |||
23 | 24 | | |||
24 | #ifndef IMAGE_HEADER | 25 | #ifndef IMAGE_HEADER | ||
25 | #define IMAGE_HEADER | 26 | #define IMAGE_HEADER | ||
26 | 27 | | |||
28 | | ||||
27 | #include <QTimer> | 29 | #include <QTimer> | ||
28 | #include <QPixmap> | 30 | #include <QPixmap> | ||
29 | #include <QStringList> | 31 | #include <QStringList> | ||
30 | #include <QObject> | 32 | #include <QObject> | ||
31 | #include <QPersistentModelIndex> | 33 | #include <QPersistentModelIndex> | ||
32 | #include <QDateTime> | 34 | #include <QDateTime> | ||
33 | #include <QPointer> | 35 | #include <QPointer> | ||
34 | #include <QQmlParserStatus> | 36 | #include <QQmlParserStatus> | ||
35 | 37 | | |||
36 | #include <KPackage/Package> | 38 | #include <KPackage/Package> | ||
37 | 39 | | |||
38 | 40 | | |||
39 | class QFileDialog; | 41 | class QFileDialog; | ||
40 | class QQuickItem; | 42 | class QQuickItem; | ||
41 | 43 | | |||
42 | class KDirWatch; | 44 | class KDirWatch; | ||
43 | class KJob; | 45 | class KJob; | ||
44 | 46 | | |||
45 | namespace KNS3 { | 47 | namespace KNS3 { | ||
46 | class DownloadDialog; | 48 | class DownloadDialog; | ||
47 | } | 49 | } | ||
48 | 50 | | |||
49 | class BackgroundListModel; | 51 | class BackgroundListModel; | ||
50 | class SlideModel; | 52 | class SlideModel; | ||
53 | class SlideFilterModel; | ||||
51 | 54 | | |||
52 | class Image : public QObject, public QQmlParserStatus | 55 | class Image : public QObject, public QQmlParserStatus | ||
53 | { | 56 | { | ||
54 | Q_OBJECT | 57 | Q_OBJECT | ||
55 | Q_INTERFACES(QQmlParserStatus) | 58 | Q_INTERFACES(QQmlParserStatus) | ||
56 | 59 | | |||
57 | Q_PROPERTY(RenderingMode renderingMode READ renderingMode WRITE setRenderingMode NOTIFY renderingModeChanged) | 60 | Q_PROPERTY(RenderingMode renderingMode READ renderingMode WRITE setRenderingMode NOTIFY renderingModeChanged) | ||
61 | Q_PROPERTY(SlideshowMode slideshowMode READ slideshowMode WRITE setSlideshowMode NOTIFY slideshowModeChanged) | ||||
58 | Q_PROPERTY(QUrl wallpaperPath READ wallpaperPath NOTIFY wallpaperPathChanged) | 62 | Q_PROPERTY(QUrl wallpaperPath READ wallpaperPath NOTIFY wallpaperPathChanged) | ||
59 | Q_PROPERTY(QAbstractItemModel *wallpaperModel READ wallpaperModel CONSTANT) | 63 | Q_PROPERTY(QAbstractItemModel *wallpaperModel READ wallpaperModel CONSTANT) | ||
60 | Q_PROPERTY(QAbstractItemModel *slideshowModel READ slideshowModel CONSTANT) | 64 | Q_PROPERTY(QAbstractItemModel *slideFilterModel READ slideFilterModel CONSTANT) | ||
61 | Q_PROPERTY(int slideTimer READ slideTimer WRITE setSlideTimer NOTIFY slideTimerChanged) | 65 | Q_PROPERTY(int slideTimer READ slideTimer WRITE setSlideTimer NOTIFY slideTimerChanged) | ||
62 | Q_PROPERTY(QStringList usersWallpapers READ usersWallpapers WRITE setUsersWallpapers NOTIFY usersWallpapersChanged) | 66 | Q_PROPERTY(QStringList usersWallpapers READ usersWallpapers WRITE setUsersWallpapers NOTIFY usersWallpapersChanged) | ||
63 | Q_PROPERTY(QStringList slidePaths READ slidePaths WRITE setSlidePaths NOTIFY slidePathsChanged) | 67 | Q_PROPERTY(QStringList slidePaths READ slidePaths WRITE setSlidePaths NOTIFY slidePathsChanged) | ||
64 | Q_PROPERTY(QSize targetSize READ targetSize WRITE setTargetSize NOTIFY targetSizeChanged) | 68 | Q_PROPERTY(QSize targetSize READ targetSize WRITE setTargetSize NOTIFY targetSizeChanged) | ||
65 | Q_PROPERTY(QString photosPath READ photosPath CONSTANT) | 69 | Q_PROPERTY(QString photosPath READ photosPath CONSTANT) | ||
66 | Q_PROPERTY(QStringList uncheckedSlides READ uncheckedSlides WRITE setUncheckedSlides NOTIFY uncheckedSlidesChanged) | 70 | Q_PROPERTY(QStringList uncheckedSlides READ uncheckedSlides WRITE setUncheckedSlides NOTIFY uncheckedSlidesChanged) | ||
67 | 71 | | |||
68 | public: | 72 | public: | ||
69 | 73 | | |||
70 | enum RenderingMode { | 74 | enum RenderingMode { | ||
71 | SingleImage, | 75 | SingleImage, | ||
72 | SlideShow | 76 | SlideShow | ||
73 | }; | 77 | }; | ||
74 | Q_ENUM(RenderingMode) | 78 | Q_ENUM(RenderingMode) | ||
75 | 79 | | |||
80 | enum SlideshowMode { | ||||
81 | Random, | ||||
82 | Alphabetical, | ||||
83 | AlphabeticalReversed, | ||||
84 | Modified, | ||||
85 | ModifiedReversed | ||||
86 | }; | ||||
87 | Q_ENUM(SlideshowMode) | ||||
88 | | ||||
76 | explicit Image(QObject* parent = nullptr); | 89 | explicit Image(QObject* parent = nullptr); | ||
77 | ~Image() override; | 90 | ~Image() override; | ||
78 | 91 | | |||
79 | QUrl wallpaperPath() const; | 92 | QUrl wallpaperPath() const; | ||
80 | 93 | | |||
81 | //this is for QML use | 94 | //this is for QML use | ||
82 | Q_INVOKABLE void addUrl(const QString &url); | 95 | Q_INVOKABLE void addUrl(const QString &url); | ||
83 | Q_INVOKABLE void addUrls(const QStringList &urls); | 96 | Q_INVOKABLE void addUrls(const QStringList &urls); | ||
84 | 97 | | |||
85 | Q_INVOKABLE void addSlidePath(const QString &path); | 98 | Q_INVOKABLE void addSlidePath(const QString &path); | ||
86 | Q_INVOKABLE void removeSlidePath(const QString &path); | 99 | Q_INVOKABLE void removeSlidePath(const QString &path); | ||
87 | Q_INVOKABLE void openFolder(const QString& path); | 100 | Q_INVOKABLE void openFolder(const QString& path); | ||
88 | 101 | | |||
89 | Q_INVOKABLE void getNewWallpaper(QQuickItem *ctx = nullptr); | 102 | Q_INVOKABLE void getNewWallpaper(QQuickItem *ctx = nullptr); | ||
90 | Q_INVOKABLE void showFileDialog(); | 103 | Q_INVOKABLE void showFileDialog(); | ||
91 | 104 | | |||
92 | Q_INVOKABLE void addUsersWallpaper(const QString &file); | 105 | Q_INVOKABLE void addUsersWallpaper(const QString &file); | ||
93 | Q_INVOKABLE void commitDeletion(); | 106 | Q_INVOKABLE void commitDeletion(); | ||
94 | 107 | | |||
95 | Q_INVOKABLE void toggleSlide(const QString &path, bool checked); | 108 | Q_INVOKABLE void toggleSlide(const QString &path, bool checked); | ||
96 | 109 | | |||
97 | RenderingMode renderingMode() const; | 110 | RenderingMode renderingMode() const; | ||
98 | void setRenderingMode(RenderingMode mode); | 111 | void setRenderingMode(RenderingMode mode); | ||
99 | 112 | | |||
113 | SlideshowMode slideshowMode() const; | ||||
114 | void setSlideshowMode(SlideshowMode mode); | ||||
115 | | ||||
100 | QSize targetSize() const; | 116 | QSize targetSize() const; | ||
101 | void setTargetSize(const QSize &size); | 117 | void setTargetSize(const QSize &size); | ||
102 | 118 | | |||
103 | KPackage::Package *package(); | 119 | KPackage::Package *package(); | ||
104 | 120 | | |||
105 | QAbstractItemModel* wallpaperModel(); | 121 | QAbstractItemModel* wallpaperModel(); | ||
106 | QAbstractItemModel* slideshowModel(); | 122 | QAbstractItemModel* slideFilterModel(); | ||
107 | 123 | | |||
108 | int slideTimer() const; | 124 | int slideTimer() const; | ||
109 | void setSlideTimer(int time); | 125 | void setSlideTimer(int time); | ||
110 | 126 | | |||
111 | QStringList usersWallpapers() const; | 127 | QStringList usersWallpapers() const; | ||
112 | void setUsersWallpapers(const QStringList &usersWallpapers); | 128 | void setUsersWallpapers(const QStringList &usersWallpapers); | ||
113 | 129 | | |||
114 | QStringList slidePaths() const; | 130 | QStringList slidePaths() const; | ||
Show All 13 Lines | |||||
128 | public Q_SLOTS: | 144 | public Q_SLOTS: | ||
129 | void nextSlide(); | 145 | void nextSlide(); | ||
130 | void removeWallpaper(QString name); | 146 | void removeWallpaper(QString name); | ||
131 | 147 | | |||
132 | Q_SIGNALS: | 148 | Q_SIGNALS: | ||
133 | void settingsChanged(bool); | 149 | void settingsChanged(bool); | ||
134 | void wallpaperPathChanged(); | 150 | void wallpaperPathChanged(); | ||
135 | void renderingModeChanged(); | 151 | void renderingModeChanged(); | ||
152 | void slideshowModeChanged(); | ||||
136 | void targetSizeChanged(); | 153 | void targetSizeChanged(); | ||
137 | void slideTimerChanged(); | 154 | void slideTimerChanged(); | ||
138 | void usersWallpapersChanged(); | 155 | void usersWallpapersChanged(); | ||
139 | void slidePathsChanged(); | 156 | void slidePathsChanged(); | ||
140 | void resizeMethodChanged(); | 157 | void resizeMethodChanged(); | ||
141 | void customWallpaperPicked(const QString &path); | 158 | void customWallpaperPicked(const QString &path); | ||
142 | void uncheckedSlidesChanged(); | 159 | void uncheckedSlidesChanged(); | ||
143 | 160 | | |||
Show All 12 Lines | 161 | protected Q_SLOTS: | |||
156 | void setWallpaperRetrieved(KJob *job); | 173 | void setWallpaperRetrieved(KJob *job); | ||
157 | void addWallpaperRetrieved(KJob *job); | 174 | void addWallpaperRetrieved(KJob *job); | ||
158 | void newStuffFinished(); | 175 | void newStuffFinished(); | ||
159 | void updateDirWatch(const QStringList &newDirs); | 176 | void updateDirWatch(const QStringList &newDirs); | ||
160 | void addDirFromSelectionDialog(); | 177 | void addDirFromSelectionDialog(); | ||
161 | void pathCreated(const QString &path); | 178 | void pathCreated(const QString &path); | ||
162 | void pathDeleted(const QString &path); | 179 | void pathDeleted(const QString &path); | ||
163 | void pathDirty(const QString &path); | 180 | void pathDirty(const QString &path); | ||
164 | void backgroundsFound(const QStringList &paths, const QString &token); | 181 | void backgroundsFound(); | ||
165 | 182 | | |||
166 | protected: | 183 | protected: | ||
167 | void syncWallpaperPackage(); | 184 | void syncWallpaperPackage(); | ||
168 | void setSingleImage(); | 185 | void setSingleImage(); | ||
169 | void useSingleImageDefaults(); | 186 | void useSingleImageDefaults(); | ||
170 | 187 | | |||
171 | private: | 188 | private: | ||
172 | | ||||
173 | bool m_ready; | 189 | bool m_ready; | ||
174 | int m_delay; | 190 | int m_delay; | ||
175 | QStringList m_dirs; | 191 | QStringList m_dirs; | ||
176 | QString m_wallpaper; | 192 | QString m_wallpaper; | ||
177 | QString m_wallpaperPath; | 193 | QString m_wallpaperPath; | ||
178 | QStringList m_usersWallpapers; | 194 | QStringList m_usersWallpapers; | ||
179 | KDirWatch *m_dirWatch; | 195 | KDirWatch *m_dirWatch; | ||
180 | bool m_scanDirty; | 196 | bool m_scanDirty; | ||
181 | QSize m_targetSize; | 197 | QSize m_targetSize; | ||
182 | 198 | | |||
183 | RenderingMode m_mode; | 199 | RenderingMode m_mode; | ||
200 | SlideshowMode m_slideshowMode; | ||||
201 | | ||||
184 | KPackage::Package m_wallpaperPackage; | 202 | KPackage::Package m_wallpaperPackage; | ||
185 | QStringList m_slideshowBackgrounds; | | |||
186 | QStringList m_unseenSlideshowBackgrounds; | | |||
187 | QStringList m_slidePaths; | 203 | QStringList m_slidePaths; | ||
188 | QStringList m_uncheckedSlides; | 204 | QStringList m_uncheckedSlides; | ||
189 | QTimer m_timer; | 205 | QTimer m_timer; | ||
190 | int m_currentSlide; | 206 | int m_currentSlide; | ||
191 | BackgroundListModel *m_model; | 207 | BackgroundListModel *m_model; | ||
192 | SlideModel* m_slideshowModel; | 208 | SlideModel* m_slideshowModel; | ||
209 | SlideFilterModel* m_slideFilterModel; | ||||
193 | QFileDialog *m_dialog; | 210 | QFileDialog *m_dialog; | ||
194 | QString m_img; | 211 | QString m_img; | ||
195 | QDateTime m_previousModified; | 212 | QDateTime m_previousModified; | ||
196 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | 213 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | ||
197 | QString m_findToken; | 214 | QString m_findToken; | ||
198 | }; | 215 | }; | ||
199 | 216 | | |||
200 | #endif | 217 | #endif |