summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoacursor.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoacursor.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm87
1 files changed, 41 insertions, 46 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 9e3bdb7b60..aaa35a91ef 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <AppKit/AppKit.h>
@@ -47,8 +11,19 @@
#include <QtGui/QBitmap>
+#if !defined(QT_APPLE_NO_PRIVATE_APIS)
+@interface NSCursor()
++ (id)_windowResizeNorthWestSouthEastCursor;
++ (id)_windowResizeNorthEastSouthWestCursor;
++ (id)_windowResizeNorthSouthCursor;
++ (id)_windowResizeEastWestCursor;
+@end
+#endif // QT_APPLE_NO_PRIVATE_APIS
+
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
QCocoaCursor::QCocoaCursor()
{
}
@@ -118,7 +93,7 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
return nil;
const Qt::CursorShape newShape = cursor->shape();
- NSCursor *cocoaCursor;
+ NSCursor *cocoaCursor = nil;
// Check for a suitable built-in NSCursor first:
switch (newShape) {
@@ -159,7 +134,29 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
case Qt::DragLinkCursor:
cocoaCursor = [NSCursor dragLinkCursor];
break;
- default : {
+#if !defined(QT_APPLE_NO_PRIVATE_APIS)
+ case Qt::SizeVerCursor:
+ if ([NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)])
+ cocoaCursor = [NSCursor _windowResizeNorthSouthCursor];
+ break;
+ case Qt::SizeHorCursor:
+ if ([NSCursor respondsToSelector:@selector(_windowResizeEastWestCursor)])
+ cocoaCursor = [NSCursor _windowResizeEastWestCursor];
+ break;
+ case Qt::SizeBDiagCursor:
+ if ([NSCursor respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)])
+ cocoaCursor = [NSCursor _windowResizeNorthEastSouthWestCursor];
+ break;
+ case Qt::SizeFDiagCursor:
+ if ([NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)])
+ cocoaCursor = [NSCursor _windowResizeNorthWestSouthEastCursor];
+ break;
+#endif // QT_APPLE_NO_PRIVATE_APIS
+ default:
+ break;
+ }
+
+ if (!cocoaCursor) {
// No suitable OS cursor exist, use cursors provided
// by Qt for the rest. Check for a cached cursor:
cocoaCursor = m_cursors.value(newShape);
@@ -174,8 +171,6 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
m_cursors.insert(newShape, cocoaCursor);
}
-
- break; }
}
return cocoaCursor;
}
@@ -245,7 +240,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
switch (cursor->shape()) {
case Qt::BitmapCursor: {
if (cursor->pixmap().isNull())
- return createCursorFromBitmap(cursor->bitmap(Qt::ReturnByValue), cursor->mask(Qt::ReturnByValue), hotspot);
+ return createCursorFromBitmap(cursor->bitmap(), cursor->mask(), hotspot);
else
return createCursorFromPixmap(cursor->pixmap(), hotspot);
break; }
@@ -255,15 +250,15 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
return createCursorFromPixmap(pixmap);
break; }
case Qt::WaitCursor: {
- QPixmap pixmap = QPixmap(QLatin1String(":/qt-project.org/mac/cursors/images/spincursor.png"));
+ QPixmap pixmap = QPixmap(":/qt-project.org/mac/cursors/images/spincursor.png"_L1);
return createCursorFromPixmap(pixmap, hotspot);
break; }
case Qt::SizeAllCursor: {
- QPixmap pixmap = QPixmap(QLatin1String(":/qt-project.org/mac/cursors/images/sizeallcursor.png"));
+ QPixmap pixmap = QPixmap(":/qt-project.org/mac/cursors/images/sizeallcursor.png"_L1);
return createCursorFromPixmap(pixmap, QPoint(8, 8));
break; }
case Qt::BusyCursor: {
- QPixmap pixmap = QPixmap(QLatin1String(":/qt-project.org/mac/cursors/images/waitcursor.png"));
+ QPixmap pixmap = QPixmap(":/qt-project.org/mac/cursors/images/waitcursor.png"_L1);
return createCursorFromPixmap(pixmap, hotspot);
break; }
#define QT_USE_APPROXIMATE_CURSORS