macOS: Better document plain-text code-path in QMacPasteboard::retrieveData
Due to PasteboardCopyItemFlavorData converting newlines to '\r' for some UTIs we have traditionally had to shortcut these UTIs via NSStringPboardType instead of the mime converters such as QMacPasteboardMimeUnicodeText. Let's explain this a bit better for future generations. Note that public.utf8-plain-text doesn't seem to have this problem anymore, but it's left in for now to not cause any regressions due to behavior change. Change-Id: I7dce80828865c6323ed308780b8ca07b7a3e7c17 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
4504d9ca31
commit
e6036cfc5a
@ -489,13 +489,12 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
|
||||
QMacInternalPasteboardMime *c = mimes.at(mime);
|
||||
QString c_flavor = c->flavorFor(format);
|
||||
if (!c_flavor.isEmpty()) {
|
||||
// Handle text/plain a little differently. Try handling Unicode first.
|
||||
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.
|
||||
// Converting via PasteboardCopyItemFlavorData below will for some UITs result
|
||||
// in newlines mapping to '\r' instead of '\n'. To work around this we shortcut
|
||||
// the conversion via NSPasteboard's NSStringPboardType if possible.
|
||||
if (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text")
|
||||
|| c_flavor == QLatin1String("public.utf8-plain-text")
|
||||
|| c_flavor == QLatin1String("public.utf16-plain-text")) {
|
||||
QString str = qt_mac_get_pasteboardString(paste);
|
||||
if (!str.isEmpty())
|
||||
return str;
|
||||
|
Loading…
Reference in New Issue
Block a user