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
qohossharekit.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 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
6#include <QtCore/private/qohoscommon_p.h>
7#include <QtCore/private/qohoslogger_p.h>
8#include <QtCore/qmimedatabase.h>
9#include <QtGui/qwindow.h>
10
12
13namespace QtOhosAppKit {
14
15using namespace Private;
16
17/*!
18 \namespace QtOhosAppKit::ShareKit
19 \inmodule QtOhosAppKit
20 \since 5.12.12
21 \brief The ShareKit to expose Share Kit API.
22*/
23namespace ShareKit {
24
25namespace {
26
27constexpr const char *mimeTextUriList = "text/uri-list";
28
29std::optional<QOhosShareKit::ShareAbilityType> tryMapShareAbilityTypeToShareKitEnum(
30 ShareAbilityType abilityType)
31{
32 switch (abilityType) {
40 return std::make_optional(QOhosShareKit::ShareAbilityType::PRINT);
43 }
44
45 return {};
46}
47
48std::vector<QOhosShareKit::ShareAbilityType> mapExcludedAbilitiesToShareKit(
49 const QList<ShareAbilityType> &excludedAbilities)
50{
51 std::vector<QOhosShareKit::ShareAbilityType> shareKitExcludedAbilities;
52 for (auto excludedAbilityType : excludedAbilities) {
53 auto optShareKitExcludedAbilityType = tryMapShareAbilityTypeToShareKitEnum(excludedAbilityType);
54 if (optShareKitExcludedAbilityType.has_value())
55 shareKitExcludedAbilities.push_back(optShareKitExcludedAbilityType.value());
56 }
57 return shareKitExcludedAbilities;
58}
59
60class SharedRecordImpl : public SharedRecord
61{
62public:
63 SharedRecordImpl(const QMimeType &mimeType, const QString &content, bool urlContent);
64 SharedRecordImpl(const QFileInfo &fileInfo);
65
66 QMimeType mimeType() const override;
67 QString content() const override;
68 QString filePath() const override;
69 bool isUrlContent() const override;
70
71 void setTitle(const QString &title) override;
72 QString title() const override;
73
74 void setLabel(const QString &label) override;
75 QString label() const override;
76
77 void setDescription(const QString &description) override;
78 QString description() const override;
79
80 void setThumbnail(const QByteArray &thumbnail) override;
81 QByteArray thumbnail() const override;
82
83 void setThumbnailFilePath(const QString &thumbnailFilePath) override;
84 QString thumbnailFilePath() const override;
85
86 void setExtraData(const QVariantMap &extraData) override;
87 QVariantMap extraData() const override;
88
89private:
90 QMimeType m_mimeType;
91 std::optional<QString> m_content;
92 std::optional<QString> m_filePath;
93 bool m_urlContent;
94 std::optional<QString> m_title;
95 std::optional<QString> m_label;
96 std::optional<QString> m_description;
97 std::optional<QByteArray> m_thumbnail;
98 std::optional<QString> m_thumbnailFilePath;
99 std::optional<QVariantMap> m_extraData;
100};
101
102SharedRecordImpl::SharedRecordImpl(const QMimeType &mimeType, const QString &content, bool urlContent)
103 : SharedRecord()
104 , m_mimeType(mimeType)
105 , m_content(content)
106 , m_urlContent(urlContent)
107{
108}
109
110SharedRecordImpl::SharedRecordImpl(const QFileInfo &fileInfo)
111 : SharedRecord()
112 , m_mimeType(QMimeDatabase().mimeTypeForFile(fileInfo))
113 , m_filePath(fileInfo.absoluteFilePath())
114 , m_urlContent(false)
115{
116}
117
118QMimeType SharedRecordImpl::mimeType() const
119{
120 return m_mimeType;
121}
122
123QString SharedRecordImpl::content() const
124{
125 return m_content.value_or(QString());
126}
127
128QString SharedRecordImpl::filePath() const
129{
130 return m_filePath.value_or(QString());
131}
132
133bool SharedRecordImpl::isUrlContent() const
134{
135 return m_urlContent;
136}
137
138void SharedRecordImpl::setTitle(const QString &title)
139{
140 m_title = title;
141}
142
143QString SharedRecordImpl::title() const
144{
145 return m_title.value_or(QString());
146}
147
148void SharedRecordImpl::setLabel(const QString &label)
149{
150 m_label = label;
151}
152
153QString SharedRecordImpl::label() const
154{
155 return m_label.value_or(QString());
156}
157
158void SharedRecordImpl::setDescription(const QString &description)
159{
160 m_description = description;
161}
162
163QString SharedRecordImpl::description() const
164{
165 return m_description.value_or(QString());
166}
167
168void SharedRecordImpl::setThumbnail(const QByteArray &thumbnail)
169{
170 m_thumbnail = thumbnail;
171}
172
173QByteArray SharedRecordImpl::thumbnail() const
174{
175 return m_thumbnail.value_or(QByteArray());
176}
177
178void SharedRecordImpl::setThumbnailFilePath(const QString &thumbnailFilePath)
179{
180 m_thumbnailFilePath = thumbnailFilePath;
181}
182
183QString SharedRecordImpl::thumbnailFilePath() const
184{
185 return m_thumbnailFilePath.value_or(QString());
186}
187
188void SharedRecordImpl::setExtraData(const QVariantMap &extraData)
189{
190 m_extraData = extraData;
191}
192
193QVariantMap SharedRecordImpl::extraData() const
194{
195 return m_extraData.value_or(QVariantMap());
196}
197
198class ShareControllerOptionsImpl : public ShareControllerOptions
199{
200public:
201 void setAnchorOffset(QPoint anchorOffset) override;
202 void setAnchor(QRect anchor) override;
203 std::optional<QPoint> anchorOffset() const;
204 std::optional<QSize> anchorSize() const;
205
206 void setSingleSelectionMode(bool singleSelectionMode) override;
207 std::optional<bool> isSingleSelection() const;
208
209 void setDefaultPreviewMode(bool defaultPreviewMode) override;
210 std::optional<bool> isDefaultPreview() const;
211
212 void setExcludedAbilities(const QList<ShareAbilityType> &excludedAbilities) override;
213 std::optional<QList<ShareAbilityType>> excludedAbilities() const;
214
215private:
216 std::optional<QPoint> m_anchorOffset;
217 std::optional<QSize> m_anchorSize;
218 std::optional<bool> m_singleSelectionMode;
219 std::optional<bool> m_defaultPreviewMode;
220 std::optional<QList<ShareAbilityType>> m_excludedAbilities;
221};
222
223void ShareControllerOptionsImpl::setAnchorOffset(QPoint anchorOffset)
224{
225 m_anchorOffset = anchorOffset;
226}
227
228void ShareControllerOptionsImpl::setAnchor(QRect anchor)
229{
230 m_anchorOffset = anchor.topLeft();
231 m_anchorSize = anchor.size();
232}
233
234std::optional<QPoint> ShareControllerOptionsImpl::anchorOffset() const
235{
236 return m_anchorOffset;
237}
238
239std::optional<QSize> ShareControllerOptionsImpl::anchorSize() const
240{
241 return m_anchorSize;
242}
243
244void ShareControllerOptionsImpl::setSingleSelectionMode(bool singleSelectionMode)
245{
246 m_singleSelectionMode = singleSelectionMode;
247}
248
249std::optional<bool> ShareControllerOptionsImpl::isSingleSelection() const
250{
251 return m_singleSelectionMode;
252}
253
254void ShareControllerOptionsImpl::setDefaultPreviewMode(bool defaultPreviewMode)
255{
256 m_defaultPreviewMode = defaultPreviewMode;
257}
258
259std::optional<bool> ShareControllerOptionsImpl::isDefaultPreview() const
260{
261 return m_defaultPreviewMode;
262}
263
264void ShareControllerOptionsImpl::setExcludedAbilities(const QList<ShareAbilityType> &excludedAbilities)
265{
266 m_excludedAbilities = excludedAbilities;
267}
268
269std::optional<QList<ShareAbilityType>> ShareControllerOptionsImpl::excludedAbilities() const
270{
271 return m_excludedAbilities;
272}
273
274class ShareOperationResultImpl : public ShareOperationResult
275{
276public:
277 ShareOperationResultImpl(
278 const QOhosShareKit::ShareOperationResult &shareOperationResult);
279
280 QString targetAbilityName() const override;
281
282private:
283 QString m_targetAbilityName;
284};
285
286ShareOperationResultImpl::ShareOperationResultImpl(
287 const QOhosShareKit::ShareOperationResult &shareOperationResult)
288 : ShareOperationResult()
289 , m_targetAbilityName(QString::fromStdString(shareOperationResult.targetAbilityName))
290{
291}
292
293QString ShareOperationResultImpl::targetAbilityName() const
294{
295 return m_targetAbilityName;
296}
297
298std::vector<QOhosShareKit::SharedRecord> convertToShareKitSharedRecords(
299 const QList<std::shared_ptr<SharedRecord>> &dataToShare)
300{
301 std::vector<QOhosShareKit::SharedRecord> records;
302
303 for (const auto &sharedRecord : dataToShare) {
304 const auto *sharedRecordImpl = static_cast<const SharedRecordImpl *>(sharedRecord.get());
305
306 auto shareKitSharedRecord = QOhosShareKit::SharedRecord{
307 .mimeType = !sharedRecordImpl->isUrlContent()
308 ? sharedRecordImpl->mimeType().name().toStdString()
309 : std::string(mimeTextUriList),
310 };
311
312 if (!sharedRecordImpl->content().isNull()) {
313 shareKitSharedRecord.content = sharedRecordImpl->content().toStdString();
314 } else if (!sharedRecordImpl->filePath().isNull()) {
315 shareKitSharedRecord.filePath = sharedRecordImpl->filePath().toStdString();
316 } else {
317 qOhosPrintfWarning("%s: SharedRecord doesn't have content or uri, skipping...", Q_FUNC_INFO);
318 continue;
319 }
320
321 if (!sharedRecordImpl->title().isNull())
322 shareKitSharedRecord.title = sharedRecordImpl->title().toStdString();
323 if (!sharedRecordImpl->label().isNull())
324 shareKitSharedRecord.label = sharedRecordImpl->label().toStdString();
325 if (!sharedRecordImpl->description().isNull())
326 shareKitSharedRecord.description = sharedRecordImpl->description().toStdString();
327 if (!sharedRecordImpl->thumbnail().isNull())
328 shareKitSharedRecord.thumbnail = sharedRecordImpl->thumbnail();
329 if (!sharedRecordImpl->thumbnailFilePath().isNull())
330 shareKitSharedRecord.thumbnailFilePath = sharedRecordImpl->thumbnailFilePath().toStdString();
331 if (!sharedRecordImpl->extraData().isEmpty())
332 shareKitSharedRecord.extraData = sharedRecordImpl->extraData();
333
334 records.push_back(shareKitSharedRecord);
335 }
336
337 return records;
338}
339
340}
341
342/*!
343 \class QtOhosAppKit::ShareKit::SharedRecord
344 \inmodule QtOhosAppKit
345 \since 5.12.12
346 \brief The SharedRecord class represents a record to be shared with other application. A record can be created using
347 \sa QtOhosAppKit::ShareKit::createContentRecord(), QtOhosAppKit::ShareKit::createFileRecord() or QtOhosAppKit::ShareKit::createUrlRecord().
348 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
349 {SharedRecord}.
350*/
351
352/*!
353 \fn virtual QMimeType QtOhosAppKit::ShareKit::SharedRecord::mimeType() const = 0
354
355 Gets the shared record associated mime type.
356 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
357 {SharedRecord.utd}
358*/
359
360/*!
361 \fn virtual QString QtOhosAppKit::ShareKit::SharedRecord::content() const = 0
362
363 Gets the shared record optional content. Either content or file path must be set. If there is no content null string is provided.
364 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
365 {SharedRecord.content}
366*/
367
368/*!
369 \fn virtual QString QtOhosAppKit::ShareKit::SharedRecord::filePath() const = 0
370
371 Gets the shared record optional file path. Either content or file path must be set. If there is no file path null string is provided.
372 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
373 {SharedRecord.content}
374*/
375
376/*!
377 \fn virtual bool QtOhosAppKit::ShareKit::SharedRecord::isUrlContent() const = 0
378
379 Provides information if content() contains URL string. For URL content the mimeType() should not be used.
380 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
381 {SharedRecord.content}
382*/
383
384/*!
385 \fn virtual void QtOhosAppKit::ShareKit::SharedRecord::setTitle(const QString &title) = 0
386
387 Sets the title of shared content with a given \a title.
388 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
389 {SharedRecord.title}
390*/
391
392/*!
393 \fn virtual QString QtOhosAppKit::ShareKit::SharedRecord::title() const = 0
394
395 Gets the optional title of the shared record. If there is no title null string is provided.
396 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
397 {SharedRecord.title}
398*/
399
400/*!
401 \fn virtual void QtOhosAppKit::ShareKit::SharedRecord::setLabel(const QString &label) = 0
402
403 Sets the label indicating the current data record type with a given \a label.
404 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
405 {SharedRecord.label}
406*/
407
408/*!
409 \fn virtual QString QtOhosAppKit::ShareKit::SharedRecord::label() const = 0
410
411 Gets the optional label of the shared record. If there is no label null string is provided.
412 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
413 {SharedRecord.label}
414*/
415
416/*!
417 \fn virtual void QtOhosAppKit::ShareKit::SharedRecord::setDescription(const QString &description) = 0
418
419 Sets data record description with a given \a description.
420 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
421 {SharedRecord.description}
422*/
423
424/*!
425 \fn virtual QString QtOhosAppKit::ShareKit::SharedRecord::description() const = 0
426
427 Gets the optional description of the shared record. If there is no description null string is provided.
428 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
429 {SharedRecord.description}
430*/
431
432/*!
433 \fn virtual void QtOhosAppKit::ShareKit::SharedRecord::setThumbnail(const QByteArray &thumbnail) = 0
434
435 Sets data record thumbnail with a given \a thumbnail. The thumbnail is an image file content.
436 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
437 {SharedRecord.thumbnail}
438*/
439
440/*!
441 \fn virtual QByteArray QtOhosAppKit::ShareKit::SharedRecord::thumbnail() const = 0
442
443 Gets the optional thumbnail content of the shared record. If there is no thumbnail empty byte array is provided.
444 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
445 {SharedRecord.thumbnail}
446*/
447
448/*!
449 \fn virtual void QtOhosAppKit::ShareKit::SharedRecord::setThumbnailFilePath(const QString &thumbnailFilePath) = 0
450
451 Sets data record thumbnail uri with a given \a thumbnailFilePath.
452 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
453 {SharedRecord.thumbnailUri}
454*/
455
456/*!
457 \fn virtual QString QtOhosAppKit::ShareKit::SharedRecord::thumbnailFilePath() const = 0
458
459 Gets the optional thumbnail file path of the shared record. If there is no thumbnail file path null string is provided.
460 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
461 {SharedRecord.thumbnailFilePath}
462*/
463
464/*!
465 \fn virtual void QtOhosAppKit::ShareKit::SharedRecord::setExtraData(const QVariantMap &extraData) = 0
466
467 Sets exatra data for sharing with a given \a extraData.
468 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
469 {SharedRecord.extraData}
470*/
471
472/*!
473 \fn virtual QVariantMap QtOhosAppKit::ShareKit::SharedRecord::extraData() const = 0
474
475 Gets the optional extra data of the shared record. If there is no extra data empty variant map is provided.
476 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
477 {SharedRecord.extraData}
478*/
479
480SharedRecord::SharedRecord() = default;
481SharedRecord::~SharedRecord() = default;
482
483/*!
484 \class QtOhosAppKit::ShareKit::ShareControllerOptions
485 \inmodule QtOhosAppKit
486 \since 5.12.12
487 \brief The ShareControllerOptions class is to configure items, such as the preview mode of the shared content, selection mode,
488 and other information, and pop-up window anchor. It determines the display style of the sharing panel.
489 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section107934816010}
490 {ShareControllerOptions}
491*/
492
493/*!
494 \fn virtual void QtOhosAppKit::ShareKit::ShareControllerOptions::setAnchorOffset(QPoint anchorOffset) = 0
495
496 Sets sharing pop-up window anchor window offset with a given \a anchorOffset.
497 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section107934816010}
498 {ShareControllerOptions.anchor}
499*/
500
501/*!
502 \fn virtual void QtOhosAppKit::ShareKit::ShareControllerOptions::setAnchor(QRect anchor) = 0
503
504 Sets anchor offset and size with a given \a anchor.
505 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section19505934714}
506 {ShareControllerAnchor}
507*/
508
509/*!
510 \fn virtual void QtOhosAppKit::ShareKit::ShareControllerOptions::setSingleSelectionMode(bool singleSelectionMode) = 0
511
512 Sets sharing selection mode with a given \a singleSelectionMode. If singleSelectionMode is true,
513 single selection is set, batch mode otherwise.
514 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section107934816010}
515 {ShareControllerOptions.selectionMode}
516*/
517
518
519/*!
520 \fn virtual void QtOhosAppKit::ShareKit::ShareControllerOptions::setDefaultPreviewMode(bool defaultPreviewMode) = 0
521
522 Set sharing panel preview mode with a given \a defaultPreviewMode. If defaultPreviewMode is true, default preview
523 mode (thumbnail card) is set, detail mode otherwise. Detail mode is recommended for images and videos.
524 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section107934816010}
525 {ShareControllerOptions.previewMode}
526*/
527
528/*!
529 \fn virtual void QtOhosAppKit::ShareKit::ShareControllerOptions::setExcludedAbilities(const QList<ShareAbilityType> &excludedAbilities) = 0
530
531 Set a list of capabilities that do not need to be displayed in the operation area.
532 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section107934816010}
533 {ShareControllerOptions.excludedAbilities}
534*/
535
538
539/*!
540 \class QtOhosAppKit::ShareKit::ShareOperationResult
541 \inmodule QtOhosAppKit
542 \since 5.12.12
543 \brief ShareOperationResult wraps Ohos \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section17135118312}
544 {ShareOperationResult} interface.
545
546 It keeps information about share target ability.
547*/
548
549/*!
550 \fn virtual QString QtOhosAppKit::ShareKit::ShareOperationResult::targetAbilityName() const = 0
551
552 Gets the target ability name. For more info how the name is built please check following link.
553 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
554 {SharedRecord.utd}
555*/
556
559
560/*!
561 \fn std::shared_ptr<QtOhosAppKit::ShareKit::SharedRecord> QtOhosAppKit::ShareKit::createContentRecord(const QMimeType &mimeType, const QString &content)
562
563 Creates a shared "content" record with a given \a mimeType and \a content. Shared record can be created
564 with content (this function) or as a file shared record \sa QtOhosAppKit::ShareKit::createFileRecord().
565 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
566 {SharedRecord.content}
567*/
569 const QMimeType &mimeType, const QString &content)
570{
571 return std::make_shared<SharedRecordImpl>(mimeType, content, false);
572}
573
574/*!
575 \fn std::shared_ptr<QtOhosAppKit::ShareKit::SharedRecord> QtOhosAppKit::ShareKit::createFileRecord(const QFileInfo &fileInfo)
576
577 Creates a shared "file" record with a given \a fileInfo. Shared record can be created
578 with file (this function) or as a content record \sa QtOhosAppKit::ShareKit::createContentRecord().
579 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
580 {SharedRecord.uri}
581*/
582std::shared_ptr<SharedRecord> createFileRecord(const QFileInfo &fileInfo)
583{
584 return std::make_shared<SharedRecordImpl>(fileInfo);
585}
586
587/*!
588 \fn std::shared_ptr<QtOhosAppKit::ShareKit::SharedRecord> QtOhosAppKit::ShareKit::createUrlRecord(const QUrl &url)
589
590 Creates a shared record with a given \a url.
591 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section20696483813}
592 {SharedRecord.content}
593*/
595{
596 return std::make_shared<SharedRecordImpl>(QMimeType(), url.toString(), true);
597}
598
599/*!
600 \fn std::shared_ptr<QtOhosAppKit::ShareKit::ShareControllerOptions> QtOhosAppKit::ShareKit::createControllerOptions()
601
602 Creates a controller options instnace. Controller options can be used to configure preview mode,
603 selection mode and pop-up window anchor.
604 See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section107934816010}
605 {ShareControllerOptions}
606*/
608{
609 return std::make_shared<ShareControllerOptionsImpl>();
610}
611
612}
613
614namespace Private {
615
616using namespace ShareKit;
617
618std::shared_ptr<void> shareData(
619 QWindow *optMainWindow, const QList<std::shared_ptr<SharedRecord>> &records,
620 std::shared_ptr<ShareControllerOptions> controllerOptions,
621 std::function<void()> panelClosedCallback,
622 std::function<void(std::shared_ptr<ShareKit::ShareOperationResult>)> shareCompletedCallback)
623{
624 QOhosShareKit::ControllerOptions shareKitControllerOptions;
625 if (controllerOptions) {
626 const auto *controllerOptionsImpl = static_cast<const ShareControllerOptionsImpl *>(controllerOptions.get());
627
628 const auto optAnchorOffset = controllerOptionsImpl->anchorOffset();
629 if (optAnchorOffset.has_value()) {
630 shareKitControllerOptions.anchor = QOhosShareKit::ShareControllerAnchor{
631 .windowOffset = optAnchorOffset.value(),
632 .size = controllerOptionsImpl->anchorSize(),
633 };
634 }
635
636 const auto optSingleSelection = controllerOptionsImpl->isSingleSelection();
637 if (optSingleSelection.has_value()) {
638 shareKitControllerOptions.selectionMode = optSingleSelection.value()
641 }
642
643 const auto optDefaultPreview = controllerOptionsImpl->isDefaultPreview();
644 if (optDefaultPreview.has_value()) {
645 shareKitControllerOptions.previewMode = optDefaultPreview.value()
648 }
649
650 const auto optExcludedAbilities = controllerOptionsImpl->excludedAbilities();
651 if (optExcludedAbilities.has_value())
652 shareKitControllerOptions.excludedAbilities =
653 mapExcludedAbilitiesToShareKit(optExcludedAbilities.value());
654 }
655
656 return QOhosShareKit::shareData(
657 optMainWindow, convertToShareKitSharedRecords(records), shareKitControllerOptions,
658 std::move(panelClosedCallback),
659 [shareCompletedCallback = std::move(shareCompletedCallback)](auto shareOperationResult) {
660 shareCompletedCallback(std::make_shared<ShareOperationResultImpl>(shareOperationResult));
661 });
662}
663
664}
665
666}
667
668QT_END_NAMESPACE
Combined button and popup list for selecting options.
QtOhos::enums::kit::ShareKit::systemShare::ShareAbilityType ShareAbilityType
QtOhos::enums::kit::ShareKit::systemShare::SharePreviewMode SharePreviewMode
QtOhos::enums::kit::ShareKit::systemShare::SelectionMode SelectionMode
std::shared_ptr< void > shareData(QWindow *optMainWindow, const QList< std::shared_ptr< SharedRecord > > &records, std::shared_ptr< ShareControllerOptions > controllerOptions, std::function< void()> panelClosedCallback, std::function< void(std::shared_ptr< ShareKit::ShareOperationResult >)> shareCompletedCallback)
std::shared_ptr< SharedRecord > createContentRecord(const QMimeType &mimeType, const QString &content)
Creates a shared "content" record with a given mimeType and content.
std::shared_ptr< SharedRecord > createUrlRecord(const QUrl &url)
Creates a shared record with a given url.
std::shared_ptr< SharedRecord > createFileRecord(const QFileInfo &fileInfo)
Creates a shared "file" record with a given fileInfo.
std::shared_ptr< ShareControllerOptions > createControllerOptions()
Creates a controller options instnace.