summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qglobal.cpp29
-rw-r--r--src/corelib/io/qsettings_win.cpp2
-rw-r--r--src/corelib/kernel/kernel.pri6
-rw-r--r--src/corelib/kernel/qwinregistry.cpp120
-rw-r--r--src/corelib/kernel/qwinregistry_p.h89
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp81
-rw-r--r--src/gui/rhi/qrhigles2.cpp28
-rw-r--r--src/gui/rhi/qrhigles2_p_p.h1
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm183
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h2
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp52
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h2
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp7
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm9
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h10
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.h10
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm21
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoansmenu.h13
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm11
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h19
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm26
-rw-r--r--src/plugins/platforms/cocoa/qnsview_accessibility.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_complextext.mm4
-rw-r--r--src/plugins/platforms/cocoa/qnsview_dragging.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_drawing.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_gestures.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_keys.mm4
-rw-r--r--src/plugins/platforms/cocoa/qnsview_menus.mm4
-rw-r--r--src/plugins/platforms/cocoa/qnsview_mouse.mm8
-rw-r--r--src/plugins/platforms/cocoa/qnsview_tablet.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_touch.mm2
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac_p.h6
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp26
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp27
-rw-r--r--src/tools/bootstrap/bootstrap.pro1
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp8
-rw-r--r--src/widgets/util/qscroller.cpp3
-rw-r--r--src/widgets/widgets/qeffects.cpp2
49 files changed, 505 insertions, 362 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 17aab17fe4..6ae5bf299a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -47,12 +47,11 @@
#include "qoperatingsystemversion.h"
#include "qoperatingsystemversion_p.h"
#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT)
-#include "qoperatingsystemversion_win_p.h"
-# if QT_CONFIG(settings)
-# include "qsettings.h"
-# include "qvariant.h"
+# include "qoperatingsystemversion_win_p.h"
+# ifndef Q_OS_WINRT
+# include "private/qwinregistry_p.h"
# endif
-#endif
+#endif // Q_OS_WIN || Q_OS_CYGWIN
#include <private/qlocale_tools_p.h>
#include <qmutex.h>
@@ -2190,28 +2189,25 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
QT_WARNING_POP
#endif
-static QString readRegistryString(const QString &key, const QString &subKey)
+static QString readVersionRegistryString(const wchar_t *subKey)
{
-#if QT_CONFIG(settings)
- QSettings settings(key, QSettings::NativeFormat);
- return settings.value(subKey).toString();
+#if !defined(QT_BUILD_QMAKE) && !defined(Q_OS_WINRT)
+ return QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)")
+ .stringValue(subKey);
#else
- Q_UNUSED(key);
- Q_UNUSED(subKey);
- return QString();
+ Q_UNUSED(subKey);
+ return QString();
#endif
}
-static inline QString windowsVersionKey() { return QStringLiteral(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion)"); }
-
static inline QString windows10ReleaseId()
{
- return readRegistryString(windowsVersionKey(), QStringLiteral("ReleaseId"));
+ return readVersionRegistryString(L"ReleaseId");
}
static inline QString windows7Build()
{
- return readRegistryString(windowsVersionKey(), QStringLiteral("CurrentBuild"));
+ return readVersionRegistryString(L"CurrentBuild");
}
static QString winSp_helper()
@@ -3078,6 +3074,7 @@ QByteArray QSysInfo::machineUniqueId()
}
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Let's poke at the registry
+ // ### Qt 6: Use new helpers from qwinregistry.cpp (once bootstrap builds are obsolete)
HKEY key = NULL;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ | KEY_WOW64_64KEY, &key)
== ERROR_SUCCESS) {
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 679212ea21..6eb318006e 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -136,6 +136,8 @@ static void mergeKeySets(NameSet *dest, const QStringList &src)
** Wrappers for the insane windows registry API
*/
+// ### Qt 6: Use new helpers from qwinregistry.cpp (once bootstrap builds are obsolete)
+
// Open a key with the specified "perms".
// "access" is to explicitly use the 32- or 64-bit branch.
static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey, REGSAM access = 0)
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 789bcb7927..bd3cabc01a 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -88,8 +88,10 @@ win32 {
SOURCES += kernel/qeventdispatcher_winrt.cpp
HEADERS += kernel/qeventdispatcher_winrt_p.h
} else {
- SOURCES += kernel/qeventdispatcher_win.cpp
- HEADERS += kernel/qeventdispatcher_win_p.h
+ SOURCES += kernel/qeventdispatcher_win.cpp \
+ kernel/qwinregistry.cpp
+ HEADERS += kernel/qeventdispatcher_win_p.h \
+ kernel/qwinregistry_p.h
}
!winrt: LIBS_PRIVATE += -lversion
diff --git a/src/corelib/kernel/qwinregistry.cpp b/src/corelib/kernel/qwinregistry.cpp
new file mode 100644
index 0000000000..6566dd3c76
--- /dev/null
+++ b/src/corelib/kernel/qwinregistry.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwinregistry_p.h"
+
+#include <QtCore/qvarlengtharray.h>
+
+#include <algorithm>
+
+QT_BEGIN_NAMESPACE
+
+QWinRegistryKey::QWinRegistryKey() :
+ m_key(nullptr)
+{
+}
+
+// Open a key with the specified permissions (KEY_READ/KEY_WRITE).
+// "access" is to explicitly use the 32- or 64-bit branch.
+QWinRegistryKey::QWinRegistryKey(HKEY parentHandle, QStringView subKey,
+ REGSAM permissions, REGSAM access)
+{
+ if (RegOpenKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(subKey.utf16()),
+ 0, permissions | access, &m_key) != ERROR_SUCCESS) {
+ m_key = nullptr;
+ }
+}
+
+QWinRegistryKey::~QWinRegistryKey()
+{
+ close();
+}
+
+void QWinRegistryKey::close()
+{
+ if (isValid()) {
+ RegCloseKey(m_key);
+ m_key = nullptr;
+ }
+}
+
+QString QWinRegistryKey::stringValue(QStringView subKey) const
+{
+ QString result;
+ if (!isValid())
+ return result;
+ DWORD type;
+ DWORD size;
+ auto subKeyC = reinterpret_cast<const wchar_t *>(subKey.utf16());
+ if (RegQueryValueEx(m_key, subKeyC, nullptr, &type, nullptr, &size) != ERROR_SUCCESS
+ || (type != REG_SZ && type != REG_EXPAND_SZ) || size <= 2) {
+ return result;
+ }
+ // Reserve more for rare cases where trailing '\0' are missing in registry,
+ // otherwise chop off the '\0' received.
+ QString buffer(int(size / sizeof(wchar_t)), Qt::Uninitialized);
+ if (RegQueryValueEx(m_key, subKeyC, nullptr, &type,
+ reinterpret_cast<LPBYTE>(buffer.data()), &size) == ERROR_SUCCESS) {
+ if (buffer.endsWith(QChar::Null))
+ buffer.chop(1);
+ } else {
+ buffer.clear();
+ }
+ return buffer;
+}
+
+QPair<DWORD, bool> QWinRegistryKey::dwordValue(QStringView subKey) const
+{
+ if (!isValid())
+ return qMakePair(0, false);
+ DWORD type;
+ auto subKeyC = reinterpret_cast<const wchar_t *>(subKey.utf16());
+ if (RegQueryValueEx(m_key, subKeyC, nullptr, &type, nullptr, nullptr) != ERROR_SUCCESS
+ || type != REG_DWORD) {
+ return qMakePair(0, false);
+ }
+ DWORD value = 0;
+ DWORD size = sizeof(value);
+ const bool ok =
+ RegQueryValueEx(m_key, subKeyC, nullptr, nullptr,
+ reinterpret_cast<unsigned char *>(&value), &size) == ERROR_SUCCESS;
+ return qMakePair(value, ok);
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qwinregistry_p.h b/src/corelib/kernel/qwinregistry_p.h
new file mode 100644
index 0000000000..d249a97988
--- /dev/null
+++ b/src/corelib/kernel/qwinregistry_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINREGISTRY_H
+#define QWINREGISTRY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qpair.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringview.h>
+#include <QtCore/qt_windows.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QWinRegistryKey
+{
+public:
+ Q_DISABLE_COPY(QWinRegistryKey)
+
+ QWinRegistryKey();
+ explicit QWinRegistryKey(HKEY parentHandle, QStringView subKey,
+ REGSAM permissions = KEY_READ, REGSAM access = 0);
+ ~QWinRegistryKey();
+
+ QWinRegistryKey(QWinRegistryKey &&other) noexcept { swap(other); }
+ QWinRegistryKey &operator=(QWinRegistryKey &&other) noexcept { swap(other); return *this; }
+
+ void swap(QWinRegistryKey &other) noexcept { qSwap(m_key, other.m_key); }
+
+ bool isValid() const { return m_key != nullptr; }
+ operator HKEY() const { return m_key; }
+ void close();
+
+ QString stringValue(QStringView subKey) const;
+ QPair<DWORD, bool> dwordValue(QStringView subKey) const;
+
+private:
+ HKEY m_key;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINREGISTRY_H
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index 5a480222e0..0fec5355b2 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -46,13 +46,14 @@
#include <algorithm>
-QT_BEGIN_NAMESPACE
-
#ifndef Q_OS_WINRT
+#include <private/qwinregistry_p.h>
// The registry-based timezone backend is not available on WinRT, which falls back to equivalent APIs.
#define QT_USE_REGISTRY_TIMEZONE 1
#endif
+QT_BEGIN_NAMESPACE
+
/*
Private
@@ -71,8 +72,8 @@ QT_BEGIN_NAMESPACE
// Vista introduced support for historic data, see MSDN docs on DYNAMIC_TIME_ZONE_INFORMATION
// http://msdn.microsoft.com/en-gb/library/windows/desktop/ms724253%28v=vs.85%29.aspx
#ifdef QT_USE_REGISTRY_TIMEZONE
-static const char tzRegPath[] = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones";
-static const char currTzRegPath[] = "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation";
+static const wchar_t tzRegPath[] = LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones)";
+static const wchar_t currTzRegPath[] = LR"(SYSTEM\CurrentControlSet\Control\TimeZoneInformation)";
#endif
enum {
@@ -138,27 +139,6 @@ bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMATION &tz
}
#ifdef QT_USE_REGISTRY_TIMEZONE
-bool openRegistryKey(const QString &keyPath, HKEY *key)
-{
- return RegOpenKeyEx(HKEY_LOCAL_MACHINE, reinterpret_cast<const wchar_t*>(keyPath.utf16()),
- 0, KEY_READ, key) == ERROR_SUCCESS;
-}
-
-QString readRegistryString(const HKEY &key, const wchar_t *value)
-{
- wchar_t buffer[MAX_PATH] = {0};
- DWORD size = sizeof(wchar_t) * MAX_PATH;
- RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast<LPBYTE>(buffer), &size);
- return QString::fromWCharArray(buffer);
-}
-
-int readRegistryValue(const HKEY &key, const wchar_t *value)
-{
- DWORD buffer;
- DWORD size = sizeof(buffer);
- RegQueryValueEx(key, value, nullptr, nullptr, reinterpret_cast<LPBYTE>(&buffer), &size);
- return buffer;
-}
QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key,
const wchar_t *value, bool *ok)
@@ -185,12 +165,11 @@ TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok)
TIME_ZONE_INFORMATION tzi;
REG_TZI_FORMAT regTzi;
DWORD regTziSize = sizeof(regTzi);
- HKEY key = NULL;
- const QString tziKeyPath = QString::fromUtf8(tzRegPath) + QLatin1Char('\\')
+ const QString tziKeyPath = QString::fromWCharArray(tzRegPath) + QLatin1Char('\\')
+ QString::fromUtf8(windowsId);
- if (openRegistryKey(tziKeyPath, &key)) {
-
+ QWinRegistryKey key(HKEY_LOCAL_MACHINE, tziKeyPath);
+ if (key.isValid()) {
DWORD size = sizeof(tzi.DaylightName);
RegQueryValueEx(key, L"Dlt", nullptr, nullptr, reinterpret_cast<LPBYTE>(tzi.DaylightName), &size);
@@ -206,8 +185,6 @@ TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok)
tzi.DaylightDate = regTzi.DaylightDate;
*ok = true;
}
-
- RegCloseKey(key);
}
return tzi;
@@ -299,8 +276,8 @@ QList<QByteArray> availableWindowsIds()
#ifdef QT_USE_REGISTRY_TIMEZONE
// TODO Consider caching results in a global static, very unlikely to change.
QList<QByteArray> list;
- HKEY key = NULL;
- if (openRegistryKey(QString::fromUtf8(tzRegPath), &key)) {
+ QWinRegistryKey key(HKEY_LOCAL_MACHINE, tzRegPath);
+ if (key.isValid()) {
DWORD idCount = 0;
if (RegQueryInfoKey(key, 0, 0, 0, &idCount, 0, 0, 0, 0, 0, 0, 0) == ERROR_SUCCESS
&& idCount > 0) {
@@ -311,7 +288,6 @@ QList<QByteArray> availableWindowsIds()
list.append(QString::fromWCharArray(buffer).toUtf8());
}
}
- RegCloseKey(key);
}
return list;
#else // QT_USE_REGISTRY_TIMEZONE
@@ -325,15 +301,10 @@ QByteArray windowsSystemZoneId()
{
#ifdef QT_USE_REGISTRY_TIMEZONE
// On Vista and later is held in the value TimeZoneKeyName in key currTzRegPath
- QString id;
- HKEY key = NULL;
- QString tziKeyPath = QString::fromUtf8(currTzRegPath);
- if (openRegistryKey(tziKeyPath, &key)) {
- id = readRegistryString(key, L"TimeZoneKeyName");
- RegCloseKey(key);
- if (!id.isEmpty())
- return std::move(id).toUtf8();
- }
+ const QString id = QWinRegistryKey(HKEY_LOCAL_MACHINE, currTzRegPath)
+ .stringValue(L"TimeZoneKeyName");
+ if (!id.isEmpty())
+ return id.toUtf8();
// On XP we have to iterate over the zones until we find a match on
// names/offsets with the current data
@@ -575,22 +546,22 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
if (!m_windowsId.isEmpty()) {
#ifdef QT_USE_REGISTRY_TIMEZONE
// Open the base TZI for the time zone
- HKEY baseKey = NULL;
- const QString baseKeyPath = QString::fromUtf8(tzRegPath) + QLatin1Char('\\')
+ const QString baseKeyPath = QString::fromWCharArray(tzRegPath) + QLatin1Char('\\')
+ QString::fromUtf8(m_windowsId);
- if (openRegistryKey(baseKeyPath, &baseKey)) {
+ QWinRegistryKey baseKey(HKEY_LOCAL_MACHINE, baseKeyPath);
+ if (baseKey.isValid()) {
// Load the localized names
- m_displayName = readRegistryString(baseKey, L"Display");
- m_standardName = readRegistryString(baseKey, L"Std");
- m_daylightName = readRegistryString(baseKey, L"Dlt");
+ m_displayName = baseKey.stringValue(L"Display");
+ m_standardName = baseKey.stringValue(L"Std");
+ m_daylightName = baseKey.stringValue(L"Dlt");
// On Vista and later the optional dynamic key holds historic data
const QString dynamicKeyPath = baseKeyPath + QLatin1String("\\Dynamic DST");
- HKEY dynamicKey = NULL;
- if (openRegistryKey(dynamicKeyPath, &dynamicKey)) {
+ QWinRegistryKey dynamicKey(HKEY_LOCAL_MACHINE, dynamicKeyPath);
+ if (dynamicKey.isValid()) {
// Find out the start and end years stored, then iterate over them
- int startYear = readRegistryValue(dynamicKey, L"FirstEntry");
- int endYear = readRegistryValue(dynamicKey, L"LastEntry");
- for (int year = startYear; year <= endYear; ++year) {
+ const auto startYear = dynamicKey.dwordValue(L"FirstEntry");
+ const auto endYear = dynamicKey.dwordValue(L"LastEntry");
+ for (int year = int(startYear.first); year <= int(endYear.first); ++year) {
bool ruleOk;
QWinTransitionRule rule = readRegistryRule(dynamicKey,
reinterpret_cast<LPCWSTR>(QString::number(year).utf16()),
@@ -611,7 +582,6 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
m_tranRules.append(rule);
}
}
- RegCloseKey(dynamicKey);
} else {
// No dynamic data so use the base data
bool ruleOk;
@@ -620,7 +590,6 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
if (ruleOk)
m_tranRules.append(rule);
}
- RegCloseKey(baseKey);
}
#else // QT_USE_REGISTRY_TIMEZONE
if (gTimeZones->isEmpty())
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index e355979626..dec28cac9b 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -525,6 +525,11 @@ void QRhiGles2::destroy()
ensureContext();
executeDeferredReleases();
+ if (vao) {
+ f->glDeleteVertexArrays(1, &vao);
+ vao = 0;
+ }
+
for (uint shader : m_shaderCache)
f->glDeleteShader(shader);
m_shaderCache.clear();
@@ -1151,6 +1156,13 @@ const QRhiNativeHandles *QRhiGles2::nativeHandles(QRhiCommandBuffer *cb)
return nullptr;
}
+static void addBoundaryCommand(QGles2CommandBuffer *cbD, QGles2CommandBuffer::Command::Cmd type)
+{
+ QGles2CommandBuffer::Command cmd;
+ cmd.cmd = type;
+ cbD->commands.append(cmd);
+}
+
void QRhiGles2::beginExternal(QRhiCommandBuffer *cb)
{
if (ofr.active) {
@@ -1166,6 +1178,9 @@ void QRhiGles2::beginExternal(QRhiCommandBuffer *cb)
QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb);
executeCommandBuffer(cbD);
cbD->resetCommands();
+
+ if (vao)
+ f->glBindVertexArray(0);
}
void QRhiGles2::endExternal(QRhiCommandBuffer *cb)
@@ -1183,17 +1198,12 @@ void QRhiGles2::endExternal(QRhiCommandBuffer *cb)
enqueueBarriersForPass(cbD);
}
+ addBoundaryCommand(cbD, QGles2CommandBuffer::Command::ResetFrame);
+
if (cbD->currentTarget)
enqueueBindFramebuffer(cbD->currentTarget, cbD);
}
-static void addBoundaryCommand(QGles2CommandBuffer *cb, QGles2CommandBuffer::Command::Cmd type)
-{
- QGles2CommandBuffer::Command cmd;
- cmd.cmd = type;
- cb->commands.append(cmd);
-}
-
QRhi::FrameOpResult QRhiGles2::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)
{
Q_UNUSED(flags);
@@ -1913,6 +1923,10 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
if (vao)
f->glBindVertexArray(0);
break;
+ case QGles2CommandBuffer::Command::ResetFrame:
+ if (vao)
+ f->glBindVertexArray(vao);
+ break;
case QGles2CommandBuffer::Command::Viewport:
f->glViewport(GLint(cmd.args.viewport.x), GLint(cmd.args.viewport.y), GLsizei(cmd.args.viewport.w), GLsizei(cmd.args.viewport.h));
f->glDepthRangef(cmd.args.viewport.d0, cmd.args.viewport.d1);
diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h
index 8814d9c19d..cc945876e6 100644
--- a/src/gui/rhi/qrhigles2_p_p.h
+++ b/src/gui/rhi/qrhigles2_p_p.h
@@ -300,6 +300,7 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer
enum Cmd {
BeginFrame,
EndFrame,
+ ResetFrame,
Viewport,
Scissor,
BlendConstants,
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 4887a501ba..daa3dc94ea 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -432,88 +432,142 @@ template class QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>;
template class QCoreTextFontDatabaseEngineFactory<QFontEngineFT>;
#endif
-QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family)
+CTFontDescriptorRef descriptorForFamily(const QString &familyName)
{
- if (family.isEmpty())
- return QStringList();
+ return CTFontDescriptorCreateWithAttributes(CFDictionaryRef(@{
+ (id)kCTFontFamilyNameAttribute: familyName.toNSString()
+ }));
+}
- auto attributes = @{ id(kCTFontFamilyNameAttribute): family.toNSString() };
- QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(CFDictionaryRef(attributes));
- if (!fontDescriptor) {
- qCWarning(lcQpaFonts) << "Failed to create fallback font descriptor for" << family;
- return QStringList();
- }
+CTFontDescriptorRef descriptorForFamily(const char *familyName)
+{
+ return descriptorForFamily(QString::fromLatin1(familyName));
+}
- QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0);
+CFArrayRef fallbacksForDescriptor(CTFontDescriptorRef descriptor)
+{
+ QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(descriptor, 0.0, nullptr);
if (!font) {
- qCWarning(lcQpaFonts) << "Failed to create fallback font for" << family;
- return QStringList();
+ qCWarning(lcQpaFonts) << "Failed to create fallback font for" << descriptor;
+ return nullptr;
}
- QCFType<CFArrayRef> cascadeList = CFArrayRef(CTFontCopyDefaultCascadeListForLanguages(font,
+ CFArrayRef cascadeList = CFArrayRef(CTFontCopyDefaultCascadeListForLanguages(font,
(CFArrayRef)[NSUserDefaults.standardUserDefaults stringArrayForKey:@"AppleLanguages"]));
+
if (!cascadeList) {
- qCWarning(lcQpaFonts) << "Failed to create fallback cascade list for" << family;
- return QStringList();
+ qCWarning(lcQpaFonts) << "Failed to create fallback cascade list for" << descriptor;
+ return nullptr;
}
- QStringList fallbackList;
- const int numCascades = CFArrayGetCount(cascadeList);
- for (int i = 0; i < numCascades; ++i) {
- CTFontDescriptorRef fontFallback = CTFontDescriptorRef(CFArrayGetValueAtIndex(cascadeList, i));
- QCFString fallbackFamilyName = CFStringRef(CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute));
- fallbackList.append(QString::fromCFString(fallbackFamilyName));
+ return cascadeList;
+}
+
+CFArrayRef QCoreTextFontDatabase::fallbacksForFamily(const QString &family)
+{
+ if (family.isEmpty())
+ return nullptr;
+
+ QCFType<CTFontDescriptorRef> fontDescriptor = descriptorForFamily(family);
+ if (!fontDescriptor) {
+ qCWarning(lcQpaFonts) << "Failed to create fallback font descriptor for" << family;
+ return nullptr;
}
- return fallbackList;
+ // If the font is not available we want to fall back to the style hint.
+ // By creating a matching font descriptor we can verify whether the font
+ // is available or not, and avoid CTFontCreateWithFontDescriptor picking
+ // a default font for us based on incomplete information.
+ fontDescriptor = CTFontDescriptorCreateMatchingFontDescriptor(fontDescriptor, 0);
+ if (!fontDescriptor)
+ return nullptr;
+
+ return fallbacksForDescriptor(fontDescriptor);
+}
+
+CTFontDescriptorRef descriptorForFontType(CTFontUIFontType uiType)
+{
+ static const CGFloat kDefaultSizeForRequestedUIType = 0.0;
+ QCFType<CTFontRef> ctFont = CTFontCreateUIFontForLanguage(
+ uiType, kDefaultSizeForRequestedUIType, nullptr);
+ return CTFontCopyFontDescriptor(ctFont);
+}
+
+CTFontDescriptorRef descriptorForStyle(QFont::StyleHint styleHint)
+{
+ switch (styleHint) {
+ case QFont::SansSerif: return descriptorForFamily("Helvetica");
+ case QFont::Serif: return descriptorForFamily("Times New Roman");
+ case QFont::Monospace: return descriptorForFamily("Menlo");
+#ifdef Q_OS_MACOS
+ case QFont::Cursive: return descriptorForFamily("Apple Chancery");
+#endif
+ case QFont::Fantasy: return descriptorForFamily("Zapfino");
+ case QFont::TypeWriter: return descriptorForFamily("American Typewriter");
+ case QFont::AnyStyle: Q_FALLTHROUGH();
+ case QFont::System: return descriptorForFontType(kCTFontUIFontSystem);
+ default: return nullptr; // No matching font on this platform
+ }
}
QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
Q_UNUSED(style);
+ qCDebug(lcQpaFonts).nospace() << "Resolving fallbacks families for"
+ << (!family.isEmpty() ? qPrintable(QLatin1String(" family '%1' with").arg(family)) : "")
+ << " style hint " << styleHint;
+
QMacAutoReleasePool pool;
- QStringList fallbackList = fallbacksForFamily(family);
+ QStringList fallbackList;
- if (fallbackList.isEmpty()) {
+ QCFType<CFArrayRef> fallbackFonts = fallbacksForFamily(family);
+ if (!fallbackFonts || !CFArrayGetCount(fallbackFonts)) {
// We were not able to find a fallback for the specific family,
// or the family was empty, so we fall back to the style hint.
- QString styleFamily = [styleHint]{
- switch (styleHint) {
- case QFont::SansSerif: return QStringLiteral("Helvetica");
- case QFont::Serif: return QStringLiteral("Times New Roman");
- case QFont::Monospace: return QStringLiteral("Menlo");
-#ifdef Q_OS_MACOS
- case QFont::Cursive: return QStringLiteral("Apple Chancery");
-#endif
- case QFont::Fantasy: return QStringLiteral("Zapfino");
- case QFont::TypeWriter: return QStringLiteral("American Typewriter");
- case QFont::AnyStyle: Q_FALLTHROUGH();
- case QFont::System: {
- QCFType<CTFontRef> font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12.0, NULL);
- return static_cast<QString>(QCFString(CTFontCopyFullName(font)));
- }
- default: return QString(); // No matching font on this platform
- }
- }();
- if (!styleFamily.isEmpty()) {
- fallbackList = fallbacksForFamily(styleFamily);
- if (!fallbackList.contains(styleFamily))
- fallbackList.prepend(styleFamily);
+ if (!family.isEmpty())
+ qCDebug(lcQpaFonts) << "No fallbacks found. Using style hint instead";
+
+ if (QCFType<CTFontDescriptorRef> styleDescriptor = descriptorForStyle(styleHint)) {
+ CFMutableArrayRef tmp = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ CFArrayAppendValue(tmp, styleDescriptor);
+ QCFType<CFArrayRef> styleFallbacks = fallbacksForDescriptor(styleDescriptor);
+ CFArrayAppendArray(tmp, styleFallbacks, CFRangeMake(0, CFArrayGetCount(styleFallbacks)));
+ fallbackFonts = tmp;
}
}
- if (fallbackList.isEmpty())
+ if (!fallbackFonts)
return fallbackList;
- // .Apple Symbols Fallback will be at the beginning of the list and we will
- // detect that this has glyphs for Arabic and other writing systems.
- // Since it is a symbol font, it should be the last resort, so that
- // the proper fonts for these writing systems are preferred.
- int symbolIndex = fallbackList.indexOf(QLatin1String(".Apple Symbols Fallback"));
- if (symbolIndex >= 0)
- fallbackList.move(symbolIndex, fallbackList.size() - 1);
+ const int numberOfFallbacks = CFArrayGetCount(fallbackFonts);
+ for (int i = 0; i < numberOfFallbacks; ++i) {
+ auto fallbackDescriptor = CTFontDescriptorRef(CFArrayGetValueAtIndex(fallbackFonts, i));
+ auto fallbackFamilyName = QCFString(CTFontDescriptorCopyAttribute(fallbackDescriptor, kCTFontFamilyNameAttribute));
+
+ if (!isFamilyPopulated(fallbackFamilyName)) {
+ // We need to populate, or at least register the fallback fonts,
+ // otherwise the Qt font database may not know they exist.
+ if (isPrivateFontFamily(fallbackFamilyName))
+ const_cast<QCoreTextFontDatabase *>(this)->populateFromDescriptor(fallbackDescriptor);
+ else
+ registerFontFamily(fallbackFamilyName);
+ }
+
+ fallbackList.append(fallbackFamilyName);
+ }
+
+ // Some fallback fonts will have have an order in the list returned
+ // by Core Text that would indicate they should be preferred for e.g.
+ // Arabic, or Emoji, while in reality only supporting a tiny subset
+ // of the required glyphs, or representing them by question marks.
+ // Move these to the end, so that the proper fonts are preferred.
+ for (const char *family : { ".Apple Symbols Fallback", ".Noto Sans Universal" }) {
+ int index = fallbackList.indexOf(QLatin1String(family));
+ if (index >= 0)
+ fallbackList.move(index, fallbackList.size() - 1);
+ }
#if defined(Q_OS_MACOS)
// Since we are only returning a list of default fonts for the current language, we do not
@@ -529,18 +583,11 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
fallbackList.append(QStringLiteral("Apple Symbols"));
#endif
- // Since iOS 13, the cascade list may contain meta-fonts which have not been
- // populated to the database, such as ".AppleJapaneseFont". It is important that we
- // include this in the fallback list, in order to get fallback support for all
- // languages
- for (const QString &fallback : fallbackList) {
- if (!QPlatformFontDatabase::isFamilyPopulated(fallback))
- const_cast<QCoreTextFontDatabase *>(this)->populateFamily(fallback);
- }
-
extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &);
fallbackList = qt_sort_families_by_writing_system(script, fallbackList);
+ qCDebug(lcQpaFonts).nospace() << "Fallback families ordered by script " << script << ": " << fallbackList;
+
return fallbackList;
}
@@ -700,10 +747,8 @@ static CTFontDescriptorRef fontDescriptorFromTheme(QPlatformTheme::Font f)
}
#endif // Q_OS_IOS, Q_OS_TVOS, Q_OS_WATCHOS
- // OSX default case and iOS fallback case
- CTFontUIFontType fontType = fontTypeFromTheme(f);
- QCFType<CTFontRef> ctFont = CTFontCreateUIFontForLanguage(fontType, 0.0, NULL);
- return CTFontCopyFontDescriptor(ctFont);
+ // macOS default case and iOS fallback case
+ return descriptorForFontType(fontTypeFromTheme(f));
}
const QHash<QPlatformTheme::Font, QFont *> &QCoreTextFontDatabase::themeFonts() const
@@ -736,8 +781,8 @@ QFont *QCoreTextFontDatabase::themeFont(QPlatformTheme::Font f) const
QFont QCoreTextFontDatabase::defaultFont() const
{
if (defaultFontName.isEmpty()) {
- QCFType<CTFontRef> font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12.0, NULL);
- defaultFontName = (QString) QCFString(CTFontCopyFullName(font));
+ QCFType<CTFontDescriptorRef> systemFont = descriptorForFontType(kCTFontUIFontSystem);
+ defaultFontName = QCFString(CTFontDescriptorCopyAttribute(systemFont, kCTFontFamilyNameAttribute));
}
return QFont(defaultFontName);
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index 69ff454d1e..eebb3eb964 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -92,7 +92,7 @@ protected:
private:
void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString());
- static QStringList fallbacksForFamily(const QString &family);
+ static CFArrayRef fallbacksForFamily(const QString &family);
mutable QString defaultFontName;
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
index 79f7eb3d43..011476cf13 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -53,6 +53,7 @@
#include <QtCore/QtEndian>
#include <QtCore/QThreadStorage>
#include <QtCore/private/qsystemlibrary_p.h>
+#include <QtCore/private/qwinregistry_p.h>
#include <wchar.h>
@@ -1210,33 +1211,8 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE
void QWindowsFontDatabase::addDefaultEUDCFont()
{
- QString path;
- {
- HKEY key;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,
- L"EUDC\\1252",
- 0,
- KEY_READ,
- &key) != ERROR_SUCCESS) {
- return;
- }
-
- WCHAR value[MAX_PATH];
- DWORD bufferSize = sizeof(value);
- ZeroMemory(value, bufferSize);
-
- if (RegQueryValueEx(key,
- L"SystemDefaultEUDCFont",
- nullptr,
- nullptr,
- reinterpret_cast<LPBYTE>(value),
- &bufferSize) == ERROR_SUCCESS) {
- path = QString::fromWCharArray(value);
- }
-
- RegCloseKey(key);
- }
-
+ const QString path = QWinRegistryKey(HKEY_CURRENT_USER, LR"(EUDC\1252)")
+ .stringValue(L"SystemDefaultEUDCFont");
if (!path.isEmpty()) {
QFile file(path);
if (!file.open(QIODevice::ReadOnly)) {
@@ -2105,28 +2081,6 @@ int QWindowsFontDatabase::defaultVerticalDPI()
return vDPI;
}
-QString QWindowsFontDatabase::readRegistryString(HKEY parentHandle, const wchar_t *keyPath, const wchar_t *keyName)
-{
- QString result;
- HKEY handle = 0;
- if (RegOpenKeyEx(parentHandle, keyPath, 0, KEY_READ, &handle) == ERROR_SUCCESS) {
- // get the size and type of the value
- DWORD dataType;
- DWORD dataSize;
- if (RegQueryValueEx(handle, keyName, 0, &dataType, 0, &dataSize) == ERROR_SUCCESS) {
- if (dataType == REG_SZ || dataType == REG_EXPAND_SZ) {
- dataSize += 2; // '\0' missing?
- QVarLengthArray<unsigned char> data(dataSize);
- data[dataSize - 2] = data[dataSize - 1] = '\0';
- if (RegQueryValueEx(handle, keyName, 0, 0, data.data(), &dataSize) == ERROR_SUCCESS)
- result = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.data()));
- }
- }
- RegCloseKey(handle);
- }
- return result;
-}
-
bool QWindowsFontDatabase::isPrivateFontFamily(const QString &family) const
{
return m_eudcFonts.contains(family) || QPlatformFontDatabase::isPrivateFontFamily(family);
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h
index a1cab17a87..f132e69d4d 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h
@@ -133,8 +133,6 @@ public:
static void setFontOptions(unsigned options);
static unsigned fontOptions();
- static QString readRegistryString(HKEY parentHandle, const wchar_t *keyPath, const wchar_t *keyName);
-
private:
void removeApplicationFonts();
void addDefaultEUDCFont();
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
index a4490a6664..e796c18e79 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QFile>
#include <private/qstringiterator_p.h>
#include <QtCore/private/qsystemlibrary_p.h>
+#include <QtCore/private/qwinregistry_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <QtGui/private/qhighdpiscaling_p.h>
@@ -945,10 +946,10 @@ void QWindowsFontEngineDirectWrite::initFontInfo(const QFontDef &request,
QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyName)
{
- const wchar_t key[] = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes";
const QString substitute =
- QWindowsFontDatabase::readRegistryString(HKEY_LOCAL_MACHINE, key,
- reinterpret_cast<const wchar_t *>(familyName.utf16()));
+ QWinRegistryKey(HKEY_LOCAL_MACHINE,
+ LR"(Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes)")
+ .stringValue(familyName);
return substitute.isEmpty() ? familyName : substitute;
}
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 4644b5af9f..66f2ed017b 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -62,12 +62,11 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
#include <ifaddrs.h>
@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject <CWEventDelegate>
-
@property (assign) QCoreWlanEngine* engine;
-
@end
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSListener);
-@implementation QT_MANGLE_NAMESPACE(QNSListener) {
+@implementation QNSListener {
NSNotificationCenter *notificationCenter;
CWWiFiClient *client;
QCoreWlanEngine *engine;
@@ -88,7 +87,7 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
return self;
}
-static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
+static QNSListener *listener = 0;
-(void)dealloc
{
@@ -415,7 +414,7 @@ void QCoreWlanEngine::initialize()
QMacAutoReleasePool pool;
if ([[CWWiFiClient interfaceNames] count] > 0 && !listener) {
- listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
+ listener = [QNSListener alloc] init];
listener.engine = this;
hasWifi = true;
} else {
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.h b/src/plugins/platforms/cocoa/qcocoaaccessibility.h
index 457c158ddc..539d876094 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.h
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.h
@@ -44,9 +44,9 @@
#include <QtGui>
#include <qpa/qplatformaccessibility.h>
-#ifndef QT_NO_ACCESSIBILITY
+#include "qcocoaaccessibilityelement.h"
-@class QT_MANGLE_NAMESPACE(QMacAccessibilityElement);
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
@@ -84,7 +84,7 @@ namespace QCocoaAccessible {
NSString *macRole(QAccessibleInterface *interface);
NSString *macSubrole(QAccessibleInterface *interface);
bool shouldBeIgnored(QAccessibleInterface *interface);
-NSArray<QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *> *unignoredChildren(QAccessibleInterface *interface);
+NSArray<QMacAccessibilityElement *> *unignoredChildren(QAccessibleInterface *interface);
NSString *getTranslatedAction(const QString &qtAction);
QString translateAction(NSString *nsAction, QAccessibleInterface *interface);
bool hasValueAttribute(QAccessibleInterface *interface);
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
index 7fbe729381..141ce6bf1a 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
@@ -50,8 +50,6 @@
#import <qaccessible.h>
-@class QT_MANGLE_NAMESPACE(QMacAccessibilityElement);
-
@interface QT_MANGLE_NAMESPACE(QMacAccessibilityElement) : NSObject <NSAccessibilityElement>
- (instancetype)initWithId:(QAccessible::Id)anId;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index 340191622a..c6029bcf03 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -144,7 +144,7 @@ static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
}
}
-@implementation QT_MANGLE_NAMESPACE(QNSApplication)
+@implementation QNSApplication
- (void)QT_MANGLE_NAMESPACE(qt_sendEvent_original):(NSEvent *)event
{
@@ -188,7 +188,7 @@ void qt_redirectNSApplicationSendEvent()
// can be unloaded.
return;
- if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
+ if ([NSApp isMemberOfClass:[QNSApplication class]]) {
// No need to change implementation since Qt
// already controls a subclass of NSApplication
return;
@@ -201,7 +201,7 @@ void qt_redirectNSApplicationSendEvent()
qt_cocoa_change_implementation(
[NSApplication class],
@selector(sendEvent:),
- [QT_MANGLE_NAMESPACE(QNSApplication) class],
+ [QNSApplication class],
@selector(QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):),
@selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));
}
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
index 0816730c54..8ec9d6fbe0 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
@@ -89,8 +89,7 @@
#include <qglobal.h>
#include <private/qcore_mac_p.h>
-
-Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaNSMenuItem));
+#include "qcocoansmenu.h"
@interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) : NSObject <NSApplicationDelegate>
@property (nonatomic, retain) NSMenu *dockMenu;
@@ -100,8 +99,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaNSMenuItem));
- (bool)inLaunch;
@end
-@interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) (MenuAPI)
-- (void)qt_itemFired:(QT_MANGLE_NAMESPACE(QCocoaNSMenuItem) *)item;
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate);
+
+@interface QCocoaApplicationDelegate (MenuAPI)
+- (void)qt_itemFired:(QCocoaNSMenuItem *)item;
@end
-QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate);
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 2df85c791b..00f5a1bf09 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -145,7 +145,7 @@ QT_USE_NAMESPACE
[[NSApp mainMenu] cancelTracking];
bool handle_quit = true;
- NSMenuItem *quitMenuItem = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) sharedMenuLoader] quitMenuItem];
+ NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem];
if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty()
&& [quitMenuItem isEnabled]) {
int visible = 0;
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index d7850b1481..c9fa035d87 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -293,7 +293,7 @@ class QCocoaColorPanel
public:
QCocoaColorPanel()
{
- mDelegate = [[QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) alloc] init];
+ mDelegate = [[QNSColorPanelDelegate alloc] init];
}
~QCocoaColorPanel()
@@ -366,7 +366,7 @@ public:
}
private:
- QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *mDelegate;
+ QNSColorPanelDelegate *mDelegate;
};
Q_GLOBAL_STATIC(QCocoaColorPanel, sharedColorPanel)
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
index 2ddda14289..dd0afbefe6 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
@@ -43,10 +43,16 @@
#include <QObject>
#include <QtWidgets/qtwidgetsglobal.h>
#include <qpa/qplatformdialoghelper.h>
+#include <QtCore/private/qcore_mac_p.h>
+
+#import <AppKit/NSSavePanel.h>
QT_REQUIRE_CONFIG(filedialog);
-Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate));
+@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) : NSObject<NSOpenSavePanelDelegate>
+@end
+
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
QT_BEGIN_NAMESPACE
@@ -84,7 +90,7 @@ public:
void QNSOpenSavePanelDelegate_filterSelected(int menuIndex);
private:
- QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *mDelegate;
+ QNSOpenSavePanelDelegate *mDelegate;
QUrl mDir;
};
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 03677ef0bc..6aa21d78d1 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -76,27 +76,6 @@ QT_USE_NAMESPACE
typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
-@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate)
- : NSObject<NSOpenSavePanelDelegate>
-
-- (NSString *)strip:(const QString &)label;
-- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url;
-- (void)filterChanged:(id)sender;
-- (void)showModelessPanel;
-- (BOOL)runApplicationModalPanel;
-- (void)showWindowModalSheet:(QWindow *)docWidget;
-- (void)updateProperties;
-- (QStringList)acceptableExtensionsForSave;
-- (QString)removeExtensions:(const QString &)filter;
-- (void)createTextField;
-- (void)createPopUpButton:(const QString &)selectedFilter hideDetails:(BOOL)hideDetails;
-- (QStringList)findStrippedFilterWithVisualFilterName:(QString)name;
-- (void)createAccessory;
-
-@end
-
-QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
-
@implementation QNSOpenSavePanelDelegate {
@public
NSOpenPanel *mOpenPanel;
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 8c0af97a68..7748c304e3 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -283,7 +283,7 @@ class QCocoaFontPanel
public:
QCocoaFontPanel()
{
- mDelegate = [[QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) alloc] init];
+ mDelegate = [[QNSFontPanelDelegate alloc] init];
}
~QCocoaFontPanel()
@@ -356,7 +356,7 @@ public:
}
private:
- QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *mDelegate;
+ QNSFontPanelDelegate *mDelegate;
};
Q_GLOBAL_STATIC(QCocoaFontPanel, sharedFontPanel)
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h
index a957710a88..1dccf0621c 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.h
+++ b/src/plugins/platforms/cocoa/qcocoamenu.h
@@ -44,8 +44,7 @@
#include <QtCore/QList>
#include <qpa/qplatformmenu.h>
#include "qcocoamenuitem.h"
-
-Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaNSMenu));
+#include "qcocoansmenu.h"
QT_BEGIN_NAMESPACE
@@ -107,7 +106,7 @@ private:
void scheduleUpdate();
QList<QCocoaMenuItem *> m_menuItems;
- QT_MANGLE_NAMESPACE(QCocoaNSMenu) *m_nativeMenu;
+ QCocoaNSMenu *m_nativeMenu;
NSMenuItem *m_attachedItem;
int m_updateTimer;
bool m_enabled:1;
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 30bff78a36..363defdd28 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -278,12 +278,11 @@ void QCocoaMenuBar::updateMenuBarImmediately()
// we still have to update the menubar.
if ((win->flags() & Qt::WindowType_Mask) != Qt::Tool)
return;
- typedef QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) AppDelegate;
NSApplication *app = [NSApplication sharedApplication];
- if (![app.delegate isKindOfClass:[AppDelegate class]])
+ if (![app.delegate isKindOfClass:[QCocoaApplicationDelegate class]])
return;
// We apply this logic _only_ during the startup.
- AppDelegate *appDelegate = app.delegate;
+ QCocoaApplicationDelegate *appDelegate = app.delegate;
if (!appDelegate.inLaunch)
return;
}
@@ -403,3 +402,4 @@ QCocoaWindow *QCocoaMenuBar::cocoaWindow() const
QT_END_NAMESPACE
+#include "moc_qcocoamenubar.cpp"
diff --git a/src/plugins/platforms/cocoa/qcocoansmenu.h b/src/plugins/platforms/cocoa/qcocoansmenu.h
index 6cbb6e4a01..0c77e2f1aa 100644
--- a/src/plugins/platforms/cocoa/qcocoansmenu.h
+++ b/src/plugins/platforms/cocoa/qcocoansmenu.h
@@ -59,31 +59,20 @@ QT_FORWARD_DECLARE_CLASS(QCocoaMenu);
QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem);
@interface QT_MANGLE_NAMESPACE(QCocoaNSMenuDelegate) : NSObject <NSMenuDelegate>
-
+ (instancetype)sharedMenuDelegate;
-
-- (NSMenuItem *)findItemInMenu:(NSMenu *)menu
- forKey:(NSString *)key
- modifiers:(NSUInteger)modifiers;
-
+- (NSMenuItem *)findItemInMenu:(NSMenu *)menu forKey:(NSString *)key modifiers:(NSUInteger)modifiers;
@end
@interface QT_MANGLE_NAMESPACE(QCocoaNSMenu) : NSMenu
-
@property (readonly, nonatomic) QCocoaMenu *platformMenu;
-
- (instancetype)initWithPlatformMenu:(QCocoaMenu *)menu;
-
@end
@interface QT_MANGLE_NAMESPACE(QCocoaNSMenuItem) : NSMenuItem
-
@property (nonatomic) QCocoaMenuItem *platformMenuItem;
-
+ (instancetype)separatorItemWithPlatformMenuItem:(QCocoaMenuItem *)menuItem;
- (instancetype)initWithPlatformMenuItem:(QCocoaMenuItem *)menuItem;
- (instancetype)init;
-
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaNSMenu);
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 1390ace632..559188aa5f 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -80,6 +80,8 @@
#include <qimagewriter.h>
#include <qdebug.h>
+#include <QtCore/private/qcore_mac_p.h>
+
#include "qcocoamenu.h"
#include "qt_mac_p.h"
@@ -92,8 +94,6 @@
QT_USE_NAMESPACE
-@class QT_MANGLE_NAMESPACE(QNSImageView);
-
@interface QT_MANGLE_NAMESPACE(QNSStatusItem) : NSObject <NSUserNotificationCenterDelegate>
@property (nonatomic, assign) QCocoaMenu *menu;
@property (nonatomic, assign) QIcon icon;
@@ -104,12 +104,13 @@ QT_USE_NAMESPACE
- (void)doubleClickSelector:(id)sender;
@end
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSStatusItem);
+
@interface QT_MANGLE_NAMESPACE(QNSImageView) : NSImageView
@property (nonatomic, assign) BOOL down;
-@property (nonatomic, assign) QT_MANGLE_NAMESPACE(QNSStatusItem) *parent;
+@property (nonatomic, assign) QNSStatusItem *parent;
@end
-QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSStatusItem);
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSImageView);
QT_BEGIN_NAMESPACE
@@ -364,7 +365,7 @@ QT_END_NAMESPACE
@implementation QNSStatusItem {
QCocoaSystemTrayIcon *systray;
NSStatusItem *item;
- QT_MANGLE_NAMESPACE(QNSImageView) *imageCell;
+ QNSImageView *imageCell;
}
@synthesize menu = menu;
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
index 788b616e78..a00cbdfea3 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
@@ -43,8 +43,6 @@
#include <QtCore/QHash>
#include <qpa/qplatformtheme.h>
-Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaThemeAppAppearanceObserver));
-
#include <QtCore/private/qcore_mac_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index b40dfe0d14..74d0735b4c 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -51,37 +51,30 @@ class QCocoaGLContext;
class QPointF;
QT_END_NAMESPACE
-Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
-Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaNSMenuItem));
-
@interface QT_MANGLE_NAMESPACE(QNSView) : NSView
-
@property (nonatomic, retain) NSCursor *cursor;
-
- (instancetype)initWithCocoaWindow:(QCocoaWindow *)platformWindow;
-
- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint;
-
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (MouseAPI)
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);
+
+@interface QNSView (MouseAPI)
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent;
- (void)resetMouseButtons;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (KeysAPI)
+@interface QNSView (KeysAPI)
+ (Qt::KeyboardModifiers)convertKeyModifiers:(ulong)modifierFlags;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (ComplexTextAPI)
+@interface QNSView (ComplexTextAPI)
- (void)unmarkText;
- (void)cancelComposingText;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (QtExtras)
+@interface QNSView (QtExtras)
@property (nonatomic, readonly) QCocoaWindow *platformWindow;
@end
-QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);
-
#endif //QNSVIEW_H
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 5309449dce..a6e5ca5f7b 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -66,13 +66,13 @@
#include "qcocoaintegration.h"
// Private interface
-@interface QT_MANGLE_NAMESPACE(QNSView) ()
+@interface QNSView ()
- (BOOL)isTransparentForUserInput;
@property (assign) NSView* previousSuperview;
@property (assign) NSWindow* previousWindow;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Drawing) <CALayerDelegate>
+@interface QNSView (Drawing) <CALayerDelegate>
- (void)initDrawing;
@end
@@ -84,7 +84,9 @@
- (void)cursorUpdate:(NSEvent *)theEvent;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Mouse)
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper);
+
+@interface QNSView (Mouse)
- (void)initMouse;
- (NSPoint)screenMousePoint:(NSEvent *)theEvent;
- (void)mouseMovedImpl:(NSEvent *)theEvent;
@@ -92,28 +94,28 @@
- (void)mouseExitedImpl:(NSEvent *)theEvent;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Touch)
+@interface QNSView (Touch)
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Tablet)
+@interface QNSView (Tablet)
- (bool)handleTabletEvent:(NSEvent *)theEvent;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Gestures)
+@interface QNSView (Gestures)
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Dragging)
+@interface QNSView (Dragging)
-(void)registerDragTypes;
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (Keys)
+@interface QNSView (Keys)
@end
-@interface QT_MANGLE_NAMESPACE(QNSView) (ComplexText) <NSTextInputClient>
+@interface QNSView (ComplexText) <NSTextInputClient>
- (void)textInputContextKeyboardSelectionDidChangeNotification:(NSNotification *)textInputContextKeyboardSelectionDidChangeNotification;
@end
-@implementation QT_MANGLE_NAMESPACE(QNSView) {
+@implementation QNSView {
QPointer<QCocoaWindow> m_platformWindow;
Qt::MouseButtons m_buttons;
Qt::MouseButtons m_acceptedMouseDowns;
@@ -125,7 +127,7 @@
bool m_sendUpAsRightButton;
Qt::KeyboardModifiers m_currentWheelModifiers;
NSString *m_inputSource;
- QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper;
+ QNSViewMouseMoveHelper *m_mouseMoveHelper;
bool m_resendKeyEvent;
bool m_scrolling;
bool m_updatingDrag;
@@ -379,7 +381,7 @@
// -----------------------------------------------------
-@implementation QT_MANGLE_NAMESPACE(QNSView) (QtExtras)
+@implementation QNSView (QtExtras)
- (QCocoaWindow*)platformWindow
{
diff --git a/src/plugins/platforms/cocoa/qnsview_accessibility.mm b/src/plugins/platforms/cocoa/qnsview_accessibility.mm
index 32ec0b74d4..7041e14da7 100644
--- a/src/plugins/platforms/cocoa/qnsview_accessibility.mm
+++ b/src/plugins/platforms/cocoa/qnsview_accessibility.mm
@@ -47,7 +47,7 @@
#import <AppKit/NSAccessibility.h>
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Accessibility)
+@implementation QNSView (Accessibility)
- (id)childAccessibleElement
{
diff --git a/src/plugins/platforms/cocoa/qnsview_complextext.mm b/src/plugins/platforms/cocoa/qnsview_complextext.mm
index 6ff9b26ca4..5926840cf3 100644
--- a/src/plugins/platforms/cocoa/qnsview_complextext.mm
+++ b/src/plugins/platforms/cocoa/qnsview_complextext.mm
@@ -39,7 +39,7 @@
// This file is included from qnsview.mm, and only used to organize the code
-@implementation QT_MANGLE_NAMESPACE(QNSView) (ComplexTextAPI)
+@implementation QNSView (ComplexTextAPI)
- (void)cancelComposingText
{
@@ -80,7 +80,7 @@
@end
-@implementation QT_MANGLE_NAMESPACE(QNSView) (ComplexText)
+@implementation QNSView (ComplexText)
- (void)insertNewline:(id)sender
{
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
index 41b96b2df6..650612e7ff 100644
--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
+++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
@@ -39,7 +39,7 @@
// This file is included from qnsview.mm, and only used to organize the code
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Dragging)
+@implementation QNSView (Dragging)
-(void)registerDragTypes
{
diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm
index ce5488ead0..eb9286519d 100644
--- a/src/plugins/platforms/cocoa/qnsview_drawing.mm
+++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm
@@ -39,7 +39,7 @@
// This file is included from qnsview.mm, and only used to organize the code
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Drawing)
+@implementation QNSView (Drawing)
- (void)initDrawing
{
diff --git a/src/plugins/platforms/cocoa/qnsview_gestures.mm b/src/plugins/platforms/cocoa/qnsview_gestures.mm
index f6cd3af4da..a80261fd6a 100644
--- a/src/plugins/platforms/cocoa/qnsview_gestures.mm
+++ b/src/plugins/platforms/cocoa/qnsview_gestures.mm
@@ -43,7 +43,7 @@
Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Gestures)
+@implementation QNSView (Gestures)
- (bool)handleGestureAsBeginEnd:(NSEvent *)event
{
diff --git a/src/plugins/platforms/cocoa/qnsview_keys.mm b/src/plugins/platforms/cocoa/qnsview_keys.mm
index ad751279bb..847adca207 100644
--- a/src/plugins/platforms/cocoa/qnsview_keys.mm
+++ b/src/plugins/platforms/cocoa/qnsview_keys.mm
@@ -39,7 +39,7 @@
// This file is included from qnsview.mm, and only used to organize the code
-@implementation QT_MANGLE_NAMESPACE(QNSView) (KeysAPI)
+@implementation QNSView (KeysAPI)
+ (Qt::KeyboardModifiers)convertKeyModifiers:(ulong)modifierFlags
{
@@ -60,7 +60,7 @@
@end
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Keys)
+@implementation QNSView (Keys)
- (int)convertKeyCode:(QChar)keyChar
{
diff --git a/src/plugins/platforms/cocoa/qnsview_menus.mm b/src/plugins/platforms/cocoa/qnsview_menus.mm
index f0489552aa..a55fd97eb7 100644
--- a/src/plugins/platforms/cocoa/qnsview_menus.mm
+++ b/src/plugins/platforms/cocoa/qnsview_menus.mm
@@ -53,11 +53,11 @@ static bool selectorIsCutCopyPaste(SEL selector)
|| selector == @selector(selectAll:));
}
-@interface QT_MANGLE_NAMESPACE(QNSView) (Menus)
+@interface QNSView (Menus)
- (void)qt_itemFired:(QCocoaNSMenuItem *)item;
@end
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Menus)
+@implementation QNSView (Menus)
- (BOOL)validateMenuItem:(NSMenuItem*)item
{
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm
index 30613eca32..9e2761f850 100644
--- a/src/plugins/platforms/cocoa/qnsview_mouse.mm
+++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm
@@ -55,7 +55,7 @@
interact with the responder chain by e.g. calling super if Qt does not
accept the mouse event
*/
-@implementation QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) {
+@implementation QNSViewMouseMoveHelper {
QNSView *view;
}
@@ -89,7 +89,7 @@
@end
-@implementation QT_MANGLE_NAMESPACE(QNSView) (MouseAPI)
+@implementation QNSView (MouseAPI)
- (void)resetMouseButtons
{
@@ -178,7 +178,7 @@
}
@end
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Mouse)
+@implementation QNSView (Mouse)
- (void)initMouse
{
@@ -193,7 +193,7 @@
m_dontOverrideCtrlLMB = qt_mac_resolveOption(false, m_platformWindow->window(),
"_q_platform_MacDontOverrideCtrlLMB", "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
- m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self];
+ m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self];
NSUInteger trackingOptions = NSTrackingActiveInActiveApp
| NSTrackingMouseEnteredAndExited | NSTrackingCursorUpdate;
diff --git a/src/plugins/platforms/cocoa/qnsview_tablet.mm b/src/plugins/platforms/cocoa/qnsview_tablet.mm
index 43b0aa0960..ba1fa55892 100644
--- a/src/plugins/platforms/cocoa/qnsview_tablet.mm
+++ b/src/plugins/platforms/cocoa/qnsview_tablet.mm
@@ -54,7 +54,7 @@ struct QCocoaTabletDeviceData
typedef QHash<uint, QCocoaTabletDeviceData> QCocoaTabletDeviceDataHash;
Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Tablet)
+@implementation QNSView (Tablet)
- (bool)handleTabletEvent:(NSEvent *)theEvent
{
diff --git a/src/plugins/platforms/cocoa/qnsview_touch.mm b/src/plugins/platforms/cocoa/qnsview_touch.mm
index 9330844aec..8dfae27c63 100644
--- a/src/plugins/platforms/cocoa/qnsview_touch.mm
+++ b/src/plugins/platforms/cocoa/qnsview_touch.mm
@@ -41,7 +41,7 @@
Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
-@implementation QT_MANGLE_NAMESPACE(QNSView) (Touch)
+@implementation QNSView (Touch)
- (bool)shouldSendSingleTouch
{
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac_p.h b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
index 3d94227ae4..6a1ed2e263 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac_p.h
+++ b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
@@ -64,11 +64,7 @@
#include "qpaintengine_mac_p.h"
-#ifdef __OBJC__
-@class NSPrintInfo;
-#else
-typedef void NSPrintInfo;
-#endif
+Q_FORWARD_DECLARE_OBJC_CLASS(NSPrintInfo);
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index bb349f08a7..f7d04b667d 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -79,6 +79,7 @@
#include <QtCore/qscopedpointer.h>
#include <QtCore/quuid.h>
#include <QtCore/private/qsystemlibrary_p.h>
+#include <QtCore/private/qwinregistry_p.h>
#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
@@ -1518,28 +1519,13 @@ QTouchDevice *QWindowsContext::touchDevice() const
d->m_pointerHandler.touchDevice() : d->m_mouseHandler.touchDevice();
}
-static DWORD readDwordRegistrySetting(const wchar_t *regKey, const wchar_t *subKey, DWORD defaultValue)
-{
- DWORD result = defaultValue;
- HKEY handle;
- if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &handle) == ERROR_SUCCESS) {
- DWORD type;
- if (RegQueryValueEx(handle, subKey, nullptr, &type, nullptr, nullptr) == ERROR_SUCCESS
- && type == REG_DWORD) {
- DWORD value;
- DWORD size = sizeof(result);
- if (RegQueryValueEx(handle, subKey, nullptr, nullptr, reinterpret_cast<unsigned char *>(&value), &size) == ERROR_SUCCESS)
- result = value;
- }
- RegCloseKey(handle);
- }
- return result;
-}
-
DWORD QWindowsContext::readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue)
{
- return readDwordRegistrySetting(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
- subKey, defaultValue);
+ const auto value =
+ QWinRegistryKey(HKEY_CURRENT_USER,
+ LR"(Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced)")
+ .dwordValue(subKey);
+ return value.second ? value.first : defaultValue;
}
static inline bool isEmptyRect(const RECT &rect)
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index b2b1dee232..83b052bb49 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -45,6 +45,8 @@
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
+#include <QtCore/private/qwinregistry_p.h>
+
#include <shlobj.h>
#include <intshcut.h>
@@ -78,35 +80,24 @@ static inline QString mailCommand()
const wchar_t mailUserKey[] = L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice";
- wchar_t command[MAX_PATH] = {0};
// Check if user has set preference, otherwise use default.
- HKEY handle;
- QString keyName;
- if (!RegOpenKeyEx(HKEY_CURRENT_USER, mailUserKey, 0, KEY_READ, &handle)) {
- DWORD bufferSize = BufferSize;
- if (!RegQueryValueEx(handle, L"Progid", nullptr, nullptr, reinterpret_cast<unsigned char*>(command), &bufferSize))
- keyName = QString::fromWCharArray(command);
- RegCloseKey(handle);
- }
+ QString keyName = QWinRegistryKey(HKEY_CURRENT_USER, mailUserKey)
+ .stringValue( L"Progid");
const QLatin1String mailto = keyName.isEmpty() ? QLatin1String("mailto") : QLatin1String();
keyName += mailto + QLatin1String("\\Shell\\Open\\Command");
if (debug)
qDebug() << __FUNCTION__ << "keyName=" << keyName;
- command[0] = 0;
- if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, reinterpret_cast<const wchar_t*>(keyName.utf16()), 0, KEY_READ, &handle)) {
- DWORD bufferSize = BufferSize;
- RegQueryValueEx(handle, L"", nullptr, nullptr, reinterpret_cast<unsigned char*>(command), &bufferSize);
- RegCloseKey(handle);
- }
+ const QString command = QWinRegistryKey(HKEY_CLASSES_ROOT, keyName).stringValue(L"");
// QTBUG-57816: As of Windows 10, if there is no mail client installed, an entry like
// "rundll32.exe .. url.dll,MailToProtocolHandler %l" is returned. Launching it
// silently fails or brings up a broken dialog after a long time, so exclude it and
// fall back to ShellExecute() which brings up the URL assocation dialog.
- if (!command[0] || wcsstr(command, L",MailToProtocolHandler") != nullptr)
+ if (command.isEmpty() || command.contains(QLatin1String(",MailToProtocolHandler")))
return QString();
wchar_t expandedCommand[MAX_PATH] = {0};
- return ExpandEnvironmentStrings(command, expandedCommand, MAX_PATH) ?
- QString::fromWCharArray(expandedCommand) : QString::fromWCharArray(command);
+ return ExpandEnvironmentStrings(reinterpret_cast<const wchar_t *>(command.utf16()),
+ expandedCommand, MAX_PATH)
+ ? QString::fromWCharArray(expandedCommand) : command;
}
static inline bool launchMail(const QUrl &url)
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index 09a1c68001..9863ff5e69 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -126,6 +126,7 @@ win32:SOURCES += ../../corelib/global/qoperatingsystemversion_win.cpp \
../../corelib/kernel/qsharedmemory_win.cpp \
../../corelib/kernel/qsystemsemaphore_win.cpp \
../../corelib/plugin/qsystemlibrary.cpp \
+ ../../corelib/kernel/qwinregistry.cpp \
mac {
SOURCES += \
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 4fbe6bba3f..9e90adec46 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -211,7 +211,9 @@ QDesktopWidget::QDesktopWidget()
setObjectName(QLatin1String("desktop"));
d->_q_updateScreens();
connect(qApp, SIGNAL(screenAdded(QScreen*)), this, SLOT(_q_updateScreens()));
+#if QT_DEPRECATED_SINCE(5, 11)
connect(qApp, SIGNAL(primaryScreenChanged(QScreen*)), this, SIGNAL(primaryScreenChanged()));
+#endif
}
QDesktopWidget::~QDesktopWidget()
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 588bed0366..74aebd1223 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2914,6 +2914,8 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
{
Q_D(QWidget);
Qt::WindowStates oldstate = windowState();
+ if (newstate.testFlag(Qt::WindowMinimized)) // QTBUG-46763
+ newstate.setFlag(Qt::WindowActive, false);
if (oldstate == newstate)
return;
if (isWindow() && !testAttribute(Qt::WA_WState_Created))
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 88c6c288e8..3f57992311 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -5035,6 +5035,14 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
sz = subRule.adjustSize(csz);
+ if (!sz.isValid()) {
+ // Try to set the missing values based on the base style.
+ const auto baseSize = baseStyle()->sizeFromContents(ct, opt, sz, w);
+ if (sz.width() < 0)
+ sz.setWidth(baseSize.width());
+ if (sz.height() < 0)
+ sz.setHeight(baseSize.height());
+ }
if (!subRule.hasGeometry()) {
QSize nativeContentsSize;
bool nullIcon = hdr->icon.isNull();
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index 1e84237253..df05bbf71c 100644
--- a/src/widgets/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
@@ -1031,7 +1031,8 @@ void QScrollerPrivate::setDpi(const QPointF &dpi)
*/
void QScrollerPrivate::setDpiFromWidget(QWidget *widget)
{
- const QScreen *screen = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(widget));
+ const QScreen *screen = widget ? widget->screen() : QGuiApplication::primaryScreen();
+ Q_ASSERT(screen);
setDpi(QPointF(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY()));
}
diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index 9463641369..7069ef0368 100644
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -99,7 +99,7 @@ static QAlphaWidget* q_blend = 0;
Constructs a QAlphaWidget.
*/
QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen()
+QT_WARNING_DISABLE_DEPRECATED // ### Qt 6: Find a replacement for QDesktopWidget::screen()
QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f)
: QWidget(QApplication::desktop()->screen(QDesktopWidgetPrivate::screenNumber(w)), f)
{