Changeset View
Changeset View
Standalone View
Standalone View
components/containmentlayoutmanager/appletslayout.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 80 | connect(m_sizeSyncTimer, &QTimer::timeout, this, [this]() { | |||
---|---|---|---|---|---|
87 | } else if (!m_geometryBeforeResolutionChange.isEmpty()) { | 87 | } else if (!m_geometryBeforeResolutionChange.isEmpty()) { | ||
88 | m_layoutManager->layoutGeometryChanged(newGeom, m_geometryBeforeResolutionChange); | 88 | m_layoutManager->layoutGeometryChanged(newGeom, m_geometryBeforeResolutionChange); | ||
89 | m_geometryBeforeResolutionChange = QRectF(); | 89 | m_geometryBeforeResolutionChange = QRectF(); | ||
90 | 90 | | |||
91 | // Heuristically relayout items only when the plasma startup is fully completed | 91 | // Heuristically relayout items only when the plasma startup is fully completed | ||
92 | } else { | 92 | } else { | ||
93 | polish(); | 93 | polish(); | ||
94 | } | 94 | } | ||
95 | }); | 95 | }); | ||
96 | | ||||
97 | m_window = window(); | | |||
98 | if (m_window) { | | |||
99 | connect(m_window, &QWindow::activeChanged, this, [this]() { | | |||
100 | if (!m_window->isActive()) { | | |||
101 | setEditMode(false); | | |||
102 | } | | |||
103 | }); | | |||
104 | } | | |||
105 | connect(this, &QQuickItem::windowChanged, this, [this]() { | | |||
106 | if (m_window) { | | |||
107 | disconnect(m_window, &QWindow::activeChanged, this, nullptr); | | |||
108 | } | | |||
109 | m_window = window(); | | |||
110 | if (m_window) { | | |||
111 | connect(m_window, &QWindow::activeChanged, this, [this]() { | | |||
112 | if (!m_window->isActive()) { | | |||
113 | setEditMode(false); | | |||
114 | } | | |||
115 | }); | | |||
116 | } | | |||
117 | }); | | |||
118 | } | 96 | } | ||
davidedmundson: But we only evaluate this when this window changes - doesn't that mean we could when any other… | |||||
right.. it wouldn't notice if the edit mode was initiated when its window not in focus, i-.e. dbus from systemsettings case. mart: right.. it wouldn't notice if the edit mode was initiated when its window not in focus, i-.e. | |||||
mart: different approach in current version | |||||
119 | 97 | | |||
120 | AppletsLayout::~AppletsLayout() | 98 | AppletsLayout::~AppletsLayout() | ||
121 | { | 99 | { | ||
122 | } | 100 | } | ||
123 | 101 | | |||
124 | PlasmaQuick::AppletQuickItem *AppletsLayout::containment() const | 102 | PlasmaQuick::AppletQuickItem *AppletsLayout::containment() const | ||
125 | { | 103 | { | ||
126 | return m_containmentItem; | 104 | return m_containmentItem; | ||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Line(s) | 335 | { | |||
362 | m_placeHolder = placeHolder; | 340 | m_placeHolder = placeHolder; | ||
363 | m_placeHolder->setParentItem(this); | 341 | m_placeHolder->setParentItem(this); | ||
364 | m_placeHolder->setZ(9999); | 342 | m_placeHolder->setZ(9999); | ||
365 | m_placeHolder->setOpacity(false); | 343 | m_placeHolder->setOpacity(false); | ||
366 | 344 | | |||
367 | emit placeHolderChanged(); | 345 | emit placeHolderChanged(); | ||
368 | } | 346 | } | ||
369 | 347 | | |||
348 | QQuickItem *AppletsLayout::eventManagerToFilter() const | ||||
349 | { | ||||
350 | return m_eventManagerToFilter; | ||||
351 | } | ||||
352 | | ||||
353 | void AppletsLayout::setEventManagerToFilter(QQuickItem *item) | ||||
354 | { | ||||
355 | if (m_eventManagerToFilter == item) { | ||||
356 | return; | ||||
357 | } | ||||
358 | | ||||
359 | m_eventManagerToFilter = item; | ||||
360 | setFiltersChildMouseEvents(m_eventManagerToFilter); | ||||
361 | emit eventManagerToFilterChanged(); | ||||
362 | } | ||||
363 | | ||||
364 | | ||||
370 | void AppletsLayout::save() | 365 | void AppletsLayout::save() | ||
371 | { | 366 | { | ||
372 | m_saveLayoutTimer->start(); | 367 | m_saveLayoutTimer->start(); | ||
373 | } | 368 | } | ||
374 | 369 | | |||
375 | void AppletsLayout::showPlaceHolderAt(const QRectF &geom) | 370 | void AppletsLayout::showPlaceHolderAt(const QRectF &geom) | ||
376 | { | 371 | { | ||
377 | if (!m_placeHolder) { | 372 | if (!m_placeHolder) { | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 515 | connect(m_containment->corona(), &Plasma::Corona::screenGeometryChanged, this, [this](int id){ | |||
523 | } | 518 | } | ||
524 | }); | 519 | }); | ||
525 | } | 520 | } | ||
526 | QQuickItem::componentComplete(); | 521 | QQuickItem::componentComplete(); | ||
527 | } | 522 | } | ||
528 | 523 | | |||
529 | 524 | | |||
530 | 525 | | |||
526 | | ||||
527 | bool AppletsLayout::childMouseEventFilter(QQuickItem *item, QEvent *event) | ||||
528 | { | ||||
529 | if (item != m_eventManagerToFilter) { | ||||
530 | return QQuickItem::childMouseEventFilter(item, event); | ||||
531 | } | ||||
532 | | ||||
533 | switch (event->type()) { | ||||
534 | case QEvent::MouseButtonPress: { | ||||
davidedmundson: the first clause seems redundant | |||||
535 | QMouseEvent *me = static_cast<QMouseEvent *>(event); | ||||
536 | mousePressEvent(me); | ||||
537 | break; | ||||
538 | } | ||||
539 | case QEvent::MouseMove: { | ||||
540 | QMouseEvent *me = static_cast<QMouseEvent *>(event); | ||||
541 | mouseMoveEvent(me); | ||||
542 | break; | ||||
543 | } | ||||
544 | case QEvent::MouseButtonRelease: { | ||||
545 | QMouseEvent *me = static_cast<QMouseEvent *>(event); | ||||
546 | mouseReleaseEvent(me); | ||||
547 | break; | ||||
548 | } | ||||
549 | default: | ||||
550 | break; | ||||
551 | } | ||||
552 | | ||||
553 | return QQuickItem::childMouseEventFilter(item, event); | ||||
554 | } | ||||
555 | | ||||
531 | void AppletsLayout::mousePressEvent(QMouseEvent *event) | 556 | void AppletsLayout::mousePressEvent(QMouseEvent *event) | ||
532 | { | 557 | { | ||
533 | forceActiveFocus(Qt::MouseFocusReason); | 558 | forceActiveFocus(Qt::MouseFocusReason); | ||
534 | 559 | | |||
535 | if (!m_editMode && m_editModeCondition == AppletsLayout::Manual) { | 560 | if (!m_editMode && m_editModeCondition == AppletsLayout::Manual) { | ||
536 | return; | 561 | return; | ||
537 | } | 562 | } | ||
538 | 563 | | |||
Show All 18 Lines | 580 | if (!m_editMode | |||
557 | m_pressAndHoldTimer->stop(); | 582 | m_pressAndHoldTimer->stop(); | ||
558 | } | 583 | } | ||
559 | } | 584 | } | ||
560 | 585 | | |||
561 | void AppletsLayout::mouseReleaseEvent(QMouseEvent *event) | 586 | void AppletsLayout::mouseReleaseEvent(QMouseEvent *event) | ||
562 | { | 587 | { | ||
563 | if (m_editMode | 588 | if (m_editMode | ||
564 | && m_mouseDownWasEditMode | 589 | && m_mouseDownWasEditMode | ||
565 | && QPointF(event->windowPos() - m_mouseDownPosition).manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) { | 590 | && QPointF(event->windowPos() - m_mouseDownPosition).manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) { | ||
Please comment what this is doing.
davidedmundson: Please comment what this is doing.
> want with normal mouse the edit mode not being dismissed… | |||||
566 | setEditMode(false); | 591 | setEditMode(false); | ||
567 | } | 592 | } | ||
568 | 593 | | |||
569 | m_pressAndHoldTimer->stop(); | 594 | m_pressAndHoldTimer->stop(); | ||
570 | 595 | | |||
571 | if (!m_editMode) { | 596 | if (!m_editMode) { | ||
572 | for (auto *child : childItems()) { | 597 | for (auto *child : childItems()) { | ||
573 | ItemContainer *item = qobject_cast<ItemContainer *>(child); | 598 | ItemContainer *item = qobject_cast<ItemContainer *>(child); | ||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |
But we only evaluate this when this window changes - doesn't that mean we could when any other plasma window had focus and then loses it?