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{
59 KPluginFactory *factory = KoPluginLoader::instance()->loadSinglePlugin(
60 std::make_pair("X-Krita-PlatformId", QApplication::platformName()),
61 "Krita/PlatformPlugin");
62
63 if (factory) {
64 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(nativeWindow, nullptr);
65
66 QVariantList args = {QVariant::fromValue(nativeWindow)};
67
68 return factory->create<KisSurfaceColorManagerInterface>(nullptr, args);
69 }
70
71 return nullptr;
72}
73
74#endif
75
80
82{
83#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
85 KisRootSurfaceInfoProxy proxy(widget);
87 return proxy.colorManagementReport();
88 } else {
89 return "Surface color management is not supported on this platform\n";
90 }
91#else
92 return "Surface color management is disabled\n";
93#endif
94}
95
97{
98#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
100 KisRootSurfaceInfoProxy proxy(widget);
102 return proxy.osPreferredColorSpaceReport();
103 } else {
104 return "Surface color management is not supported on this platform\n";
105 }
106#else
107 return "Surface color management is disabled\n";
108#endif
109}
110
111
113{
114 KPluginFactory *factory = KoPluginLoader::instance()->loadSinglePlugin(
115 std::make_pair("X-Krita-PlatformId", QApplication::platformName()),
116 "Krita/PlatformPlugin");
117
118 if (factory) {
119 return factory->create<KisExtendedModifiersMapperPluginInterface>();
120 }
121
122 return nullptr;
123}
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