Skip to content

Commit 5c04046

Browse files
authored
QWKCore/cocoawindowcontext: Use typeId() instead of type() in Qt 6.0+. (#181)
用typeId()代替type()来消除在Qt 6.0+上出现的编译警告,因为type()已经被标记为弃用。
1 parent ac1a62b commit 5c04046

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/core/contexts/cocoawindowcontext.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,22 +745,34 @@ static inline void releaseWindowProxy(const WId windowId) {
745745
Q_ASSERT(m_windowId);
746746

747747
if (key == QStringLiteral("no-system-buttons")) {
748+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
748749
if (attribute.type() != QVariant::Bool)
750+
#else
751+
if (attribute.typeId() != QMetaType::Type::Bool)
752+
#endif
749753
return false;
750754
ensureWindowProxy(m_windowId)->setSystemButtonVisible(!attribute.toBool());
751755
return true;
752756
}
753757

754758
if (key == QStringLiteral("blur-effect")) {
755759
auto mode = NSWindowProxy::BlurMode::None;
760+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
756761
if (attribute.type() == QVariant::Bool) {
762+
#else
763+
if (attribute.typeId() == QMetaType::Type::Bool) {
764+
#endif
757765
if (attribute.toBool()) {
758766
NSString *osxMode =
759767
[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
760768
mode = [osxMode isEqualToString:@"Dark"] ? NSWindowProxy::BlurMode::Dark
761769
: NSWindowProxy::BlurMode::Light;
762770
}
771+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
763772
} else if (attribute.type() == QVariant::String) {
773+
#else
774+
} else if (attribute.typeId() == QMetaType::Type::QString) {
775+
#endif
764776
auto value = attribute.toString();
765777
if (value == QStringLiteral("dark")) {
766778
mode = NSWindowProxy::BlurMode::Dark;

0 commit comments

Comments
 (0)