Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [thumbnail] The file thumbnail is not displayed in the file detail view #1237

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dfm-base/file/local/asyncfileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void AsyncFileInfo::refresh()
d->extraProperties.clear();
d->attributesExtend.clear();
d->extendIDs.clear();
d->fileIcon = QIcon();
extendOtherCache.clear();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "detailview.h"

#include <dfm-base/base/schemefactory.h>
#include <dfm-base/utils/thumbnail/thumbnailhelper.h>

#include <dfm-framework/dpf.h>

Expand Down Expand Up @@ -149,11 +150,22 @@ void DetailView::createHeadUI(const QUrl &url, int widgetFilter)
};

// get icon from plugin
QIcon icon;
const QString &iconName = findPluginIcon(info->urlOf(UrlInfoType::kUrl));
if (!iconName.isEmpty())
iconLabel->setPixmap(QIcon::fromTheme(iconName).pixmap(targetSize));
else
iconLabel->setPixmap(info->fileIcon().pixmap(targetSize));
if (!iconName.isEmpty()) {
icon = QIcon::fromTheme(iconName);
} else if (ThumbnailHelper::instance()->checkThumbEnable(url)) {
icon = info->extendAttributes(ExtInfoType::kFileThumbnail).value<QIcon>();
if (icon.isNull()) {
const auto &img = ThumbnailHelper::instance()->thumbnailImage(url, Global::kLarge);
icon = QPixmap::fromImage(img);
}
}

if (icon.isNull())
icon = info->fileIcon();

iconLabel->setPixmap(icon.pixmap(targetSize));
iconLabel->setAlignment(Qt::AlignCenter);
iconLabel->setContentsMargins(0, 0, 0, 15);
vLayout->insertWidget(0, iconLabel, 0, Qt::AlignHCenter);
Expand Down
2 changes: 2 additions & 0 deletions tests/plugins/common/dfmplugin-dirshare/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ file(GLOB_RECURSE SRC_FILES
find_package(Dtk COMPONENTS Widget REQUIRED)
find_package(Qt5 COMPONENTS DBus REQUIRED)
find_package(Qt5 COMPONENTS Svg REQUIRED)
find_package(Qt5 COMPONENTS Network REQUIRED)

add_executable(${PROJECT_NAME}
${SRC_FILES}
Expand All @@ -34,6 +35,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
DFM::base
DFM::extension
Qt5::Svg
Qt5::Network
${DtkWidget_LIBRARIES}
)

Expand Down
Loading