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 ||
79 if (atomName ==
"text/uri-list"_L1
84 }
else if (atomName ==
"application/x-color"_L1)
89 }
else if (atomName ==
"text/plain"_L1 &&
mimeData->
hasFormat(
"text/uri-list"_L1)) {
104 if (
format ==
"text/plain"_L1) {
106 atoms.
append(XCB_ATOM_STRING);
111 if (
format ==
"text/uri-list"_L1) {
117 if (
format ==
"image/ppm"_L1)
118 atoms.
append(XCB_ATOM_PIXMAP);
119 if (
format ==
"image/pbm"_L1)
120 atoms.
append(XCB_ATOM_BITMAP);
132 if (hasUtf8 && atomName ==
format +
";charset=utf-8"_L1) {
133 if (requestedType.
id() == QMetaType::QString)
139 if (
format ==
"text/plain"_L1) {
140 if (
data.endsWith(
'\0'))
145 if (
a == XCB_ATOM_STRING ||
153 if ((
format ==
"text/html"_L1 ||
format ==
"text/uri-list"_L1)
154 &&
data.size() > 1) {
157 if ((byte0 == 0xff && byte1 == 0xfe) || (byte0 == 0xfe && byte1 == 0xff)
158 || (byte0 != 0 && byte1 == 0) || (byte0 == 0 && byte1 != 0)) {
160 reinterpret_cast<const char16_t *
>(
data.constData()),
data.size() / 2);
162 if (
format ==
"text/uri-list"_L1) {
167 const QUrl url(
s.trimmed().toString());
183 if (
data.endsWith(
'\0'))
192 if (
format ==
"image/ppm"_L1) {
193 if (
a == XCB_ATOM_PIXMAP &&
data.size() ==
sizeof(
Pixmap)) {
207 QImage qimg = QXlibStatic::qimageFromXImage(ximg);
215 imageWriter.
write(qimg);
229 if (
format ==
"text/plain"_L1) {
232 if (atoms.
contains(XCB_ATOM_STRING))
233 return XCB_ATOM_STRING;
239 if (
format ==
"text/uri-list"_L1) {
249 if (
format ==
"image/ppm"_L1) {
250 if (atoms.
contains(XCB_ATOM_PIXMAP))
251 return XCB_ATOM_PIXMAP;
256 if (requestedType.
id() == QMetaType::QString
257 &&
format.startsWith(
"text/"_L1)
258 && !
format.contains(
"charset="_L1)) {
261 formatWithCharset.
append(
";charset=utf-8"_L1);
263 xcb_atom_t
a =
connection->internAtom(std::move(formatWithCharset).toLatin1());
279#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 setDevice(QIODevice *device)
Sets QImageWriter's device to device.
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
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
QByteArray toLatin1() const &
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.
static QString fromUtf16(const char16_t *, qsizetype size=-1)
bool isNull() const
Returns true if this string is null; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QChar * data()
Returns a pointer to the data stored in the QString.
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
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
QUrl url("example.com")
[constructor-url-reference]
bool contains(const AT &t) const noexcept