QWaylandMimeData: Return converted MIME types in formats(), too
This brings it in line with QXcbDropData where formats_sys() returns the format from mimeAtomToString (which contains the special-case for text/x-moz-url). Furthermore, in hasFormat_sys() just check formats() to avoid yet another place where a special-case is added, again in line with QXcbDropData. Pick-to: 6.8 Change-Id: Ia2b7c149b35110ff9dd8deed94c3378afb047ac1 Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
34b6195385
commit
936260bbb9
@ -17,6 +17,11 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
static QString plainText()
|
||||
{
|
||||
return QStringLiteral("text/plain");
|
||||
}
|
||||
|
||||
static QString utf8Text()
|
||||
{
|
||||
return QStringLiteral("text/plain;charset=utf-8");
|
||||
@ -163,21 +168,29 @@ void QWaylandMimeData::appendFormat(const QString &mimeType)
|
||||
|
||||
bool QWaylandMimeData::hasFormat_sys(const QString &mimeType) const
|
||||
{
|
||||
if (m_types.contains(mimeType))
|
||||
return true;
|
||||
|
||||
if (mimeType == QStringLiteral("text/plain") && m_types.contains(utf8Text()))
|
||||
return true;
|
||||
|
||||
if (mimeType == uriList() && m_types.contains(mozUrl()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return formats().contains(mimeType);
|
||||
}
|
||||
|
||||
QStringList QWaylandMimeData::formats_sys() const
|
||||
{
|
||||
return m_types;
|
||||
QStringList types;
|
||||
types.reserve(m_types.size());
|
||||
|
||||
for (const QString &type : m_types) {
|
||||
QString mime = type;
|
||||
|
||||
if (mime == utf8Text()) {
|
||||
mime = plainText();
|
||||
} else if (mime == mozUrl()) {
|
||||
mime = uriList();
|
||||
}
|
||||
|
||||
if (!types.contains(mime)) {
|
||||
types << mime;
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QMetaType type) const
|
||||
@ -191,7 +204,7 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QMetaType t
|
||||
QString mime = mimeType;
|
||||
|
||||
if (!m_types.contains(mimeType)) {
|
||||
if (mimeType == QStringLiteral("text/plain") && m_types.contains(utf8Text()))
|
||||
if (mimeType == plainText() && m_types.contains(utf8Text()))
|
||||
mime = utf8Text();
|
||||
else if (mimeType == uriList() && m_types.contains(mozUrl()))
|
||||
mime = mozUrl();
|
||||
|
@ -352,7 +352,7 @@ void tst_primaryselectionv1::pasteUtf8()
|
||||
pointer()->sendButton(client(), BTN_MIDDLE, 0);
|
||||
pointer()->sendFrame(client());
|
||||
});
|
||||
QTRY_COMPARE(window.m_formats, QStringList({"text/plain", "text/plain;charset=utf-8"}));
|
||||
QTRY_COMPARE(window.m_formats, QStringList({"text/plain"}));
|
||||
QTRY_COMPARE(window.m_text, "face with tears of joy: 😂");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user