Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
24
QT_BEGIN_NAMESPACE
25
26
struct
PlatformQuirks
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
39
if
(QGuiApplication::platformName() != QLatin1StringView(
"xcb"
))
40
return
true
;
41
42
// On XCB a clipboard may be dysfunctional due to platform restrictions
43
QClipboard *clipBoard = QGuiApplication::clipboard();
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
56
QT_END_NAMESPACE
57
58
#
endif
qtdeclarative
src
quicktestutils
qml
platformquirks_p.h
Generated on
for Qt by
1.18.0