qt515: fix on darwin after bump to 5.15.2
This commit is contained in:
parent
0ea05f401f
commit
b583611cec
@ -57,6 +57,12 @@ let
|
|||||||
|
|
||||||
# Downgrade minimal required SDK to 10.12
|
# Downgrade minimal required SDK to 10.12
|
||||||
./qtbase.patch.d/0013-define-kiosurfacesuccess.patch
|
./qtbase.patch.d/0013-define-kiosurfacesuccess.patch
|
||||||
|
./qtbase.patch.d/macos-sdk-10.12/0001-Revert-QCocoaDrag-set-image-only-on-the-first-drag-i.patch
|
||||||
|
./qtbase.patch.d/macos-sdk-10.12/0002-Revert-QCocoaDrag-drag-make-sure-clipboard-is-ours-a.patch
|
||||||
|
./qtbase.patch.d/macos-sdk-10.12/0003-Revert-QCocoaDrag-maybeDragMultipleItems-fix-erroneo.patch
|
||||||
|
./qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch
|
||||||
|
./qtbase.patch.d/macos-sdk-10.12/0005-Revert-macOS-Fix-use-of-deprecated-NSOffState.patch
|
||||||
|
./qtbase.patch.d/macos-sdk-10.12/0006-git-checkout-v5.15.0-src-plugins-platforms-cocoa-qco.patch
|
||||||
./qtbase.patch.d/qtbase-sdk-10.12-mac.patch
|
./qtbase.patch.d/qtbase-sdk-10.12-mac.patch
|
||||||
|
|
||||||
# Patch framework detection to support X.framework/X.tbd,
|
# Patch framework detection to support X.framework/X.tbd,
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
From f156c35975e7844d2369ec5a6633ee40ec56f17a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
||||||
|
Date: Mon, 7 Dec 2020 12:32:29 -0500
|
||||||
|
Subject: [PATCH 1/6] Revert "QCocoaDrag - set image only on the first drag
|
||||||
|
item"
|
||||||
|
|
||||||
|
This reverts commit 7ee9bfc158a290776f622f62d0202220c6d159bc.
|
||||||
|
---
|
||||||
|
src/plugins/platforms/cocoa/qcocoadrag.mm | 9 ++-------
|
||||||
|
1 file changed, 2 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
index 4bd1b129bd..a506126c72 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
@@ -217,18 +217,13 @@ bool QCocoaDrag::maybeDragMultipleItems()
|
||||||
|
// 0. We start from URLs, which can be actually in a list (thus technically
|
||||||
|
// only ONE item in the pasteboard. The fact it's only one does not help, we are
|
||||||
|
// still getting an exception because of the number of items/images mismatch ...
|
||||||
|
- // We only set the image for the first item and nil for the rest, the image already
|
||||||
|
- // contains a combined picture for all urls we drag.
|
||||||
|
- auto imageOrNil = dragImage;
|
||||||
|
for (const auto &qtUrl : qtUrls) {
|
||||||
|
NSURL *nsUrl = qtUrl.toNSURL();
|
||||||
|
auto *newItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:nsUrl] autorelease];
|
||||||
|
const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y,
|
||||||
|
dragImage.size.width,
|
||||||
|
dragImage.size.height);
|
||||||
|
-
|
||||||
|
- [newItem setDraggingFrame:itemFrame contents:imageOrNil];
|
||||||
|
- imageOrNil = nil;
|
||||||
|
+ [newItem setDraggingFrame:itemFrame contents:dragImage];
|
||||||
|
[dragItems addObject:newItem];
|
||||||
|
}
|
||||||
|
// 1. Repeat for non-url items, if any:
|
||||||
|
@@ -237,7 +232,7 @@ bool QCocoaDrag::maybeDragMultipleItems()
|
||||||
|
const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y,
|
||||||
|
dragImage.size.width,
|
||||||
|
dragImage.size.height);
|
||||||
|
- [newItem setDraggingFrame:itemFrame contents:imageOrNil];
|
||||||
|
+ [newItem setDraggingFrame:itemFrame contents:dragImage];
|
||||||
|
[dragItems addObject:newItem];
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
From 9aaac67e3c3bf40ef3efc3b07b1655f72c8c54aa Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
||||||
|
Date: Mon, 7 Dec 2020 12:32:31 -0500
|
||||||
|
Subject: [PATCH 2/6] Revert "QCocoaDrag::drag - make sure clipboard is ours
|
||||||
|
and populated"
|
||||||
|
|
||||||
|
This reverts commit 720e2e0c92ca6635c5f05f318770a70cf653c1c7.
|
||||||
|
---
|
||||||
|
src/plugins/platforms/cocoa/qcocoadrag.mm | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
index a506126c72..c6ee4323ce 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
@@ -131,10 +131,6 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
|
||||||
|
m_drag = o;
|
||||||
|
m_executed_drop_action = Qt::IgnoreAction;
|
||||||
|
|
||||||
|
- QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
|
||||||
|
- m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
|
||||||
|
- dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
|
||||||
|
-
|
||||||
|
if (maybeDragMultipleItems())
|
||||||
|
return m_executed_drop_action;
|
||||||
|
|
||||||
|
@@ -143,6 +139,10 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
|
||||||
|
NSImage *dragImage = [NSImage imageFromQImage:pm.toImage()];
|
||||||
|
Q_ASSERT(dragImage);
|
||||||
|
|
||||||
|
+ QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
|
||||||
|
+ m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
|
||||||
|
+ dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
|
||||||
|
+
|
||||||
|
NSPoint event_location = [m_lastEvent locationInWindow];
|
||||||
|
NSWindow *theWindow = [m_lastEvent window];
|
||||||
|
Q_ASSERT(theWindow);
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
From d1626c55d10537274c6f365855342a1c619a4c3a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
||||||
|
Date: Mon, 7 Dec 2020 12:32:32 -0500
|
||||||
|
Subject: [PATCH 3/6] Revert "QCocoaDrag::maybeDragMultipleItems - fix
|
||||||
|
erroneous size check"
|
||||||
|
|
||||||
|
This reverts commit b8a03411784803c07ecc1f769860756d6fdc04cd.
|
||||||
|
---
|
||||||
|
src/plugins/platforms/cocoa/qcocoadrag.mm | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
index c6ee4323ce..ab6863a432 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
@@ -187,7 +187,7 @@ bool QCocoaDrag::maybeDragMultipleItems()
|
||||||
|
const auto &qtUrls = m_drag->mimeData()->urls();
|
||||||
|
NSPasteboard *dragBoard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];
|
||||||
|
|
||||||
|
- if (qtUrls.size() <= 1) {
|
||||||
|
+ if (int(dragBoard.pasteboardItems.count) == 1 && qtUrls.size() <= 1) {
|
||||||
|
// Good old -dragImage: works perfectly for this ...
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
@ -0,0 +1,192 @@
|
|||||||
|
From d5c155a9f3ff38e28ac073f6df43175724ebc290 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
||||||
|
Date: Mon, 7 Dec 2020 12:32:34 -0500
|
||||||
|
Subject: [PATCH 4/6] Revert "QCocoaDrag - avoid using the deprecated API if
|
||||||
|
possible"
|
||||||
|
|
||||||
|
This reverts commit 8481a9fc974a1f1dd44a9f82decb18fe2290689f.
|
||||||
|
---
|
||||||
|
src/plugins/platforms/cocoa/qcocoadrag.h | 6 --
|
||||||
|
src/plugins/platforms/cocoa/qcocoadrag.mm | 90 -------------------
|
||||||
|
.../platforms/cocoa/qnsview_dragging.mm | 9 +-
|
||||||
|
3 files changed, 1 insertion(+), 104 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h
|
||||||
|
index 975741c270..5a5b985c6e 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qcocoadrag.h
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qcocoadrag.h
|
||||||
|
@@ -48,8 +48,6 @@
|
||||||
|
#include <QtGui/private/qdnd_p.h>
|
||||||
|
#include <QtGui/private/qinternalmimedata_p.h>
|
||||||
|
|
||||||
|
-#include <QtCore/qeventloop.h>
|
||||||
|
-
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QCocoaDrag : public QPlatformDrag
|
||||||
|
@@ -71,15 +69,11 @@ public:
|
||||||
|
void setLastMouseEvent(NSEvent *event, NSView *view);
|
||||||
|
|
||||||
|
void setAcceptedAction(Qt::DropAction act);
|
||||||
|
- void exitDragLoop();
|
||||||
|
private:
|
||||||
|
QDrag *m_drag;
|
||||||
|
NSEvent *m_lastEvent;
|
||||||
|
NSView *m_lastView;
|
||||||
|
Qt::DropAction m_executed_drop_action;
|
||||||
|
- QEventLoop internalDragLoop;
|
||||||
|
-
|
||||||
|
- bool maybeDragMultipleItems();
|
||||||
|
|
||||||
|
QPixmap dragPixmap(QDrag *drag, QPoint &hotSpot) const;
|
||||||
|
};
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
index ab6863a432..b4a16ab912 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
|
||||||
|
@@ -44,9 +44,6 @@
|
||||||
|
#include <QtWidgets/qwidget.h>
|
||||||
|
#endif
|
||||||
|
#include <QtGui/private/qcoregraphics_p.h>
|
||||||
|
-#include <QtCore/qsysinfo.h>
|
||||||
|
-
|
||||||
|
-#include <vector>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@@ -131,9 +128,6 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
|
||||||
|
m_drag = o;
|
||||||
|
m_executed_drop_action = Qt::IgnoreAction;
|
||||||
|
|
||||||
|
- if (maybeDragMultipleItems())
|
||||||
|
- return m_executed_drop_action;
|
||||||
|
-
|
||||||
|
QPoint hotSpot = m_drag->hotSpot();
|
||||||
|
QPixmap pm = dragPixmap(m_drag, hotSpot);
|
||||||
|
NSImage *dragImage = [NSImage imageFromQImage:pm.toImage()];
|
||||||
|
@@ -164,95 +158,11 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
|
||||||
|
return m_executed_drop_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
-bool QCocoaDrag::maybeDragMultipleItems()
|
||||||
|
-{
|
||||||
|
- Q_ASSERT(m_drag && m_drag->mimeData());
|
||||||
|
- Q_ASSERT(m_executed_drop_action == Qt::IgnoreAction);
|
||||||
|
-
|
||||||
|
- if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave) {
|
||||||
|
- // -dragImage: stopped working in 10.14 first.
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- const QMacAutoReleasePool pool;
|
||||||
|
-
|
||||||
|
- NSWindow *theWindow = [m_lastEvent window];
|
||||||
|
- Q_ASSERT(theWindow);
|
||||||
|
-
|
||||||
|
- if (![theWindow.contentView respondsToSelector:@selector(draggingSession:sourceOperationMaskForDraggingContext:)])
|
||||||
|
- return false;
|
||||||
|
-
|
||||||
|
- auto *sourceView = static_cast<NSView<NSDraggingSource>*>(theWindow.contentView);
|
||||||
|
-
|
||||||
|
- const auto &qtUrls = m_drag->mimeData()->urls();
|
||||||
|
- NSPasteboard *dragBoard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];
|
||||||
|
-
|
||||||
|
- if (int(dragBoard.pasteboardItems.count) == 1 && qtUrls.size() <= 1) {
|
||||||
|
- // Good old -dragImage: works perfectly for this ...
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- std::vector<NSPasteboardItem *> nonUrls;
|
||||||
|
- for (NSPasteboardItem *item in dragBoard.pasteboardItems) {
|
||||||
|
- bool isUrl = false;
|
||||||
|
- for (NSPasteboardType type in item.types) {
|
||||||
|
- using NSStringRef = NSString *;
|
||||||
|
- if ([type isEqualToString:NSStringRef(kUTTypeFileURL)]) {
|
||||||
|
- isUrl = true;
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (!isUrl)
|
||||||
|
- nonUrls.push_back(item);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- QPoint hotSpot = m_drag->hotSpot();
|
||||||
|
- const auto pixmap = dragPixmap(m_drag, hotSpot);
|
||||||
|
- NSImage *dragImage = [NSImage imageFromQImage:pixmap.toImage()];
|
||||||
|
- Q_ASSERT(dragImage);
|
||||||
|
-
|
||||||
|
- NSMutableArray<NSDraggingItem *> *dragItems = [[[NSMutableArray alloc] init] autorelease];
|
||||||
|
- const NSPoint itemLocation = m_drag->hotSpot().toCGPoint();
|
||||||
|
- // 0. We start from URLs, which can be actually in a list (thus technically
|
||||||
|
- // only ONE item in the pasteboard. The fact it's only one does not help, we are
|
||||||
|
- // still getting an exception because of the number of items/images mismatch ...
|
||||||
|
- for (const auto &qtUrl : qtUrls) {
|
||||||
|
- NSURL *nsUrl = qtUrl.toNSURL();
|
||||||
|
- auto *newItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:nsUrl] autorelease];
|
||||||
|
- const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y,
|
||||||
|
- dragImage.size.width,
|
||||||
|
- dragImage.size.height);
|
||||||
|
- [newItem setDraggingFrame:itemFrame contents:dragImage];
|
||||||
|
- [dragItems addObject:newItem];
|
||||||
|
- }
|
||||||
|
- // 1. Repeat for non-url items, if any:
|
||||||
|
- for (auto *pbItem : nonUrls) {
|
||||||
|
- auto *newItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:pbItem] autorelease];
|
||||||
|
- const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y,
|
||||||
|
- dragImage.size.width,
|
||||||
|
- dragImage.size.height);
|
||||||
|
- [newItem setDraggingFrame:itemFrame contents:dragImage];
|
||||||
|
- [dragItems addObject:newItem];
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- [sourceView beginDraggingSessionWithItems:dragItems event:m_lastEvent source:sourceView];
|
||||||
|
- internalDragLoop.exec();
|
||||||
|
- return true;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
void QCocoaDrag::setAcceptedAction(Qt::DropAction act)
|
||||||
|
{
|
||||||
|
m_executed_drop_action = act;
|
||||||
|
}
|
||||||
|
|
||||||
|
-void QCocoaDrag::exitDragLoop()
|
||||||
|
-{
|
||||||
|
- if (internalDragLoop.isRunning())
|
||||||
|
- internalDragLoop.exit();
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-
|
||||||
|
QPixmap QCocoaDrag::dragPixmap(QDrag *drag, QPoint &hotSpot) const
|
||||||
|
{
|
||||||
|
const QMimeData* data = drag->mimeData();
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
|
||||||
|
index 978d73f7d9..463e3c5579 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
|
||||||
|
@@ -232,10 +232,6 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- auto *nativeDrag = QCocoaIntegration::instance()->drag();
|
||||||
|
- Q_ASSERT(nativeDrag);
|
||||||
|
- nativeDrag->exitDragLoop();
|
||||||
|
-
|
||||||
|
QPoint windowPoint = QPointF::fromCGPoint([self convertPoint:sender.draggingLocation fromView:nil]).toPoint();
|
||||||
|
|
||||||
|
qCDebug(lcQpaMouse) << QEvent::DragLeave << self << "at" << windowPoint;
|
||||||
|
@@ -294,10 +290,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
|
||||||
|
- Q_ASSERT(nativeDrag);
|
||||||
|
- nativeDrag->exitDragLoop();
|
||||||
|
- nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation));
|
||||||
|
+ QCocoaIntegration::instance()->drag();
|
||||||
|
|
||||||
|
// Qt starts drag-and-drop on a mouse button press event. Cococa in
|
||||||
|
// this case won't send the matching release event, so we have to
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
From e55ca5d08b29e67b699dc217abcb65e4a7655f72 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
||||||
|
Date: Mon, 7 Dec 2020 12:32:37 -0500
|
||||||
|
Subject: [PATCH 5/6] Revert "macOS: Fix use of deprecated NSOffState"
|
||||||
|
|
||||||
|
This reverts commit 6a0995525d306a1fa224adcbcb9f0ae1fc7d01bd.
|
||||||
|
---
|
||||||
|
src/plugins/styles/mac/qmacstyle_mac.mm | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
|
||||||
|
index d1febd81d4..b5e6e60ec0 100644
|
||||||
|
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
|
||||||
|
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
|
||||||
|
@@ -3955,7 +3955,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
||||||
|
pbCell = static_cast<NSPopUpButtonCell *>(pb.cell);
|
||||||
|
oldPosition = pbCell.arrowPosition;
|
||||||
|
pbCell.arrowPosition = NSPopUpNoArrow;
|
||||||
|
- if (pb.state == NSControlStateValueOff) {
|
||||||
|
+ if (pb.state == NSOffState) {
|
||||||
|
// NSPopUpButton in this state is smaller.
|
||||||
|
rAdjusted.origin.x -= 3;
|
||||||
|
rAdjusted.size.width += 6;
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
@ -0,0 +1,77 @@
|
|||||||
|
From 3ce5e752c66307f905fdf732b102a396d9248fbb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
||||||
|
Date: Mon, 7 Dec 2020 13:22:02 -0500
|
||||||
|
Subject: [PATCH 6/6] git checkout v5.15.0 --
|
||||||
|
src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
||||||
|
|
||||||
|
---
|
||||||
|
.../cocoa/qcocoacolordialoghelper.mm | 50 +++++++++----------
|
||||||
|
1 file changed, 25 insertions(+), 25 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
||||||
|
index 5ad1f9d7bb..c9fa035d87 100644
|
||||||
|
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
||||||
|
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
||||||
|
@@ -180,34 +180,34 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
|
||||||
|
|
||||||
|
- (void)updateQtColor
|
||||||
|
{
|
||||||
|
- // Discard the color space and pass the color components to QColor. This
|
||||||
|
- // is a good option as long as QColor is color-unmanaged: we preserve the
|
||||||
|
- // exact RGB value from the color picker, which is predictable. Further,
|
||||||
|
- // painting with the color will reproduce the same color on-screen, as
|
||||||
|
- // long as the the same screen is used for selecting the color.
|
||||||
|
- NSColor *componentColor = [[mColorPanel color] colorUsingType:NSColorTypeComponentBased];
|
||||||
|
- switch (componentColor.colorSpace.colorSpaceModel)
|
||||||
|
- {
|
||||||
|
- case NSColorSpaceModelGray: {
|
||||||
|
- CGFloat white = 0, alpha = 0;
|
||||||
|
- [componentColor getWhite:&white alpha:&alpha];
|
||||||
|
- mQtColor.setRgbF(white, white, white, alpha);
|
||||||
|
- } break;
|
||||||
|
- case NSColorSpaceModelRGB: {
|
||||||
|
- CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
||||||
|
- [componentColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||||
|
- mQtColor.setRgbF(red, green, blue, alpha);
|
||||||
|
- } break;
|
||||||
|
- case NSColorSpaceModelCMYK: {
|
||||||
|
+ NSColor *color = [mColorPanel color];
|
||||||
|
+ NSString *colorSpaceName = [color colorSpaceName];
|
||||||
|
+ if (colorSpaceName == NSDeviceCMYKColorSpace) {
|
||||||
|
CGFloat cyan = 0, magenta = 0, yellow = 0, black = 0, alpha = 0;
|
||||||
|
- [componentColor getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha];
|
||||||
|
+ [color getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha];
|
||||||
|
mQtColor.setCmykF(cyan, magenta, yellow, black, alpha);
|
||||||
|
- } break;
|
||||||
|
- default:
|
||||||
|
- qWarning("QNSColorPanelDelegate: Unsupported color space model");
|
||||||
|
- break;
|
||||||
|
+ } else if (colorSpaceName == NSCalibratedRGBColorSpace || colorSpaceName == NSDeviceRGBColorSpace) {
|
||||||
|
+ CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
||||||
|
+ [color getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||||
|
+ mQtColor.setRgbF(red, green, blue, alpha);
|
||||||
|
+ } else if (colorSpaceName == NSNamedColorSpace) {
|
||||||
|
+ NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||||
|
+ CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
||||||
|
+ [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||||
|
+ mQtColor.setRgbF(red, green, blue, alpha);
|
||||||
|
+ } else {
|
||||||
|
+ NSColorSpace *colorSpace = [color colorSpace];
|
||||||
|
+ if ([colorSpace colorSpaceModel] == NSCMYKColorSpaceModel && [color numberOfComponents] == 5){
|
||||||
|
+ CGFloat components[5];
|
||||||
|
+ [color getComponents:components];
|
||||||
|
+ mQtColor.setCmykF(components[0], components[1], components[2], components[3], components[4]);
|
||||||
|
+ } else {
|
||||||
|
+ NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||||
|
+ CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
||||||
|
+ [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||||
|
+ mQtColor.setRgbF(red, green, blue, alpha);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
-
|
||||||
|
if (mHelper)
|
||||||
|
emit mHelper->currentColorChanged(mQtColor);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user