diff --git a/src/kernel/dguiapplicationhelper.cpp b/src/kernel/dguiapplicationhelper.cpp index 3eec52e..5541a27 100644 --- a/src/kernel/dguiapplicationhelper.cpp +++ b/src/kernel/dguiapplicationhelper.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #ifdef Q_OS_UNIX #include @@ -495,10 +494,7 @@ DGuiApplicationHelper::DGuiApplicationHelper() : QObject(nullptr) , DObject(*new DGuiApplicationHelperPrivate(this)) { - // load qt/qtbase translation for qt app which load dtk ? - QTimer::singleShot(0, [](){ - DGuiApplicationHelper::loadTranslator(); - }); + } void DGuiApplicationHelper::initialize() diff --git a/src/util/private/diconproxyengine.cpp b/src/util/private/diconproxyengine.cpp index 2406c5c..1728c22 100644 --- a/src/util/private/diconproxyengine.cpp +++ b/src/util/private/diconproxyengine.cpp @@ -18,7 +18,7 @@ #include #include -#if (XDG_ICON_VERSION_MAR >= 3) +#if XDG_ICON_VERSION_MAR >= 3 #define private public #include #undef private @@ -156,8 +156,9 @@ QIconEngine *DIconProxyEngine::clone() const bool DIconProxyEngine::read(QDataStream &in) { - // ensureEngine, will changed themeName if not the same in >> m_iconName >> m_iconThemeName; + + ensureEngine(); return m_iconEngine ? m_iconEngine->read(in) : false; } diff --git a/src/util/private/xdgiconproxyengine.cpp b/src/util/private/xdgiconproxyengine.cpp index 534fafc..9b296cb 100644 --- a/src/util/private/xdgiconproxyengine.cpp +++ b/src/util/private/xdgiconproxyengine.cpp @@ -243,11 +243,8 @@ void XdgIconProxyEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode QPixmap XdgIconProxyEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) { engine->ensureLoaded(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QIconLoaderEngineEntry *entry = engine->entryForSize(size); -#else - QIconLoaderEngineEntry *entry = engine->entryForSize(engine->m_info ,size); -#endif if (!entry) { DEEPIN_XDG_THEME::colorScheme.setLocalData(DEEPIN_XDG_THEME::PALETTE_MAP()); @@ -302,12 +299,7 @@ void XdgIconProxyEngine::virtual_hook(int id, void *data) QIconEngine::ScaledPixmapArgument &arg = *reinterpret_cast(data); // QIcon::pixmap() multiplies size by the device pixel ratio. const int integerScale = qCeil(arg.scale); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QIconLoaderEngineEntry *entry = engine->entryForSize(arg.size / integerScale, integerScale); -#else - QIconLoaderEngineEntry *entry = engine->entryForSize(engine->m_info, arg.size / integerScale, integerScale); -#endif // 先禁用缩放,因为此size是已经缩放过的 bool useHighDpiPixmap = qGuiApp->testAttribute(Qt::AA_UseHighDpiPixmaps); qGuiApp->setAttribute(Qt::AA_UseHighDpiPixmaps, false); diff --git a/src/util/private/xdgiconproxyengine_p.h b/src/util/private/xdgiconproxyengine_p.h index 30a340b..d00f184 100644 --- a/src/util/private/xdgiconproxyengine_p.h +++ b/src/util/private/xdgiconproxyengine_p.h @@ -6,7 +6,6 @@ #define XDGICONPROXYENGINE_H #include -#include #if XDG_ICON_VERSION_MAR >= 3 #include @@ -26,8 +25,7 @@ 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: diff --git a/src/util/util.cmake b/src/util/util.cmake index cfaa7fc..4c62960 100644 --- a/src/util/util.cmake +++ b/src/util/util.cmake @@ -1,9 +1,10 @@ if(NOT DTK_DISABLE_LIBXDG) message("Enable libxdg!") - find_package(qt${QT_VERSION_MAJOR}xdgiconloader) - - add_definitions(-DXDG_ICON_VERSION_MAR=${qt${QT_VERSION_MAJOR}xdgiconloader_VERSION_MAJOR}) - +# find_package(qt${QT_VERSION_MAJOR}xdgiconloader) +if (Qt5_FOUND) + find_package(qt5xdgiconloader) + add_definitions(-DXDG_ICON_VERSION_MAR=${qt5xdgiconloader_VERSION_MAJOR}) +endif() set(UTIL_PRIVATE ${CMAKE_CURRENT_LIST_DIR}/private/xdgiconproxyengine_p.h ${CMAKE_CURRENT_LIST_DIR}/private/xdgiconproxyengine.cpp diff --git a/tests/dcis/selected_indicator.dci b/tests/dcis/selected_indicator.dci index 27f1a44..c164df6 100644 Binary files a/tests/dcis/selected_indicator.dci and b/tests/dcis/selected_indicator.dci differ diff --git a/tests/src/ut_diconproxyengine.cpp b/tests/src/ut_diconproxyengine.cpp index 3669edf..a4737a4 100644 --- a/tests/src/ut_diconproxyengine.cpp +++ b/tests/src/ut_diconproxyengine.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -115,18 +116,21 @@ TEST_F(ut_DIconProxyEngine, read_write) ASSERT_EQ(iconName, mIconEngine->iconName()); } - iconName = "test_icon_name"; - themeName = "test_theme_name"; { + auto engine = new DIconProxyEngine("selected_indicator" ,DIconTheme::DontFallbackToQIconFromTheme); + QIcon icon_write(engine); QDataStream out(&data, QIODevice::WriteOnly); - out << iconName << themeName; - } - { + out << icon_write; + + QIcon icon_read; QDataStream in(&data, QIODevice::ReadOnly); - mIconEngine->read(in); + in >> icon_read; - ASSERT_EQ(themeName, mIconEngine->themeName()); - ASSERT_EQ(iconName, mIconEngine->iconName()); + ASSERT_TRUE(icon_read.data_ptr()->engine); + EXPECT_EQ(icon_read.data_ptr()->engine->key(), + engine->key()); + EXPECT_EQ(icon_read.data_ptr()->engine->iconName(), + engine->iconName()); } } diff --git a/tests/src/ut_xdgiconproxyengine.cpp b/tests/src/ut_xdgiconproxyengine.cpp index 5bc1585..92c2e92 100644 --- a/tests/src/ut_xdgiconproxyengine.cpp +++ b/tests/src/ut_xdgiconproxyengine.cpp @@ -89,11 +89,8 @@ TEST_F(ut_XdgIconProxyEngine, pixmapByEntry) QPalette pa = qApp->palette(); // ensureLoaded EXPECT_EQ(s64, mIconEngine->actualSize(s64, QIcon::Normal, QIcon::On)); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QIconLoaderEngineEntry *entry = mIconEngine->engine->entryForSize(s64); -#else - QIconLoaderEngineEntry *entry = mIconEngine->engine->entryForSize(mIconEngine->engine->m_info, s64); -#endif ASSERT_TRUE(entry); QPixmap normalPix = mIconEngine->pixmapByEntry(entry, s64, QIcon::Normal, QIcon::On);