From 5f50b701d2cf9facec1c4ac930727a4dd06c33cb Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Fri, 14 Jun 2024 22:39:42 +0300 Subject: [PATCH] Don't use custom "file icon provider" on Windows PR #20936. Closes #20908. --- src/gui/torrentcontentmodel.cpp | 42 +++++++-------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 61c43cebc..694e75958 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2022-2023 Vladimir Golovnev + * Copyright (C) 2022-2024 Vladimir Golovnev * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -37,17 +37,12 @@ #include #include -#if defined(Q_OS_WIN) -#include -#include -#else -#include -#include -#endif - -#if defined Q_OS_WIN || defined Q_OS_MACOS +#if defined(Q_OS_MACOS) #define QBT_PIXMAP_CACHE_FOR_FILE_ICONS #include +#elif !defined(Q_OS_WIN) +#include +#include #endif #include "base/bittorrent/downloadpriority.h" @@ -116,27 +111,8 @@ namespace }; #endif // QBT_PIXMAP_CACHE_FOR_FILE_ICONS -#if defined(Q_OS_WIN) - // See QTBUG-25319 for explanation why this is required - class WinShellFileIconProvider final : public CachingFileIconProvider - { - QPixmap pixmapForExtension(const QString &ext) const override - { - const std::wstring extWStr = QString(u'.' + ext).toStdWString(); - - SHFILEINFOW sfi {}; - const HRESULT hr = ::SHGetFileInfoW(extWStr.c_str(), - FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), (SHGFI_ICON | SHGFI_USEFILEATTRIBUTES)); - if (FAILED(hr)) - return {}; - - const auto iconPixmap = QPixmap::fromImage(QImage::fromHICON(sfi.hIcon)); - ::DestroyIcon(sfi.hIcon); - return iconPixmap; - } - }; -#elif defined(Q_OS_MACOS) - // There is a similar bug on macOS, to be reported to Qt +#if defined(Q_OS_MACOS) + // There is a bug on macOS, to be reported to Qt // https://github.com/qbittorrent/qBittorrent/pull/6156#issuecomment-316302615 class MacFileIconProvider final : public CachingFileIconProvider { @@ -145,7 +121,7 @@ namespace return MacUtils::pixmapForExtension(ext, QSize(32, 32)); } }; -#else +#elif !defined(Q_OS_WIN) /** * @brief Tests whether QFileIconProvider actually works * @@ -189,7 +165,7 @@ TorrentContentModel::TorrentContentModel(QObject *parent) : QAbstractItemModel(parent) , m_rootItem(new TorrentContentModelFolder(QVector({ tr("Name"), tr("Total Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") }))) #if defined(Q_OS_WIN) - , m_fileIconProvider {new WinShellFileIconProvider} + , m_fileIconProvider {new QFileIconProvider} #elif defined(Q_OS_MACOS) , m_fileIconProvider {new MacFileIconProvider} #else