TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

previewjob.h 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // -*- c++ -*-
  2. // vim: ts=4 sw=4 et
  3. /* This file is part of the KDE libraries
  4. Copyright (C) 2000 David Faure <faure@kde.org>
  5. 2000 Carsten Pfeiffer <pfeiffer@kde.org>
  6. 2001 Malte Starostik <malte.starostik@t-online.de>
  7. This library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Library General Public
  9. License as published by the Free Software Foundation; either
  10. version 2 of the License, or (at your option) any later version.
  11. This library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public License
  16. along with this library; see the file COPYING.LIB. If not, write to
  17. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __tdeio_previewjob_h__
  21. #define __tdeio_previewjob_h__
  22. #include <tdefileitem.h>
  23. #include <tdeio/job.h>
  24. class TQPixmap;
  25. namespace TDEIO {
  26. /*!
  27. * This class catches a preview (thumbnail) for files.
  28. * @short KIO Job to get a thumbnail picture
  29. */
  30. class TDEIO_EXPORT PreviewJob : public TDEIO::Job
  31. {
  32. Q_OBJECT
  33. public:
  34. /**
  35. * Creates a new PreviewJob.
  36. * @param items a list of files to create previews for
  37. * @param width the desired width
  38. * @param height the desired height, 0 to use the @p width
  39. * @param iconSize the size of the mimetype icon to overlay over the
  40. * preview or zero to not overlay an icon. This has no effect if the
  41. * preview plugin that will be used doesn't use icon overlays.
  42. * @param iconAlpha transparency to use for the icon overlay
  43. * @param scale if the image is to be scaled to the requested size or
  44. * returned in its original size
  45. * @param save if the image should be cached for later use
  46. * @param enabledPlugins if non-zero, this points to a list containing
  47. * the names of the plugins that may be used.
  48. * @param deleteItems true to delete the items when done
  49. */
  50. PreviewJob( const KFileItemList &items, int width, int height,
  51. int iconSize, int iconAlpha, bool scale, bool save,
  52. const TQStringList *enabledPlugins, bool deleteItems = false );
  53. virtual ~PreviewJob();
  54. /**
  55. * Removes an item from preview processing. Use this if you passed
  56. * an item to filePreview and want to delete it now.
  57. *
  58. * @param item the item that should be removed from the preview queue
  59. */
  60. void removeItem( const KFileItem *item );
  61. /**
  62. * If @p ignoreSize is true, then the preview is always
  63. * generated regardless of the settings
  64. *
  65. * @since KDE 3.4
  66. **/
  67. void setIgnoreMaximumSize(bool ignoreSize = true);
  68. /**
  69. * Returns a list of all available preview plugins. The list
  70. * contains the basenames of the plugins' .desktop files (no path,
  71. * no .desktop).
  72. * @return the list of plugins
  73. */
  74. static TQStringList availablePlugins();
  75. /**
  76. * Returns a list of all supported MIME types. The list can
  77. * contain entries like text/ * (without the space).
  78. * @return the list of mime types
  79. */
  80. static TQStringList supportedMimeTypes();
  81. /**
  82. * Reimplemented for internal reasons
  83. */
  84. virtual void kill( bool quietly = true );
  85. signals:
  86. /**
  87. * Emitted when a thumbnail picture for @p item has been successfully
  88. * retrieved.
  89. * @param item the file of the preview
  90. * @param preview the preview image
  91. */
  92. void gotPreview( const KFileItem *item, const TQPixmap &preview );
  93. /**
  94. * Emitted when a thumbnail for @p item could not be created,
  95. * either because a ThumbCreator for its MIME type does not
  96. * exist, or because something went wrong.
  97. * @param item the file that failed
  98. */
  99. void failed( const KFileItem *item );
  100. protected:
  101. void getOrCreateThumbnail();
  102. bool statResultThumbnail();
  103. void createThumbnail( TQString );
  104. protected slots:
  105. virtual void slotResult( TDEIO::Job *job );
  106. private slots:
  107. void startPreview();
  108. void slotThumbData(TDEIO::Job *, const TQByteArray &);
  109. private:
  110. void determineNextFile();
  111. void emitPreview(const TQImage &thumb);
  112. void emitFailed(const KFileItem *item = 0);
  113. protected:
  114. virtual void virtual_hook( int id, void* data );
  115. private:
  116. struct PreviewJobPrivate *d;
  117. };
  118. /**
  119. * Creates a PreviewJob to generate or retrieve a preview image
  120. * for the given URL.
  121. *
  122. * @param items files to get previews for
  123. * @param width the maximum width to use
  124. * @param height the maximum height to use, if this is 0, the same
  125. * value as width is used.
  126. * @param iconSize the size of the mimetype icon to overlay over the
  127. * preview or zero to not overlay an icon. This has no effect if the
  128. * preview plugin that will be used doesn't use icon overlays.
  129. * @param iconAlpha transparency to use for the icon overlay
  130. * @param scale if the image is to be scaled to the requested size or
  131. * returned in its original size
  132. * @param save if the image should be cached for later use
  133. * @param enabledPlugins if non-zero, this points to a list containing
  134. * the names of the plugins that may be used.
  135. * @return the new PreviewJob
  136. * @see PreviewJob::availablePlugins()
  137. */
  138. TDEIO_EXPORT PreviewJob *filePreview( const KFileItemList &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const TQStringList *enabledPlugins = 0 );
  139. /**
  140. * Creates a PreviewJob to generate or retrieve a preview image
  141. * for the given URL.
  142. *
  143. * @param items files to get previews for
  144. * @param width the maximum width to use
  145. * @param height the maximum height to use, if this is 0, the same
  146. * value as width is used.
  147. * @param iconSize the size of the mimetype icon to overlay over the
  148. * preview or zero to not overlay an icon. This has no effect if the
  149. * preview plugin that will be used doesn't use icon overlays.
  150. * @param iconAlpha transparency to use for the icon overlay
  151. * @param scale if the image is to be scaled to the requested size or
  152. * returned in its original size
  153. * @param save if the image should be cached for later use
  154. * @param enabledPlugins if non-zero, this points to a list containing
  155. * the names of the plugins that may be used.
  156. * @return the new PreviewJob
  157. * @see PreviewJob::availablePlugins()
  158. */
  159. TDEIO_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 TQStringList *enabledPlugins = 0 );
  160. }
  161. #endif