Krita Source Code Documentation
Loading...
Searching...
No Matches
KisScreenMigrationTracker.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QGuiApplication>
10#include <QWidget>
11#include <QWindow>
12#include <QScreen>
13#include <kis_assert.h>
15
16#include <kis_debug.h>
17
18
19KisScreenMigrationTracker::KisScreenMigrationTracker(QWidget *trackedWidget, QObject *parent)
20 : KisRootSurfaceTrackerBase(trackedWidget, parent)
21 , m_resolutionChangeCompressor(new KisSignalCompressor(100, KisSignalCompressor::POSTPONE, this))
22{
24 // WARNING: we potentially call virtual functions here!
25 initialize();
26
29}
30
36
38{
39 return m_connectedTopLevelWindow ? m_connectedTopLevelWindow->screen() : qApp->screens().first();
40}
41
50
52{
54
55 if (window != m_connectedTopLevelWindow) {
57 connect(window, &QWindow::screenChanged, this, &KisScreenMigrationTracker::slotScreenChanged);
58 connectScreenSignals(window->screen());
60
61 Q_EMIT sigScreenChanged(window->screen());
62 Q_EMIT sigScreenOrResolutionChanged(window->screen());
63 }
64}
71
73{
75
76 Q_EMIT sigScreenChanged(screen);
77 Q_EMIT sigScreenOrResolutionChanged(screen);
78}
79
85
91
93{
95 // the tracker is not yet initialized, it should happen only
96 // when the widget have not yet been shown at least once
98 return;
99 }
101}
float value(const T *src, size_t ch)
KisScreenMigrationTracker(QWidget *trackedWidget, QObject *parent=nullptr)
KisSignalAutoConnectionsStore m_screenConnections
void connectScreenSignals(QScreen *screen)
void connectToNativeWindow(QWindow *window) override
QMetaObject::Connection m_topLevelWindowConnection
void slotScreenLogicalResolutionChanged(qreal value)
KisSignalCompressor * m_resolutionChangeCompressor
QPointer< QWindow > m_connectedTopLevelWindow
void sigScreenChanged(QScreen *screen)
void sigScreenOrResolutionChanged(QScreen *screen)
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130