Skip to content

Commit

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

Source-pull-request: linuxdeepin/qt5integration#199
  • Loading branch information
deepin-ci-robot authored and asterwyx committed Nov 10, 2023
1 parent 9342673 commit 8399021
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Copyright: None
License: CC0-1.0

# ignore git
Files: .git*
Files: .git* .syncexclude
Copyright: None
License: CC0-1.0

Expand Down
11 changes: 11 additions & 0 deletions .syncexclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Paths that will be exclude from synchronize workflow
# Please use relative path which use project directory as root
# Notice that
# * .git
# * debian
# * archlinux
# * .obs
# * .github
# are always ignored
linglong.yaml
conanfile.py
8 changes: 6 additions & 2 deletions imageformatplugins/dci/qdciiohandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ bool QDciIOHandlerPrivate::load(QIODevice *device)

if (loaded)
return current;
if (q->format().isEmpty())
if (q->format().isEmpty() && !q->canRead())
return false;

loaded = true;

QBuffer *buf = qobject_cast<QBuffer *>(device);
Expand Down Expand Up @@ -95,7 +96,6 @@ QDciIOHandler::QDciIOHandler()

}


QDciIOHandler::~QDciIOHandler()
{
delete d;
Expand All @@ -110,6 +110,10 @@ bool QDciIOHandler::canRead() const

QByteArray buf = device()->peek(4);
if (buf.startsWith(QByteArrayLiteral("DCI"))) {
// Decide format from content..
if (format().isEmpty())
setFormat("dci");

return true;
}
return false;
Expand Down
27 changes: 27 additions & 0 deletions platformthemeplugin/qdeepintheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,33 @@ static void onIconThemeSetCallback()
}
}

static inline uint resolveMask(const QFont &f)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return f.resolve();
#else
return f.resolveMask();
#endif
}

static inline void setResolveMask(QFont &f, uint mask)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return f.resolve(mask);
#else
return f.setResolveMask(mask);
#endif
}

static void onFontChanged()
{
// 插件中初始化 appFont 时会 resolve(0) 即清空 resolve_mask
// 如果用户再主动设置字体会改变 resolve_mask 即 app_font->resolve() > 0
// qApp->setFont(resolvedFont) 将不再响应 xsettings 字体变化
if (QGuiApplicationPrivate::app_font &&
resolveMask(*QGuiApplicationPrivate::app_font))
return;

// 先清理旧的font对象
if (QGuiApplicationPrivate::app_font)
delete QGuiApplicationPrivate::app_font;
Expand Down Expand Up @@ -661,6 +686,7 @@ const QFont *QDeepinTheme::font(QPlatformTheme::Font type) const
sysFont.reset(new QFont(QString()));
sysFont->setFamily(font_name);
sysFont->setPointSizeF(font_size);
setResolveMask(*sysFont, QFont::NoPropertiesResolved);

return sysFont.data();
}
Expand All @@ -686,6 +712,7 @@ const QFont *QDeepinTheme::font(QPlatformTheme::Font type) const
fixedFont.reset(new QFont(QString()));
fixedFont->setFamily(font_name);
fixedFont->setPointSizeF(font_size);
setResolveMask(*fixedFont, QFont::NoPropertiesResolved);

return fixedFont.data();
}
Expand Down

0 comments on commit 8399021

Please sign in to comment.