Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 66 | { | |||
---|---|---|---|---|---|
73 | } | 73 | } | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | void PreviewItem::createDecoration() | 76 | void PreviewItem::createDecoration() | ||
77 | { | 77 | { | ||
78 | if (m_bridge.isNull() || m_settings.isNull() || m_decoration) { | 78 | if (m_bridge.isNull() || m_settings.isNull() || m_decoration) { | ||
79 | return; | 79 | return; | ||
80 | } | 80 | } | ||
81 | m_decoration = m_bridge->createDecoration(0); | 81 | Decoration *decoration = m_bridge->createDecoration(0); | ||
82 | if (!m_decoration) { | | |||
83 | return; | | |||
84 | } | | |||
85 | m_decoration->setProperty("visualParent", QVariant::fromValue(this)); | | |||
86 | m_client = m_bridge->lastCreatedClient(); | 82 | m_client = m_bridge->lastCreatedClient(); | ||
87 | connect(m_decoration, &Decoration::bordersChanged, this, &PreviewItem::syncSize); | 83 | setDecoration(decoration); | ||
88 | connect(m_decoration, &Decoration::shadowChanged, this, &PreviewItem::syncSize); | | |||
89 | emit decorationChanged(m_decoration); | | |||
90 | } | 84 | } | ||
91 | 85 | | |||
92 | Decoration *PreviewItem::decoration() const | 86 | Decoration *PreviewItem::decoration() const | ||
93 | { | 87 | { | ||
94 | return m_decoration; | 88 | return m_decoration; | ||
95 | } | 89 | } | ||
96 | 90 | | |||
97 | void PreviewItem::setDecoration(Decoration *deco) | 91 | void PreviewItem::setDecoration(Decoration *deco) | ||
98 | { | 92 | { | ||
99 | if (m_decoration == deco) { | 93 | if (!deco || m_decoration == deco) { | ||
100 | return; | 94 | return; | ||
101 | } | 95 | } | ||
102 | auto updateSlot = static_cast<void (QQuickItem::*)()>(&QQuickItem::update); | 96 | | ||
103 | if (m_decoration) { | | |||
104 | disconnect(m_decoration, &Decoration::bordersChanged, this, updateSlot); | | |||
105 | } | | |||
106 | m_decoration = deco; | 97 | m_decoration = deco; | ||
107 | m_decoration->setProperty("visualParent", QVariant::fromValue(this)); | 98 | m_decoration->setProperty("visualParent", QVariant::fromValue(this)); | ||
108 | connect(m_decoration, &Decoration::bordersChanged, this, updateSlot); | 99 | connect(m_decoration, &Decoration::bordersChanged, this, &PreviewItem::syncSize); | ||
109 | connect(m_decoration, &Decoration::sectionUnderMouseChanged, this, | 100 | connect(m_decoration, &Decoration::shadowChanged, this, &PreviewItem::syncSize); | ||
110 | [this](Qt::WindowFrameSection section) { | 101 | connect(m_decoration, &Decoration::shadowChanged, this, &PreviewItem::shadowChanged); | ||
111 | switch (section) { | | |||
112 | case Qt::TopRightSection: | | |||
113 | case Qt::BottomLeftSection: | | |||
114 | setCursor(Qt::SizeBDiagCursor); | | |||
115 | return; | | |||
116 | case Qt::TopLeftSection: | | |||
117 | case Qt::BottomRightSection: | | |||
118 | setCursor(Qt::SizeFDiagCursor); | | |||
119 | return; | | |||
120 | case Qt::TopSection: | | |||
121 | case Qt::BottomSection: | | |||
122 | setCursor(Qt::SizeVerCursor); | | |||
123 | return; | | |||
124 | case Qt::LeftSection: | | |||
125 | case Qt::RightSection: | | |||
126 | setCursor(Qt::SizeHorCursor); | | |||
127 | return; | | |||
128 | default: | | |||
129 | setCursor(Qt::ArrowCursor); | | |||
130 | } | | |||
131 | } | | |||
132 | ); | | |||
133 | connect(m_decoration, &KDecoration2::Decoration::shadowChanged, this, &PreviewItem::shadowChanged); | | |||
134 | emit decorationChanged(m_decoration); | 102 | emit decorationChanged(m_decoration); | ||
135 | } | 103 | } | ||
136 | 104 | | |||
137 | QColor PreviewItem::windowColor() const | 105 | QColor PreviewItem::windowColor() const | ||
138 | { | 106 | { | ||
139 | return m_windowColor; | 107 | return m_windowColor; | ||
140 | } | 108 | } | ||
141 | 109 | | |||
▲ Show 20 Lines • Show All 359 Lines • Show Last 20 Lines |