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 return "Surface color management is disabled\n";
97#endif
98}
99
101{
102#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
104 KisRootSurfaceInfoProxy proxy(widget);
106 return proxy.osPreferredColorSpaceReport();
107 } else {
108 return "Surface color management is not supported on this platform\n";
109 }
110#else
111 return "Surface color management is disabled\n";
112#endif
113}
114
115
117{
118 KPluginFactory *factory = KoPluginLoader::instance()->loadSinglePlugin(
119 std::make_pair("X-Krita-PlatformId", QApplication::platformName()),
120 "Krita/PlatformPlugin");
121
122 if (factory) {
123 return factory->create<KisExtendedModifiersMapperPluginInterface>();
124 }
125
126 return nullptr;
127}
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