6#include <QtGui/QImageWriter>
7#include <QtCore/QBuffer>
29 if (
a == XCB_ATOM_STRING
32 return "text/plain"_L1;
35 if (
a == XCB_ATOM_PIXMAP)
36 return "image/ppm"_L1;
41 if (atomName ==
"text/x-moz-url")
42 atomName =
"text/uri-list";
48 xcb_atom_t *atomFormat,
int *dataFormat)
58 ||
a == XCB_ATOM_STRING
64 }
else if (
a == XCB_ATOM_STRING ||
68 "text/plain"_L1,
mimeData)).toLatin1();
79 if (atomName ==
"text/uri-list"_L1
82 data->assign({
reinterpret_cast<const char *
>(mozUri.data()), mozUri.size() * 2});
83 }
else if (atomName ==
"application/x-color"_L1)
88 }
else if (atomName ==
"text/plain"_L1 &&
mimeData->
hasFormat(
"text/uri-list"_L1)) {
98 QList<xcb_atom_t> atoms;
103 if (
format ==
"text/plain"_L1) {
105 atoms.append(XCB_ATOM_STRING);
110 if (
format ==
"text/uri-list"_L1) {
111 atoms.append(
connection->internAtom(
"text/x-moz-url"));
112 atoms.append(
connection->internAtom(
"text/plain"));
116 if (
format ==
"image/ppm"_L1)
117 atoms.append(XCB_ATOM_PIXMAP);
118 if (
format ==
"image/pbm"_L1)
119 atoms.append(XCB_ATOM_BITMAP);
131 if (hasUtf8 && atomName ==
format +
";charset=utf-8"_L1) {
132 if (requestedType.id() == QMetaType::QString)
138 if (
format ==
"text/plain"_L1) {
139 if (
data.endsWith(
'\0'))
144 if (
a == XCB_ATOM_STRING ||
152 if ((
format ==
"text/html"_L1 ||
format ==
"text/uri-list"_L1)
153 &&
data.size() > 1) {
156 if ((byte0 == 0xff && byte1 == 0xfe) || (byte0 == 0xfe && byte1 == 0xff)
157 || (byte0 != 0 && byte1 == 0) || (byte0 == 0 && byte1 != 0)) {
159 reinterpret_cast<const char16_t *
>(
data.constData()),
data.size() / 2);
161 if (
format ==
"text/uri-list"_L1) {
163 QList<QVariant>
list;
166 const QUrl url(
s.trimmed().toString());
177 return str.toString();
182 if (
data.endsWith(
'\0'))
191 if (
format ==
"image/ppm"_L1) {
192 if (
a == XCB_ATOM_PIXMAP &&
data.size() ==
sizeof(
Pixmap)) {
206 QImage qimg = QXlibStatic::qimageFromXImage(ximg);
213 imageWriter.setDevice(&
buf);
214 imageWriter.write(qimg);
223 const QList<xcb_atom_t> &atoms,
bool *hasUtf8)
228 if (
format ==
"text/plain"_L1) {
231 if (atoms.contains(XCB_ATOM_STRING))
232 return XCB_ATOM_STRING;
238 if (
format ==
"text/uri-list"_L1) {
240 if (
a && atoms.contains(
a))
243 if (
a && atoms.contains(
a))
248 if (
format ==
"image/ppm"_L1) {
249 if (atoms.contains(XCB_ATOM_PIXMAP))
250 return XCB_ATOM_PIXMAP;
255 if (requestedType.id() == QMetaType::QString
256 &&
format.startsWith(
"text/"_L1)
257 && !
format.contains(
"charset="_L1)) {
260 formatWithCharset.
append(
";charset=utf-8"_L1);
262 xcb_atom_t
a =
connection->internAtom(std::move(formatWithCharset).toLatin1());
263 if (
a && atoms.contains(
a)) {
270 if (
a && atoms.contains(
a))
278#include "moc_qxcbmime.cpp"
\inmodule QtCore \reentrant
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
The QImageWriter class provides a format independent interface for writing images to files or other d...
void setFormat(const QByteArray &format)
Sets the format QImageWriter will use when writing images, to format.
static bool hasFormatHelper(const QString &mimeType, const QMimeData *data)
static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data)
qsizetype size() const noexcept
bool isEmpty() const noexcept
const T & constFirst() const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
bool hasImage() const
Returns true if the object can return an image; otherwise returns false.
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
QList< QUrl > urls() const
Returns a list of URLs contained within the MIME data object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void chop(qsizetype n)
Removes n characters from the end of the string.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
bool isNull() const
Returns true if this string is null; otherwise returns false.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
static QVariant mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format, QMetaType requestedType, bool hasUtf8)
static QList< xcb_atom_t > mimeAtomsForFormat(QXcbConnection *connection, const QString &format)
static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType requestedType, const QList< xcb_atom_t > &atoms, bool *hasUtf8)
static bool mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data, xcb_atom_t *atomFormat, int *dataFormat)
static QString mimeAtomToString(QXcbConnection *connection, xcb_atom_t a)
struct wl_display * display
Combined button and popup list for selecting options.
DBusConnection * connection
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum format
QUrl url("example.com")
[constructor-url-reference]