Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/previewjob.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | 77 | public: | |||
---|---|---|---|---|---|
157 | void emitPreview(const QImage &thumb); | 157 | void emitPreview(const QImage &thumb); | ||
158 | 158 | | |||
159 | void startPreview(); | 159 | void startPreview(); | ||
160 | void slotThumbData(KIO::Job *, const QByteArray &); | 160 | void slotThumbData(KIO::Job *, const QByteArray &); | ||
161 | 161 | | |||
162 | Q_DECLARE_PUBLIC(PreviewJob) | 162 | Q_DECLARE_PUBLIC(PreviewJob) | ||
163 | }; | 163 | }; | ||
164 | 164 | | |||
165 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
166 | PreviewJob::PreviewJob(const KFileItemList &items, int width, int height, | 165 | PreviewJob::PreviewJob(const KFileItemList &items, int width, int height, | ||
167 | int iconSize, int iconAlpha, bool scale, bool save, | 166 | int iconSize, int iconAlpha, bool scale, bool save, | ||
168 | const QStringList *enabledPlugins) | 167 | const QStringList *enabledPlugins) | ||
169 | : KIO::Job(*new PreviewJobPrivate(items, QSize(width, height ? height : width))) | 168 | : KIO::Job(*new PreviewJobPrivate(items, QSize(width, height ? height : width))) | ||
170 | { | 169 | { | ||
171 | Q_D(PreviewJob); | 170 | Q_D(PreviewJob); | ||
172 | d->enabledPlugins = enabledPlugins ? *enabledPlugins : availablePlugins(); | 171 | d->enabledPlugins = enabledPlugins ? *enabledPlugins : availablePlugins(); | ||
173 | d->iconSize = iconSize; | 172 | d->iconSize = iconSize; | ||
174 | d->iconAlpha = iconAlpha; | 173 | d->iconAlpha = iconAlpha; | ||
175 | d->bScale = scale; | 174 | d->bScale = scale; | ||
176 | d->bSave = save && scale; | 175 | d->bSave = save && scale; | ||
177 | 176 | | |||
178 | // Return to event loop first, determineNextFile() might delete this; | 177 | // Return to event loop first, determineNextFile() might delete this; | ||
179 | QTimer::singleShot(0, this, SLOT(startPreview())); | 178 | QTimer::singleShot(0, this, SLOT(startPreview())); | ||
180 | } | 179 | } | ||
181 | #endif | | |||
182 | 180 | | |||
183 | PreviewJob::PreviewJob(const KFileItemList &items, | 181 | PreviewJob::PreviewJob(const KFileItemList &items, | ||
184 | const QSize &size, | 182 | const QSize &size, | ||
185 | const QStringList *enabledPlugins) : | 183 | const QStringList *enabledPlugins) : | ||
186 | KIO::Job(*new PreviewJobPrivate(items, size)) | 184 | KIO::Job(*new PreviewJobPrivate(items, size)) | ||
187 | { | 185 | { | ||
188 | Q_D(PreviewJob); | 186 | Q_D(PreviewJob); | ||
189 | 187 | | |||
▲ Show 20 Lines • Show All 593 Lines • ▼ Show 20 Line(s) | 780 | { | |||
783 | QStringList result; | 781 | QStringList result; | ||
784 | const KService::List plugins = KServiceTypeTrader::self()->query(QStringLiteral("ThumbCreator")); | 782 | const KService::List plugins = KServiceTypeTrader::self()->query(QStringLiteral("ThumbCreator")); | ||
785 | for (const KService::Ptr &plugin : plugins) { | 783 | for (const KService::Ptr &plugin : plugins) { | ||
786 | result += plugin->mimeTypes(); | 784 | result += plugin->mimeTypes(); | ||
787 | } | 785 | } | ||
788 | return result; | 786 | return result; | ||
789 | } | 787 | } | ||
790 | 788 | | |||
791 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
792 | PreviewJob *KIO::filePreview(const KFileItemList &items, int width, int height, | 789 | PreviewJob *KIO::filePreview(const KFileItemList &items, int width, int height, | ||
793 | int iconSize, int iconAlpha, bool scale, bool save, | 790 | int iconSize, int iconAlpha, bool scale, bool save, | ||
794 | const QStringList *enabledPlugins) | 791 | const QStringList *enabledPlugins) | ||
795 | { | 792 | { | ||
796 | return new PreviewJob(items, width, height, iconSize, iconAlpha, | 793 | return new PreviewJob(items, width, height, iconSize, iconAlpha, | ||
797 | scale, save, enabledPlugins); | 794 | scale, save, enabledPlugins); | ||
798 | } | 795 | } | ||
799 | 796 | | |||
800 | PreviewJob *KIO::filePreview(const QList<QUrl> &items, int width, int height, | 797 | PreviewJob *KIO::filePreview(const QList<QUrl> &items, int width, int height, | ||
801 | int iconSize, int iconAlpha, bool scale, bool save, | 798 | int iconSize, int iconAlpha, bool scale, bool save, | ||
802 | const QStringList *enabledPlugins) | 799 | const QStringList *enabledPlugins) | ||
803 | { | 800 | { | ||
804 | KFileItemList fileItems; | 801 | KFileItemList fileItems; | ||
805 | fileItems.reserve(items.size()); | 802 | fileItems.reserve(items.size()); | ||
806 | for (const QUrl &url : items) { | 803 | for (const QUrl &url : items) { | ||
807 | Q_ASSERT(url.isValid()); // please call us with valid urls only | 804 | Q_ASSERT(url.isValid()); // please call us with valid urls only | ||
808 | fileItems.append(KFileItem(url)); | 805 | fileItems.append(KFileItem(url)); | ||
809 | } | 806 | } | ||
810 | return new PreviewJob(fileItems, width, height, iconSize, iconAlpha, | 807 | return new PreviewJob(fileItems, width, height, iconSize, iconAlpha, | ||
811 | scale, save, enabledPlugins); | 808 | scale, save, enabledPlugins); | ||
812 | } | 809 | } | ||
813 | #endif | | |||
814 | 810 | | |||
815 | PreviewJob *KIO::filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins) | 811 | PreviewJob *KIO::filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins) | ||
816 | { | 812 | { | ||
817 | return new PreviewJob(items, size, enabledPlugins); | 813 | return new PreviewJob(items, size, enabledPlugins); | ||
818 | } | 814 | } | ||
819 | 815 | | |||
820 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
821 | KIO::filesize_t PreviewJob::maximumFileSize() | 816 | KIO::filesize_t PreviewJob::maximumFileSize() | ||
822 | { | 817 | { | ||
823 | KConfigGroup cg(KSharedConfig::openConfig(), "PreviewSettings"); | 818 | KConfigGroup cg(KSharedConfig::openConfig(), "PreviewSettings"); | ||
824 | return cg.readEntry("MaximumSize", 5 * 1024 * 1024LL /* 5MB */); | 819 | return cg.readEntry("MaximumSize", 5 * 1024 * 1024LL /* 5MB */); | ||
825 | } | 820 | } | ||
826 | #endif | | |||
827 | 821 | | |||
828 | #include "moc_previewjob.cpp" | 822 | #include "moc_previewjob.cpp" |