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#217
  • Loading branch information
deepin-ci-robot authored and kegechen committed Jan 10, 2024
1 parent 2f0d0d4 commit 8033b5d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
15 changes: 11 additions & 4 deletions src/kernel/dplatformhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,17 @@ static void initWindowRadius(QWindow *window)
int radius = theme->windowRadius(18); //###(zccrs): 暂时在此处给窗口默认设置为18px的圆角

setWindowProperty(window, _windowRadius, radius);
window->connect(theme, &DPlatformTheme::windowRadiusChanged, window, [=] (int radius) {
if (!resolved(window, PropRole::WindowRadius))
setWindowProperty(window, _windowRadius, radius);
}, Qt::UniqueConnection);
// Qt::UniqueConnection will report a warning
// to `unique connections require a pointer to member function of a QObject subclass`.
const char *uniqueueConnectionFlag("_d_uniqueueConnectionFlag");
bool connected = window->property(uniqueueConnectionFlag).toBool();
if (!connected) {
window->setProperty(uniqueueConnectionFlag, true);
window->connect(theme, &DPlatformTheme::windowRadiusChanged, window, [window] (int radius) {
if (!resolved(window, PropRole::WindowRadius))
setWindowProperty(window, _windowRadius, radius);
});
}
}

class Q_DECL_HIDDEN CreatorWindowEventFile : public QObject {
Expand Down
14 changes: 7 additions & 7 deletions src/util/icons/deepin-theme-plugin-icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
<file>texts/checked_20px.svg</file>
<file>texts/next_indicator_24px.svg</file>
<file>texts/prev_indicator_24px.svg</file>
<file>actions/edit-select-all_16px.svg</file>
<file>actions/edit-copy_16px.svg</file>
<file>actions/edit-cut_16px.svg</file>
<file>actions/edit-delete_16px.svg</file>
<file>actions/edit-paste_16px.svg</file>
<file>actions/edit-redo_16px.svg</file>
<file>actions/edit-undo_16px.svg</file>
<file alias="texts/edit-select-all_16px.svg">actions/edit-select-all_16px.svg</file>
<file alias="texts/edit-copy_16px.svg">actions/edit-copy_16px.svg</file>
<file alias="texts/edit-cut_16px.svg">actions/edit-cut_16px.svg</file>
<file alias="texts/edit-delete_16px.svg">actions/edit-delete_16px.svg</file>
<file alias="texts/edit-paste_16px.svg">actions/edit-paste_16px.svg</file>
<file alias="texts/edit-redo_16px.svg">actions/edit-redo_16px.svg</file>
<file alias="texts/edit-undo_16px.svg">actions/edit-undo_16px.svg</file>
</qresource>
<qresource prefix="/icons/deepin/builtin/light">
<file alias="icons/button_edit-clear_30px.svg/normal.svg">icons/light/edit-clear_30px.svg</file>
Expand Down
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
10 changes: 9 additions & 1 deletion src/util/private/xdgiconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,11 @@ 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());
Expand Down Expand Up @@ -299,7 +302,12 @@ 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);

#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);
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
5 changes: 4 additions & 1 deletion tests/src/ut_xdgiconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ 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);
Expand Down

0 comments on commit 8033b5d

Please sign in to comment.