Krita Source Code Documentation
Loading...
Searching...
No Matches
KritaPlatformPluginWayland.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include <kpluginfactory.h>
8
9#include <kis_assert.h>
10
12
13#include <config-use-surface-color-management-api.h>
14
15#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
16
21
22#include <QWindow>
23
24namespace detail {
25
26// just a simple wrapper that unpacks arguments from a QVariantList into
27// a proper interface for KisWaylandSurfaceColorManager
28class KisWaylandSurfaceColorManagerWrapper: public KisWaylandSurfaceColorManager
29{
30public:
31 KisWaylandSurfaceColorManagerWrapper(QObject *parent, const QVariantList &args)
32 : KisWaylandSurfaceColorManager(args.first().value<QWindow*>(), parent)
33 {
34 KIS_SAFE_ASSERT_RECOVER_NOOP(args.size() == 1);
35 }
36};
37
38} // namespace detail
39
40class KisWaylandSurfaceColorManagementInfo : public KisSurfaceColorManagementInfo
41{
42 Q_OBJECT
43public:
45 bool surfaceColorManagedByOS() override {
46 return true;
47 }
48
49 QFuture<QString> debugReport() override {
50 QPromise<QString> promise;
51 promise.start();
52
53 std::shared_ptr<KisWaylandDebugInfoFetcher> infoFetcher(new KisWaylandDebugInfoFetcher());
54
55 if (infoFetcher->isReady()) {
56 promise.addResult(infoFetcher->report());
57 promise.finish();
58
59 return promise.future();
60 } else {
61 // wrap the info fetcher into the resulting lambda
62 QFuture<QString> result = promise.future().then(
63 [infoFetcher] (const QString &report) {
64 // a simple wrapping class that holds the fetcher until the
65 // result is reported or the future is destroyed
66 return report;
67 });
68
69 // move the promise into the handler of its completion signal
71 infoFetcher.get(), [promise = std::move(promise)] (const QString &report) mutable {
72 promise.addResult(report);
73 promise.finish();
74 });
75
76 return result;
77 }
78 }
79};
80
81#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
82
83K_PLUGIN_FACTORY_WITH_JSON(KritaPlatformPluginWaylandFactory, "kritaplatformwayland.json",
84 (
85 registerPlugin<KisExtendedModifiersMapperWayland>()
86#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
87 , registerPlugin<detail::KisWaylandSurfaceColorManagerWrapper>()
88 , registerPlugin<KisWaylandOutputColorInfo>()
89 , registerPlugin<KisWaylandSurfaceColorManagementInfo>()
90#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
91 );)
92
93#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
94// for detail::KisWaylandSurfaceColorManagerWrapper
95#include <KritaPlatformPluginWayland.moc>
96#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisSurfaceColorManagementInfo(QObject *parent=nullptr)
virtual QFuture< QString > debugReport()=0
virtual bool surfaceColorManagedByOS()=0
void sigDebugInfoReady(const QString &report)
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327