From 0f0d14d4c236eee7f1df4f0c21c60f6b784dab75 Mon Sep 17 00:00:00 2001 From: Gastón Haro Date: Tue, 9 Jun 2020 11:03:30 -0600 Subject: Provide ability to configure size cut-off for local file previews Summary: FileWidgets read from kdeglobals the property "MaximumSize" under "PreviewSettings" to decide if a preview will be generated for that file. There is no current GUI to change that file size limit. On the other hand Dolphin ignores it. This patch aims to fix that by adding new configuration options to Dolphin. That is a new spinbox in Dolphin settings under General -> Previews tab. Test Plan: 1 - Set up a local folder with 2 jpg images of less and more than 1 MB respectively. 2 - Go to Dolphin Preferences. General -> Previews and check "JPEG Images" from the list. And set "Skip previews for files above:" to 1MB. 3 - Navigate to the afore mentioned folder. Only the image of size less than 1 MB should show a preview. BUG: 331240 Reviewers: ngraham, #dolphin, meven, elvisangelaccio Reviewed By: ngraham, #dolphin, meven, elvisangelaccio Subscribers: cfeck, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D28402 --- src/kitemviews/kfileitemmodelrolesupdater.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/kitemviews/kfileitemmodelrolesupdater.cpp') diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index c28e240a5..eb2c1b646 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -85,7 +85,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO m_recentlyChangedItemsTimer(nullptr), m_recentlyChangedItems(), m_changedItems(), - m_directoryContentsCounter(nullptr) + m_directoryContentsCounter(nullptr), + m_localFileSizePreviewLimit(0) #ifdef HAVE_BALOO , m_balooFileMonitor(nullptr) #endif @@ -94,6 +95,7 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings"); m_enabledPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()); + m_localFileSizePreviewLimit = static_cast(globalConfig.readEntry("MaximumSize", 0)); connect(m_model, &KFileItemModel::itemsInserted, this, &KFileItemModelRolesUpdater::slotItemsInserted); @@ -317,6 +319,16 @@ QStringList KFileItemModelRolesUpdater::enabledPlugins() const return m_enabledPlugins; } +void KFileItemModelRolesUpdater::setLocalFileSizePreviewLimit(const qlonglong size) +{ + m_localFileSizePreviewLimit = size; +} + +qlonglong KFileItemModelRolesUpdater::localFileSizePreviewLimit() const +{ + return m_localFileSizePreviewLimit; +} + void KFileItemModelRolesUpdater::slotItemsInserted(const KItemRangeList& itemRanges) { QElapsedTimer timer; @@ -898,7 +910,7 @@ void KFileItemModelRolesUpdater::startPreviewJob() KIO::PreviewJob* job = new KIO::PreviewJob(itemSubSet, cacheSize, &m_enabledPlugins); - job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile()); + job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile() && m_localFileSizePreviewLimit <= 0); if (job->uiDelegate()) { KJobWidgets::setWindow(job, qApp->activeWindow()); } -- cgit v1.3.1