diff options
Diffstat (limited to 'src/plugins/platforms/ios')
21 files changed, 216 insertions, 162 deletions
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm index bea2897240..54152aebf7 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm @@ -302,7 +302,7 @@ public: g_iteratorCurrentUrl.setLocalData(QString()); } - QString next() Q_DECL_OVERRIDE + QString next() override { // Cache the URL that we are about to return, since QDir will immediately create a // new file engine on the file and ask if it exists. Unless we do this, we end up @@ -314,17 +314,17 @@ public: return url; } - bool hasNext() const Q_DECL_OVERRIDE + bool hasNext() const override { return m_enumerator->hasNext(); } - QString currentFileName() const Q_DECL_OVERRIDE + QString currentFileName() const override { return g_iteratorCurrentUrl.localData(); } - QFileInfo currentFileInfo() const Q_DECL_OVERRIDE + QFileInfo currentFileInfo() const override { return QFileInfo(currentFileName()); } diff --git a/src/plugins/platforms/ios/qiosbackingstore.h b/src/plugins/platforms/ios/qiosbackingstore.h index e6b890251a..38006ba90b 100644 --- a/src/plugins/platforms/ios/qiosbackingstore.h +++ b/src/plugins/platforms/ios/qiosbackingstore.h @@ -54,7 +54,7 @@ public: QIOSBackingStore(QWindow *window); ~QIOSBackingStore(); - void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosclipboard.h b/src/plugins/platforms/ios/qiosclipboard.h index f3ccfcace0..3fe9b29b71 100644 --- a/src/plugins/platforms/ios/qiosclipboard.h +++ b/src/plugins/platforms/ios/qiosclipboard.h @@ -58,10 +58,10 @@ public: QIOSClipboard(); ~QIOSClipboard(); - QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE; - void setMimeData(QMimeData *mimeData, QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE; - bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; - bool ownsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; + QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override; + void setMimeData(QMimeData *mimeData, QClipboard::Mode mode = QClipboard::Clipboard) override; + bool supportsMode(QClipboard::Mode mode) const override; + bool ownsMode(QClipboard::Mode mode) const override; private: QUIClipboard *m_clipboard; diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm index 15deb3332e..9a975eadc9 100644 --- a/src/plugins/platforms/ios/qiosclipboard.mm +++ b/src/plugins/platforms/ios/qiosclipboard.mm @@ -138,8 +138,8 @@ public: QIOSMimeData(QClipboard::Mode mode) : QMimeData(), m_mode(mode) { } ~QIOSMimeData() { } - QStringList formats() const Q_DECL_OVERRIDE; - QVariant retrieveData(const QString &mimeType, QVariant::Type type) const Q_DECL_OVERRIDE; + QStringList formats() const override; + QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; private: const QClipboard::Mode m_mode; diff --git a/src/plugins/platforms/ios/qioscontext.h b/src/plugins/platforms/ios/qioscontext.h index 5b7917f7b4..7539e981c0 100644 --- a/src/plugins/platforms/ios/qioscontext.h +++ b/src/plugins/platforms/ios/qioscontext.h @@ -57,18 +57,18 @@ public: QIOSContext(QOpenGLContext *context); ~QIOSContext(); - QSurfaceFormat format() const Q_DECL_OVERRIDE; + QSurfaceFormat format() const override; - void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; + void swapBuffers(QPlatformSurface *surface) override; - bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE; - void doneCurrent() Q_DECL_OVERRIDE; + bool makeCurrent(QPlatformSurface *surface) override; + void doneCurrent() override; - GLuint defaultFramebufferObject(QPlatformSurface *) const Q_DECL_OVERRIDE; - QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; + GLuint defaultFramebufferObject(QPlatformSurface *) const override; + QFunctionPointer getProcAddress(const char *procName) override; - bool isSharing() const Q_DECL_OVERRIDE; - bool isValid() const Q_DECL_OVERRIDE; + bool isSharing() const override; + bool isValid() const override; private Q_SLOTS: void windowDestroyed(QObject *object); diff --git a/src/plugins/platforms/ios/qioseventdispatcher.h b/src/plugins/platforms/ios/qioseventdispatcher.h index c1442ed1e8..62133b9510 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.h +++ b/src/plugins/platforms/ios/qioseventdispatcher.h @@ -51,8 +51,8 @@ class QIOSEventDispatcher : public QEventDispatcherCoreFoundation public: explicit QIOSEventDispatcher(QObject *parent = 0); - bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE; - bool processPostedEvents() Q_DECL_OVERRIDE; + bool processEvents(QEventLoop::ProcessEventsFlags flags) override; + bool processPostedEvents() override; void handleRunLoopExit(CFRunLoopActivity activity); diff --git a/src/plugins/platforms/ios/qiosfiledialog.h b/src/plugins/platforms/ios/qiosfiledialog.h index 0b56bd20bf..5cb1b45e20 100644 --- a/src/plugins/platforms/ios/qiosfiledialog.h +++ b/src/plugins/platforms/ios/qiosfiledialog.h @@ -53,17 +53,17 @@ public: QIOSFileDialog(); ~QIOSFileDialog(); - void exec() Q_DECL_OVERRIDE; - bool defaultNameFilterDisables() const Q_DECL_OVERRIDE { return false; } - bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) Q_DECL_OVERRIDE; - void hide() Q_DECL_OVERRIDE; - void setDirectory(const QUrl &) Q_DECL_OVERRIDE {} - QUrl directory() const Q_DECL_OVERRIDE { return QUrl(); } - void selectFile(const QUrl &) Q_DECL_OVERRIDE {} - QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE; - void setFilter() Q_DECL_OVERRIDE {} - void selectNameFilter(const QString &) Q_DECL_OVERRIDE {} - QString selectedNameFilter() const Q_DECL_OVERRIDE { return QString(); } + void exec() override; + bool defaultNameFilterDisables() const override { return false; } + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override; + void hide() override; + void setDirectory(const QUrl &) override {} + QUrl directory() const override { return QUrl(); } + void selectFile(const QUrl &) override {} + QList<QUrl> selectedFiles() const override; + void setFilter() override {} + void selectNameFilter(const QString &) override {} + QString selectedNameFilter() const override { return QString(); } void selectedFilesChanged(QList<QUrl> selection); diff --git a/src/plugins/platforms/ios/qiosfiledialog.mm b/src/plugins/platforms/ios/qiosfiledialog.mm index c5722d33f8..5987bc1540 100644 --- a/src/plugins/platforms/ios/qiosfiledialog.mm +++ b/src/plugins/platforms/ios/qiosfiledialog.mm @@ -48,7 +48,7 @@ #include "qiosoptionalplugininterface.h" QIOSFileDialog::QIOSFileDialog() - : m_viewController(Q_NULLPTR) + : m_viewController(nullptr) { } @@ -112,7 +112,7 @@ void QIOSFileDialog::hide() [m_viewController dismissViewControllerAnimated:YES completion:nil]; [m_viewController release]; - m_viewController = Q_NULLPTR; + m_viewController = nullptr; m_eventLoop.exit(); } diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h index 966d1a7e80..255cf8bca9 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.h +++ b/src/plugins/platforms/ios/qiosinputcontext.h @@ -88,24 +88,24 @@ public: QIOSInputContext(); ~QIOSInputContext(); - bool isValid() const Q_DECL_OVERRIDE { return true; } + bool isValid() const override { return true; } - void showInputPanel() Q_DECL_OVERRIDE; - void hideInputPanel() Q_DECL_OVERRIDE; + void showInputPanel() override; + void hideInputPanel() override; - bool isInputPanelVisible() const Q_DECL_OVERRIDE; - bool isAnimating() const Q_DECL_OVERRIDE; - QRectF keyboardRect() const Q_DECL_OVERRIDE; + bool isInputPanelVisible() const override; + bool isAnimating() const override; + QRectF keyboardRect() const override; - void update(Qt::InputMethodQueries) Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void commit() Q_DECL_OVERRIDE; + void update(Qt::InputMethodQueries) override; + void reset() override; + void commit() override; - QLocale locale() const Q_DECL_OVERRIDE; + QLocale locale() const override; void clearCurrentFocusObject(); - void setFocusObject(QObject *object) Q_DECL_OVERRIDE; + void setFocusObject(QObject *object) override; void focusWindowChanged(QWindow *focusWindow); void scrollToCursor(); diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index 6f3f18af48..20eb210cd5 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -62,45 +62,45 @@ public: QIOSIntegration(); ~QIOSIntegration(); - bool hasCapability(Capability cap) const Q_DECL_OVERRIDE; + bool hasCapability(Capability cap) const override; - QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE; - QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE; + QPlatformWindow *createPlatformWindow(QWindow *window) const override; + QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; - QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE; - QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE; + QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; + QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; - QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE; + QPlatformFontDatabase *fontDatabase() const override; #ifndef QT_NO_CLIPBOARD - QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE; + QPlatformClipboard *clipboard() const override; #endif - QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE; - QPlatformServices *services() const Q_DECL_OVERRIDE; + QPlatformInputContext *inputContext() const override; + QPlatformServices *services() const override; - QVariant styleHint(StyleHint hint) const Q_DECL_OVERRIDE; + QVariant styleHint(StyleHint hint) const override; - QStringList themeNames() const Q_DECL_OVERRIDE; - QPlatformTheme *createPlatformTheme(const QString &name) const Q_DECL_OVERRIDE; + QStringList themeNames() const override; + QPlatformTheme *createPlatformTheme(const QString &name) const override; - QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE; - QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE; + QAbstractEventDispatcher *createEventDispatcher() const override; + QPlatformNativeInterface *nativeInterface() const override; QTouchDevice *touchDevice(); #ifndef QT_NO_ACCESSIBILITY - QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE; + QPlatformAccessibility *accessibility() const override; #endif // Called from Objective-C class QIOSScreenTracker, which can't be friended void addScreen(QPlatformScreen *screen) { screenAdded(screen); } void destroyScreen(QPlatformScreen *screen) { QPlatformIntegration::destroyScreen(screen); } - void beep() const Q_DECL_OVERRIDE; + void beep() const override; static QIOSIntegration *instance(); // -- QPlatformNativeInterface -- - void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) Q_DECL_OVERRIDE; + void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override; QFactoryLoader *optionalPlugins() { return m_optionalPlugins; } diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 94a30eb931..92c1e39d72 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -118,6 +118,9 @@ QIOSIntegration::QIOSIntegration() } m_touchDevice->setCapabilities(touchCapabilities); QWindowSystemInterface::registerTouchDevice(m_touchDevice); +#if QT_CONFIG(tabletevent) + QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); +#endif QMacInternalPasteboardMime::initializeMimeTypes(); for (int i = 0; i < m_optionalPlugins->metaData().size(); ++i) @@ -196,12 +199,12 @@ class QIOSOffscreenSurface : public QPlatformOffscreenSurface public: QIOSOffscreenSurface(QOffscreenSurface *offscreenSurface) : QPlatformOffscreenSurface(offscreenSurface) {} - QSurfaceFormat format() const Q_DECL_OVERRIDE + QSurfaceFormat format() const override { Q_ASSERT(offscreenSurface()); return offscreenSurface()->requestedFormat(); } - bool isValid() const Q_DECL_OVERRIDE { return true; } + bool isValid() const override { return true; } }; QPlatformOffscreenSurface *QIOSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const diff --git a/src/plugins/platforms/ios/qiosmenu.h b/src/plugins/platforms/ios/qiosmenu.h index 61cadab56d..32022a3bb8 100644 --- a/src/plugins/platforms/ios/qiosmenu.h +++ b/src/plugins/platforms/ios/qiosmenu.h @@ -56,20 +56,20 @@ class QIOSMenuItem : public QPlatformMenuItem public: QIOSMenuItem(); - void setText(const QString &text) Q_DECL_OVERRIDE; - void setIcon(const QIcon &) Q_DECL_OVERRIDE {} - void setMenu(QPlatformMenu *) Q_DECL_OVERRIDE; - void setVisible(bool isVisible) Q_DECL_OVERRIDE; - void setIsSeparator(bool) Q_DECL_OVERRIDE; - void setFont(const QFont &) Q_DECL_OVERRIDE {} - void setRole(MenuRole role) Q_DECL_OVERRIDE; - void setCheckable(bool) Q_DECL_OVERRIDE {} - void setChecked(bool) Q_DECL_OVERRIDE {} + void setText(const QString &text) override; + void setIcon(const QIcon &) override {} + void setMenu(QPlatformMenu *) override; + void setVisible(bool isVisible) override; + void setIsSeparator(bool) override; + void setFont(const QFont &) override {} + void setRole(MenuRole role) override; + void setCheckable(bool) override {} + void setChecked(bool) override {} #ifndef QT_NO_SHORTCUT - void setShortcut(const QKeySequence&) Q_DECL_OVERRIDE; + void setShortcut(const QKeySequence&) override; #endif - void setEnabled(bool enabled) Q_DECL_OVERRIDE; - void setIconSize(int) Q_DECL_OVERRIDE {} + void setEnabled(bool enabled) override; + void setIconSize(int) override {} bool m_visible; QString m_text; @@ -88,22 +88,22 @@ public: QIOSMenu(); ~QIOSMenu(); - void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) Q_DECL_OVERRIDE; - void removeMenuItem(QPlatformMenuItem *menuItem) Q_DECL_OVERRIDE; - void syncMenuItem(QPlatformMenuItem *) Q_DECL_OVERRIDE; - void syncSeparatorsCollapsible(bool) Q_DECL_OVERRIDE {} + void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) override; + void removeMenuItem(QPlatformMenuItem *menuItem) override; + void syncMenuItem(QPlatformMenuItem *) override; + void syncSeparatorsCollapsible(bool) override {} - void setText(const QString &) Q_DECL_OVERRIDE; - void setIcon(const QIcon &) Q_DECL_OVERRIDE {} - void setEnabled(bool enabled) Q_DECL_OVERRIDE; - void setVisible(bool visible) Q_DECL_OVERRIDE; - void setMenuType(MenuType type) Q_DECL_OVERRIDE; + void setText(const QString &) override; + void setIcon(const QIcon &) override {} + void setEnabled(bool enabled) override; + void setVisible(bool visible) override; + void setMenuType(MenuType type) override; - void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE; - void dismiss() Q_DECL_OVERRIDE; + void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) override; + void dismiss() override; - QPlatformMenuItem *menuItemAt(int position) const Q_DECL_OVERRIDE; - QPlatformMenuItem *menuItemForTag(quintptr tag) const Q_DECL_OVERRIDE; + QPlatformMenuItem *menuItemAt(int position) const override; + QPlatformMenuItem *menuItemForTag(quintptr tag) const override; void handleItemSelected(QIOSMenuItem *menuItem); @@ -111,7 +111,7 @@ public: static id menuActionTarget() { return m_currentMenu ? m_currentMenu->m_menuController : 0; } protected: - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; private: bool m_enabled; diff --git a/src/plugins/platforms/ios/qiosmessagedialog.h b/src/plugins/platforms/ios/qiosmessagedialog.h index e67e10a5e1..92a4db8319 100644 --- a/src/plugins/platforms/ios/qiosmessagedialog.h +++ b/src/plugins/platforms/ios/qiosmessagedialog.h @@ -54,9 +54,9 @@ public: QIOSMessageDialog(); ~QIOSMessageDialog(); - void exec() Q_DECL_OVERRIDE; - bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) Q_DECL_OVERRIDE; - void hide() Q_DECL_OVERRIDE; + void exec() override; + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override; + void hide() override; private: QEventLoop m_eventLoop; diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm index 5507f13de7..9d05b792c2 100644 --- a/src/plugins/platforms/ios/qiosmessagedialog.mm +++ b/src/plugins/platforms/ios/qiosmessagedialog.mm @@ -48,7 +48,7 @@ #include "qiosmessagedialog.h" QIOSMessageDialog::QIOSMessageDialog() - : m_alertController(Q_NULLPTR) + : m_alertController(nullptr) { } @@ -136,5 +136,5 @@ void QIOSMessageDialog::hide() m_eventLoop.exit(); [m_alertController dismissViewControllerAnimated:YES completion:nil]; [m_alertController release]; - m_alertController = Q_NULLPTR; + m_alertController = nullptr; } diff --git a/src/plugins/platforms/ios/qiosoptionalplugininterface.h b/src/plugins/platforms/ios/qiosoptionalplugininterface.h index 3f74e41c83..660c74e856 100644 --- a/src/plugins/platforms/ios/qiosoptionalplugininterface.h +++ b/src/plugins/platforms/ios/qiosoptionalplugininterface.h @@ -55,7 +55,7 @@ class QIosOptionalPluginInterface public: virtual ~QIosOptionalPluginInterface() {} virtual void initPlugin() const {}; - virtual UIViewController* createImagePickerController(QIOSFileDialog *) const { return Q_NULLPTR; }; + virtual UIViewController* createImagePickerController(QIOSFileDialog *) const { return nullptr; }; }; Q_DECLARE_INTERFACE(QIosOptionalPluginInterface, QIosOptionalPluginInterface_iid) diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h index 9fcce42825..329fb1f9e2 100644 --- a/src/plugins/platforms/ios/qiosscreen.h +++ b/src/plugins/platforms/ios/qiosscreen.h @@ -56,17 +56,17 @@ public: QIOSScreen(UIScreen *screen); ~QIOSScreen(); - QRect geometry() const Q_DECL_OVERRIDE; - QRect availableGeometry() const Q_DECL_OVERRIDE; - int depth() const Q_DECL_OVERRIDE; - QImage::Format format() const Q_DECL_OVERRIDE; - QSizeF physicalSize() const Q_DECL_OVERRIDE; - QDpi logicalDpi() const Q_DECL_OVERRIDE; - qreal devicePixelRatio() const Q_DECL_OVERRIDE; - - Qt::ScreenOrientation nativeOrientation() const Q_DECL_OVERRIDE; - Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE; - void setOrientationUpdateMask(Qt::ScreenOrientations mask) Q_DECL_OVERRIDE; + QRect geometry() const override; + QRect availableGeometry() const override; + int depth() const override; + QImage::Format format() const override; + QSizeF physicalSize() const override; + QDpi logicalDpi() const override; + qreal devicePixelRatio() const override; + + Qt::ScreenOrientation nativeOrientation() const override; + Qt::ScreenOrientation orientation() const override; + void setOrientationUpdateMask(Qt::ScreenOrientations mask) override; QPixmap grabWindow(WId window, int x, int y, int width, int height) const override; diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index bb9fe4d58f..fe3c29d037 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -608,7 +608,7 @@ static void executeBlockWithoutAnimation(Block block) - (QIOSLoupeLayer *)createLoupeLayer { Q_UNREACHABLE(); - return Q_NULLPTR; + return nullptr; } - (void)updateFocalPoint:(QPointF)touchPoint @@ -984,12 +984,12 @@ static void executeBlockWithoutAnimation(Block block) QT_BEGIN_NAMESPACE -QIOSEditMenu *QIOSTextInputOverlay::s_editMenu = Q_NULLPTR; +QIOSEditMenu *QIOSTextInputOverlay::s_editMenu = nullptr; QIOSTextInputOverlay::QIOSTextInputOverlay() - : m_cursorRecognizer(Q_NULLPTR) - , m_selectionRecognizer(Q_NULLPTR) - , m_openMenuOnTapRecognizer(Q_NULLPTR) + : m_cursorRecognizer(nullptr) + , m_selectionRecognizer(nullptr) + , m_openMenuOnTapRecognizer(nullptr) { connect(qApp, &QGuiApplication::focusObjectChanged, this, &QIOSTextInputOverlay::updateFocusObject); } @@ -1012,10 +1012,10 @@ void QIOSTextInputOverlay::updateFocusObject() [m_selectionRecognizer release]; [m_openMenuOnTapRecognizer release]; [s_editMenu release]; - m_cursorRecognizer = Q_NULLPTR; - m_selectionRecognizer = Q_NULLPTR; - m_openMenuOnTapRecognizer = Q_NULLPTR; - s_editMenu = Q_NULLPTR; + m_cursorRecognizer = nullptr; + m_selectionRecognizer = nullptr; + m_openMenuOnTapRecognizer = nullptr; + s_editMenu = nullptr; } if (platformInputContext()->inputMethodAccepted()) { diff --git a/src/plugins/platforms/ios/qiostheme.h b/src/plugins/platforms/ios/qiostheme.h index fc6b58178a..c917679a91 100644 --- a/src/plugins/platforms/ios/qiostheme.h +++ b/src/plugins/platforms/ios/qiostheme.h @@ -52,16 +52,16 @@ public: QIOSTheme(); ~QIOSTheme(); - const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE; - QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; + const QPalette *palette(Palette type = SystemPalette) const override; + QVariant themeHint(ThemeHint hint) const override; - QPlatformMenuItem* createPlatformMenuItem() const Q_DECL_OVERRIDE; - QPlatformMenu* createPlatformMenu() const Q_DECL_OVERRIDE; + QPlatformMenuItem* createPlatformMenuItem() const override; + QPlatformMenu* createPlatformMenu() const override; - bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE; - QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE; + bool usePlatformNativeDialog(DialogType type) const override; + QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override; - const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE; + const QFont *font(Font type = SystemFont) const override; static const char *name; diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index da8a6aabdc..1342d66201 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -60,35 +60,35 @@ public: explicit QIOSWindow(QWindow *window); ~QIOSWindow(); - void setGeometry(const QRect &rect) Q_DECL_OVERRIDE; + void setGeometry(const QRect &rect) override; - void setWindowState(Qt::WindowStates state) Q_DECL_OVERRIDE; - void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE; - void handleContentOrientationChange(Qt::ScreenOrientation orientation) Q_DECL_OVERRIDE; - void setVisible(bool visible) Q_DECL_OVERRIDE; - void setOpacity(qreal level) Q_DECL_OVERRIDE; + void setWindowState(Qt::WindowStates state) override; + void setParent(const QPlatformWindow *window) override; + void handleContentOrientationChange(Qt::ScreenOrientation orientation) override; + void setVisible(bool visible) override; + void setOpacity(qreal level) override; - bool isExposed() const Q_DECL_OVERRIDE; - void propagateSizeHints() Q_DECL_OVERRIDE {} + bool isExposed() const override; + void propagateSizeHints() override {} - void raise() Q_DECL_OVERRIDE{ raiseOrLower(true); } - void lower() Q_DECL_OVERRIDE { raiseOrLower(false); } + void raise() override{ raiseOrLower(true); } + void lower() override { raiseOrLower(false); } bool shouldAutoActivateWindow() const; - void requestActivateWindow() Q_DECL_OVERRIDE; + void requestActivateWindow() override; - qreal devicePixelRatio() const Q_DECL_OVERRIDE; + qreal devicePixelRatio() const override; - bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE { return grab; } - bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE { return grab; } + bool setMouseGrabEnabled(bool grab) override { return grab; } + bool setKeyboardGrabEnabled(bool grab) override { return grab; } - WId winId() const Q_DECL_OVERRIDE { return WId(m_view); } + WId winId() const override { return WId(m_view); } void clearAccessibleCache(); - QSurfaceFormat format() const Q_DECL_OVERRIDE; + QSurfaceFormat format() const override; - void requestUpdate() Q_DECL_OVERRIDE; + void requestUpdate() override; CAEAGLLayer *eaglLayer() const; diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index 1500f0b41c..2224ee336a 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -58,6 +58,7 @@ QT_END_NAMESPACE QT_PREPEND_NAMESPACE(QIOSWindow) *m_qioswindow; @private QHash<UITouch *, QWindowSystemInterface::TouchPoint> m_activeTouches; + UITouch *m_activePencilTouch; int m_nextTouchId; @private diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index a56530e1d9..406bfcf5b3 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -52,6 +52,8 @@ #include <QtGui/private/qwindow_p.h> #include <qpa/qwindowsysteminterface_p.h> +Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") + @implementation QUIView + (Class)layerClass @@ -311,11 +313,44 @@ return [super pointInside:point withEvent:event]; } -- (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state +- (void)handleTouches:(NSSet *)touches withEvent:(UIEvent *)event withState:(Qt::TouchPointState)state withTimestamp:(ulong)timeStamp { + QIOSIntegration *iosIntegration = QIOSIntegration::instance(); bool supportsPressure = QIOSIntegration::instance()->touchDevice()->capabilities() & QTouchDevice::Pressure; - foreach (UITouch *uiTouch, m_activeTouches.keys()) { +#if QT_CONFIG(tabletevent) + if (m_activePencilTouch && [touches containsObject:m_activePencilTouch]) { + NSArray<UITouch *> *cTouches = [event coalescedTouchesForTouch:m_activePencilTouch]; + int i = 0; + for (UITouch *cTouch in cTouches) { + QPointF localViewPosition = QPointF::fromCGPoint([cTouch preciseLocationInView:self]); + QPoint localViewPositionI = localViewPosition.toPoint(); + QPointF globalScreenPosition = m_qioswindow->mapToGlobal(localViewPositionI) + + (localViewPosition - localViewPositionI); + qreal pressure = cTouch.force / cTouch.maximumPossibleForce; + // azimuth unit vector: +x to the right, +y going downwards + CGVector azimuth = [cTouch azimuthUnitVectorInView: self]; + // azimuthAngle given in radians, zero when the stylus points towards +x axis; converted to degrees with 0 pointing straight up + qreal azimuthAngle = [cTouch azimuthAngleInView: self] * 180 / M_PI + 90; + // altitudeAngle given in radians, pi / 2 is with the stylus perpendicular to the iPad, smaller values mean more tilted, but never negative. + // Convert to degrees with zero being perpendicular. + qreal altitudeAngle = 90 - cTouch.altitudeAngle * 180 / M_PI; + qCDebug(lcQpaTablet) << i << ":" << timeStamp << localViewPosition << pressure << state << "azimuth" << azimuth.dx << azimuth.dy + << "angle" << azimuthAngle << "altitude" << cTouch.altitudeAngle + << "xTilt" << qBound(-60.0, altitudeAngle * azimuth.dx, 60.0) << "yTilt" << qBound(-60.0, altitudeAngle * azimuth.dy, 60.0); + QWindowSystemInterface::handleTabletEvent(m_qioswindow->window(), timeStamp, localViewPosition, globalScreenPosition, + // device, pointerType, buttons + QTabletEvent::RotationStylus, QTabletEvent::Pen, state == Qt::TouchPointReleased ? Qt::NoButton : Qt::LeftButton, + // pressure, xTilt, yTilt + pressure, qBound(-60.0, altitudeAngle * azimuth.dx, 60.0), qBound(-60.0, altitudeAngle * azimuth.dy, 60.0), + // tangentialPressure, rotation, z, uid, modifiers + 0, azimuthAngle, 0, 0, Qt::NoModifier); + ++i; + } + } +#endif + + for (UITouch *uiTouch : m_activeTouches.keys()) { QWindowSystemInterface::TouchPoint &touchPoint = m_activeTouches[uiTouch]; if (![touches containsObject:uiTouch]) { touchPoint.state = Qt::TouchPointStationary; @@ -344,17 +379,13 @@ touchPoint.pressure = uiTouch.force / uiTouch.maximumPossibleForce; } else { // We don't claim that our touch device supports QTouchDevice::Pressure, - // but fill in a meaningfull value in case clients use it anyways. + // but fill in a meaningful value in case clients use it anyway. touchPoint.pressure = (state == Qt::TouchPointReleased) ? 0.0 : 1.0; } } } -} - -- (void)sendTouchEventWithTimestamp:(ulong)timeStamp -{ - QIOSIntegration *iosIntegration = QIOSIntegration::instance(); - QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); + if (!m_activeTouches.isEmpty()) + QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event @@ -364,8 +395,21 @@ // points to QWindowSystemInterface::TouchPoints, and assigns each TouchPoint // an id for use by Qt. for (UITouch *touch in touches) { - Q_ASSERT(!m_activeTouches.contains(touch)); - m_activeTouches[touch].id = m_nextTouchId++; +#if QT_CONFIG(tabletevent) + if (touch.type == UITouchTypeStylus) { + if (Q_UNLIKELY(m_activePencilTouch)) { + qWarning("ignoring additional Pencil while first is still active"); + continue; + } + m_activePencilTouch = touch; + } else + { + Q_ASSERT(!m_activeTouches.contains(touch)); +#endif + m_activeTouches[touch].id = m_nextTouchId++; +#if QT_CONFIG(tabletevent) + } +#endif } if (m_qioswindow->shouldAutoActivateWindow() && m_activeTouches.size() == 1) { @@ -376,31 +420,36 @@ topLevel->requestActivateWindow(); } - [self updateTouchList:touches withState:Qt::TouchPointPressed]; - [self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)]; + [self handleTouches:touches withEvent:event withState:Qt::TouchPointPressed withTimestamp:ulong(event.timestamp * 1000)]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - [self updateTouchList:touches withState:Qt::TouchPointMoved]; - [self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)]; + [self handleTouches:touches withEvent:event withState:Qt::TouchPointMoved withTimestamp:ulong(event.timestamp * 1000)]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - [self updateTouchList:touches withState:Qt::TouchPointReleased]; - [self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)]; + [self handleTouches:touches withEvent:event withState:Qt::TouchPointReleased withTimestamp:ulong(event.timestamp * 1000)]; // Remove ended touch points from the active set: - for (UITouch *touch in touches) - m_activeTouches.remove(touch); - if (m_activeTouches.isEmpty()) + for (UITouch *touch in touches) { +#if QT_CONFIG(tabletevent) + if (touch.type == UITouchTypeStylus) { + m_activePencilTouch = nil; + } else +#endif + { + m_activeTouches.remove(touch); + } + } + if (m_activeTouches.isEmpty() && !m_activePencilTouch) m_nextTouchId = 0; } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - if (m_activeTouches.isEmpty()) + if (m_activeTouches.isEmpty() && !m_activePencilTouch) return; // When four-finger swiping, we get a touchesCancelled callback @@ -424,11 +473,12 @@ // sub-set of the active touch events are intentionally cancelled. NSInteger count = static_cast<NSInteger>([touches count]); - if (count != 0 && count != m_activeTouches.count()) + if (count != 0 && count != m_activeTouches.count() && !m_activePencilTouch) qWarning("Subset of active touches cancelled by UIKit"); m_activeTouches.clear(); m_nextTouchId = 0; + m_activePencilTouch = nil; NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime]; |