diff --git a/components/containmentlayoutmanager/appletslayout.h b/components/containmentlayoutmanager/appletslayout.h --- a/components/containmentlayoutmanager/appletslayout.h +++ b/components/containmentlayoutmanager/appletslayout.h @@ -200,7 +200,6 @@ QHash m_containerForApplet; - QPointer m_window; QSizeF m_minimumItemSize; QSizeF m_defaultItemSize; QSizeF m_savedSize; diff --git a/components/containmentlayoutmanager/appletslayout.cpp b/components/containmentlayoutmanager/appletslayout.cpp --- a/components/containmentlayoutmanager/appletslayout.cpp +++ b/components/containmentlayoutmanager/appletslayout.cpp @@ -93,28 +93,6 @@ polish(); } }); - - m_window = window(); - if (m_window) { - connect(m_window, &QWindow::activeChanged, this, [this]() { - if (!m_window->isActive()) { - setEditMode(false); - } - }); - } - connect(this, &QQuickItem::windowChanged, this, [this]() { - if (m_window) { - disconnect(m_window, &QWindow::activeChanged, this, nullptr); - } - m_window = window(); - if (m_window) { - connect(m_window, &QWindow::activeChanged, this, [this]() { - if (!m_window->isActive()) { - setEditMode(false); - } - }); - } - }); } AppletsLayout::~AppletsLayout() diff --git a/components/containmentlayoutmanager/itemcontainer.cpp b/components/containmentlayoutmanager/itemcontainer.cpp --- a/components/containmentlayoutmanager/itemcontainer.cpp +++ b/components/containmentlayoutmanager/itemcontainer.cpp @@ -106,8 +106,7 @@ m_editMode = editMode; - // Leave this decision to QML? - if (m_editModeCondition != AfterMouseOver || m_layout->editMode()) { + if (m_editModeCondition != AfterMouseOver || (m_layout && m_layout->editMode())) { m_contentItem->setEnabled(!editMode); } @@ -153,7 +152,7 @@ m_editModeCondition = condition; - setAcceptHoverEvents(condition == AfterMouseOver); + setAcceptHoverEvents(condition == AfterMouseOver || (m_layout && m_layout->editMode())); emit editModeConditionChanged(); } @@ -182,6 +181,7 @@ if (m_layout) { disconnect(m_layout, &AppletsLayout::editModeConditionChanged, this, nullptr); + disconnect(m_layout, &AppletsLayout::editModeChanged, this, nullptr); if (m_editMode) { m_layout->hidePlaceHolder(); @@ -208,6 +208,9 @@ emit editModeConditionChanged(); } }); + connect(m_layout, &AppletsLayout::editModeChanged, this, [this]() { + setAcceptHoverEvents(m_editModeCondition == AfterMouseOver || m_layout->editMode()); + }); emit layoutChanged(); } @@ -625,22 +628,26 @@ { Q_UNUSED(event); - if (m_editModeCondition != AfterMouseOver) { + if (m_editModeCondition != AfterMouseOver && !m_layout->editMode()) { return; } if (m_closeEditModeTimer) { m_closeEditModeTimer->stop(); } - m_editModeTimer->start(QGuiApplication::styleHints()->mousePressAndHoldInterval()); + if (m_layout->editMode()) { + setEditMode(true); + } else { + m_editModeTimer->start(QGuiApplication::styleHints()->mousePressAndHoldInterval()); + } } void ItemContainer::hoverLeaveEvent(QHoverEvent *event) { Q_UNUSED(event); - if (m_editModeCondition != AfterMouseOver) { + if (m_editModeCondition != AfterMouseOver && !m_layout->editMode()) { return; } diff --git a/containmentactions/contextmenu/menu.cpp b/containmentactions/contextmenu/menu.cpp --- a/containmentactions/contextmenu/menu.cpp +++ b/containmentactions/contextmenu/menu.cpp @@ -72,11 +72,11 @@ if (c->containmentType() == Plasma::Types::PanelContainment || c->containmentType() == Plasma::Types::CustomPanelContainment) { - m_actionOrder << QStringLiteral("add widgets") << QStringLiteral("_add panel") << QStringLiteral("lock widgets") << QStringLiteral("_context") << QStringLiteral("configure") << QStringLiteral("remove"); + m_actionOrder << QStringLiteral("add widgets") << QStringLiteral("_add panel") << QStringLiteral("lock widgets") << QStringLiteral("edit mode") << QStringLiteral("_context") << QStringLiteral("configure") << QStringLiteral("remove"); } else { actions.insert(QStringLiteral("configure shortcuts"), false); m_actionOrder << QStringLiteral("_context") << QStringLiteral("_run_command") << QStringLiteral("add widgets") << QStringLiteral("_add panel") - << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("lock widgets") << QStringLiteral("_sep1") + << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("lock widgets") << QStringLiteral("edit mode") << QStringLiteral("_sep1") <corona()) { return c->corona()->actions()->action(QStringLiteral("lock widgets")); } + } else if (name == QLatin1String("edit mode")) { + if (c->corona()) { + return c->corona()->actions()->action(QStringLiteral("edit mode")); + } } else if (name == QLatin1String("manage activities")) { if (c->corona()) { return c->corona()->actions()->action(QStringLiteral("manage activities")); diff --git a/shell/dbus/org.kde.PlasmaShell.xml b/shell/dbus/org.kde.PlasmaShell.xml --- a/shell/dbus/org.kde.PlasmaShell.xml +++ b/shell/dbus/org.kde.PlasmaShell.xml @@ -1,6 +1,7 @@ + diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -216,6 +216,14 @@ KDirWatch::self()->addFile(m_configPath); connect(KDirWatch::self(), &KDirWatch::dirty, this, &ShellCorona::configurationChanged); connect(KDirWatch::self(), &KDirWatch::created, this, &ShellCorona::configurationChanged); + + connect(qApp, &QGuiApplication::focusWindowChanged, + this, [this] (QWindow *focusWindow) { + if (!focusWindow) { + setEditMode(false); + } + } + ); } ShellCorona::~ShellCorona()