diff options
author | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2009-07-08 11:40:29 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2009-07-08 11:50:31 (GMT) |
commit | a92a6ede9c6a13833d1a6c83b863a5e492b2ba9e (patch) | |
tree | 18fe197d27a1e7e3d026e5748b2037073a816e2b /src/gui/kernel/qclipboard_mac.cpp | |
parent | 19a824cfe36458732f12e6374848df37cd92eed8 (diff) | |
download | Qt-a92a6ede9c6a13833d1a6c83b863a5e492b2ba9e.zip Qt-a92a6ede9c6a13833d1a6c83b863a5e492b2ba9e.tar.gz Qt-a92a6ede9c6a13833d1a6c83b863a5e492b2ba9e.tar.bz2 |
Cocoa: Plain text from clipboard use '\r' as newline instead of '\n'
The 'public.utf16-plain-text' clipboard type maps newlines to '\r'
instead of '\n'. The NSStringPboardType from NSPasteboard does this
correctly, so first try to get data through this type.
Task-number: 257661
Reviewed-by: Norwegian Rock Cat
Diffstat (limited to 'src/gui/kernel/qclipboard_mac.cpp')
-rw-r--r-- | src/gui/kernel/qclipboard_mac.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/kernel/qclipboard_mac.cpp b/src/gui/kernel/qclipboard_mac.cpp index b7b57b8..45050b2 100644 --- a/src/gui/kernel/qclipboard_mac.cpp +++ b/src/gui/kernel/qclipboard_mac.cpp @@ -50,6 +50,7 @@ #include "qurl.h" #include <stdlib.h> #include <string.h> +#include "qt_cocoa_helpers_mac_p.h" QT_BEGIN_NAMESPACE @@ -525,8 +526,17 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const QString c_flavor = c->flavorFor(format); if(!c_flavor.isEmpty()) { // Handle text/plain a little differently. Try handling Unicode first. - if((c_flavor == QLatin1String("com.apple.traditional-mac-plain-text") || c_flavor == QLatin1String("public.utf8-plain-text")) && - hasFlavor(QLatin1String("public.utf16-plain-text"))) + bool checkForUtf16 = (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text") + || c_flavor == QLatin1String("public.utf8-plain-text")); + if (checkForUtf16 || c_flavor == QLatin1String("public.utf16-plain-text")) { + // Try to get the NSStringPboardType from NSPasteboard, newlines are mapped + // correctly (as '\n') in this data. The 'public.utf16-plain-text' type + // usually maps newlines to '\r' instead. + QString str = qt_mac_get_pasteboardString(); + if (!str.isEmpty()) + return str; + } + if (checkForUtf16 && hasFlavor(QLatin1String("public.utf16-plain-text"))) c_flavor = QLatin1String("public.utf16-plain-text"); QVariant ret; |