diff --git a/components/HomeScreenControls.qml b/components/HomeScreenControls.qml index 271301d7..64f07de6 100644 --- a/components/HomeScreenControls.qml +++ b/components/HomeScreenControls.qml @@ -31,4 +31,5 @@ QtObject { property Item homeScreen property QtObject homeScreenWindow property bool homeScreenVisible: true + property bool taskSwitcherVisible: false } diff --git a/containments/homescreen/applicationlistmodel.cpp b/containments/homescreen/applicationlistmodel.cpp index 07c03d58..6823d29e 100644 --- a/containments/homescreen/applicationlistmodel.cpp +++ b/containments/homescreen/applicationlistmodel.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include // KDE #include @@ -38,6 +40,7 @@ #include #include #include +#include constexpr int MAX_FAVOURITES = 5; @@ -444,5 +447,38 @@ void ApplicationListModel::setMaxFavoriteCount(int count) emit maxFavoriteCountChanged(); } +void ApplicationListModel::setMinimizedDelegate(int row, QQuickItem *delegate) +{ + if (row < 0 || row >= m_applicationList.count()) { + return; + } + + if (!delegate || !delegate->parentItem() || !delegate->window()) { + return; + } + + QWindow *delegateWindow = delegate->window(); + + if (!delegateWindow) { + return; + } + + using namespace KWayland::Client; + KWayland::Client::PlasmaWindow *window = m_applicationList[row].window; + if (!window) { + return; + } + + Surface *surface = Surface::fromWindow(delegateWindow); + + if (!surface) { + return; + } + + QRect rect = delegate->mapRectToScene(QRectF(0,0, delegate->width(), delegate->height())).toRect(); + + window->setMinimizedGeometry(surface, rect); +} + #include "moc_applicationlistmodel.cpp" diff --git a/containments/homescreen/applicationlistmodel.h b/containments/homescreen/applicationlistmodel.h index adb0c846..9df10206 100644 --- a/containments/homescreen/applicationlistmodel.h +++ b/containments/homescreen/applicationlistmodel.h @@ -106,6 +106,8 @@ public: Q_INVOKABLE void loadApplications(); + Q_INVOKABLE void setMinimizedDelegate(int row, QQuickItem *delegate); + public Q_SLOTS: void sycocaDbChanged(const QStringList &change); diff --git a/containments/homescreen/package/contents/ui/launcher/Delegate.qml b/containments/homescreen/package/contents/ui/launcher/Delegate.qml index a7aceb7b..bd8c331a 100644 --- a/containments/homescreen/package/contents/ui/launcher/Delegate.qml +++ b/containments/homescreen/package/contents/ui/launcher/Delegate.qml @@ -27,7 +27,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager - +import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.phone.homescreen 1.0 ContainmentLayoutManager.ItemContainer { @@ -51,9 +51,30 @@ ContainmentLayoutManager.ItemContainer { signal launch(int x, int y, var source, string title) + readonly property bool applicationRunning: model.applicationRunning + onApplicationRunningChanged: { + if (applicationRunning && !MobileShell.HomeScreenControls.taskSwitcherVisible) { + plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); + } + } Connections { target: mainFlickable - onCancelEditModeForItemsRequested: cancelEdit() + function onCancelEditModeForItemsRequested() { + cancelEdit() + } + function onContentYChanged() { + if (applicationRunning && !MobileShell.HomeScreenControls.taskSwitcherVisible) { + plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); + } + } + } + Connections { + target: MobileShell.HomeScreenControls + function taskSwitcherVisibleChanged() { + if (applicationRunning && !MobileShell.HomeScreenControls.taskSwitcherVisible) { + plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); + } + } } onDragActiveChanged: { launcherDragManager.active = dragActive diff --git a/containments/taskpanel/package/contents/ui/Task.qml b/containments/taskpanel/package/contents/ui/Task.qml index 47cc469c..20e870b8 100644 --- a/containments/taskpanel/package/contents/ui/Task.qml +++ b/containments/taskpanel/package/contents/ui/Task.qml @@ -43,7 +43,7 @@ Item { if (window.visible) { tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, delegate.width, delegate.height), delegate); } else { - tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, delegate.width, delegate.height), dummyWindowTask); + // tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, delegate.width, delegate.height), dummyWindowTask); } } Connections { @@ -58,6 +58,7 @@ Item { syncDelegateGeometry(); } } + Component.onCompleted: syncDelegateGeometry(); Item { diff --git a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml b/containments/taskpanel/package/contents/ui/TaskSwitcher.qml index 45d0d128..a6913fbe 100644 --- a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml +++ b/containments/taskpanel/package/contents/ui/TaskSwitcher.qml @@ -24,6 +24,7 @@ import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.nanoshell 2.0 as NanoShell +import org.kde.plasma.private.mobileshell 1.0 as MobileShell NanoShell.FullScreenOverlay { id: window @@ -96,6 +97,7 @@ NanoShell.FullScreenOverlay { if (!visible) { tasksView.contentY = 0; } + MobileShell.HomeScreenControls.taskSwitcherVisible = visible; } SequentialAnimation {