Commit 2861ae7c authored by Thomas Surrel's avatar Thomas Surrel

[Task Manager] When closing apps, resize only when mouse is out.

Summary:
When closing several apps from the task manager with the mouse
middle button, it is convenient that the remaining tasks are not
resized so that you don't need to move your mouse to target the
next app you intend to close. The tasks will be resized when the
mouse is moved out of the task manager.
This mimics the behavior of tabs in Firefox or Chrome.

Test Plan:
With the task manager configured without grouping, open several
applications so that the tasks displayed in the task manager get
smaller to fit in the available space. Now close the last three
for example: you should be able to do so without having to move
your mouse.

Reviewers: #plasma, #vdg, hein

Reviewed By: #plasma, hein

Subscribers: hein, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D18438
parent ccdc8362
......@@ -43,6 +43,7 @@ MouseArea {
readonly property int pid: model.AppPid !== undefined ? model.AppPid : 0
readonly property string appName: model.AppName
readonly property variant winIdList: model.WinIdList
property int itemIndex: index
property bool inPopup: false
property bool isWindow: model.IsWindow === true
......@@ -152,6 +153,7 @@ MouseArea {
if (plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.NewInstance) {
tasksModel.requestNewInstance(modelIndex());
} else if (plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.Close) {
tasks.taskClosedWithMouseMiddleButton = winIdList.slice()
tasksModel.requestClose(modelIndex());
} else if (plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.ToggleMinimized) {
tasksModel.requestToggleMinimized(modelIndex());
......
......@@ -29,16 +29,20 @@ import org.kde.plasma.private.taskmanager 0.1 as TaskManagerApplet
import "code/layout.js" as LayoutManager
import "code/tools.js" as TaskTools
Item {
MouseArea {
id: tasks
anchors.fill: parent
hoverEnabled: true
property bool vertical: (plasmoid.formFactor === PlasmaCore.Types.Vertical)
property bool iconsOnly: (plasmoid.pluginName === "org.kde.plasma.icontasks")
property QtObject contextMenuComponent: Qt.createComponent("ContextMenu.qml");
property bool needLayoutRefresh: false;
property variant taskClosedWithMouseMiddleButton: []
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.onUserConfiguringChanged: {
......@@ -85,6 +89,13 @@ Item {
}
}
onExited: {
if (needLayoutRefresh) {
LayoutManager.layout(taskRepeater)
needLayoutRefresh = false;
}
}
TaskManager.TasksModel {
id: tasksModel
......@@ -439,7 +450,15 @@ Item {
delegate: Task {}
onItemAdded: taskList.layout()
onItemRemoved: taskList.layout()
onItemRemoved: {
if (tasks.containsMouse && index != taskRepeater.count &&
item.winIdList.length > 0 && taskClosedWithMouseMiddleButton.indexOf(item.winIdList[0]) > -1) {
needLayoutRefresh = true;
} else {
taskList.layout();
}
taskClosedWithMouseMiddleButton = [];
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment