KGuiAddons

waylandclipboard.cpp
1/*
2 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
3 SPDX-FileCopyrightText: 2021 Méven Car <meven.car@enioka.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "waylandclipboard_p.h"
9
10#include <QBuffer>
11#include <QFile>
12#include <QGuiApplication>
13#include <QImageReader>
14#include <QImageWriter>
15#include <QMimeData>
16#include <QPointer>
17#include <QWaylandClientExtension>
18#include <QWindow>
19#include <QtWaylandClientVersion>
20
21#include <errno.h>
22#include <poll.h>
23#include <signal.h>
24#include <string.h>
25#include <unistd.h>
26
27#include "qwayland-wayland.h"
28#include "qwayland-wlr-data-control-unstable-v1.h"
29
30static inline QString applicationQtXImageLiteral()
31{
32 return QStringLiteral("application/x-qt-image");
33}
34
35// copied from https://code.woboq.org/qt5/qtbase/src/gui/kernel/qinternalmimedata.cpp.html
36static QString utf8Text()
37{
38 return QStringLiteral("text/plain;charset=utf-8");
39}
40
41static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
42{
43 QStringList formats;
44 formats.reserve(imageFormats.size());
45 for (const auto &format : imageFormats)
46 formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
47 // put png at the front because it is best
48 int pngIndex = formats.indexOf(QLatin1String("image/png"));
49 if (pngIndex != -1 && pngIndex != 0)
50 formats.move(pngIndex, 0);
51 return formats;
52}
53
54static inline QStringList imageReadMimeFormats()
55{
56 return imageMimeFormats(QImageReader::supportedImageFormats());
57}
58
59static inline QStringList imageWriteMimeFormats()
60{
61 return imageMimeFormats(QImageWriter::supportedImageFormats());
62}
63// end copied
64
65class DataControlDeviceManager : public QWaylandClientExtensionTemplate<DataControlDeviceManager>, public QtWayland::zwlr_data_control_manager_v1
66{
67 Q_OBJECT
68public:
69 DataControlDeviceManager()
70 : QWaylandClientExtensionTemplate<DataControlDeviceManager>(2)
71 {
72 }
73
74 void instantiate()
75 {
76 initialize();
77 }
78
79 ~DataControlDeviceManager()
80 {
81 if (isInitialized()) {
82 destroy();
83 }
84 }
85};
86
87class DataControlOffer : public QMimeData, public QtWayland::zwlr_data_control_offer_v1
88{
90public:
91 DataControlOffer(struct ::zwlr_data_control_offer_v1 *id)
92 : QtWayland::zwlr_data_control_offer_v1(id)
93 {
94 }
95
96 ~DataControlOffer()
97 {
98 destroy();
99 }
100
101 QStringList formats() const override
102 {
103 return m_receivedFormats;
104 }
105
106 bool containsImageData() const
107 {
108 if (m_receivedFormats.contains(applicationQtXImageLiteral())) {
109 return true;
110 }
111 const auto formats = imageReadMimeFormats();
112 for (const auto &receivedFormat : m_receivedFormats) {
113 if (formats.contains(receivedFormat)) {
114 return true;
115 }
116 }
117 return false;
118 }
119
120 bool hasFormat(const QString &mimeType) const override
121 {
122 if (mimeType == QStringLiteral("text/plain") && m_receivedFormats.contains(utf8Text())) {
123 return true;
124 }
125 if (m_receivedFormats.contains(mimeType)) {
126 return true;
127 }
128
129 // If we have image data
130 if (containsImageData()) {
131 // is the requested output mimeType supported ?
132 const QStringList imageFormats = imageWriteMimeFormats();
133 for (const QString &imageFormat : imageFormats) {
134 if (imageFormat == mimeType) {
135 return true;
136 }
137 }
138 if (mimeType == applicationQtXImageLiteral()) {
139 return true;
140 }
141 }
142
143 return false;
144 }
145
146protected:
147 void zwlr_data_control_offer_v1_offer(const QString &mime_type) override
148 {
149 if (!m_receivedFormats.contains(mime_type)) {
150 m_receivedFormats << mime_type;
151 }
152 }
153
154 QVariant retrieveData(const QString &mimeType, QMetaType type) const override;
155
156private:
157 /** reads data from a file descriptor with a timeout of 1 second
158 * true if data is read successfully
159 */
160 static bool readData(int fd, QByteArray &data);
161 QStringList m_receivedFormats;
162};
163
164QVariant DataControlOffer::retrieveData(const QString &mimeType, QMetaType type) const
165{
166 Q_UNUSED(type);
167
168 QString mime;
169 if (!m_receivedFormats.contains(mimeType)) {
170 if (mimeType == QStringLiteral("text/plain") && m_receivedFormats.contains(utf8Text())) {
171 mime = utf8Text();
172 } else if (mimeType == applicationQtXImageLiteral()) {
173 const auto writeFormats = imageWriteMimeFormats();
174 for (const auto &receivedFormat : m_receivedFormats) {
175 if (writeFormats.contains(receivedFormat)) {
176 mime = receivedFormat;
177 break;
178 }
179 }
180 if (mime.isEmpty()) {
181 // default exchange format
182 mime = QStringLiteral("image/png");
183 }
184 }
185
186 if (mime.isEmpty()) {
187 return QVariant();
188 }
189 } else {
190 mime = mimeType;
191 }
192
193 int pipeFds[2];
194 if (pipe(pipeFds) != 0) {
195 return QVariant();
196 }
197
198 auto t = const_cast<DataControlOffer *>(this);
199 t->receive(mime, pipeFds[1]);
200
201 close(pipeFds[1]);
202
203 /*
204 * Ideally we need to introduce a non-blocking QMimeData object
205 * Or a non-blocking constructor to QMimeData with the mimetypes that are relevant
206 *
207 * However this isn't actually any worse than X.
208 */
209
210 auto waylandApp = qGuiApp->nativeInterface<QNativeInterface::QWaylandApplication>();
211 auto display = waylandApp->display();
212
213 wl_display_flush(display);
214
215 QFile readPipe;
216 if (readPipe.open(pipeFds[0], QIODevice::ReadOnly)) {
218 if (readData(pipeFds[0], data)) {
219 close(pipeFds[0]);
220
221 if (mimeType == applicationQtXImageLiteral()) {
222 QImage img = QImage::fromData(data, mime.mid(mime.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper().data());
223 if (!img.isNull()) {
224 return img;
225 }
226 } else if (data.size() > 1 && mimeType == u"text/uri-list") {
227 const auto urls = data.split('\n');
228 QVariantList list;
229 list.reserve(urls.size());
230 for (const QByteArray &s : urls) {
231#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
232 if (QUrl url(QUrl::fromEncoded(QByteArrayView(s).trimmed())); url.isValid()) {
233#else
234 if (QUrl url(QUrl::fromEncoded(QByteArrayView(s).trimmed().toByteArray())); url.isValid()) {
235#endif
236 list.emplace_back(std::move(url));
237 }
238 }
239 return list;
240 }
241 return data;
242 }
243 close(pipeFds[0]);
244 }
245 return QVariant();
246}
247
248bool DataControlOffer::readData(int fd, QByteArray &data)
249{
250 pollfd pfds[1];
251 pfds[0].fd = fd;
252 pfds[0].events = POLLIN;
253
254 while (true) {
255 const int ready = poll(pfds, 1, 1000);
256 if (ready < 0) {
257 if (errno != EINTR) {
258 qWarning("DataControlOffer: poll() failed: %s", strerror(errno));
259 return false;
260 }
261 } else if (ready == 0) {
262 qWarning("DataControlOffer: timeout reading from pipe");
263 return false;
264 } else {
265 char buf[4096];
266 int n = read(fd, buf, sizeof buf);
267
268 if (n < 0) {
269 qWarning("DataControlOffer: read() failed: %s", strerror(errno));
270 return false;
271 } else if (n == 0) {
272 return true;
273 } else if (n > 0) {
274 data.append(buf, n);
275 }
276 }
277 }
278}
279
280class DataControlSource : public QObject, public QtWayland::zwlr_data_control_source_v1
281{
282 Q_OBJECT
283public:
284 DataControlSource(struct ::zwlr_data_control_source_v1 *id, QMimeData *mimeData);
285 DataControlSource() = default;
286 ~DataControlSource()
287 {
288 destroy();
289 }
290
291 QMimeData *mimeData()
292 {
293 return m_mimeData.get();
294 }
295 std::unique_ptr<QMimeData> releaseMimeData()
296 {
297 return std::move(m_mimeData);
298 }
299
300Q_SIGNALS:
301 void cancelled();
302
303protected:
304 void zwlr_data_control_source_v1_send(const QString &mime_type, int32_t fd) override;
305 void zwlr_data_control_source_v1_cancelled() override;
306
307private:
308 std::unique_ptr<QMimeData> m_mimeData;
309};
310
311DataControlSource::DataControlSource(struct ::zwlr_data_control_source_v1 *id, QMimeData *mimeData)
312 : QtWayland::zwlr_data_control_source_v1(id)
313 , m_mimeData(mimeData)
314{
315 const auto formats = mimeData->formats();
316 for (const QString &format : formats) {
317 offer(format);
318 }
319 if (mimeData->hasText()) {
320 // ensure GTK applications get this mimetype to avoid them discarding the offer
321 offer(QStringLiteral("text/plain;charset=utf-8"));
322 }
323
324 if (mimeData->hasImage()) {
325 const QStringList imageFormats = imageWriteMimeFormats();
326 for (const QString &imageFormat : imageFormats) {
327 if (!formats.contains(imageFormat)) {
328 offer(imageFormat);
329 }
330 }
331 }
332}
333
334void DataControlSource::zwlr_data_control_source_v1_send(const QString &mime_type, int32_t fd)
335{
336 QString send_mime_type = mime_type;
337 if (send_mime_type == QStringLiteral("text/plain;charset=utf-8")) {
338 // if we get a request on the fallback mime, send the data from the original mime type
339 send_mime_type = QStringLiteral("text/plain");
340 }
341
342 QByteArray ba;
343 if (m_mimeData->hasImage()) {
344 // adapted from QInternalMimeData::renderDataHelper
345 if (mime_type == applicationQtXImageLiteral()) {
346 QImage image = qvariant_cast<QImage>(m_mimeData->imageData());
347 QBuffer buf(&ba);
348 buf.open(QBuffer::WriteOnly);
349 // would there not be PNG ??
350 image.save(&buf, "PNG");
351
352 } else if (mime_type.startsWith(QLatin1String("image/"))) {
353 QImage image = qvariant_cast<QImage>(m_mimeData->imageData());
354 QBuffer buf(&ba);
355 buf.open(QBuffer::WriteOnly);
356 image.save(&buf, mime_type.mid(mime_type.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper().data());
357 }
358 // end adapted
359 } else {
360 ba = m_mimeData->data(send_mime_type);
361 }
362
363 // Create a sigpipe handler that does nothing, or clients may be forced to terminate
364 // if the pipe is closed in the other end.
365 struct sigaction action, oldAction;
366 action.sa_handler = SIG_IGN;
367 sigemptyset(&action.sa_mask);
368 action.sa_flags = 0;
369 sigaction(SIGPIPE, &action, &oldAction);
370 write(fd, ba.constData(), ba.size());
371 sigaction(SIGPIPE, &oldAction, nullptr);
372 close(fd);
373}
374
375void DataControlSource::zwlr_data_control_source_v1_cancelled()
376{
377 Q_EMIT cancelled();
378}
379
380class DataControlDevice : public QObject, public QtWayland::zwlr_data_control_device_v1
381{
383public:
384 DataControlDevice(struct ::zwlr_data_control_device_v1 *id)
385 : QtWayland::zwlr_data_control_device_v1(id)
386 {
387 }
388
389 ~DataControlDevice()
390 {
391 destroy();
392 }
393
394 void setSelection(std::unique_ptr<DataControlSource> selection);
395 QMimeData *receivedSelection()
396 {
397 return m_receivedSelection.get();
398 }
399 QMimeData *selection()
400 {
401 return m_selection ? m_selection->mimeData() : nullptr;
402 }
403
404 void setPrimarySelection(std::unique_ptr<DataControlSource> selection);
405 QMimeData *receivedPrimarySelection()
406 {
407 return m_receivedPrimarySelection.get();
408 }
409 QMimeData *primarySelection()
410 {
411 return m_primarySelection ? m_primarySelection->mimeData() : nullptr;
412 }
413
415 void receivedSelectionChanged();
416 void selectionChanged();
417
418 void receivedPrimarySelectionChanged();
419 void primarySelectionChanged();
420
421protected:
422 void zwlr_data_control_device_v1_data_offer(struct ::zwlr_data_control_offer_v1 *id) override
423 {
424 // this will become memory managed when we retrieve the selection event
425 // a compositor calling data_offer without doing that would be a bug
426 new DataControlOffer(id);
427 }
428
429 void zwlr_data_control_device_v1_selection(struct ::zwlr_data_control_offer_v1 *id) override
430 {
431 if (!id) {
432 m_receivedSelection.reset();
433 } else {
434 auto derivated = QtWayland::zwlr_data_control_offer_v1::fromObject(id);
435 auto offer = dynamic_cast<DataControlOffer *>(derivated); // dynamic because of the dual inheritance
436 m_receivedSelection.reset(offer);
437 }
438 Q_EMIT receivedSelectionChanged();
439 }
440
441 void zwlr_data_control_device_v1_primary_selection(struct ::zwlr_data_control_offer_v1 *id) override
442 {
443 if (!id) {
444 m_receivedPrimarySelection.reset();
445 } else {
446 auto derivated = QtWayland::zwlr_data_control_offer_v1::fromObject(id);
447 auto offer = dynamic_cast<DataControlOffer *>(derivated); // dynamic because of the dual inheritance
448 m_receivedPrimarySelection.reset(offer);
449 }
450 Q_EMIT receivedPrimarySelectionChanged();
451 }
452
453private:
454 std::unique_ptr<DataControlSource> m_selection; // selection set locally
455 std::unique_ptr<DataControlOffer> m_receivedSelection; // latest selection set from externally to here
456
457 std::unique_ptr<DataControlSource> m_primarySelection; // selection set locally
458 std::unique_ptr<DataControlOffer> m_receivedPrimarySelection; // latest selection set from externally to here
459 friend WaylandClipboard;
460};
461
462void DataControlDevice::setSelection(std::unique_ptr<DataControlSource> selection)
463{
464 m_selection = std::move(selection);
465 connect(m_selection.get(), &DataControlSource::cancelled, this, [this]() {
466 m_selection.reset();
467 });
468 set_selection(m_selection->object());
469 Q_EMIT selectionChanged();
470}
471
472void DataControlDevice::setPrimarySelection(std::unique_ptr<DataControlSource> selection)
473{
474 m_primarySelection = std::move(selection);
475 connect(m_primarySelection.get(), &DataControlSource::cancelled, this, [this]() {
476 m_primarySelection.reset();
477 });
478
479 if (zwlr_data_control_device_v1_get_version(object()) >= ZWLR_DATA_CONTROL_DEVICE_V1_SET_PRIMARY_SELECTION_SINCE_VERSION) {
480 set_primary_selection(m_primarySelection->object());
481 Q_EMIT primarySelectionChanged();
482 }
483}
484class Keyboard;
485// We are binding to Seat/Keyboard manually because we want to react to gaining focus but inside Qt the events are Qt and arrive to late
486class KeyboardFocusWatcher : public QWaylandClientExtensionTemplate<KeyboardFocusWatcher>, public QtWayland::wl_seat
487{
488 Q_OBJECT
489public:
490 KeyboardFocusWatcher()
491 : QWaylandClientExtensionTemplate(5)
492 {
493 initialize();
494 auto waylandApp = qGuiApp->nativeInterface<QNativeInterface::QWaylandApplication>();
495 auto display = waylandApp->display();
496 // so we get capabilities
497 wl_display_roundtrip(display);
498 }
499 ~KeyboardFocusWatcher() override
500 {
501 if (isActive()) {
502 release();
503 }
504 }
505 void seat_capabilities(uint32_t capabilities) override
506 {
507 const bool hasKeyboard = capabilities & capability_keyboard;
508 if (hasKeyboard && !m_keyboard) {
509 m_keyboard = std::make_unique<Keyboard>(get_keyboard(), *this);
510 } else if (!hasKeyboard && m_keyboard) {
511 m_keyboard.reset();
512 }
513 }
514 bool hasFocus() const
515 {
516 return m_focus;
517 }
518Q_SIGNALS:
519 void keyboardEntered();
520
521private:
522 friend Keyboard;
523 bool m_focus = false;
524 std::unique_ptr<Keyboard> m_keyboard;
525};
526
527class Keyboard : public QtWayland::wl_keyboard
528{
529public:
530 Keyboard(::wl_keyboard *keyboard, KeyboardFocusWatcher &seat)
531 : wl_keyboard(keyboard)
532 , m_seat(seat)
533 {
534 }
535 ~Keyboard()
536 {
537 release();
538 }
539
540private:
541 void keyboard_enter([[maybe_unused]] uint32_t serial, [[maybe_unused]] wl_surface *surface, [[maybe_unused]] wl_array *keys) override
542 {
543 m_seat.m_focus = true;
544 Q_EMIT m_seat.keyboardEntered();
545 }
546 void keyboard_leave([[maybe_unused]] uint32_t serial, [[maybe_unused]] wl_surface *surface) override
547 {
548 m_seat.m_focus = false;
549 }
550 KeyboardFocusWatcher &m_seat;
551};
552
553WaylandClipboard::WaylandClipboard(QObject *parent)
554 : KSystemClipboard(parent)
555 , m_keyboardFocusWatcher(new KeyboardFocusWatcher)
556 , m_manager(new DataControlDeviceManager)
557{
558 connect(m_manager.get(), &DataControlDeviceManager::activeChanged, this, [this]() {
559 if (m_manager->isActive()) {
560 auto waylandApp = qGuiApp->nativeInterface<QNativeInterface::QWaylandApplication>();
561 if (!waylandApp) {
562 return;
563 }
564 auto seat = waylandApp->seat();
565
566 if (!seat) {
567 return;
568 }
569 m_device.reset(new DataControlDevice(m_manager->get_data_device(seat)));
570
571 connect(m_device.get(), &DataControlDevice::receivedSelectionChanged, this, [this]() {
572 // When our source is still valid, so the offer is for setting it or we emit changed when it is cancelled
573 if (!m_device->selection()) {
574 Q_EMIT changed(QClipboard::Clipboard);
575 }
576 });
577 connect(m_device.get(), &DataControlDevice::selectionChanged, this, [this]() {
578 Q_EMIT changed(QClipboard::Clipboard);
579 });
580
581 connect(m_device.get(), &DataControlDevice::receivedPrimarySelectionChanged, this, [this]() {
582 // When our source is still valid, so the offer is for setting it or we emit changed when it is cancelled
583 if (!m_device->primarySelection()) {
584 Q_EMIT changed(QClipboard::Selection);
585 }
586 });
587 connect(m_device.get(), &DataControlDevice::primarySelectionChanged, this, [this]() {
588 Q_EMIT changed(QClipboard::Selection);
589 });
590
591 } else {
592 m_device.reset();
593 }
594 });
595
596 m_manager->instantiate();
597}
598
599WaylandClipboard::~WaylandClipboard() = default;
600
601bool WaylandClipboard::isValid()
602{
603 return m_manager && m_manager->isInitialized();
604}
605
606void WaylandClipboard::setMimeData(QMimeData *mime, QClipboard::Mode mode)
607{
608 if (!m_device) {
609 return;
610 }
611
612 // roundtrip to have accurate focus state when losing focus but setting mime data before processing wayland events.
613 auto waylandApp = qGuiApp->nativeInterface<QNativeInterface::QWaylandApplication>();
614 auto display = waylandApp->display();
615 wl_display_roundtrip(display);
616
617 // If the application is focused, use the normal mechanism so a future paste will not deadlock itselfs
618 if (m_keyboardFocusWatcher->hasFocus()) {
620 // if we short-circuit the wlr_data_device, when we receive the data
621 // we cannot identify ourselves as the owner
622 // because of that we act like it's a synchronous action to not confuse klipper.
623 wl_display_roundtrip(display);
624 return;
625 }
626 // If not, set the clipboard once the app receives focus to avoid the deadlock
627 connect(m_keyboardFocusWatcher.get(), &KeyboardFocusWatcher::keyboardEntered, this, &WaylandClipboard::gainedFocus, Qt::UniqueConnection);
628 auto source = std::make_unique<DataControlSource>(m_manager->create_data_source(), mime);
629 if (mode == QClipboard::Clipboard) {
630 m_device->setSelection(std::move(source));
631 } else if (mode == QClipboard::Selection) {
632 m_device->setPrimarySelection(std::move(source));
633 }
634}
635
636void WaylandClipboard::gainedFocus()
637{
638 disconnect(m_keyboardFocusWatcher.get(), &KeyboardFocusWatcher::keyboardEntered, this, nullptr);
639 // QClipboard takes ownership of the QMimeData so we need to transfer and unset our selections
640 if (auto &selection = m_device->m_selection) {
641 std::unique_ptr<QMimeData> data = selection->releaseMimeData();
642 selection.reset();
644 }
645 if (auto &primarySelection = m_device->m_primarySelection) {
646 std::unique_ptr<QMimeData> data = primarySelection->releaseMimeData();
647 primarySelection.reset();
649 }
650}
651
652void WaylandClipboard::clear(QClipboard::Mode mode)
653{
654 if (!m_device) {
655 return;
656 }
657 if (mode == QClipboard::Clipboard) {
658 m_device->set_selection(nullptr);
659 m_device->m_selection.reset();
660 } else if (mode == QClipboard::Selection) {
661 if (zwlr_data_control_device_v1_get_version(m_device->object()) >= ZWLR_DATA_CONTROL_DEVICE_V1_SET_PRIMARY_SELECTION_SINCE_VERSION) {
662 m_device->set_primary_selection(nullptr);
663 m_device->m_primarySelection.reset();
664 }
665 }
666}
667
668const QMimeData *WaylandClipboard::mimeData(QClipboard::Mode mode) const
669{
670 if (!m_device) {
671 return nullptr;
672 }
673
674 // return our locally set selection if it's not cancelled to avoid copying data to ourselves
675 if (mode == QClipboard::Clipboard) {
676 if (m_device->selection()) {
677 return m_device->selection();
678 }
679 // This application owns the clipboard via the regular data_device, use it so we don't block ourselves
680 if (QGuiApplication::clipboard()->ownsClipboard()) {
681 return QGuiApplication::clipboard()->mimeData(mode);
682 }
683 return m_device->receivedSelection();
684 } else if (mode == QClipboard::Selection) {
685 if (m_device->primarySelection()) {
686 return m_device->primarySelection();
687 }
688 // This application owns the primary selection via the regular primary_selection_device, use it so we don't block ourselves
689 if (QGuiApplication::clipboard()->ownsSelection()) {
690 return QGuiApplication::clipboard()->mimeData(mode);
691 }
692 return m_device->receivedPrimarySelection();
693 }
694 return nullptr;
695}
696
697#include "waylandclipboard.moc"
This class mimics QClipboard but unlike QClipboard it will continue to get updates even when our wind...
KCALUTILS_EXPORT QString mimeType()
Capabilities capabilities()
QVariant read(const QByteArray &data, int versionOverride=0)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QList< QKeySequence > & close()
void initialize(StandardShortcut id)
QByteArray & append(QByteArrayView data)
const char * constData() const const
qsizetype size() const const
QList< QByteArray > split(char sep) const const
const QMimeData * mimeData(Mode mode) const const
void setMimeData(QMimeData *src, Mode mode)
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
QClipboard * clipboard()
QImage fromData(QByteArrayView data, const char *format)
bool isNull() const const
bool save(QIODevice *device, const char *format, int quality) const const
QList< QByteArray > supportedImageFormats()
QList< QByteArray > supportedImageFormats()
void append(QList< T > &&value)
reference emplace_back(Args &&... args)
void move(qsizetype from, qsizetype to)
void reserve(qsizetype size)
qsizetype size() const const
QByteArray data(const QString &mimeType) const const
virtual QStringList formats() const const
bool hasImage() const const
bool hasText() const const
QList< QUrl > urls() const const
virtual wl_display * display() const const=0
Q_EMITQ_EMIT
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString mid(qsizetype position, qsizetype n) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const
UniqueConnection
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromEncoded(const QByteArray &input, ParsingMode parsingMode)
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.