minimize to launcher when the switcher is not visible

This commit is contained in:
Marco Martin 2020-07-30 17:20:07 +02:00
parent 69d9c2557d
commit a1b7ef5d36
6 changed files with 66 additions and 3 deletions

View file

@ -31,4 +31,5 @@ QtObject {
property Item homeScreen property Item homeScreen
property QtObject homeScreenWindow property QtObject homeScreenWindow
property bool homeScreenVisible: true property bool homeScreenVisible: true
property bool taskSwitcherVisible: false
} }

View file

@ -25,6 +25,8 @@
#include <QModelIndex> #include <QModelIndex>
#include <QProcess> #include <QProcess>
#include <QDebug> #include <QDebug>
#include <QQuickItem>
#include <QQuickWindow>
// KDE // KDE
#include <KIO/ApplicationLauncherJob> #include <KIO/ApplicationLauncherJob>
@ -38,6 +40,7 @@
#include <KWayland/Client/connection_thread.h> #include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmawindowmanagement.h> #include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/registry.h> #include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
constexpr int MAX_FAVOURITES = 5; constexpr int MAX_FAVOURITES = 5;
@ -444,5 +447,38 @@ void ApplicationListModel::setMaxFavoriteCount(int count)
emit maxFavoriteCountChanged(); 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" #include "moc_applicationlistmodel.cpp"

View file

@ -106,6 +106,8 @@ public:
Q_INVOKABLE void loadApplications(); Q_INVOKABLE void loadApplications();
Q_INVOKABLE void setMinimizedDelegate(int row, QQuickItem *delegate);
public Q_SLOTS: public Q_SLOTS:
void sycocaDbChanged(const QStringList &change); void sycocaDbChanged(const QStringList &change);

View file

@ -27,7 +27,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager 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 import org.kde.phone.homescreen 1.0
ContainmentLayoutManager.ItemContainer { ContainmentLayoutManager.ItemContainer {
@ -51,9 +51,30 @@ ContainmentLayoutManager.ItemContainer {
signal launch(int x, int y, var source, string title) 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 { Connections {
target: mainFlickable 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: { onDragActiveChanged: {
launcherDragManager.active = dragActive launcherDragManager.active = dragActive

View file

@ -43,7 +43,7 @@ Item {
if (window.visible) { if (window.visible) {
tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, delegate.width, delegate.height), delegate); tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, delegate.width, delegate.height), delegate);
} else { } 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 { Connections {
@ -58,6 +58,7 @@ Item {
syncDelegateGeometry(); syncDelegateGeometry();
} }
} }
Component.onCompleted: syncDelegateGeometry(); Component.onCompleted: syncDelegateGeometry();
Item { Item {

View file

@ -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.core 2.1 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
NanoShell.FullScreenOverlay { NanoShell.FullScreenOverlay {
id: window id: window
@ -96,6 +97,7 @@ NanoShell.FullScreenOverlay {
if (!visible) { if (!visible) {
tasksView.contentY = 0; tasksView.contentY = 0;
} }
MobileShell.HomeScreenControls.taskSwitcherVisible = visible;
} }
SequentialAnimation { SequentialAnimation {