Changeset View
Changeset View
Standalone View
Standalone View
components/containmentlayoutmanager/itemcontainer.cpp
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 98 | { | |||
---|---|---|---|---|---|
101 | } | 101 | } | ||
102 | 102 | | |||
103 | if (editMode && editModeCondition() == Locked) { | 103 | if (editMode && editModeCondition() == Locked) { | ||
104 | return; | 104 | return; | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | m_editMode = editMode; | 107 | m_editMode = editMode; | ||
108 | 108 | | |||
109 | // Leave this decision to QML? | 109 | if (m_editModeCondition != AfterMouseOver || (m_layout && m_layout->editMode())) { | ||
110 | if (m_editModeCondition != AfterMouseOver || m_layout->editMode()) { | | |||
111 | m_contentItem->setEnabled(!editMode); | 110 | m_contentItem->setEnabled(!editMode); | ||
112 | } | 111 | } | ||
113 | 112 | | |||
114 | if (editMode) { | 113 | if (editMode) { | ||
115 | setZ(1); | 114 | setZ(1); | ||
116 | } else { | 115 | } else { | ||
117 | setZ(0); | 116 | setZ(0); | ||
118 | } | 117 | } | ||
Show All 29 Lines | 144 | { | |||
148 | } | 147 | } | ||
149 | 148 | | |||
150 | if (condition == Locked) { | 149 | if (condition == Locked) { | ||
151 | setEditMode(false); | 150 | setEditMode(false); | ||
152 | } | 151 | } | ||
153 | 152 | | |||
154 | m_editModeCondition = condition; | 153 | m_editModeCondition = condition; | ||
155 | 154 | | |||
156 | setAcceptHoverEvents(condition == AfterMouseOver); | 155 | setAcceptHoverEvents(condition == AfterMouseOver || (m_layout && m_layout->editMode())); | ||
157 | 156 | | |||
158 | emit editModeConditionChanged(); | 157 | emit editModeConditionChanged(); | ||
159 | } | 158 | } | ||
160 | 159 | | |||
161 | AppletsLayout::PreferredLayoutDirection ItemContainer::preferredLayoutDirection() const | 160 | AppletsLayout::PreferredLayoutDirection ItemContainer::preferredLayoutDirection() const | ||
162 | { | 161 | { | ||
163 | return m_preferredLayoutDirection; | 162 | return m_preferredLayoutDirection; | ||
164 | } | 163 | } | ||
Show All 12 Lines | |||||
177 | void ItemContainer::setLayout(AppletsLayout *layout) | 176 | void ItemContainer::setLayout(AppletsLayout *layout) | ||
178 | { | 177 | { | ||
179 | if (m_layout == layout) { | 178 | if (m_layout == layout) { | ||
180 | return; | 179 | return; | ||
181 | } | 180 | } | ||
182 | 181 | | |||
183 | if (m_layout) { | 182 | if (m_layout) { | ||
184 | disconnect(m_layout, &AppletsLayout::editModeConditionChanged, this, nullptr); | 183 | disconnect(m_layout, &AppletsLayout::editModeConditionChanged, this, nullptr); | ||
184 | disconnect(m_layout, &AppletsLayout::editModeChanged, this, nullptr); | ||||
185 | 185 | | |||
186 | if (m_editMode) { | 186 | if (m_editMode) { | ||
187 | m_layout->hidePlaceHolder(); | 187 | m_layout->hidePlaceHolder(); | ||
188 | } | 188 | } | ||
189 | } | 189 | } | ||
190 | 190 | | |||
191 | m_layout = layout; | 191 | m_layout = layout; | ||
192 | 192 | | |||
Show All 10 Lines | 202 | connect(m_layout, &AppletsLayout::editModeConditionChanged, this, [this]() { | |||
203 | if (m_layout->editModeCondition() == AppletsLayout::Locked) { | 203 | if (m_layout->editModeCondition() == AppletsLayout::Locked) { | ||
204 | setEditMode(false); | 204 | setEditMode(false); | ||
205 | } | 205 | } | ||
206 | if ((m_layout->editModeCondition() == AppletsLayout::Locked) != | 206 | if ((m_layout->editModeCondition() == AppletsLayout::Locked) != | ||
207 | (m_editModeCondition == ItemContainer::Locked)) { | 207 | (m_editModeCondition == ItemContainer::Locked)) { | ||
208 | emit editModeConditionChanged(); | 208 | emit editModeConditionChanged(); | ||
209 | } | 209 | } | ||
210 | }); | 210 | }); | ||
211 | connect(m_layout, &AppletsLayout::editModeChanged, this, [this]() { | ||||
212 | setAcceptHoverEvents(m_editModeCondition == AfterMouseOver || m_layout->editMode()); | ||||
213 | }); | ||||
211 | emit layoutChanged(); | 214 | emit layoutChanged(); | ||
212 | } | 215 | } | ||
213 | 216 | | |||
214 | AppletsLayout *ItemContainer::layout() const | 217 | AppletsLayout *ItemContainer::layout() const | ||
215 | { | 218 | { | ||
216 | return m_layout; | 219 | return m_layout; | ||
217 | } | 220 | } | ||
218 | 221 | | |||
▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Line(s) | 622 | if (m_editMode) { | |||
620 | emit dragActiveChanged(); | 623 | emit dragActiveChanged(); | ||
621 | } | 624 | } | ||
622 | } | 625 | } | ||
623 | 626 | | |||
624 | void ItemContainer::hoverEnterEvent(QHoverEvent *event) | 627 | void ItemContainer::hoverEnterEvent(QHoverEvent *event) | ||
625 | { | 628 | { | ||
626 | Q_UNUSED(event); | 629 | Q_UNUSED(event); | ||
627 | 630 | | |||
628 | if (m_editModeCondition != AfterMouseOver) { | 631 | if (m_editModeCondition != AfterMouseOver && !m_layout->editMode()) { | ||
629 | return; | 632 | return; | ||
630 | } | 633 | } | ||
631 | 634 | | |||
632 | if (m_closeEditModeTimer) { | 635 | if (m_closeEditModeTimer) { | ||
633 | m_closeEditModeTimer->stop(); | 636 | m_closeEditModeTimer->stop(); | ||
634 | } | 637 | } | ||
635 | 638 | | |||
639 | if (m_layout->editMode()) { | ||||
640 | setEditMode(true); | ||||
641 | } else { | ||||
636 | m_editModeTimer->start(QGuiApplication::styleHints()->mousePressAndHoldInterval()); | 642 | m_editModeTimer->start(QGuiApplication::styleHints()->mousePressAndHoldInterval()); | ||
637 | } | 643 | } | ||
644 | } | ||||
638 | 645 | | |||
639 | void ItemContainer::hoverLeaveEvent(QHoverEvent *event) | 646 | void ItemContainer::hoverLeaveEvent(QHoverEvent *event) | ||
640 | { | 647 | { | ||
641 | Q_UNUSED(event); | 648 | Q_UNUSED(event); | ||
642 | 649 | | |||
643 | if (m_editModeCondition != AfterMouseOver) { | 650 | if (m_editModeCondition != AfterMouseOver && !m_layout->editMode()) { | ||
644 | return; | 651 | return; | ||
645 | } | 652 | } | ||
646 | 653 | | |||
647 | m_editModeTimer->stop(); | 654 | m_editModeTimer->stop(); | ||
648 | if (!m_closeEditModeTimer) { | 655 | if (!m_closeEditModeTimer) { | ||
649 | m_closeEditModeTimer = new QTimer(this); | 656 | m_closeEditModeTimer = new QTimer(this); | ||
650 | m_closeEditModeTimer->setSingleShot(true); | 657 | m_closeEditModeTimer->setSingleShot(true); | ||
651 | m_closeEditModeTimer->setInterval(500); | 658 | m_closeEditModeTimer->setInterval(500); | ||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |