Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkgui
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#211
  • Loading branch information
deepin-ci-robot committed Dec 13, 2023
1 parent d96aef2 commit eb99fd5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/util/private/diconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <QDir>

#include <private/qiconloader_p.h>
#if XDG_ICON_VERSION_MAR >= 3
#if (XDG_ICON_VERSION_MAR >= 3)
#define private public
#include <private/xdgiconloader/xdgiconloader_p.h>
#undef private
Expand Down
5 changes: 3 additions & 2 deletions src/util/private/xdgiconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ QPixmap XdgIconProxyEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::S
{
engine->ensureLoaded();

QIconLoaderEngineEntry *entry = engine->entryForSize(size);
QIconLoaderEngineEntry *entry = engine->entryForSize(engine->m_info ,size);

if (!entry) {
DEEPIN_XDG_THEME::colorScheme.setLocalData(DEEPIN_XDG_THEME::PALETTE_MAP());
Expand Down Expand Up @@ -299,7 +299,8 @@ void XdgIconProxyEngine::virtual_hook(int id, void *data)
QIconEngine::ScaledPixmapArgument &arg = *reinterpret_cast<QIconEngine::ScaledPixmapArgument *>(data);
// QIcon::pixmap() multiplies size by the device pixel ratio.
const int integerScale = qCeil(arg.scale);
QIconLoaderEngineEntry *entry = engine->entryForSize(arg.size / integerScale, integerScale);

QIconLoaderEngineEntry *entry = engine->entryForSize(engine->m_info, arg.size / integerScale, integerScale);
// 先禁用缩放,因为此size是已经缩放过的
bool useHighDpiPixmap = qGuiApp->testAttribute(Qt::AA_UseHighDpiPixmaps);
qGuiApp->setAttribute(Qt::AA_UseHighDpiPixmaps, false);
Expand Down
4 changes: 3 additions & 1 deletion src/util/private/xdgiconproxyengine_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define XDGICONPROXYENGINE_H

#include <dtkgui_global.h>
#include <QHash>

#if XDG_ICON_VERSION_MAR >= 3
#include <QIconEngine>
Expand All @@ -25,7 +26,8 @@ struct ScalableEntry;
class QIconLoaderEngineEntry;
class XdgIconLoaderEngine;
DGUI_BEGIN_NAMESPACE
#if XDG_ICON_VERSION_MAR >= 3

#if (XDG_ICON_VERSION_MAR >= 3)
class Q_DECL_HIDDEN XdgIconProxyEngine : public QIconEngine
{
public:
Expand Down
9 changes: 4 additions & 5 deletions src/util/util.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
if(NOT DTK_DISABLE_LIBXDG)
message("Enable libxdg!")
# find_package(qt${QT_VERSION_MAJOR}xdgiconloader)
if (Qt5_FOUND)
find_package(qt5xdgiconloader)
add_definitions(-DXDG_ICON_VERSION_MAR=${qt5xdgiconloader_VERSION_MAJOR})
endif()
find_package(qt${QT_VERSION_MAJOR}xdgiconloader)

add_definitions(-DXDG_ICON_VERSION_MAR=${qt${QT_VERSION_MAJOR}xdgiconloader_VERSION_MAJOR})

set(UTIL_PRIVATE
${CMAKE_CURRENT_LIST_DIR}/private/xdgiconproxyengine_p.h
${CMAKE_CURRENT_LIST_DIR}/private/xdgiconproxyengine.cpp
Expand Down
2 changes: 1 addition & 1 deletion tests/src/ut_xdgiconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST_F(ut_XdgIconProxyEngine, pixmapByEntry)
// ensureLoaded
EXPECT_EQ(s64, mIconEngine->actualSize(s64, QIcon::Normal, QIcon::On));

QIconLoaderEngineEntry *entry = mIconEngine->engine->entryForSize(s64);
QIconLoaderEngineEntry *entry = mIconEngine->engine->entryForSize(mIconEngine->engine->m_info, s64);
ASSERT_TRUE(entry);

QPixmap normalPix = mIconEngine->pixmapByEntry(entry, s64, QIcon::Normal, QIcon::On);
Expand Down

0 comments on commit eb99fd5

Please sign in to comment.