~ubuntu-branches/ubuntu/quantal/kde4libs/quantal

« back to all changes in this revision

Viewing changes to debian/patches/kubuntu_KIO-PreviewJob-Respect-the-enabled-plugins-from-Prev.diff

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Philip Muškovac, Jonathan Thomas, Felix Geyer
  • Date: 2011-05-29 17:19:55 UTC
  • mfrom: (1.14.5 upstream) (0.1.19 sid)
  • Revision ID: package-import@ubuntu.com-20110529171955-nodep1593tuwyu6k
Tags: 4:4.6.3-1ubuntu1
[ Philip Muškovac]
* Drop kubuntu_83_fix_solid_network_status.diff
* Update Vcs links as the branch is owned by kubuntu-packagers now

[ Jonathan Thomas ]
* Drop kubuntu_06_user_disk_mounting. We no longer compile the hal
  backend, so this patch is useless.

[ Felix Geyer ]
* Merge from Debian unstable, remaining changes:
  - no build-dep on libaspell-dev
  - no build-dep on libfam-dev
  - kdelibs5-data: don't install kspell_aspell.desktop and
    usr/lib/kde4/kspell_aspell.so
  - kdelibs5-dev: don't install preparetips
  - Pass -DKDESU_USE_SUDO_DEFAULT=true to configure
  - dh_fixperms: exclude /usr/lib/kde4/libexec/fileshareset
  - set export KUBUNTU_DESKTOP_POT=kdelibs
  - don't apply use_dejavu_as_default_font.diff
  - don't apply kconf_update_migrate_from_kde3_icon_theme.diff
    - kdelibs5-data.install: drop usr/share/kde4/apps/kconf_update/kdeui.upd
  - don't build depend on libglu1-mesa-dev, not needed due to
    kubuntu_no_direct_gl_usage.diff
  - Add kdelibs5-data.links: link from /usr/share/doc/kde4 to kde for
    backwards compatible with old docs location
  - Keep the kdelibs5 transitional package
  - kdelibs5-dev.install: install ksambasharedata.h
  - kdelibs5-plugins: recommend ttf-dejavu-core instead of ttf-dejavu to save
    CD space.
* Add Breaks in addition to Replaces for moving files between packages.
* Drop no longer needed Breaks and Replaces.
* Completely drop kubuntu_51_launchpad_integration.diff and
  kubuntu_68_remove_applet_confirmation.diff.
  + Also drop the launchpad and kubuntu icons.
* Remove sequence numbers from kubuntu patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
https://projects.kde.org/projects/kde/kdelibs/repository/revisions/bda3fc424059a201a20153dd00b85aa26d57de1b
 
2
commit bda3fc424059a201a20153dd00b85aa26d57de1b
 
3
Author: Peter Penz <peter.penz19@gmail.com>
 
4
Date:   Sun Feb 20 20:38:14 2011 +0100
 
5
 
 
6
    KIO::PreviewJob: Respect the enabled plugins from "PreviewSettings"
 
7
    
 
8
    Currently KIO::PreviewJob respects the settings "MaximumSize" and "MaximumRemoteSize" from the KConfigGroup "PreviewSettings", but completely ignores the "Plugins" settings. The patch provides a new constructor and does some API cleanups to support the preview-settings. See https://git.reviewboard.kde.org/r/100578/ for more details.
 
9
 
 
10
diff --git a/kio/kio/previewjob.cpp b/kio/kio/previewjob.cpp
 
11
--- a/kio/kio/previewjob.cpp
 
12
+++ b/kio/kio/previewjob.cpp
 
13
@@ -132,6 +132,7 @@ public:
 
14
     Q_DECLARE_PUBLIC(PreviewJob)
 
15
 };
 
16
 
 
17
+#ifndef KDE_NO_DEPRECATED
 
18
 PreviewJob::PreviewJob( const KFileItemList &items, int width, int height,
 
19
     int iconSize, int iconAlpha, bool scale, bool save,
 
20
     const QStringList *enabledPlugins )
 
21
@@ -142,7 +143,7 @@ PreviewJob::PreviewJob( const KFileItemList &items, int width, int height,
 
22
     d->shmid = -1;
 
23
     d->shmaddr = 0;
 
24
     d->initialItems = items;
 
25
-    d->enabledPlugins = enabledPlugins ? *enabledPlugins : QStringList();
 
26
+    d->enabledPlugins = enabledPlugins ? *enabledPlugins : availablePlugins();
 
27
     d->width = width;
 
28
     d->height = height ? height : width;
 
29
     d->cacheWidth = d->width;
 
30
@@ -152,7 +153,46 @@ PreviewJob::PreviewJob( const KFileItemList &items, int width, int height,
 
31
     d->bScale = scale;
 
32
     d->bSave = save && scale;
 
33
     d->succeeded = false;
 
34
-    d->thumbRoot = QDir::homePath() + "/.thumbnails/";
 
35
+    d->thumbRoot = QDir::homePath() + QLatin1String("/.thumbnails/");
 
36
+    d->ignoreMaximumSize = false;
 
37
+    d->sequenceIndex = 0;
 
38
+    d->maximumLocalSize = 0;
 
39
+    d->maximumRemoteSize = 0;
 
40
+
 
41
+    // Return to event loop first, determineNextFile() might delete this;
 
42
+    QTimer::singleShot(0, this, SLOT(startPreview()));
 
43
+}
 
44
+#endif
 
45
+
 
46
+PreviewJob::PreviewJob(const KFileItemList &items,
 
47
+                       const QSize &size,
 
48
+                       const QStringList *enabledPlugins) :
 
49
+    KIO::Job(*new PreviewJobPrivate)
 
50
+{
 
51
+    Q_D(PreviewJob);
 
52
+    d->tOrig = 0;
 
53
+    d->shmid = -1;
 
54
+    d->shmaddr = 0;
 
55
+    d->initialItems = items;
 
56
+    if (enabledPlugins) {
 
57
+        d->enabledPlugins = *enabledPlugins;
 
58
+    } else {
 
59
+        const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
 
60
+        d->enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
 
61
+                                                              << "directorythumbnail"
 
62
+                                                              << "imagethumbnail"
 
63
+                                                              << "jpegthumbnail");
 
64
+    }
 
65
+    d->width = size.width();
 
66
+    d->height = size.height();
 
67
+    d->cacheWidth = d->width;
 
68
+    d->cacheHeight = d->height;
 
69
+    d->iconSize = 0;
 
70
+    d->iconAlpha = 70;
 
71
+    d->bScale = true;
 
72
+    d->bSave = true;
 
73
+    d->succeeded = false;
 
74
+    d->thumbRoot = QDir::homePath() + QLatin1String("/.thumbnails/");
 
75
     d->ignoreMaximumSize = false;
 
76
     d->sequenceIndex = 0;
 
77
     d->maximumLocalSize = 0;
 
78
@@ -173,6 +213,60 @@ PreviewJob::~PreviewJob()
 
79
 #endif
 
80
 }
 
81
 
 
82
+void PreviewJob::setOverlayIconSize(int size)
 
83
+{
 
84
+    Q_D(PreviewJob);
 
85
+    d->iconSize = size;
 
86
+}
 
87
+
 
88
+int PreviewJob::overlayIconSize() const
 
89
+{
 
90
+    Q_D(const PreviewJob);
 
91
+    return d->iconSize;
 
92
+}
 
93
+
 
94
+void PreviewJob::setOverlayIconAlpha(int alpha)
 
95
+{
 
96
+    Q_D(PreviewJob);
 
97
+    d->iconAlpha = qBound(0, alpha, 255);
 
98
+}
 
99
+
 
100
+int PreviewJob::overlayIconAlpha() const
 
101
+{
 
102
+    Q_D(const PreviewJob);
 
103
+    return d->iconAlpha;
 
104
+}
 
105
+
 
106
+void PreviewJob::setScaleType(ScaleType type)
 
107
+{
 
108
+    Q_D(PreviewJob);
 
109
+    switch (type) {
 
110
+    case Unscaled:
 
111
+        d->bScale = false;
 
112
+        d->bSave = false;
 
113
+        break;
 
114
+    case Scaled:
 
115
+        d->bScale = true;
 
116
+        d->bSave = false;
 
117
+        break;
 
118
+    case ScaledAndCached:
 
119
+        d->bScale = true;
 
120
+        d->bSave = true;
 
121
+        break;
 
122
+    default:
 
123
+        break;
 
124
+    }
 
125
+}
 
126
+
 
127
+PreviewJob::ScaleType PreviewJob::scaleType() const
 
128
+{
 
129
+    Q_D(const PreviewJob);
 
130
+    if (d->bScale) {
 
131
+        return d->bSave ? ScaledAndCached : Scaled;
 
132
+    }
 
133
+    return Unscaled;
 
134
+}
 
135
+
 
136
 void PreviewJobPrivate::startPreview()
 
137
 {
 
138
     Q_Q(PreviewJob);
 
139
@@ -181,7 +275,7 @@ void PreviewJobPrivate::startPreview()
 
140
     QMap<QString, KService::Ptr> mimeMap;
 
141
 
 
142
     for (KService::List::ConstIterator it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
 
143
-        if (enabledPlugins.isEmpty() || enabledPlugins.contains((*it)->desktopEntryName())) {
 
144
+        if (enabledPlugins.contains((*it)->desktopEntryName())) {
 
145
             const QStringList mimeTypes = (*it)->serviceTypes();
 
146
             for (QStringList::ConstIterator mt = mimeTypes.constBegin(); mt != mimeTypes.constEnd(); ++mt)
 
147
                 mimeMap.insert(*mt, *it);
 
148
@@ -629,6 +723,7 @@ QStringList PreviewJob::supportedMimeTypes()
 
149
     return result;
 
150
 }
 
151
 
 
152
+#ifndef KDE_NO_DEPRECATED
 
153
 PreviewJob *KIO::filePreview( const KFileItemList &items, int width, int height,
 
154
     int iconSize, int iconAlpha, bool scale, bool save,
 
155
     const QStringList *enabledPlugins )
 
156
@@ -649,6 +744,12 @@ PreviewJob *KIO::filePreview( const KUrl::List &items, int width, int height,
 
157
     return new PreviewJob(fileItems, width, height, iconSize, iconAlpha,
 
158
                           scale, save, enabledPlugins);
 
159
 }
 
160
+#endif
 
161
+
 
162
+PreviewJob *KIO::filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins)
 
163
+{
 
164
+    return new PreviewJob(items, size, enabledPlugins);
 
165
+}
 
166
 
 
167
 #ifndef KDE_NO_DEPRECATED
 
168
 KIO::filesize_t PreviewJob::maximumFileSize()
 
169
diff --git a/kio/kio/previewjob.h b/kio/kio/previewjob.h
 
170
--- a/kio/kio/previewjob.h
 
171
+++ b/kio/kio/previewjob.h
 
172
@@ -40,6 +40,30 @@ namespace KIO {
 
173
         Q_OBJECT
 
174
     public:
 
175
         /**
 
176
+         * Specifies the type of scaling that is applied to the generated preview.
 
177
+         * @since 4.7
 
178
+         */
 
179
+        enum ScaleType {
 
180
+            /**
 
181
+             * The original size of the preview will be returned. Most previews
 
182
+             * will return a size of 256 x 256 pixels.
 
183
+             */
 
184
+            Unscaled,
 
185
+            /**
 
186
+             * The preview will be scaled to the size specified when constructing
 
187
+             * the PreviewJob. The aspect ratio will be kept.
 
188
+             */
 
189
+            Scaled,
 
190
+            /**
 
191
+             * The preview will be scaled to the size specified when constructing
 
192
+             * the PreviewJob. The result will be cached for later use. Per default
 
193
+             * ScaledAndCached is set.
 
194
+             */
 
195
+            ScaledAndCached
 
196
+        };
 
197
+
 
198
+#ifndef KDE_NO_DEPRECATED
 
199
+        /**
 
200
          * Creates a new PreviewJob.
 
201
          * @param items a list of files to create previews for
 
202
          * @param width the desired width
 
203
@@ -51,15 +75,83 @@ namespace KIO {
 
204
          * @param scale if the image is to be scaled to the requested size or
 
205
          * returned in its original size
 
206
          * @param save if the image should be cached for later use
 
207
-         * @param enabledPlugins if non-zero, this points to a list containing
 
208
-         * the names of the plugins that may be used.
 
209
+         * @param enabledPlugins If non-zero, this points to a list containing
 
210
+         * the names of the plugins that may be used. If enabledPlugins is zero
 
211
+         * all available plugins are used.
 
212
+         *
 
213
+         * @deprecated Use PreviewJob(KFileItemList, QSize, QStringList) in combination
 
214
+         *             with the setter-methods instead. Note that the semantics of
 
215
+         *             \p enabledPlugins has been slightly changed.
 
216
+         */
 
217
+        KDE_DEPRECATED PreviewJob(const KFileItemList& items, int width, int height,
 
218
+                                  int iconSize, int iconAlpha, bool scale, bool save,
 
219
+                                  const QStringList *enabledPlugins);
 
220
+#endif
 
221
+
 
222
+        /**
 
223
+         * @param items          List of files to create previews for.
 
224
+         * @param size           Desired size of the preview.
 
225
+         * @param enabledPlugins If non-zero it defines the list of plugins that
 
226
+         *                       are considered for generating the preview. If
 
227
+         *                       enabledPlugins is zero the plugins specified in the
 
228
+         *                       KConfigGroup "PreviewSettings" are used.
 
229
+         * @since 4.7
 
230
          */
 
231
-        PreviewJob( const KFileItemList& items, int width, int height,
 
232
-            int iconSize, int iconAlpha, bool scale, bool save,
 
233
-            const QStringList *enabledPlugins );
 
234
+        PreviewJob(const KFileItemList &items,
 
235
+                   const QSize &size,
 
236
+                   const QStringList *enabledPlugins = 0);
 
237
+
 
238
         virtual ~PreviewJob();
 
239
 
 
240
         /**
 
241
+         * Sets the size of the MIME-type icon which overlays the preview. If zero
 
242
+         * is passed no overlay will be shown at all. The setting has no effect if
 
243
+         * the preview plugin that will be used does not use icon overlays. Per
 
244
+         * default the size is set to 0.
 
245
+         * @since 4.7
 
246
+         */
 
247
+        void setOverlayIconSize(int size);
 
248
+
 
249
+        /**
 
250
+         * @return The size of the MIME-type icon which overlays the preview.
 
251
+         * @see PreviewJob::setOverlayIconSize()
 
252
+         * @since 4.7
 
253
+         */
 
254
+        int overlayIconSize() const;
 
255
+
 
256
+        /**
 
257
+         * Sets the alpha-value for the MIME-type icon which overlays the preview.
 
258
+         * The alpha-value may range from 0 (= fully transparent) to 255 (= opaque).
 
259
+         * Per default the value is set to 70.
 
260
+         * @see PreviewJob::setOverlayIconSize()
 
261
+         * @since 4.7
 
262
+         */
 
263
+        void setOverlayIconAlpha(int alpha);
 
264
+
 
265
+        /**
 
266
+         * @return The alpha-value for the MIME-type icon which overlays the preview.
 
267
+         *         Per default 70 is returned.
 
268
+         * @see PreviewJob::setOverlayIconAlpha()
 
269
+         * @since 4.7
 
270
+         */
 
271
+        int overlayIconAlpha() const;
 
272
+
 
273
+        /**
 
274
+         * Sets the scale type for the generated preview. Per default
 
275
+         * PreviewJob::ScaledAndCached is set.
 
276
+         * @see PreviewJob::ScaleType
 
277
+         * @since 4.7
 
278
+         */
 
279
+        void setScaleType(ScaleType type);
 
280
+
 
281
+        /**
 
282
+         * @return The scale type for the generated preview.
 
283
+         * @see PreviewJob::ScaleType
 
284
+         * @since 4.7
 
285
+         */
 
286
+        ScaleType scaleType() const;
 
287
+
 
288
+        /**
 
289
          * Removes an item from preview processing. Use this if you passed
 
290
          * an item to filePreview and want to delete it now.
 
291
          *
 
292
@@ -142,6 +234,7 @@ namespace KIO {
 
293
         Q_DECLARE_PRIVATE(PreviewJob)
 
294
     };
 
295
 
 
296
+#ifndef KDE_NO_DEPRECATED
 
297
     /**
 
298
      * Creates a PreviewJob to generate or retrieve a preview image
 
299
      * for the given URL.
 
300
@@ -161,8 +254,11 @@ namespace KIO {
 
301
      * the names of the plugins that may be used.
 
302
      * @return the new PreviewJob
 
303
      * @see PreviewJob::availablePlugins()
 
304
+     * @deprecated Use KIO::filePreview(KFileItemList, QSize, QStringList) in combination
 
305
+     *             with the setter-methods instead. Note that the semantics of
 
306
+     *             \p enabledPlugins has been slightly changed.
 
307
      */
 
308
-KIO_EXPORT PreviewJob *filePreview( const KFileItemList &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 ); // KDE5: use enums instead of bool scale + bool save
 
309
+    KIO_EXPORT_DEPRECATED PreviewJob *filePreview( const KFileItemList &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 ); // KDE5: use enums instead of bool scale + bool save
 
310
 
 
311
     /**
 
312
      * Creates a PreviewJob to generate or retrieve a preview image
 
313
@@ -183,8 +279,24 @@ KIO_EXPORT PreviewJob *filePreview( const KFileItemList &items, int width, int h
 
314
      * the names of the plugins that may be used.
 
315
      * @return the new PreviewJob
 
316
      * @see PreviewJob::availablePlugins()
 
317
+     * @deprecated Use KIO::filePreview(KFileItemList, QSize, QStringList) in combination
 
318
+     *             with the setter-methods instead. Note that the semantics of
 
319
+     *             \p enabledPlugins has been slightly changed.
 
320
+     */
 
321
+    KIO_EXPORT_DEPRECATED PreviewJob *filePreview( const KUrl::List &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 );
 
322
+#endif
 
323
+
 
324
+    /**
 
325
+     * Creates a PreviewJob to generate a preview image for the given items.
 
326
+     * @param items          List of files to create previews for.
 
327
+     * @param size           Desired size of the preview.
 
328
+     * @param enabledPlugins If non-zero it defines the list of plugins that
 
329
+     *                       are considered for generating the preview. If
 
330
+     *                       enabledPlugins is zero the plugins specified in the
 
331
+     *                       KConfigGroup "PreviewSettings" are used.
 
332
+     * @since 4.7
 
333
      */
 
334
-    KIO_EXPORT PreviewJob *filePreview( const KUrl::List &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 );
 
335
+    KIO_EXPORT PreviewJob *filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins = 0);
 
336
 }
 
337
 
 
338
 #endif