Changeset View
Changeset View
Standalone View
Standalone View
thumbnailitem.cpp
Show All 30 Lines | |||||
31 | #include <QPainter> | 31 | #include <QPainter> | ||
32 | #include <QQuickWindow> | 32 | #include <QQuickWindow> | ||
33 | 33 | | |||
34 | namespace KWin | 34 | namespace KWin | ||
35 | { | 35 | { | ||
36 | 36 | | |||
37 | AbstractThumbnailItem::AbstractThumbnailItem(QQuickItem *parent) | 37 | AbstractThumbnailItem::AbstractThumbnailItem(QQuickItem *parent) | ||
38 | : QQuickPaintedItem(parent) | 38 | : QQuickPaintedItem(parent) | ||
39 | , m_parent(QWeakPointer<EffectWindowImpl>()) | | |||
40 | , m_brightness(1.0) | 39 | , m_brightness(1.0) | ||
41 | , m_saturation(1.0) | 40 | , m_saturation(1.0) | ||
42 | , m_clipToItem() | 41 | , m_clipToItem() | ||
43 | { | 42 | { | ||
44 | connect(Compositor::self(), SIGNAL(compositingToggled(bool)), SLOT(compositingToggled())); | 43 | connect(Compositor::self(), SIGNAL(compositingToggled(bool)), SLOT(compositingToggled())); | ||
45 | compositingToggled(); | 44 | compositingToggled(); | ||
46 | QTimer::singleShot(0, this, SLOT(init())); | 45 | QTimer::singleShot(0, this, SLOT(init())); | ||
47 | } | 46 | } | ||
Show All 10 Lines | 55 | if (effects) { | |||
58 | connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), SLOT(repaint(KWin::EffectWindow*))); | 57 | connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), SLOT(repaint(KWin::EffectWindow*))); | ||
59 | effectWindowAdded(); | 58 | effectWindowAdded(); | ||
60 | } | 59 | } | ||
61 | } | 60 | } | ||
62 | 61 | | |||
63 | void AbstractThumbnailItem::init() | 62 | void AbstractThumbnailItem::init() | ||
64 | { | 63 | { | ||
65 | findParentEffectWindow(); | 64 | findParentEffectWindow(); | ||
66 | if (!m_parent.isNull()) { | 65 | if (m_parent) { | ||
67 | m_parent.data()->registerThumbnail(this); | 66 | m_parent->registerThumbnail(this); | ||
68 | } | 67 | } | ||
69 | } | 68 | } | ||
70 | 69 | | |||
71 | void AbstractThumbnailItem::findParentEffectWindow() | 70 | void AbstractThumbnailItem::findParentEffectWindow() | ||
72 | { | 71 | { | ||
73 | if (effects) { | 72 | if (effects) { | ||
74 | QQuickWindow *qw = window(); | 73 | QQuickWindow *qw = window(); | ||
75 | if (!qw) { | 74 | if (!qw) { | ||
76 | qCDebug(KWIN_CORE) << "No QQuickWindow assigned yet"; | 75 | qCDebug(KWIN_CORE) << "No QQuickWindow assigned yet"; | ||
77 | return; | 76 | return; | ||
78 | } | 77 | } | ||
79 | if (auto *w = static_cast<EffectWindowImpl*>(effects->findWindow(qw))) { | 78 | if (auto *w = static_cast<EffectWindowImpl*>(effects->findWindow(qw))) { | ||
80 | m_parent = QWeakPointer<EffectWindowImpl>(w); | 79 | m_parent = QPointer<EffectWindowImpl>(w); | ||
81 | } | 80 | } | ||
82 | } | 81 | } | ||
83 | } | 82 | } | ||
84 | 83 | | |||
85 | void AbstractThumbnailItem::effectWindowAdded() | 84 | void AbstractThumbnailItem::effectWindowAdded() | ||
86 | { | 85 | { | ||
87 | // the window might be added before the EffectWindow is created | 86 | // the window might be added before the EffectWindow is created | ||
88 | // by using this slot we can register the thumbnail when it is finally created | 87 | // by using this slot we can register the thumbnail when it is finally created | ||
89 | if (m_parent.isNull()) { | 88 | if (m_parent.isNull()) { | ||
90 | findParentEffectWindow(); | 89 | findParentEffectWindow(); | ||
91 | if (!m_parent.isNull()) { | 90 | if (m_parent) { | ||
92 | m_parent.data()->registerThumbnail(this); | 91 | m_parent->registerThumbnail(this); | ||
93 | } | 92 | } | ||
94 | } | 93 | } | ||
95 | } | 94 | } | ||
96 | 95 | | |||
97 | void AbstractThumbnailItem::setBrightness(qreal brightness) | 96 | void AbstractThumbnailItem::setBrightness(qreal brightness) | ||
98 | { | 97 | { | ||
99 | if (qFuzzyCompare(brightness, m_brightness)) { | 98 | if (qFuzzyCompare(brightness, m_brightness)) { | ||
100 | return; | 99 | return; | ||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |