From 10c1625cd8c32faf6a1d42c2106b3b3966175c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 17:00:53 +0200 Subject: macOS: Move translations to their respective source files lupdate can deal with Objective-C++ sources nowadays, most likely due to appending them to SOURCES instead of the deprecated OBJECTIVE_SOURCES. Task-number: QTBUG-30125 Change-Id: Ifc6b06f13e0f679a011d999f11c2e6d25dcf27ed Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/cocoa.pro | 4 +- src/plugins/platforms/cocoa/messages.cpp | 115 ------------------------ src/plugins/platforms/cocoa/messages.h | 69 -------------- src/plugins/platforms/cocoa/qcocoamenuitem.h | 12 +++ src/plugins/platforms/cocoa/qcocoamenuitem.mm | 60 ++++++++++++- src/plugins/platforms/cocoa/qcocoamenuloader.mm | 1 - src/plugins/platforms/cocoa/qcocoatheme.mm | 5 +- 7 files changed, 74 insertions(+), 192 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/messages.cpp delete mode 100644 src/plugins/platforms/cocoa/messages.h (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index a919963cf4..a059dcebe7 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -31,8 +31,7 @@ SOURCES += main.mm \ qcocoaintrospection.mm \ qcocoakeymapper.mm \ qcocoamimetypes.mm \ - qiosurfacegraphicsbuffer.mm \ - messages.cpp + qiosurfacegraphicsbuffer.mm HEADERS += qcocoaintegration.h \ qcocoascreen.h \ @@ -63,7 +62,6 @@ HEADERS += qcocoaintegration.h \ qcocoasystemtrayicon.h \ qcocoaintrospection.h \ qcocoakeymapper.h \ - messages.h \ qiosurfacegraphicsbuffer.h \ qcocoamimetypes.h diff --git a/src/plugins/platforms/cocoa/messages.cpp b/src/plugins/platforms/cocoa/messages.cpp deleted file mode 100644 index 06e3dd454e..0000000000 --- a/src/plugins/platforms/cocoa/messages.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins 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 "messages.h" - -#include -#include - -// Translatable messages should go into this .cpp file for them to be picked up by lupdate. - -QT_BEGIN_NAMESPACE - -QString msgAboutQt() -{ - return QCoreApplication::translate("QCocoaMenuItem", "About Qt"); -} - -static const char *application_menu_strings[] = -{ - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1") -}; - -QString qt_mac_applicationmenu_string(int type) -{ - QString menuString = QString::fromLatin1(application_menu_strings[type]); - const QString translated = QCoreApplication::translate("QMenuBar", application_menu_strings[type]); - if (translated != menuString) { - return translated; - } else { - return QCoreApplication::translate("MAC_APPLICATION_MENU", application_menu_strings[type]); - } -} - -QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption) -{ - QString captionNoAmpersand(caption); - captionNoAmpersand.remove(QLatin1Char('&')); - const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About"); - if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) - || captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) { - static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption); - if (captionNoAmpersand.contains(qtRegExp)) - return QPlatformMenuItem::AboutQtRole; - return QPlatformMenuItem::AboutRole; - } - if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) { - return QPlatformMenuItem::PreferencesRole; - } - if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) { - return QPlatformMenuItem::QuitRole; - } - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive)) - return QPlatformMenuItem::CutRole; - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive)) - return QPlatformMenuItem::CopyRole; - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive)) - return QPlatformMenuItem::PasteRole; - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive)) - return QPlatformMenuItem::SelectAllRole; - return QPlatformMenuItem::NoRole; -} - -QString msgDialogButtonDiscard() -{ - return QCoreApplication::translate("QCocoaTheme", "Don't Save"); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/messages.h b/src/plugins/platforms/cocoa/messages.h deleted file mode 100644 index 3a9eaf604e..0000000000 --- a/src/plugins/platforms/cocoa/messages.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins 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 MESSAGES_H -#define MESSAGES_H - -#include -#include - -QT_BEGIN_NAMESPACE - -enum { - AboutAppMenuItem = 0, - PreferencesAppMenuItem, - ServicesAppMenuItem, - HideAppMenuItem, - HideOthersAppMenuItem, - ShowAllAppMenuItem, - QuitAppMenuItem -}; - - -QString msgAboutQt(); - -QString qt_mac_applicationmenu_string(int type); - -QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption); - -QString msgDialogButtonDiscard(); - -QT_END_NAMESPACE - -#endif // MESSAGES_H diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h index c842b08d52..029d29be9d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.h +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h @@ -53,6 +53,18 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView); QT_BEGIN_NAMESPACE +enum { + AboutAppMenuItem = 0, + PreferencesAppMenuItem, + ServicesAppMenuItem, + HideAppMenuItem, + HideOthersAppMenuItem, + ShowAllAppMenuItem, + QuitAppMenuItem +}; + +QString qt_mac_applicationmenu_string(int type); + class QCocoaMenu; class QCocoaMenuObject diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 5aa41eeb22..c4e2dd0e92 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -45,18 +45,40 @@ #include "qcocoansmenu.h" #include "qcocoamenu.h" #include "qcocoamenubar.h" -#include "messages.h" #include "qcocoahelpers.h" #include "qt_mac_p.h" #include "qcocoaapplication.h" // for custom application category #include "qcocoamenuloader.h" #include +#include #include #include QT_BEGIN_NAMESPACE +static const char *application_menu_strings[] = +{ + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1") +}; + +QString qt_mac_applicationmenu_string(int type) +{ + QString menuString = QString::fromLatin1(application_menu_strings[type]); + const QString translated = QCoreApplication::translate("QMenuBar", application_menu_strings[type]); + if (translated != menuString) { + return translated; + } else { + return QCoreApplication::translate("MAC_APPLICATION_MENU", application_menu_strings[type]); + } +} + static quint32 constructModifierMask(quint32 accel_key) { quint32 ret = 0; @@ -226,6 +248,40 @@ void QCocoaMenuItem::setNativeContents(WId item) m_itemView.needsDisplay = YES; } +static QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption) +{ + QString captionNoAmpersand(caption); + captionNoAmpersand.remove(QLatin1Char('&')); + const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About"); + if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) + || captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) { + static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption); + if (captionNoAmpersand.contains(qtRegExp)) + return QPlatformMenuItem::AboutQtRole; + return QPlatformMenuItem::AboutRole; + } + if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) { + return QPlatformMenuItem::PreferencesRole; + } + if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) { + return QPlatformMenuItem::QuitRole; + } + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive)) + return QPlatformMenuItem::CutRole; + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive)) + return QPlatformMenuItem::CopyRole; + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive)) + return QPlatformMenuItem::PasteRole; + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive)) + return QPlatformMenuItem::SelectAllRole; + return QPlatformMenuItem::NoRole; +} + NSMenuItem *QCocoaMenuItem::sync() { if (m_isSeparator != m_native.separatorItem) { @@ -354,7 +410,7 @@ QString QCocoaMenuItem::mergeText() return qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName()); } else if (m_native== [loader aboutQtMenuItem]) { if (m_text == QString("About Qt")) - return msgAboutQt(); + return QCoreApplication::translate("QCocoaMenuItem", "About Qt"); else return m_text; } else if (m_native == [loader preferencesMenuItem]) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index d384078e91..a7c17fc177 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -39,7 +39,6 @@ #include "qcocoamenuloader.h" -#include "messages.h" #include "qcocoahelpers.h" #include "qcocoansmenu.h" #include "qcocoamenubar.h" diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index a76ba300e9..d73b028afb 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -40,7 +40,6 @@ #import #include "qcocoatheme.h" -#include "messages.h" #include #include @@ -547,7 +546,9 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const QString QCocoaTheme::standardButtonText(int button) const { - return button == QPlatformDialogHelper::Discard ? msgDialogButtonDiscard() : QPlatformTheme::standardButtonText(button); + return button == QPlatformDialogHelper::Discard ? + QCoreApplication::translate("QCocoaTheme", "Don't Save") + : QPlatformTheme::standardButtonText(button); } QKeySequence QCocoaTheme::standardButtonShortcut(int button) const -- cgit v1.2.3 From c2efc16126a9706d83f8b80133d46342baaa3265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 14:55:56 +0200 Subject: macOS: Replace foreach with ranged for loops Change-Id: I9d0dbb60e05e4ef85219740465bb941ef8d8eb0f Reviewed-by: Simon Hausmann --- src/plugins/platforms/cocoa/cocoa.pro | 2 ++ src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 2 +- src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 +- src/plugins/platforms/cocoa/qcocoamenubar.mm | 2 +- src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 4 ++-- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 2 +- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- src/plugins/platforms/cocoa/qmultitouch_mac.mm | 2 +- src/plugins/platforms/cocoa/qprintengine_mac.mm | 4 ++-- 9 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index a059dcebe7..6b93b1acf0 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -92,6 +92,8 @@ RESOURCES += qcocoaresources.qrc LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups +DEFINES += QT_NO_FOREACH + QT += \ core-private gui-private \ clipboard_support-private theme_support-private \ diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 3560c9d9b5..d86191ffa9 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -547,7 +547,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of return nsActions; const QStringList &supportedActionNames = QAccessibleBridgeUtils::effectiveActionNames(iface); - foreach (const QString &qtAction, supportedActionNames) { + for (const QString &qtAction : supportedActionNames) { NSString *nsAction = QCocoaAccessible::getTranslatedAction(qtAction); if (nsAction) [nsActions addObject : nsAction]; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index deddcd3f98..245db429c5 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -116,7 +116,7 @@ class QFontEngineFT; static QCocoaIntegration::Options parseOptions(const QStringList ¶mList) { QCocoaIntegration::Options options; - foreach (const QString ¶m, paramList) { + for (const QString ¶m : paramList) { #ifndef QT_NO_FREETYPE if (param == QLatin1String("fontengine=freetype")) options |= QCocoaIntegration::UseFreeTypeFontEngine; diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 363defdd28..a2a8535547 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -191,7 +191,7 @@ void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate) QMacAutoReleasePool pool; QCocoaMenu *cocoaMenu = static_cast(menu); - Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items()) + for (QCocoaMenuItem *item : cocoaMenu->items()) cocoaMenu->syncMenuItem_helper(item, menubarUpdate); BOOL shouldHide = YES; diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index 7605dc9d1a..6f7f29bb5e 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -117,7 +117,7 @@ QCocoaPrintDevice::~QCocoaPrintDevice() { if (m_ppd) ppdClose(m_ppd); - foreach (PMPaper paper, m_macPapers) + for (PMPaper paper : m_macPapers) PMRelease(paper); // Releasing the session appears to also release the printer if (m_session) @@ -171,7 +171,7 @@ QPageSize QCocoaPrintDevice::createPageSize(const PMPaper &paper) const void QCocoaPrintDevice::loadPageSizes() const { m_pageSizes.clear(); - foreach (PMPaper paper, m_macPapers) + for (PMPaper paper : m_macPapers) PMRelease(paper); m_macPapers.clear(); m_printableMargins.clear(); diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 8e7c86a0ef..0e48318141 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -162,7 +162,7 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon) qreal devicePixelRatio = qApp->devicePixelRatio(); const int maxPixmapHeight = maxImageHeight * devicePixelRatio; QSize selectedSize; - Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes())) { + for (const QSize& size : sortByHeight(icon.availableSizes())) { // Select a pixmap based on the height. We want the largest pixmap // with a height smaller or equal to maxPixmapHeight. The pixmap // may rectangular; assume it has a reasonable size. If there is diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c539afbfcd..79dfe58a4e 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1833,7 +1833,7 @@ qreal QCocoaWindow::devicePixelRatio() const QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint) { QWindow *targetWindow = window(); - foreach (QObject *child, targetWindow->children()) + for (QObject *child : targetWindow->children()) if (QWindow *childWindow = qobject_cast(child)) if (QPlatformWindow *handle = childWindow->handle()) if (handle->isExposed() && childWindow->geometry().contains(windowPoint)) diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm index 10652dc6a1..95256657fe 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm +++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm @@ -184,7 +184,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) if (_touchCount != _currentTouches.size()) { // Remove all instances, and basically start from scratch: touchPoints.clear(); - foreach (QCocoaTouch *qcocoaTouch, _currentTouches) { + for (QCocoaTouch *qcocoaTouch : _currentTouches) { if (!_updateInternalStateOnly) { qcocoaTouch->_touchPoint.state = Qt::TouchPointReleased; touchPoints.insert(qcocoaTouch->_touchPoint.id, qcocoaTouch->_touchPoint); diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index dcb9a85a3c..5833d097fd 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -485,7 +485,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va int bestResolution = 0; int dpi = value.toInt(); int bestDistance = INT_MAX; - foreach (int resolution, d->m_printDevice->supportedResolutions()) { + for (int resolution : d->m_printDevice->supportedResolutions()) { if (dpi == resolution) { bestResolution = resolution; break; @@ -758,7 +758,7 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const } case PPK_SupportedResolutions: { QList list; - foreach (int resolution, d->m_printDevice->supportedResolutions()) + for (int resolution : d->m_printDevice->supportedResolutions()) list << resolution; ret = list; break; -- cgit v1.2.3 From eaada70d4e76d0c35afcb36930154818a1eb1e49 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 26 Mar 2020 13:48:27 +0100 Subject: Fix deprecation warnings in QCocoaCursor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explicitly use the Qt APIs that return QPixmap and QBitmap by value, and fix the API taking those to use const references rather than pointers or const values. Change-Id: I2bb7ad1edb3b65f806f0475fca383e5b9bdb61f3 Reviewed-by: Morten Johan Sørvig (cherry picked from commit b61ea367a5f8d07afda36b49b039b2375142d7f4) Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/qcocoacursor.h | 4 ++-- src/plugins/platforms/cocoa/qcocoacursor.mm | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index 5b008eff35..6589891ef2 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -63,8 +63,8 @@ private: QHash m_cursors; NSCursor *convertCursor(QCursor *cursor); NSCursor *createCursorData(QCursor * cursor); - NSCursor *createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot = QPoint()); - NSCursor *createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot = QPoint()); + NSCursor *createCursorFromBitmap(const QBitmap &bitmap, const QBitmap &mask, const QPoint hotspot = QPoint()); + NSCursor *createCursorFromPixmap(const QPixmap &pixmap, const QPoint hotspot = QPoint()); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index c10ada1ada..8ca72ec619 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -243,7 +243,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor) switch (cursor->shape()) { case Qt::BitmapCursor: { if (cursor->pixmap().isNull()) - return createCursorFromBitmap(cursor->bitmap(), cursor->mask(), hotspot); + return createCursorFromBitmap(cursor->bitmap(Qt::ReturnByValue), cursor->mask(Qt::ReturnByValue), hotspot); else return createCursorFromPixmap(cursor->pixmap(), hotspot); break; } @@ -301,17 +301,17 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor) if (cursorData) { QBitmap bitmap(QBitmap::fromData(QSize(16, 16), cursorData, QImage::Format_Mono)); QBitmap mask(QBitmap::fromData(QSize(16, 16), cursorMaskData, QImage::Format_Mono)); - return (createCursorFromBitmap(&bitmap, &mask, hotspot)); + return (createCursorFromBitmap(bitmap, mask, hotspot)); } return nil; // should not happen, all cases covered above } -NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot) +NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap &bitmap, const QBitmap &mask, const QPoint hotspot) { - QImage finalCursor(bitmap->size(), QImage::Format_ARGB32); - QImage bmi = bitmap->toImage().convertToFormat(QImage::Format_RGB32); - QImage bmmi = mask->toImage().convertToFormat(QImage::Format_RGB32); + QImage finalCursor(bitmap.size(), QImage::Format_ARGB32); + QImage bmi = bitmap.toImage().convertToFormat(QImage::Format_RGB32); + QImage bmmi = mask.toImage().convertToFormat(QImage::Format_RGB32); for (int row = 0; row < finalCursor.height(); ++row) { QRgb *bmData = reinterpret_cast(bmi.scanLine(row)); QRgb *bmmData = reinterpret_cast(bmmi.scanLine(row)); @@ -332,7 +332,7 @@ NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBit return createCursorFromPixmap(QPixmap::fromImage(finalCursor), hotspot); } -NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot) +NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap &pixmap, const QPoint hotspot) { NSPoint hotSpot = NSMakePoint(hotspot.x(), hotspot.y()); auto *image = [NSImage imageFromQImage:pixmap.toImage()]; -- cgit v1.2.3 From c034089fa697e6dc22f04b3209768a9dc1abcb9c Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 17 Feb 2020 11:08:30 +1000 Subject: wasm: do not try to resume main thread if mainloop has not started yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit d928beb024c240b37d35d2c53f25648c99a484b4) Fixes: QTBUG-83293 Change-Id: Ibd891629d1d023e47d196dd60821cc5c583a178d Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmeventdispatcher.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index ca8db9b215..2e1b083557 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -194,7 +194,8 @@ void QWasmEventDispatcher::wakeUp() { #ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD if (!emscripten_is_main_runtime_thread()) - emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); + if (m_hasMainLoop) + emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); #endif QEventDispatcherUNIX::wakeUp(); } -- cgit v1.2.3 From c92fedd761206231f13838528943619b84df55bf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Apr 2020 08:09:04 +0200 Subject: Windows QPA: Fix restoring from fullscreen in High DPI setups The logic for checking whether the saved geometry (native pixels) is still within a screen compared them against logical coordinates. Work with the platform screen geometry instead. Fixes: QTBUG-83448 Change-Id: Ib68f967d1a33a490f88a7bec6dcc788788a10389 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 322eae7a06..01f6bef42e 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2287,8 +2287,10 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowStates newState) if (!screen) screen = QGuiApplication::primaryScreen(); // That area of the virtual desktop might not be covered by a screen anymore. - if (!screen->geometry().intersects(m_savedFrameGeometry)) - m_savedFrameGeometry.moveTo(screen->geometry().topLeft()); + if (const auto platformScreen = screen->handle()) { + if (!platformScreen->geometry().intersects(m_savedFrameGeometry)) + m_savedFrameGeometry.moveTo(platformScreen->geometry().topLeft()); + } if (newState & Qt::WindowMinimized) { setMinimizedGeometry(m_data.hwnd, m_savedFrameGeometry); -- cgit v1.2.3 From 18fa1ed74745931c15d525703ac05bbf3f2c9c5b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Apr 2020 12:25:07 +0200 Subject: Windows QPA: Fix showing translucent windows maximized/full screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Translucent (layered) windows require an additional expose event. This was sent with the wrong size since the order of handleGeometryChange(), handleWindowStateChange() in handleResized was wrong. Fixes: QTBUG-83449 Change-Id: Iafd3fa8c0893aa28079201f73b7eb529087ba079 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 01f6bef42e..429e30728f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1904,12 +1904,13 @@ void QWindowsWindow::handleResized(int wParam) handleWindowStateChange(m_windowState | Qt::WindowMinimized); return; case SIZE_MAXIMIZED: + handleGeometryChange(); if (!testFlag(WithinSetStyle) && !testFlag(WithinSetGeometry)) handleWindowStateChange(Qt::WindowMaximized | (isFullScreen_sys() ? Qt::WindowFullScreen : Qt::WindowNoState)); - handleGeometryChange(); break; case SIZE_RESTORED: + handleGeometryChange(); if (!testFlag(WithinSetStyle) && !testFlag(WithinSetGeometry)) { if (isFullScreen_sys()) handleWindowStateChange( @@ -1918,7 +1919,6 @@ void QWindowsWindow::handleResized(int wParam) else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) handleWindowStateChange(Qt::WindowNoState); } - handleGeometryChange(); break; } } -- cgit v1.2.3 From 4bb803477bacc70f756b1aaea9e048b2bae0fa6a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Apr 2020 11:03:32 +0200 Subject: Windows QPA: Fix geometry when firing a full expose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are several places in the code where a full expose event is fired, but the geometry in logical coordinates is used (pre-dating High DPI scaling). Fix by introducing a helper function for it. Task-number: QTBUG-83449 Change-Id: Ie8bb306de0b9b2b85306ed1bb6ba71181b76a958 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 13 +++++++++---- src/plugins/platforms/windows/qwindowswindow.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 429e30728f..6b53e3d4c4 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1401,6 +1401,11 @@ void QWindowsWindow::fireExpose(const QRegion ®ion, bool force) QWindowSystemInterface::handleExposeEvent(window(), region); } +void QWindowsWindow::fireFullExpose(bool force) +{ + fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), force); +} + void QWindowsWindow::destroyWindow() { qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << m_data.hwnd; @@ -1561,7 +1566,7 @@ void QWindowsWindow::setVisible(bool visible) // over the rendering of the window // There is nobody waiting for this, so we don't need to flush afterwards. if (isLayered()) - fireExpose(QRect(0, 0, win->width(), win->height())); + fireFullExpose(); // QTBUG-44928, QTBUG-7386: This is to resolve the problem where popups are // opened from the system tray and not being implicitly activated @@ -1966,7 +1971,7 @@ void QWindowsWindow::handleGeometryChange() && m_data.geometry.size() != previousGeometry.size() // Exclude plain move // One dimension grew -> Windows will send expose, no need to synthesize. && !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) { - fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); + fireFullExpose(true); } const bool wasSync = testFlag(SynchronousGeometryChangeEvent); @@ -2165,7 +2170,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) QWindow *w = window(); bool exposeEventsSent = false; if (isLayered()) { - fireExpose(QRegion(0, 0, w->width(), w->height())); + fireFullExpose(); exposeEventsSent = true; } const QWindowList allWindows = QGuiApplication::allWindows(); @@ -2173,7 +2178,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) if (child != w && child->isVisible() && child->transientParent() == w) { QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(child); if (platformWindow && platformWindow->isLayered()) { - platformWindow->fireExpose(QRegion(0, 0, child->width(), child->height())); + platformWindow->fireFullExpose(); exposeEventsSent = true; } } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index b35081d41d..cd6179bf03 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -373,6 +373,7 @@ private: void handleWindowStateChange(Qt::WindowStates state); inline void destroyIcon(); void fireExpose(const QRegion ®ion, bool force=false); + void fireFullExpose(bool force=false); void calculateFullFrameMargins(); mutable QWindowsWindowData m_data; -- cgit v1.2.3 From 7fd271e733cb30cbc9062206e36076497edbc2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 14:58:22 +0200 Subject: macOS: Clean up header includes to use quotes or brackets as appropriate The includes can be sorted and unified even more, but that's left for another rainy day. Change-Id: I4d5670d6d8389f69d2631b83b8f421d1f685a0f9 Reviewed-by: Volker Hilsheimer --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 3 ++- src/plugins/platforms/cocoa/qcocoaapplication.h | 4 ++-- .../platforms/cocoa/qcocoaeventdispatcher.mm | 21 ++++++++++++--------- .../platforms/cocoa/qcocoanativeinterface.mm | 6 +++--- src/plugins/platforms/cocoa/qcocoansmenu.h | 2 +- .../platforms/cocoa/qcocoasessionmanager.cpp | 2 +- src/plugins/platforms/cocoa/qcocoasystemtrayicon.h | 4 ++-- src/plugins/platforms/cocoa/qmacclipboard.mm | 16 ++++++++-------- src/plugins/platforms/cocoa/qnsview.h | 2 +- src/plugins/platforms/cocoa/qnsview_menus.mm | 10 +++++----- src/plugins/platforms/cocoa/qpaintengine_mac_p.h | 10 +++++----- src/plugins/platforms/cocoa/qt_mac_p.h | 17 ++++++++--------- 12 files changed, 50 insertions(+), 47 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index d86191ffa9..ad40c6b0cb 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -41,7 +41,8 @@ #include "qcocoahelpers.h" #include "qcocoawindow.h" #include "qcocoascreen.h" -#include "private/qaccessiblecache_p.h" + +#include #include #include diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.h b/src/plugins/platforms/cocoa/qcocoaapplication.h index 15530d8281..4314a01ca1 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.h +++ b/src/plugins/platforms/cocoa/qcocoaapplication.h @@ -83,8 +83,8 @@ // We mean it. // -#include "qglobal.h" -#include "private/qcore_mac_p.h" +#include +#include #import diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 94b9e62eab..338a5516d9 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -73,18 +73,21 @@ #include "qcocoaeventdispatcher.h" #include "qcocoawindow.h" - #include "qcocoahelpers.h" -#include "qguiapplication.h" -#include "qevent.h" -#include "qmutex.h" -#include "qsocketnotifier.h" + +#include +#include +#include + +#include +#include +#include +#include + #include #include -#include "private/qthread_p.h" -#include "private/qguiapplication_p.h" -#include -#include + +#include #include diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 450329f569..90e124b790 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -50,13 +50,13 @@ #include #include #include -#include "qsurfaceformat.h" +#include #ifndef QT_NO_OPENGL #include -#include "qopenglcontext.h" +#include #include "qcocoaglcontext.h" #endif -#include "qguiapplication.h" +#include #include #if !defined(QT_NO_WIDGETS) && defined(QT_PRINTSUPPORT_LIB) diff --git a/src/plugins/platforms/cocoa/qcocoansmenu.h b/src/plugins/platforms/cocoa/qcocoansmenu.h index 0c77e2f1aa..bd0334e061 100644 --- a/src/plugins/platforms/cocoa/qcocoansmenu.h +++ b/src/plugins/platforms/cocoa/qcocoansmenu.h @@ -53,7 +53,7 @@ #import -#include +#include "qcocoahelpers.h" QT_FORWARD_DECLARE_CLASS(QCocoaMenu); QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem); diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp index 74e318b5be..725fc5acc0 100644 --- a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp +++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include "qcocoasessionmanager.h" #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h index 7999438ca5..141995d1b1 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h @@ -46,8 +46,8 @@ #if QT_CONFIG(systemtrayicon) -#include "QtCore/qstring.h" -#include "QtGui/qpa/qplatformsystemtrayicon.h" +#include +#include #include "qcocoamenu.h" diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 654647b35a..99b378be68 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -38,14 +38,14 @@ ****************************************************************************/ #include "qmacclipboard.h" -#include "qclipboard.h" -#include "qguiapplication.h" -#include "qbitmap.h" -#include "qdatetime.h" -#include "qdebug.h" -#include "qguiapplication.h" -#include "qevent.h" -#include "qurl.h" +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include "qcocoahelpers.h" diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 74d0735b4c..0a18afe3a6 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -43,7 +43,7 @@ #include #include -#include "private/qcore_mac_p.h" +#include QT_BEGIN_NAMESPACE class QCocoaWindow; diff --git a/src/plugins/platforms/cocoa/qnsview_menus.mm b/src/plugins/platforms/cocoa/qnsview_menus.mm index b6cd832282..7ae274ab04 100644 --- a/src/plugins/platforms/cocoa/qnsview_menus.mm +++ b/src/plugins/platforms/cocoa/qnsview_menus.mm @@ -39,11 +39,11 @@ // This file is included from qnsview.mm, and only used to organize the code -#include -#include -#include -#include -#include +#include "qcocoaapplicationdelegate.h" +#include "qcocoansmenu.h" +#include "qcocoamenuitem.h" +#include "qcocoamenu.h" +#include "qcocoamenubar.h" static bool selectorIsCutCopyPaste(SEL selector) { diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h index 1416386745..acf72c7456 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h +++ b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h @@ -51,11 +51,11 @@ // We mean it. // -#include "QtGui/qpaintengine.h" -#include "private/qpaintengine_p.h" -#include "private/qpolygonclipper_p.h" -#include "private/qfont_p.h" -#include "QtCore/qhash.h" +#include +#include +#include +#include +#include #include "qt_mac_p.h" diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index fdcf3bcdd3..8a0513139a 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -60,15 +60,14 @@ #include -#include "QtCore/qglobal.h" -#include "QtCore/qvariant.h" -#include "QtCore/qmimedata.h" -#include "QtCore/qpointer.h" -#include "QtCore/qloggingcategory.h" -#include "private/qcore_mac_p.h" - - -#include "QtGui/qpainter.h" +#include +#include +#include +#include +#include +#include + +#include QT_BEGIN_NAMESPACE class QWidget; -- cgit v1.2.3 From 8138c812cbd65233a61d6e2e2f783d060c02de60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 16:12:18 +0200 Subject: macOS: Remove a bunch of dead (forward) declarations Change-Id: I402668a17b48c164658f775bacd832615a6d2587 Reviewed-by: Simon Hausmann --- .../platforms/cocoa/qcocoaaccessibilityelement.h | 2 +- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 1 - src/plugins/platforms/cocoa/qcocoabackingstore.mm | 1 + .../platforms/cocoa/qcocoafiledialoghelper.mm | 1 - src/plugins/platforms/cocoa/qcocoahelpers.h | 5 +- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 1 - src/plugins/platforms/cocoa/qcocoaprintdevice.h | 2 - src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 4 + src/plugins/platforms/cocoa/qcocoaprintersupport.h | 2 - .../platforms/cocoa/qcocoaprintersupport.mm | 4 + .../platforms/cocoa/qcocoasystemtrayicon.mm | 1 - src/plugins/platforms/cocoa/qcocoawindow.h | 1 - src/plugins/platforms/cocoa/qmacdefines_mac.h | 129 --------------------- src/plugins/platforms/cocoa/qnswindow.h | 2 +- src/plugins/platforms/cocoa/qpaintengine_mac.mm | 3 + src/plugins/platforms/cocoa/qpaintengine_mac_p.h | 4 +- src/plugins/platforms/cocoa/qprintengine_mac.mm | 4 + src/plugins/platforms/cocoa/qt_attribution.json | 2 +- src/plugins/platforms/cocoa/qt_mac_p.h | 126 -------------------- 19 files changed, 25 insertions(+), 270 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/qmacdefines_mac.h delete mode 100644 src/plugins/platforms/cocoa/qt_mac_p.h (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h index 141ce6bf1a..f74afb8440 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h @@ -41,7 +41,7 @@ #include -#include "qt_mac_p.h" +#include #ifndef QT_NO_ACCESSIBILITY diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 3fb9e83d35..e8d789275c 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -87,7 +87,6 @@ #include #include #include -#include "qt_mac_p.h" #include #include diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 2b4c71f279..3b9df8da3a 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -43,6 +43,7 @@ #include "qcocoahelpers.h" #include +#include #include diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 8b76e45616..15e83db48f 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -48,7 +48,6 @@ #include #include -#include "qt_mac_p.h" #include "qcocoahelpers.h" #include "qcocoaeventdispatcher.h" #include diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 95351f688b..71e72dca4f 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -50,9 +50,12 @@ // // We mean it. // -#include "qt_mac_p.h" + +#include + #include #include +#include #include #include diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index c4e2dd0e92..3b37e7c9c1 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -46,7 +46,6 @@ #include "qcocoamenu.h" #include "qcocoamenubar.h" #include "qcocoahelpers.h" -#include "qt_mac_p.h" #include "qcocoaapplication.h" // for custom application category #include "qcocoamenuloader.h" #include diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.h b/src/plugins/platforms/cocoa/qcocoaprintdevice.h index d267343b0e..59a521e0b5 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.h +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.h @@ -55,8 +55,6 @@ #ifndef QT_NO_PRINTER -#include "qt_mac_p.h" - #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index 6f7f29bb5e..ab304d9c04 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -37,6 +37,8 @@ ** ****************************************************************************/ +#include + #include "qcocoaprintdevice.h" #if QT_CONFIG(mimetype) @@ -44,6 +46,8 @@ #endif #include +#include + QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.h b/src/plugins/platforms/cocoa/qcocoaprintersupport.h index 40a638207a..b1a9541c03 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.h +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.h @@ -43,8 +43,6 @@ #include #ifndef QT_NO_PRINTER -#include "qt_mac_p.h" - QT_BEGIN_NAMESPACE class QCocoaPrinterSupport : public QPlatformPrinterSupport diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm index d7eaa469fb..4c5c7aef88 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm @@ -41,6 +41,10 @@ #ifndef QT_NO_PRINTER +#include + +#include + #include "qcocoaprintdevice.h" #include "qprintengine_mac_p.h" diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 0e48318141..704498acb1 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -84,7 +84,6 @@ #include "qcocoamenu.h" -#include "qt_mac_p.h" #include "qcocoahelpers.h" #include "qcocoaintegration.h" #include "qcocoascreen.h" diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index b15c0ac31c..291a27b15e 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -51,7 +51,6 @@ #endif #include "qnsview.h" #include "qnswindow.h" -#include "qt_mac_p.h" #if QT_CONFIG(vulkan) #include diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h deleted file mode 100644 index 9e229b8dcb..0000000000 --- a/src/plugins/platforms/cocoa/qmacdefines_mac.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui 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$ -** -****************************************************************************/ - -/**************************************************************************** -** -** Copyright (c) 2007-2008, Apple, Inc. -** -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** -** * Neither the name of Apple, Inc. nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -****************************************************************************/ - -/* - * qmacdefines_mac_p.h - * All the defines you'll ever need for Qt/Mac :-) - */ - -/* This is just many defines. Therefore it doesn't need things like: -QT_BEGIN_NAMESPACE - - -QT_END_NAMESPACE - -Yes, it is an informative comment ;-) -*/ - -#include - -#ifdef __LP64__ -typedef signed int OSStatus; -#else -typedef signed long OSStatus; -#endif - -typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef; -typedef struct OpaqueEventRef * EventRef; -typedef struct OpaqueMenuRef * MenuRef; -typedef struct OpaquePasteboardRef* PasteboardRef; -typedef struct OpaqueRgnHandle * RgnHandle; -typedef const struct __HIShape *HIShapeRef; -typedef struct __HIShape *HIMutableShapeRef; -typedef struct CGRect CGRect; -typedef struct CGImage *CGImageRef; -typedef struct CGContext *CGContextRef; -typedef struct GDevice * GDPtr; -typedef GDPtr * GDHandle; -typedef struct OpaqueIconRef * IconRef; - -#ifdef __OBJC__ -typedef NSWindow* OSWindowRef; -typedef NSView *OSViewRef; -typedef NSMenu *OSMenuRef; -typedef NSEvent *OSEventRef; -#else -typedef void *OSWindowRef; -typedef void *OSViewRef; -typedef void *OSMenuRef; -typedef void *OSEventRef; -#endif - -typedef PasteboardRef OSPasteboardRef; -typedef struct AEDesc AEDescList; -typedef AEDescList AERecord; -typedef AERecord AppleEvent; - -#ifdef check -#undef check -#endif diff --git a/src/plugins/platforms/cocoa/qnswindow.h b/src/plugins/platforms/cocoa/qnswindow.h index 5fc48d826f..3263df3862 100644 --- a/src/plugins/platforms/cocoa/qnswindow.h +++ b/src/plugins/platforms/cocoa/qnswindow.h @@ -42,7 +42,7 @@ #include #include -#include "qt_mac_p.h" +#include #include diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index df71f76644..5ced962cb1 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include + #include "qpaintengine_mac_p.h" #if defined(QT_PRINTSUPPORT_LIB) #include "qprintengine_mac_p.h" diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h index acf72c7456..a52e9cbe1c 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h +++ b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h @@ -57,9 +57,9 @@ #include #include -#include "qt_mac_p.h" - typedef struct CGColorSpace *CGColorSpaceRef; +typedef struct CGContext *CGContextRef; + QT_BEGIN_NAMESPACE class QCoreGraphicsPaintEnginePrivate; diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index 5833d097fd..9391f921ec 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include + #include "qprintengine_mac_p.h" #include "qcocoaprintersupport.h" #include @@ -44,6 +47,7 @@ #include #include +#include #ifndef QT_NO_PRINTER diff --git a/src/plugins/platforms/cocoa/qt_attribution.json b/src/plugins/platforms/cocoa/qt_attribution.json index 37c0937f29..1da0d7e370 100644 --- a/src/plugins/platforms/cocoa/qt_attribution.json +++ b/src/plugins/platforms/cocoa/qt_attribution.json @@ -3,7 +3,7 @@ "Name": "Cocoa Platform Plugin", "QDocModule": "qtgui", "QtUsage": "Code used in the Qt Platform Abstraction (QPA) for macOS.", - "Files": "qcocoaapplication.h qcocoaapplication.mm qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm qcocoaeventdispatcher.h qcocoaeventdispatcher.mm qcocoaintrospection.h qcocoaintrospection.mm qcocoasystemtrayicon.mm qmacdefines_mac.h", + "Files": "qcocoaapplication.h qcocoaapplication.mm qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm qcocoaeventdispatcher.h qcocoaeventdispatcher.mm qcocoaintrospection.h qcocoaintrospection.mm qcocoasystemtrayicon.mm", "Description": "Allows Qt to integrate into Apple's Cocoa API.", "LicenseId": "BSD-3-Clause", diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h deleted file mode 100644 index 8a0513139a..0000000000 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui 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 QT_MAC_P_H -#define QT_MAC_P_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. -// - -#ifdef __OBJC__ -#include -#include -#endif - -#include "qmacdefines_mac.h" - -#include - -#include -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE -class QWidget; -class QDragMoveEvent; - -// Simple class to manage short-lived regions -class QMacSmartQuickDrawRegion -{ - RgnHandle qdRgn; - Q_DISABLE_COPY(QMacSmartQuickDrawRegion) -public: - explicit QMacSmartQuickDrawRegion(RgnHandle rgn) : qdRgn(rgn) {} - ~QMacSmartQuickDrawRegion() { - extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp - qt_mac_dispose_rgn(qdRgn); - } - operator RgnHandle() { - return qdRgn; - } -}; - -class QMacInternalPasteboardMime; -class QMimeData; - - -extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp - -extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm -extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm -extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm - -#ifdef check -# undef check -#endif - -struct QMacDndAnswerRecord { - QRect rect; - Qt::KeyboardModifiers modifiers; - Qt::MouseButtons buttons; - Qt::DropAction lastAction; - unsigned int lastOperation; - void clear() { - rect = QRect(); - modifiers = Qt::NoModifier; - buttons = Qt::NoButton; - lastAction = Qt::IgnoreAction; - lastOperation = 0; - } -}; -extern QMacDndAnswerRecord qt_mac_dnd_answer_rec; -void qt_mac_copy_answer_rect(const QDragMoveEvent &event); -bool qt_mac_mouse_inside_answer_rect(QPoint mouse); - -QT_END_NAMESPACE - -#endif // QT_MAC_P_H -- cgit v1.2.3 From 487dd80bce9c6006f349ccb09222e1c308200f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 24 Mar 2020 09:40:10 +0100 Subject: Introduce QSocketNotifier::activate(QSocketDescriptor, QSN::Type) The pre-existing overload passes an int, but this can mean the descriptor gets truncated in compilations where the descriptor is 64-bit. The old overload with int is visible when querying the metaobject system so string-based connects still work as before, and connecting to it will produce a deprecation warning in the output. At the same time the PMF-based connect will, on recompile, pick the QSocketDescriptor overload. As an added improvement it also comes with the notification type, removing the need for separate slots where the code would be mostly shared anyway. The QSocketDescriptor type can be implicitly converted to and from qintptr to ensure existing code still compiles. It can also be constructed from Qt::HANDLE on Windows. In this same patch I also update the existing string-based connects in this module, which then includes updating the parameters for some slots as well. [ChangeLog][QtCore][QSocketNotifier] Added QSocketNotifier::activated(QSocketDescriptor, QSocketNotifier::Type). This replaces the activated(int) signal which in 64-bit environments could truncate the socket descriptor. If you use "activated" with the string-based connect() then you need to update the parameter type of the signal and slot if it had one. If you use it with the pointer to member function based connect() then all you need to do is update your slot's parameter type if it has one. If you need to compile your source code with multiple versions of Qt then connect() to this function using pointer to member function and update the slot's parameter type if needed. Task-number: QTBUG-70441 Change-Id: Ic43d6bc4c5bcb4040867b2ffad8d36fb01eed8af Reviewed-by: Edward Welbourne --- src/plugins/platforms/openwfd/qopenwfddevice.cpp | 2 +- src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp | 2 +- src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp | 2 +- src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp | 2 +- src/plugins/platforms/xcb/qxcbsessionmanager.cpp | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/openwfd/qopenwfddevice.cpp b/src/plugins/platforms/openwfd/qopenwfddevice.cpp index 7a9d22e74d..99896151b2 100644 --- a/src/plugins/platforms/openwfd/qopenwfddevice.cpp +++ b/src/plugins/platforms/openwfd/qopenwfddevice.cpp @@ -83,7 +83,7 @@ QOpenWFDDevice::QOpenWFDDevice(QOpenWFDIntegration *integration, WFDint device_e int fd = wfdDeviceEventGetFD(mDevice,mEvent); mEventSocketNotifier = new QSocketNotifier(fd,QSocketNotifier::Read,this); - connect(mEventSocketNotifier,SIGNAL(activated(int)),SLOT(readEvents())); + connect(mEventSocketNotifier,SIGNAL(activated(QSocketDescriptor)),SLOT(readEvents())); mCommitedDevice = true; commit(WFD_COMMIT_ENTIRE_DEVICE, handle()); diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp index a6236f2376..f0c4c385ef 100644 --- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp @@ -96,7 +96,7 @@ void QQnxButtonEventNotifier::start() } m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(updateButtonStates())); + QObject::connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(updateButtonStates())); qButtonDebug("successfully connected to Navigator. fd = %d", m_fd); } diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp index 1f630863b7..f7e8e7966c 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp @@ -96,7 +96,7 @@ void QQnxNavigatorEventNotifier::start() } m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readData())); + connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(readData())); } void QQnxNavigatorEventNotifier::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id) diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp index 025c03c058..6f496571fa 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -143,7 +143,7 @@ bool QQnxVirtualKeyboardPps::connect() return false; m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady())); + QObject::connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(ppsDataReady())); return true; } diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index 2eb32c069e..e9697f505b 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -61,11 +61,11 @@ public: QSmSocketReceiver(int socket) { QSocketNotifier* sn = new QSocketNotifier(socket, QSocketNotifier::Read, this); - connect(sn, SIGNAL(activated(int)), this, SLOT(socketActivated(int))); + connect(sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(socketActivated())); } public Q_SLOTS: - void socketActivated(int); + void socketActivated(); }; @@ -327,7 +327,7 @@ static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) } -void QSmSocketReceiver::socketActivated(int) +void QSmSocketReceiver::socketActivated() { IceProcessMessages(SmcGetIceConnection(smcConnection), nullptr, nullptr); } -- cgit v1.2.3