From 00e9c1ac80af64f9e20a4614ab8bf1686a5da104 Mon Sep 17 00:00:00 2001 From: Ash-86 <108089527+Ash-86@users.noreply.github.com> Date: Fri, 2 Oct 2026 19:39:56 -0300 Subject: [PATCH] close dock by middle click --- .../dockwindow/qml/Muse/Dock/DockFrame.qml | 8 +++++++- .../dockwindow/qml/Muse/Dock/DockTabBar.qml | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/framework/dockwindow/qml/Muse/Dock/DockFrame.qml b/framework/dockwindow/qml/Muse/Dock/DockFrame.qml index f3684be519..4bec0547c4 100644 --- a/framework/dockwindow/qml/Muse/Dock/DockFrame.qml +++ b/framework/dockwindow/qml/Muse/Dock/DockFrame.qml @@ -64,7 +64,13 @@ Rectangle { QtObject { id: prv readonly property alias tabsModel: frameModel.tabsModel - readonly property int currentIndex: Boolean(root.frameCpp) && root.frameCpp.currentIndex >= 0 ? root.frameCpp.currentIndex : 0 + readonly property int currentIndex: { + const tabCount = prv.tabsModel.numTabs // re-evaluate when tabs are added or closed + if (tabCount <= 0 || !Boolean(root.frameCpp)) { + return 0 + } + return root.frameCpp.currentIndex >= 0 ? root.frameCpp.currentIndex : 0 + } } NavigationPanel { diff --git a/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml b/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml index dab16732cf..bbc38888dd 100644 --- a/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml +++ b/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml @@ -155,6 +155,24 @@ Rectangle { onHandleContextMenuItemRequested: function(itemId) { root.handleContextMenuItemRequested(itemId) } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.MiddleButton + + onClicked: { + const closingCurrent = model.index === root.currentIndex + const previous = Math.max(0, model.index - 1) + + model.contextMenu.handleMenuItem("command://dock/set-open") + + if (closingCurrent) { + Qt.callLater(function() { + root.tabClicked(previous) + }) + } + } + } } }