Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
platformquirks_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef PLATFORMQUIRKS_P_H
5#define PLATFORMQUIRKS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qglobal_p.h>
19
20#ifdef Q_OS_MACOS
21#include <Carbon/Carbon.h>
22#endif
23
25
27{
28 static inline bool isClipboardAvailable()
29 {
30#if !QT_CONFIG(clipboard)
31 return false;
32#elif defined(Q_OS_MACOS)
33 PasteboardRef pasteboard;
34 OSStatus status = PasteboardCreate(0, &pasteboard);
35 if (status == noErr)
36 CFRelease(pasteboard);
37 return status == noErr;
38#else
40 return true;
41
42 // On XCB a clipboard may be dysfunctional due to platform restrictions
44 if (!clipBoard)
45 return false;
46 const QString &oldText = clipBoard->text();
47 QScopeGuard guard([&](){ clipBoard->setText(oldText); });
48 const QLatin1StringView prefix("Something to prefix ");
49 const QString newText = prefix + oldText;
50 clipBoard->setText(newText);
51 return QTest::qWaitFor([&](){ return clipBoard->text() == newText; });
52#endif
53 }
54};
55
57
58#endif
The QClipboard class provides access to the window system clipboard.
Definition qclipboard.h:20
static QClipboard * clipboard()
Returns the object for interacting with the clipboard.
QString platformName
The name of the underlying platform plugin.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
bool qWaitFor(Functor predicate, QDeadlineTimer deadline=QDeadlineTimer(std::chrono::seconds{5}))
static bool isClipboardAvailable()