Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPlatformPluginInterfaceFactory.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
8
9#include <KoPluginLoader.h>
10#include <kpluginfactory.h>
11#include <QApplication>
12#include <QWindow>
13
14#include <kis_assert.h>
15
17
18#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
19
23
24#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
25
27
29{
30#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
31
32 auto fetchSurfaceColorManagedByOS = []() {
33 KPluginFactory *factory = KoPluginLoader::instance()->loadSinglePlugin(
34 std::make_pair("X-Krita-PlatformId", QApplication::platformName()),
35 "Krita/PlatformPlugin");
36
37 if (factory) {
38 QScopedPointer<KisSurfaceColorManagementInfo> interface(factory->create<KisSurfaceColorManagementInfo>());
39 return interface && interface->surfaceColorManagedByOS();
40 }
41
42 return false;
43 };
44
45 m_surfaceColorManagedByOS = fetchSurfaceColorManagedByOS();
46
47#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
48}
49
54
55#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
56
57KisSurfaceColorManagerInterface* KisPlatformPluginInterfaceFactory::createSurfaceColorManager(QWindow *nativeWindow)
58{
60 return nullptr;
61 }
62
63 KPluginFactory *factory = KoPluginLoader::instance()->loadSinglePlugin(
64 std::make_pair("X-Krita-PlatformId", QApplication::platformName()),
65 "Krita/PlatformPlugin");
66
67 if (factory) {
68 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(nativeWindow, nullptr);
69
70 QVariantList args = {QVariant::fromValue(nativeWindow)};
71
72 return factory->create<KisSurfaceColorManagerInterface>(nullptr, args);
73 }
74
75 return nullptr;
76}
77
78#endif
79
84
86{
87#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
89 KisRootSurfaceInfoProxy proxy(widget);
91 return proxy.colorManagementReport();
92 } else {
93 return "Surface color management is not supported on this platform\n";
94 }
95#else
96 Q_UNUSED(widget);
97 return "Surface color management is disabled\n";
98#endif
99}
100
102{
103#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
105 KisRootSurfaceInfoProxy proxy(widget);
107 return proxy.osPreferredColorSpaceReport();
108 } else {
109 return "Surface color management is not supported on this platform\n";
110 }
111#else
112 Q_UNUSED(widget);
113 return "Surface color management is disabled\n";
114#endif
115}
116
117
119{
120 KPluginFactory *factory = KoPluginLoader::instance()->loadSinglePlugin(
121 std::make_pair("X-Krita-PlatformId", QApplication::platformName()),
122 "Krita/PlatformPlugin");
123
124 if (factory) {
125 return factory->create<KisExtendedModifiersMapperPluginInterface>();
126 }
127
128 return nullptr;
129}
Q_GLOBAL_STATIC(KisStoragePluginRegistry, s_instance)
static KisPlatformPluginInterfaceFactory * instance()
KisExtendedModifiersMapperPluginInterface * createExtendedModifiersMapper()
static KoPluginLoader * instance()
KPluginFactory * loadSinglePlugin(const std::vector< std::pair< QString, QString > > &predicates, const QString &serviceType)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130