Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qohosclipboardobject.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOHOSCLIPBOARDOBJECT_H
5#define QOHOSCLIPBOARDOBJECT_H
6
7#include <QtCore/private/qohoscommon_p.h>
8#include <QtCore/qglobal.h>
9#include <QtCore/qmimedata.h>
10#include <database/pasteboard/oh_pasteboard.h>
11#include <memory>
12#include <optional>
13
14QT_BEGIN_NAMESPACE
15
16class QOhosClipboardObject
17{
18public:
19 enum class PasteboardDataSource
20 {
21 OurProcess,
22 OtherProcess,
23 };
24
25 struct PasteboardData
26 {
27 std::optional<PasteboardDataSource> dataSource;
28 std::unique_ptr<QMimeData> lazyFetchingData;
29 };
30
31 static std::unique_ptr<QOhosClipboardObject> makeInstance(
32 std::function<void(std::optional<PasteboardDataSource>)> &&pasteboardUpdatesNotifier);
33
34 PasteboardData getPasteboardDataWithLazyFetch();
35 void setMimeDataSync(
36 std::shared_ptr<QMimeData> mimeData, const std::optional<bool> &shareInAppOnly);
37
38protected:
39 QOhosClipboardObject(std::function<void(std::optional<PasteboardDataSource>)> &&pasteboardUpdatesNotifier);
40
41private:
42 struct JsScopeData
43 {
44 std::shared_ptr<::OH_Pasteboard> pasteboard;
45 std::shared_ptr<void> pasteboardDataChangedListenerHandle;
46 };
47
48 std::shared_ptr<QOhosConsumer<std::optional<PasteboardDataSource>>> m_pasteboardUpdatesNotifier;
49 std::shared_ptr<JsScopeData> m_jsScopeData;
50};
51
52QT_END_NAMESPACE
53
54#endif
Combined button and popup list for selecting options.
std::shared_ptr<::OH_PasteboardObserver > createPasteboardDataObserver()
std::shared_ptr< void > subscribePasteboardObserver(std::shared_ptr<::OH_Pasteboard > pasteboard, std::shared_ptr<::OH_PasteboardObserver > pasteboardObserver, ::Pasteboard_NotifyType notifyType, std::function< void()> dataChangedFunc)
const char * getPasteboardDataSourceAsString(QOhosClipboardObject::PasteboardDataSource dataSource)
std::shared_ptr< void > addPasteboardDataChangedListener(std::shared_ptr<::OH_Pasteboard > pasteboard, std::function< void()> dataChangedListener, std::vector<::Pasteboard_NotifyType > monitoredNotifyTypes)
const char * getPasteboardNotifyTypeAsString(::Pasteboard_NotifyType notifyType)
std::unique_ptr< QOhosUdmfData > tryGetUdmfDataFromPasteboard(::OH_Pasteboard *pasteboard)
void runInJsThreadAndWait(const std::function< void(JsState &)> &task, std::string callerContextName={})
std::weak_ptr< QOhosClipboardObject > weakThis