Krita Source Code Documentation
Loading...
Searching...
No Matches
KisRootSurfaceInfoProxy Class Reference

#include <KisRootSurfaceInfoProxy.h>

+ Inheritance diagram for KisRootSurfaceInfoProxy:

Signals

void sigRootSurfaceProfileChanged (const KoColorProfile *profile) const
 

Public Member Functions

QString colorManagementReport () const
 
bool isReady () const
 
 KisRootSurfaceInfoProxy (QWidget *watched, QObject *parent=nullptr)
 
QString osPreferredColorSpaceReport () const
 
const KoColorProfilerootSurfaceProfile () const
 
 ~KisRootSurfaceInfoProxy ()
 

Private Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
 
QVector< QPointer< QObject > > getCurrentHierarchy (QWidget *wdg)
 
void reconnectToHierarchy (const QVector< QPointer< QObject > > newHierarchy)
 
void tryReconnectSurfaceManager ()
 
void tryUpdateHierarchy ()
 
void tryUpdateRootSurfaceProfile ()
 

Private Attributes

QPointer< QObject > m_childChangedFilter
 
const KoColorProfilem_rootSurfaceProfile {nullptr}
 
QMetaObject::Connection m_surfaceManagerConnection
 
QPointer< QWindow > m_topLevelNativeWindow
 
QPointer< KisSRGBSurfaceColorSpaceManagerm_topLevelSurfaceManager
 
QPointer< QWidget > m_topLevelWidgetWithSurface
 
QWidget * m_watched {nullptr}
 
QVector< QPointer< QObject > > m_watchedHierarchy
 

Detailed Description

KisRootSurfaceInfoProxy is a special proxy object for the surface color management information of the widget.

When created, the proxy does the following:

1) Finds the top-level widget that watched belongs to. (is watched changed its parent in the meantime, e.g. during construction, then the proxy will handle that as well)

2) Finds the QWindow that this toplevel widget is painted on (if platform window is not created yet, subscribes to QPlatformSurfaceEvent to attach when platform window is finally created)

3) Finds KisSRGBSurfaceColorSpaceManager object attached to this window. This object is usually attached with an event filter in KisApplication to all windows not having a special property (if the manager is not yet attached, tracks its addition by filtering QChildEvent)

4) Finally, connects to the manager and forwards its sigDisplayConfigChanged() to local sigRootSurfaceProfileChanged()

Definition at line 45 of file KisRootSurfaceInfoProxy.h.

Constructor & Destructor Documentation

◆ KisRootSurfaceInfoProxy()

KisRootSurfaceInfoProxy::KisRootSurfaceInfoProxy ( QWidget * watched,
QObject * parent = nullptr )

◆ ~KisRootSurfaceInfoProxy()

KisRootSurfaceInfoProxy::~KisRootSurfaceInfoProxy ( )

Definition at line 59 of file KisRootSurfaceInfoProxy.cpp.

60{
61}

Member Function Documentation

◆ colorManagementReport()

QString KisRootSurfaceInfoProxy::colorManagementReport ( ) const

Definition at line 73 of file KisRootSurfaceInfoProxy.cpp.

74{
75 return m_topLevelSurfaceManager ? m_topLevelSurfaceManager->colorManagementReport()
76 : QString("Top level surface color manager is not found!\n");
77}
QPointer< KisSRGBSurfaceColorSpaceManager > m_topLevelSurfaceManager

References m_topLevelSurfaceManager.

◆ eventFilter()

bool KisRootSurfaceInfoProxy::eventFilter ( QObject * watched,
QEvent * event )
overrideprivate

Definition at line 85 of file KisRootSurfaceInfoProxy.cpp.

86{
87 if (event->type() == QEvent::ParentChange && m_watchedHierarchy.contains(watched)) {
89 }
90
91 if (event->type() == QEvent::PlatformSurface && watched == m_watchedHierarchy.last().data()) {
93 }
94
95 return false;
96}
QVector< QPointer< QObject > > m_watchedHierarchy

References m_watchedHierarchy, tryReconnectSurfaceManager(), and tryUpdateHierarchy().

◆ getCurrentHierarchy()

QVector< QPointer< QObject > > KisRootSurfaceInfoProxy::getCurrentHierarchy ( QWidget * wdg)
private

Definition at line 182 of file KisRootSurfaceInfoProxy.cpp.

183{
185
186 while (wdg) {
187 result.append(wdg);
188 wdg = wdg->parentWidget();
189 }
190
191 return result;
192}

◆ isReady()

bool KisRootSurfaceInfoProxy::isReady ( ) const

Definition at line 68 of file KisRootSurfaceInfoProxy.cpp.

69{
71}

References m_topLevelSurfaceManager.

◆ osPreferredColorSpaceReport()

QString KisRootSurfaceInfoProxy::osPreferredColorSpaceReport ( ) const

Definition at line 79 of file KisRootSurfaceInfoProxy.cpp.

80{
81 return m_topLevelSurfaceManager ? m_topLevelSurfaceManager->osPreferredColorSpaceReport()
82 : QString("Top level surface color manager is not found!\n");
83}

References m_topLevelSurfaceManager.

◆ reconnectToHierarchy()

void KisRootSurfaceInfoProxy::reconnectToHierarchy ( const QVector< QPointer< QObject > > newHierarchy)
private

Definition at line 194 of file KisRootSurfaceInfoProxy.cpp.

195{
196 Q_FOREACH (QPointer<QObject> widget, m_watchedHierarchy) {
197 KIS_SAFE_ASSERT_RECOVER(widget) continue;
198 widget->removeEventFilter(this);
199 }
200
201 m_watchedHierarchy.clear();
202
203 Q_FOREACH (QPointer<QObject> widget, newHierarchy) {
204 widget->installEventFilter(this);
205 }
206
207 m_watchedHierarchy = newHierarchy;
208}
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References KIS_SAFE_ASSERT_RECOVER, and m_watchedHierarchy.

◆ rootSurfaceProfile()

const KoColorProfile * KisRootSurfaceInfoProxy::rootSurfaceProfile ( ) const

Definition at line 63 of file KisRootSurfaceInfoProxy.cpp.

64{
66}

References m_rootSurfaceProfile.

◆ sigRootSurfaceProfileChanged

void KisRootSurfaceInfoProxy::sigRootSurfaceProfileChanged ( const KoColorProfile * profile) const
signal

◆ tryReconnectSurfaceManager()

void KisRootSurfaceInfoProxy::tryReconnectSurfaceManager ( )
private

Definition at line 111 of file KisRootSurfaceInfoProxy.cpp.

112{
113 auto disconnectExistingManager = [this]() {
116 disconnect(m_surfaceManagerConnection);
117 }
118 };
119
121 disconnectExistingManager();
123 return;
124 }
125
126 QWindow *nativeWindow = m_topLevelWidgetWithSurface->windowHandle();
127
128 if (nativeWindow != m_topLevelNativeWindow) {
131 m_childChangedFilter->deleteLater();
132 m_childChangedFilter.clear();
133 }
134
135 m_topLevelNativeWindow = nativeWindow;
136
138 auto *filter = new ChildChangedEventFilter(m_topLevelNativeWindow, m_topLevelNativeWindow);
139 connect(filter,
140 &ChildChangedEventFilter::sigChildrenChanged,
141 this,
143 m_childChangedFilter = filter;
144 m_topLevelNativeWindow->installEventFilter(m_childChangedFilter);
145 }
146 }
147
148 if (nativeWindow) {
149 if (auto manager = nativeWindow->findChild<KisSRGBSurfaceColorSpaceManager *>()) {
150 if (manager != m_topLevelSurfaceManager) {
151 disconnectExistingManager();
152 m_topLevelSurfaceManager = manager;
155 this,
158 }
159 }
160 } else {
161 disconnectExistingManager();
163 }
164}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QMetaObject::Connection m_surfaceManagerConnection
QPointer< QObject > m_childChangedFilter
QPointer< QWidget > m_topLevelWidgetWithSurface
QPointer< QWindow > m_topLevelNativeWindow
void sigDisplayConfigChanged(const KisDisplayConfig &config)

References connect(), m_childChangedFilter, m_surfaceManagerConnection, m_topLevelNativeWindow, m_topLevelSurfaceManager, m_topLevelWidgetWithSurface, KisCanvasSurfaceColorSpaceManager::sigDisplayConfigChanged(), tryReconnectSurfaceManager(), and tryUpdateRootSurfaceProfile().

◆ tryUpdateHierarchy()

void KisRootSurfaceInfoProxy::tryUpdateHierarchy ( )
private

Definition at line 98 of file KisRootSurfaceInfoProxy.cpp.

99{
100 auto newHierarchy = getCurrentHierarchy(m_watched);
101 if (newHierarchy != m_watchedHierarchy) {
102 reconnectToHierarchy(newHierarchy);
103 QWidget *topLevel = static_cast<QWidget *>(newHierarchy.last().data());
104 if (topLevel != m_topLevelWidgetWithSurface) {
107 }
108 }
109}
void reconnectToHierarchy(const QVector< QPointer< QObject > > newHierarchy)
QVector< QPointer< QObject > > getCurrentHierarchy(QWidget *wdg)

References getCurrentHierarchy(), m_topLevelWidgetWithSurface, m_watched, m_watchedHierarchy, reconnectToHierarchy(), and tryReconnectSurfaceManager().

◆ tryUpdateRootSurfaceProfile()

void KisRootSurfaceInfoProxy::tryUpdateRootSurfaceProfile ( )
private

Member Data Documentation

◆ m_childChangedFilter

QPointer<QObject> KisRootSurfaceInfoProxy::m_childChangedFilter
private

Definition at line 79 of file KisRootSurfaceInfoProxy.h.

◆ m_rootSurfaceProfile

const KoColorProfile* KisRootSurfaceInfoProxy::m_rootSurfaceProfile {nullptr}
private

Definition at line 84 of file KisRootSurfaceInfoProxy.h.

84{nullptr};

◆ m_surfaceManagerConnection

QMetaObject::Connection KisRootSurfaceInfoProxy::m_surfaceManagerConnection
private

Definition at line 82 of file KisRootSurfaceInfoProxy.h.

◆ m_topLevelNativeWindow

QPointer<QWindow> KisRootSurfaceInfoProxy::m_topLevelNativeWindow
private

Definition at line 78 of file KisRootSurfaceInfoProxy.h.

◆ m_topLevelSurfaceManager

QPointer<KisSRGBSurfaceColorSpaceManager> KisRootSurfaceInfoProxy::m_topLevelSurfaceManager
private

Definition at line 81 of file KisRootSurfaceInfoProxy.h.

◆ m_topLevelWidgetWithSurface

QPointer<QWidget> KisRootSurfaceInfoProxy::m_topLevelWidgetWithSurface
private

Definition at line 76 of file KisRootSurfaceInfoProxy.h.

◆ m_watched

QWidget* KisRootSurfaceInfoProxy::m_watched {nullptr}
private

Definition at line 73 of file KisRootSurfaceInfoProxy.h.

73{nullptr};

◆ m_watchedHierarchy

QVector<QPointer<QObject> > KisRootSurfaceInfoProxy::m_watchedHierarchy
private

Definition at line 74 of file KisRootSurfaceInfoProxy.h.


The documentation for this class was generated from the following files: