Dylan Liu
2025-05-23 5c04046acae6e61280fba7fef31401edd7c36087
QWKCore/cocoawindowcontext: Use typeId() instead of type() in Qt 6.0+. (#181)

用typeId()代替type()来消除在Qt 6.0+上出现的编译警告,因为type()已经被标记为弃用。
1个文件已修改
12 ■■■■■ 已修改文件
src/core/contexts/cocoawindowcontext.mm 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/cocoawindowcontext.mm
@@ -745,7 +745,11 @@
        Q_ASSERT(m_windowId);
        if (key == QStringLiteral("no-system-buttons")) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
            if (attribute.type() != QVariant::Bool)
#else
            if (attribute.typeId() != QMetaType::Type::Bool)
#endif
                return false;
            ensureWindowProxy(m_windowId)->setSystemButtonVisible(!attribute.toBool());
            return true;
@@ -753,14 +757,22 @@
        if (key == QStringLiteral("blur-effect")) {
            auto mode = NSWindowProxy::BlurMode::None;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
            if (attribute.type() == QVariant::Bool) {
#else
            if (attribute.typeId() == QMetaType::Type::Bool) {
#endif
                if (attribute.toBool()) {
                    NSString *osxMode =
                        [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
                    mode = [osxMode isEqualToString:@"Dark"] ? NSWindowProxy::BlurMode::Dark
                                                             : NSWindowProxy::BlurMode::Light;
                }
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
            } else if (attribute.type() == QVariant::String) {
#else
            } else if (attribute.typeId() == QMetaType::Type::QString) {
#endif
                auto value = attribute.toString();
                if (value == QStringLiteral("dark")) {
                    mode = NSWindowProxy::BlurMode::Dark;