From 9bb1ab12b51c1f1ac9b03a88a189b212abe7207d Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:07:58 +0200 Subject: [PATCH 01/10] Move DockTabBar into separate component --- src/framework/dockwindow/dock.qrc | 1 + .../dockwindow/qml/Muse/Dock/DockFrame.qml | 125 +++------------ .../dockwindow/qml/Muse/Dock/DockTabBar.qml | 142 ++++++++++++++++++ 3 files changed, 163 insertions(+), 105 deletions(-) create mode 100644 src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml diff --git a/src/framework/dockwindow/dock.qrc b/src/framework/dockwindow/dock.qrc index a2a8999a50783..4702ea628460a 100644 --- a/src/framework/dockwindow/dock.qrc +++ b/src/framework/dockwindow/dock.qrc @@ -7,6 +7,7 @@ qml/Muse/Dock/DockPanel.qml qml/Muse/Dock/DockPanelTab.qml qml/Muse/Dock/DockSeparator.qml + qml/Muse/Dock/DockTabBar.qml qml/Muse/Dock/DockTitleBar.qml qml/Muse/Dock/DockToolBar.qml qml/Muse/Dock/DockWidget.qml diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml b/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml index 219b5b10d8652..5b837610b30fe 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml @@ -34,7 +34,7 @@ Rectangle { //! NOTE: please, don't rename those properties because they are used in c++ property QtObject frameCpp readonly property QtObject titleBarCpp: Boolean(frameCpp) ? frameCpp.actualTitleBar : null - readonly property int nonContentsHeight: titleBar.visible ? titleBar.heightWhenVisible + tabsPanel.height : 0 + readonly property int nonContentsHeight: titleBar.visible ? titleBar.heightWhenVisible + tabBar.height : 0 property int titleBarNavigationPanelOrder: 1 //! --- @@ -53,10 +53,6 @@ Rectangle { } } - Component.onDestruction: { - tabs.model = 0 - } - DockFrameModel { id: frameModel @@ -71,8 +67,8 @@ Rectangle { order: root.titleBarNavigationPanelOrder onNavigationEvent: function(event) { - if (event.type === NavigationEvent.AboutActive && tabsPanel.visible) { - event.setData("controlName", tabs.currentItem.navigation.name) + if (event.type === NavigationEvent.AboutActive && tabBar.visible) { + event.setData("controlName", tabBar.currentItemNavigationName) } } } @@ -96,127 +92,46 @@ Rectangle { } } - MouseArea { - id: dragMouseArea - - anchors.top: tabsPanel.top - width: tabs.contentWidth - height: tabsPanel.height - bottomSeparator.height - - z: tabsPanel.z + 1 - - hoverEnabled: false - propagateComposedEvents: true - enabled: tabsPanel.visible - cursorShape: Qt.SizeAllCursor - } - - Rectangle { - id: tabsPanel + DockTabBar { + id: tabBar anchors.top: titleBar.visible ? titleBar.bottom : parent.top height: visible ? 35 : 0 width: parent.width - visible: tabs.count > 1 - clip: true + visible: frameModel.tabs.length > 1 - color: ui.theme.backgroundSecondaryColor + tabBarCpp: Boolean(root.frameCpp) ? root.frameCpp.tabWidget.tabBar : null + tabsModel: frameModel.tabs + currentIndex: Boolean(root.frameCpp) && root.frameCpp.currentIndex >= 0 ? root.frameCpp.currentIndex : 0 - readonly property QtObject tabBarCpp: Boolean(root.frameCpp) ? root.frameCpp.tabWidget.tabBar : null - property int currentIndex: Boolean(root.frameCpp) && root.frameCpp.currentIndex >= 0 ? root.frameCpp.currentIndex : 0 + navigationPanel: navPanel - onTabBarCppChanged: { - if (Boolean(tabBarCpp)) { - tabBarCpp.setDraggableMouseArea(dragMouseArea) - tabBarCpp.tabBarQmlItem = this + function setCurrentDockWidget(index: int) { + if (root.frameCpp) { + root.frameCpp.tabWidget.setCurrentDockWidget(index) } } onCurrentIndexChanged: { - if (Boolean(root) && Boolean(root.frameCpp)) { - root.frameCpp.tabWidget.setCurrentDockWidget(currentIndex) - } + setCurrentDockWidget(currentIndex) } - ListView { - id: tabs - - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - - width: Math.min(contentWidth, availableWidth) - - orientation: Qt.Horizontal - interactive: false - spacing: 0 - - currentIndex: tabsPanel.currentIndex - model: frameModel.tabs - - readonly property real availableWidth: tabsPanel.width + 1 // + 1, because we don't need to see the rightmost separator - readonly property real implicitWidthOfActiveTab: currentItem ? currentItem.implicitWidth : 0 - readonly property real implicitWidthOfAllTabsTogether: { - let result = 0 - let items = tabs.contentItem.children - - for (let i in items) { - let item = items[i] - if (item && item.implicitWidth) { - result += item.implicitWidth - } - } - - return result - } - - delegate: DockPanelTab { - text: modelData.title - isCurrent: tabsPanel && (tabsPanel.currentIndex === model.index) - contextMenuModel: modelData.contextMenuModel - - width: isCurrent || (tabs.implicitWidthOfAllTabsTogether <= tabs.availableWidth) - ? implicitWidth - : (tabs.availableWidth - tabs.implicitWidthOfActiveTab) - / (tabs.implicitWidthOfAllTabsTogether - tabs.implicitWidthOfActiveTab) - * implicitWidth - - navigation.name: text - navigation.panel: navPanel - navigation.order: model.index * 2 // NOTE '...' button will have +1 order - - onNavigationTriggered: { - tabsPanel.currentIndex = model.index - } - - onClicked: { - tabsPanel.currentIndex = model.index - } - - onHandleContextMenuItemRequested: function(itemId) { - frameModel.handleMenuItem(itemId) - } - } + onTabClicked: function(index) { + setCurrentDockWidget(index) } - Item { - anchors.left: tabs.right - anchors.right: parent.right - anchors.bottom: parent.bottom - - height: bottomSeparator.height - - SeparatorLine { id: bottomSeparator } + onHandleContextMenuItemRequested: function(itemId) { + frameModel.handleMenuItem(itemId) } } StackLayout { id: stackLayout - anchors.top: tabsPanel.visible ? tabsPanel.bottom : (titleBar.visible ? titleBar.bottom : parent.top) - anchors.topMargin: tabsPanel.visible ? 12 : 0 + anchors.top: tabBar.visible ? tabBar.bottom : (titleBar.visible ? titleBar.bottom : parent.top) + anchors.topMargin: tabBar.visible ? 12 : 0 anchors.bottom: parent.bottom width: parent.width diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml b/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml new file mode 100644 index 0000000000000..8889756015960 --- /dev/null +++ b/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml @@ -0,0 +1,142 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2023 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +import QtQuick 2.15 + +import Muse.Ui 1.0 +import Muse.UiComponents 1.0 + +Rectangle { + id: root + + clip: true + + color: ui.theme.backgroundSecondaryColor + + property QtObject tabBarCpp: null + + property alias tabsModel: tabs.model + property alias currentIndex: tabs.currentIndex + + property bool draggingTabsAllowed: true + + property NavigationPanel navigationPanel: null + readonly property string currentItemNavigationName: tabs.currentItem && tabs.currentItem.navigation ? tabs.currentItem.navigation.name : "" + + signal tabClicked(int index) + signal handleContextMenuItemRequested(string itemId) + + function updateMouseArea() { + if (tabBarCpp) { + tabBarCpp.setDraggableMouseArea(draggingTabsAllowed ? draggingTabsMouseArea : null) + tabBarCpp.tabBarQmlItem = draggingTabsAllowed ? this : null + } + } + + onTabBarCppChanged: { updateMouseArea() } + onDraggingTabsAllowedChanged: { updateMouseArea() } + + Component.onDestruction: { + tabs.model = 0 + } + + ListView { + id: tabs + + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + + width: Math.min(contentWidth, availableWidth) + + orientation: Qt.Horizontal + interactive: false + spacing: 0 + + readonly property real availableWidth: root.width + 1 // + 1, because we don't need to see the rightmost separator + readonly property real implicitWidthOfActiveTab: currentItem ? currentItem.implicitWidth : 0 + readonly property real implicitWidthOfAllTabsTogether: { + let result = 0 + let items = tabs.contentItem.children + + for (let i in items) { + let item = items[i] + if (item && item.implicitWidth) { + result += item.implicitWidth + } + } + + return result + } + + delegate: DockPanelTab { + text: modelData.title + isCurrent: root.currentIndex === model.index + contextMenuModel: modelData.contextMenuModel + + width: isCurrent || (tabs.implicitWidthOfAllTabsTogether <= tabs.availableWidth) + ? implicitWidth + : (tabs.availableWidth - tabs.implicitWidthOfActiveTab) + / (tabs.implicitWidthOfAllTabsTogether - tabs.implicitWidthOfActiveTab) + * implicitWidth + + navigation.name: text + navigation.panel: root.navigationPanel + navigation.order: model.index * 2 // NOTE '...' button will have +1 order + + onNavigationTriggered: { + root.tabClicked(model.index) + } + + onClicked: { + root.tabClicked(model.index) + } + + onHandleContextMenuItemRequested: function(itemId) { + root.handleContextMenuItemRequested(itemId) + } + } + } + + MouseArea { + id: draggingTabsMouseArea + + anchors.top: parent.top + anchors.left: parent.left + width: tabs.contentWidth + height: root.height - bottomSeparator.height + + hoverEnabled: false + propagateComposedEvents: true + enabled: root.visible && root.draggingTabsAllowed + cursorShape: Qt.SizeAllCursor + } + + Item { + anchors.left: tabs.right + anchors.right: parent.right + anchors.bottom: parent.bottom + + height: bottomSeparator.height + + SeparatorLine { id: bottomSeparator } + } +} From 32def16bce225df1ff85745f9650d058c3499bf6 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 27 Mar 2023 22:17:54 +0200 Subject: [PATCH 02/10] Show tab bar instead of title bar for horizontal panels KDDockWidgets requires using two MouseAreas: one for dragging the title bar (which will drag the whole floating window when it's undocked) and one for dragging individual tabs (this will drag the tabs out of the floating window, which gives a strange effect when there is only one tab in the floating window. The design specifies that we want tabs instead of a title bar for horizontal panels even when there is only one tab. In this case, we need to make the tabs visible, but make their MouseArea disabled, and instead use the title bar MouseArea. --- src/framework/dockwindow/dock.qrc | 1 + .../dockwindow/internal/dockframemodel.cpp | 20 ++--- .../dockwindow/internal/dockframemodel.h | 10 +-- .../dockwindow/qml/Muse/Dock/DockFrame.qml | 35 +++++++-- .../dockwindow/qml/Muse/Dock/DockTabBar.qml | 4 +- .../dockwindow/qml/Muse/Dock/DockTitleBar.qml | 78 ++++++------------- .../qml/Muse/Dock/DockTitleBarMouseArea.qml | 44 +++++++++++ 7 files changed, 111 insertions(+), 81 deletions(-) create mode 100644 src/framework/dockwindow/qml/Muse/Dock/DockTitleBarMouseArea.qml diff --git a/src/framework/dockwindow/dock.qrc b/src/framework/dockwindow/dock.qrc index 4702ea628460a..2a9ee38d6fea7 100644 --- a/src/framework/dockwindow/dock.qrc +++ b/src/framework/dockwindow/dock.qrc @@ -9,6 +9,7 @@ qml/Muse/Dock/DockSeparator.qml qml/Muse/Dock/DockTabBar.qml qml/Muse/Dock/DockTitleBar.qml + qml/Muse/Dock/DockTitleBarMouseArea.qml qml/Muse/Dock/DockToolBar.qml qml/Muse/Dock/DockWidget.qml qml/Muse/Dock/qmldir diff --git a/src/framework/dockwindow/internal/dockframemodel.cpp b/src/framework/dockwindow/internal/dockframemodel.cpp index 76eae7b2303fd..6718eede9db60 100644 --- a/src/framework/dockwindow/internal/dockframemodel.cpp +++ b/src/framework/dockwindow/internal/dockframemodel.cpp @@ -78,7 +78,7 @@ QVariantList DockFrameModel::tabs() const { QVariantList result; - if (!m_frame || m_frame->hasSingleDockWidget()) { + if (!m_frame) { return result; } @@ -93,9 +93,9 @@ QVariantList DockFrameModel::tabs() const return result; } -bool DockFrameModel::titleBarVisible() const +bool DockFrameModel::titleBarAllowed() const { - return m_titleBarVisible; + return m_titleBarAllowed; } bool DockFrameModel::isHorizontalPanel() const @@ -130,7 +130,7 @@ void DockFrameModel::listenChangesInFrame() auto allDocks = m_frame->dockWidgets(); if (allDocks.isEmpty()) { - setTitleBarVisible(false); + setTitleBarAllowed(false); return; } @@ -139,8 +139,8 @@ void DockFrameModel::listenChangesInFrame() && (properties.location == Location::Top || properties.location == Location::Bottom); setIsHorizontalPanel(isHorizontalPanel); - bool visible = (allDocks.size() == 1) && (properties.type == DockType::Panel) && (properties.floatable || properties.closable); - setTitleBarVisible(visible); + bool allowed = (properties.type == DockType::Panel) && (properties.floatable || properties.closable); + setTitleBarAllowed(allowed); updateNavigationSection(); }); @@ -152,14 +152,14 @@ void DockFrameModel::listenChangesInFrame() }); } -void DockFrameModel::setTitleBarVisible(bool visible) +void DockFrameModel::setTitleBarAllowed(bool allowed) { - if (visible == m_titleBarVisible) { + if (allowed == m_titleBarAllowed) { return; } - m_titleBarVisible = visible; - emit titleBarVisibleChanged(visible); + m_titleBarAllowed = allowed; + emit titleBarAllowedChanged(allowed); } void DockFrameModel::setIsHorizontalPanel(bool is) diff --git a/src/framework/dockwindow/internal/dockframemodel.h b/src/framework/dockwindow/internal/dockframemodel.h index 56826fad44559..4de9072871c54 100644 --- a/src/framework/dockwindow/internal/dockframemodel.h +++ b/src/framework/dockwindow/internal/dockframemodel.h @@ -41,7 +41,7 @@ class DockFrameModel : public QObject, public muse::Injectable Q_PROPERTY(QQuickItem * frame READ frame WRITE setFrame NOTIFY frameChanged) Q_PROPERTY(QVariantList tabs READ tabs NOTIFY tabsChanged) - Q_PROPERTY(bool titleBarVisible READ titleBarVisible NOTIFY titleBarVisibleChanged) + Q_PROPERTY(bool titleBarAllowed READ titleBarAllowed NOTIFY titleBarAllowedChanged) Q_PROPERTY(bool isHorizontalPanel READ isHorizontalPanel NOTIFY isHorizontalPanelChanged) Q_PROPERTY(QObject * navigationSection READ navigationSection NOTIFY navigationSectionChanged) Q_PROPERTY(QString currentDockUniqueName READ currentDockUniqueName NOTIFY currentDockChanged) @@ -58,7 +58,7 @@ class DockFrameModel : public QObject, public muse::Injectable QQuickItem* frame() const; QVariantList tabs() const; - bool titleBarVisible() const; + bool titleBarAllowed() const; bool isHorizontalPanel() const; QObject* navigationSection() const; QString currentDockUniqueName() const; @@ -75,7 +75,7 @@ public slots: signals: void frameChanged(QQuickItem* frame); void tabsChanged(); - void titleBarVisibleChanged(bool visible); + void titleBarAllowedChanged(bool visible); void isHorizontalPanelChanged(); void navigationSectionChanged(); void currentDockChanged(); @@ -85,7 +85,7 @@ public slots: bool eventFilter(QObject* watched, QEvent* event); void listenChangesInFrame(); - void setTitleBarVisible(bool visible); + void setTitleBarAllowed(bool allowed); void setIsHorizontalPanel(bool is); KDDockWidgets::DockWidgetBase* currentDockWidget() const; @@ -95,7 +95,7 @@ public slots: void updateNavigationSection(); KDDockWidgets::Frame* m_frame = nullptr; - bool m_titleBarVisible = false; + bool m_titleBarAllowed = false; bool m_isHorizontalPanel = false; QObject* m_navigationSection = nullptr; }; diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml b/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml index 5b837610b30fe..9f48251b5f415 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml @@ -34,10 +34,14 @@ Rectangle { //! NOTE: please, don't rename those properties because they are used in c++ property QtObject frameCpp readonly property QtObject titleBarCpp: Boolean(frameCpp) ? frameCpp.actualTitleBar : null - readonly property int nonContentsHeight: titleBar.visible ? titleBar.heightWhenVisible + tabBar.height : 0 + readonly property int nonContentsHeight: titleBar.height + tabBar.height + stackLayout.anchors.topMargin property int titleBarNavigationPanelOrder: 1 //! --- + readonly property bool hasTitleBar: frameModel.titleBarAllowed && !(frameModel.tabs.length > 1 || frameModel.isHorizontalPanel) + readonly property bool hasSingleTab: frameModel.titleBarAllowed && frameModel.tabs.length === 1 && frameModel.isHorizontalPanel + readonly property bool hasTabBar: frameModel.titleBarAllowed && (frameModel.tabs.length > 1 || frameModel.isHorizontalPanel) + anchors.fill: parent color: ui.theme.backgroundPrimaryColor @@ -77,12 +81,14 @@ Rectangle { id: titleBar anchors.top: parent.top + width: parent.width + height: visible ? 34 : 0 + + visible: root.hasTitleBar titleBarCpp: root.titleBarCpp contextMenuModel: frameModel.currentDockContextMenuModel - visible: frameModel.titleBarVisible - isHorizontalPanel: frameModel.isHorizontalPanel navigation.panel: navPanel navigation.order: 1 @@ -95,12 +101,12 @@ Rectangle { DockTabBar { id: tabBar - anchors.top: titleBar.visible ? titleBar.bottom : parent.top - - height: visible ? 35 : 0 + anchors.top: parent.top width: parent.width + height: visible ? 35 : 0 - visible: frameModel.tabs.length > 1 + visible: root.hasTabBar + draggingTabsAllowed: root.hasTabBar && !root.hasSingleTab tabBarCpp: Boolean(root.frameCpp) ? root.frameCpp.tabWidget.tabBar : null tabsModel: frameModel.tabs @@ -127,10 +133,23 @@ Rectangle { } } + DockTitleBarMouseArea { + id: titleBarMouseArea + + anchors.fill: tabBar.visible ? tabBar + : titleBar.visible ? titleBar : null + + enabled: root.hasTitleBar || root.hasSingleTab + propagateComposedEvents: true + + titleBarCpp: root.titleBarCpp + } + StackLayout { id: stackLayout - anchors.top: tabBar.visible ? tabBar.bottom : (titleBar.visible ? titleBar.bottom : parent.top) + anchors.top: tabBar.visible ? tabBar.bottom + : titleBar.visible ? titleBar.bottom : parent.top anchors.topMargin: tabBar.visible ? 12 : 0 anchors.bottom: parent.bottom diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml b/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml index 8889756015960..a4db7b9337abb 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml @@ -46,8 +46,8 @@ Rectangle { function updateMouseArea() { if (tabBarCpp) { - tabBarCpp.setDraggableMouseArea(draggingTabsAllowed ? draggingTabsMouseArea : null) - tabBarCpp.tabBarQmlItem = draggingTabsAllowed ? this : null + tabBarCpp.setDraggableMouseArea(draggingTabsMouseArea) + tabBarCpp.tabBarQmlItem = this } } diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockTitleBar.qml b/src/framework/dockwindow/qml/Muse/Dock/DockTitleBar.qml index 5d17f29313eca..0f5657814fd3b 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockTitleBar.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockTitleBar.qml @@ -26,82 +26,48 @@ import QtQuick.Layouts 1.12 import Muse.Ui 1.0 import Muse.UiComponents 1.0 -import "qrc:/kddockwidgets/private/quick/qml/" as KDDW - Item { id: root required property QtObject titleBarCpp property alias contextMenuModel: contextMenuButton.menuModel - property alias heightWhenVisible: titleBar.heightWhenVisible - property bool isHorizontalPanel: false property alias navigation: contextMenuButton.navigation signal handleContextMenuItemRequested(string itemId) - width: parent.width - height: visible ? heightWhenVisible : 0 - - visible: Boolean(titleBarCpp) - - KDDW.TitleBarBase { - id: titleBar + MouseArea { + id: mouseArea + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: Qt.SizeAllCursor + } + RowLayout { anchors.fill: parent + anchors.leftMargin: 12 + anchors.rightMargin: 12 - heightWhenVisible: titleBarContent.implicitHeight - color: ui.theme.backgroundPrimaryColor + spacing: 4 - visible: parent.visible + StyledTextLabel { + id: titleLabel + Layout.fillWidth: true - MouseArea { - id: mouseArea - anchors.fill: parent - acceptedButtons: Qt.NoButton - cursorShape: Qt.SizeAllCursor + text: root.titleBarCpp ? root.titleBarCpp.title : "" + font: ui.theme.bodyBoldFont + horizontalAlignment: Text.AlignLeft } - Column { - id: titleBarContent - - anchors.fill: parent - anchors.leftMargin: 12 - anchors.rightMargin: 12 - - spacing: 0 + MenuButton { + id: contextMenuButton - RowLayout { - width: parent.width - height: 34 - - StyledTextLabel { - id: titleLabel - Layout.fillWidth: true - - text: titleBar.title - font: ui.theme.bodyBoldFont - horizontalAlignment: Qt.AlignLeft - } - - MenuButton { - id: contextMenuButton - - width: 20 - height: width - - onHandleMenuItem: function(itemId) { - root.handleContextMenuItemRequested(itemId) - } - } - } + width: 20 + height: width - SeparatorLine { - id: bottomSeparator - orientation: Qt.Horizontal - anchors.margins: -12 - visible: root.isHorizontalPanel + onHandleMenuItem: function(itemId) { + root.handleContextMenuItemRequested(itemId) } } } diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockTitleBarMouseArea.qml b/src/framework/dockwindow/qml/Muse/Dock/DockTitleBarMouseArea.qml new file mode 100644 index 0000000000000..606a52b072e66 --- /dev/null +++ b/src/framework/dockwindow/qml/Muse/Dock/DockTitleBarMouseArea.qml @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2023 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +import QtQuick 2.15 + +// Based on qrc:/kddockwidgets/private/quick/qml/TitleBarBase.qml, but adapted to our needs +MouseArea { + objectName: "titleBarMouseArea" + + required property QtObject titleBarCpp + + /// Set to true if you're using a custom MouseEventRedirector in your code + property bool hasCustomMouseEventRedirector: false + + onDoubleClicked: { + if (titleBarCpp) { + titleBarCpp.onDoubleClicked(); + } + } + + onTitleBarCppChanged: { + if (titleBarCpp && !hasCustomMouseEventRedirector) { + titleBarCpp.redirectMouseEvents(this) + } + } +} From 38bef2768222bb29ab2f6386bb86ba015d708b19 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 3 Apr 2023 10:39:23 +0200 Subject: [PATCH 03/10] Add the possibility to show toolbar items for dock panels --- .../qml/NotationPage/NotationPage.qml | 1 + src/framework/dockwindow/docktypes.h | 1 + .../dockwindow/internal/dockframemodel.cpp | 9 +++- .../dockwindow/internal/dockframemodel.h | 2 + .../dockwindow/qml/Muse/Dock/DockFrame.qml | 2 + .../dockwindow/qml/Muse/Dock/DockTabBar.qml | 13 +++++ .../dockwindow/view/dockpanelview.cpp | 23 ++++++++ src/framework/dockwindow/view/dockpanelview.h | 8 +++ src/playback/playback.qrc | 1 + .../qml/MuseScore/Playback/MixerPanel.qml | 4 ++ .../Playback/internal/MixerPanelToolbar.qml | 52 +++++++++++++++++++ 11 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml diff --git a/src/appshell/qml/NotationPage/NotationPage.qml b/src/appshell/qml/NotationPage/NotationPage.qml index f744569cf3405..7bb7e1548ccd9 100644 --- a/src/appshell/qml/NotationPage/NotationPage.qml +++ b/src/appshell/qml/NotationPage/NotationPage.qml @@ -328,6 +328,7 @@ DockPage { Component.onCompleted: { mixerPanel.contextMenuModel = contextMenuModel + mixerPanel.toolbarComponent = toolbarComponent } onResizeRequested: function(newWidth, newHeight) { diff --git a/src/framework/dockwindow/docktypes.h b/src/framework/dockwindow/docktypes.h index 8bf0747476b77..3db6413107f78 100644 --- a/src/framework/dockwindow/docktypes.h +++ b/src/framework/dockwindow/docktypes.h @@ -30,6 +30,7 @@ namespace muse::dock { inline const char* CONTEXT_MENU_MODEL_PROPERTY("contextMenuModel"); inline const char* DOCK_PANEL_PROPERTY("dockPanel"); +inline const char* TOOLBAR_COMPONENT_PROPERTY("toolbarComponent"); //! NOTE: need to be synchronized with Window shadow(see DockFloatingWindow margins) inline constexpr int DOCK_WINDOW_SHADOW(8); diff --git a/src/framework/dockwindow/internal/dockframemodel.cpp b/src/framework/dockwindow/internal/dockframemodel.cpp index 6718eede9db60..c1f01782257e0 100644 --- a/src/framework/dockwindow/internal/dockframemodel.cpp +++ b/src/framework/dockwindow/internal/dockframemodel.cpp @@ -54,7 +54,8 @@ bool DockFrameModel::eventFilter(QObject* watched, QEvent* event) return QObject::eventFilter(watched, event); } - if (propertyChangeEvent->propertyName() == CONTEXT_MENU_MODEL_PROPERTY) { + if (propertyChangeEvent->propertyName() == CONTEXT_MENU_MODEL_PROPERTY + || propertyChangeEvent->propertyName() == TOOLBAR_COMPONENT_PROPERTY) { emit tabsChanged(); if (watched == currentDockWidget()) { @@ -86,6 +87,7 @@ QVariantList DockFrameModel::tabs() const QVariantMap tab; tab["title"] = dock->title(); tab[CONTEXT_MENU_MODEL_PROPERTY] = dock->property(CONTEXT_MENU_MODEL_PROPERTY); + tab[TOOLBAR_COMPONENT_PROPERTY] = dock->property(TOOLBAR_COMPONENT_PROPERTY); result << tab; } @@ -203,6 +205,11 @@ QVariant DockFrameModel::currentDockContextMenuModel() const return currentDockProperty(CONTEXT_MENU_MODEL_PROPERTY); } +QVariant DockFrameModel::currentDockToolbarComponent() const +{ + return currentDockProperty(TOOLBAR_COMPONENT_PROPERTY); +} + bool DockFrameModel::highlightingVisible() const { return highlightingRect().isValid(); diff --git a/src/framework/dockwindow/internal/dockframemodel.h b/src/framework/dockwindow/internal/dockframemodel.h index 4de9072871c54..6df444b1696ab 100644 --- a/src/framework/dockwindow/internal/dockframemodel.h +++ b/src/framework/dockwindow/internal/dockframemodel.h @@ -46,6 +46,7 @@ class DockFrameModel : public QObject, public muse::Injectable Q_PROPERTY(QObject * navigationSection READ navigationSection NOTIFY navigationSectionChanged) Q_PROPERTY(QString currentDockUniqueName READ currentDockUniqueName NOTIFY currentDockChanged) Q_PROPERTY(QVariant currentDockContextMenuModel READ currentDockContextMenuModel NOTIFY currentDockChanged) + Q_PROPERTY(QVariant currentDockToolbarComponent READ currentDockToolbarComponent NOTIFY currentDockChanged) Q_PROPERTY(bool highlightingVisible READ highlightingVisible NOTIFY highlightingVisibleChanged) Q_PROPERTY(QRect highlightingRect READ highlightingRect NOTIFY highlightingVisibleChanged) @@ -63,6 +64,7 @@ class DockFrameModel : public QObject, public muse::Injectable QObject* navigationSection() const; QString currentDockUniqueName() const; QVariant currentDockContextMenuModel() const; + QVariant currentDockToolbarComponent() const; bool highlightingVisible() const; QRect highlightingRect() const; diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml b/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml index 9f48251b5f415..64bd611d09fbc 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockFrame.qml @@ -112,6 +112,8 @@ Rectangle { tabsModel: frameModel.tabs currentIndex: Boolean(root.frameCpp) && root.frameCpp.currentIndex >= 0 ? root.frameCpp.currentIndex : 0 + currentToolbarComponent: frameModel.currentDockToolbarComponent + navigationPanel: navPanel function setCurrentDockWidget(index: int) { diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml b/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml index a4db7b9337abb..1269072c4c7bb 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockTabBar.qml @@ -41,6 +41,8 @@ Rectangle { property NavigationPanel navigationPanel: null readonly property string currentItemNavigationName: tabs.currentItem && tabs.currentItem.navigation ? tabs.currentItem.navigation.name : "" + property alias currentToolbarComponent: toolbarLoader.sourceComponent + signal tabClicked(int index) signal handleContextMenuItemRequested(string itemId) @@ -130,7 +132,18 @@ Rectangle { cursorShape: Qt.SizeAllCursor } + Loader { + id: toolbarLoader + + anchors.top: parent.top + anchors.left: tabs.right + anchors.right: parent.right + anchors.bottom: bottomSeparatorContainer.top + } + Item { + id: bottomSeparatorContainer + anchors.left: tabs.right anchors.right: parent.right anchors.bottom: parent.bottom diff --git a/src/framework/dockwindow/view/dockpanelview.cpp b/src/framework/dockwindow/view/dockpanelview.cpp index 0642220e9285f..89c483d89cf8f 100644 --- a/src/framework/dockwindow/view/dockpanelview.cpp +++ b/src/framework/dockwindow/view/dockpanelview.cpp @@ -164,6 +164,7 @@ DockPanelView::~DockPanelView() dockWidget->setProperty(DOCK_PANEL_PROPERTY, QVariant::fromValue(nullptr)); dockWidget->setProperty(CONTEXT_MENU_MODEL_PROPERTY, QVariant::fromValue(nullptr)); + dockWidget->setProperty(TOOLBAR_COMPONENT_PROPERTY, QVariant::fromValue(nullptr)); } QString DockPanelView::groupName() const @@ -194,12 +195,19 @@ void DockPanelView::componentComplete() dockWidget->setProperty(DOCK_PANEL_PROPERTY, QVariant::fromValue(this)); dockWidget->setProperty(CONTEXT_MENU_MODEL_PROPERTY, QVariant::fromValue(m_menuModel)); + dockWidget->setProperty(TOOLBAR_COMPONENT_PROPERTY, QVariant::fromValue(m_toolbarComponent)); connect(m_menuModel, &AbstractMenuModel::itemsChanged, [dockWidget, this]() { if (dockWidget) { dockWidget->setProperty(CONTEXT_MENU_MODEL_PROPERTY, QVariant::fromValue(m_menuModel)); } }); + + connect(this, &DockPanelView::toolbarComponentChanged, this, [this, dockWidget]() { + if (dockWidget) { + dockWidget->setProperty(TOOLBAR_COMPONENT_PROPERTY, QVariant::fromValue(m_toolbarComponent)); + } + }); } QObject* DockPanelView::navigationSection() const @@ -222,6 +230,11 @@ AbstractMenuModel* DockPanelView::contextMenuModel() const return m_menuModel->customMenuModel(); } +QQmlComponent* DockPanelView::toolbarComponent() const +{ + return m_toolbarComponent; +} + void DockPanelView::setContextMenuModel(AbstractMenuModel* model) { if (m_menuModel->customMenuModel() == model) { @@ -233,6 +246,16 @@ void DockPanelView::setContextMenuModel(AbstractMenuModel* model) emit contextMenuModelChanged(); } +void DockPanelView::setToolbarComponent(QQmlComponent* component) +{ + if (m_toolbarComponent == component) { + return; + } + + m_toolbarComponent = component; + emit toolbarComponentChanged(); +} + bool DockPanelView::isTabAllowed(const DockPanelView* tab) const { IF_ASSERT_FAILED(tab) { diff --git a/src/framework/dockwindow/view/dockpanelview.h b/src/framework/dockwindow/view/dockpanelview.h index 8440e456a1bcb..35c18ac06fad0 100644 --- a/src/framework/dockwindow/view/dockpanelview.h +++ b/src/framework/dockwindow/view/dockpanelview.h @@ -27,6 +27,8 @@ #include "uicomponents/view/abstractmenumodel.h" +class QQmlComponent; + namespace muse::uicomponents { class AbstractMenuModel; } @@ -41,6 +43,7 @@ class DockPanelView : public DockBase Q_PROPERTY( muse::uicomponents::AbstractMenuModel * contextMenuModel READ contextMenuModel WRITE setContextMenuModel NOTIFY contextMenuModelChanged) + Q_PROPERTY(QQmlComponent * toolbarComponent READ toolbarComponent WRITE setToolbarComponent NOTIFY toolbarComponentChanged) public: explicit DockPanelView(QQuickItem* parent = nullptr); @@ -49,6 +52,7 @@ class DockPanelView : public DockBase QString groupName() const; QObject* navigationSection() const; uicomponents::AbstractMenuModel* contextMenuModel() const; + QQmlComponent* toolbarComponent() const; bool isTabAllowed(const DockPanelView* tab) const; void addPanelAsTab(DockPanelView* tab); @@ -58,11 +62,13 @@ public slots: void setGroupName(const QString& name); void setNavigationSection(QObject* newNavigation); void setContextMenuModel(uicomponents::AbstractMenuModel* model); + void setToolbarComponent(QQmlComponent* component); signals: void groupNameChanged(); void navigationSectionChanged(); void contextMenuModelChanged(); + void toolbarComponentChanged(); private: void componentComplete() override; @@ -72,6 +78,8 @@ public slots: class DockPanelMenuModel; DockPanelMenuModel* m_menuModel = nullptr; + + QQmlComponent* m_toolbarComponent = nullptr; }; } diff --git a/src/playback/playback.qrc b/src/playback/playback.qrc index 206c1bcf355bf..34af2d57adbf4 100644 --- a/src/playback/playback.qrc +++ b/src/playback/playback.qrc @@ -5,6 +5,7 @@ qml/MuseScore/Playback/internal/MeasureAndBeatFields.qml qml/MuseScore/Playback/internal/TempoSlider.qml qml/MuseScore/Playback/MixerPanel.qml + qml/MuseScore/Playback/internal/MixerPanelToolbar.qml qml/MuseScore/Playback/internal/MixerPanelSection.qml qml/MuseScore/Playback/internal/MixerBalanceSection.qml qml/MuseScore/Playback/internal/MixerVolumeSection.qml diff --git a/src/playback/qml/MuseScore/Playback/MixerPanel.qml b/src/playback/qml/MuseScore/Playback/MixerPanel.qml index d5a32d85163b4..0ec15834d5e70 100644 --- a/src/playback/qml/MuseScore/Playback/MixerPanel.qml +++ b/src/playback/qml/MuseScore/Playback/MixerPanel.qml @@ -34,6 +34,10 @@ ColumnLayout { id: root property alias contextMenuModel: contextMenuModel + property Component toolbarComponent: MixerPanelToolbar { + navigation.section: root.navigationSection + navigation.order: 1 + } property NavigationSection navigationSection: null property NavigationPanel navigationPanel: mixerPanelModel.count > 0 ? mixerPanelModel.get(0).channelItem.panel : null // first panel diff --git a/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml b/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml new file mode 100644 index 0000000000000..490ae9f5a5aa2 --- /dev/null +++ b/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2023 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +import QtQuick 2.15 + +import Muse.Ui 1.0 +import Muse.UiComponents 1.0 + +Item { + id: root + + property alias navigation: navPanel + + anchors.fill: parent + + NavigationPanel { + id: navPanel + name: "MixerPanelToolbarPanel" + enabled: root.enabled && root.visible + } + + FlatButton { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 2 + + icon: IconCode.SETTINGS_COG + text: qsTrc("playback", "Customize mixer") + orientation: Qt.Horizontal + + navigation.panel: navPanel + navigation.row: 0 + } +} From 652d58ec2f6c2fd7a4bd4940e978bce65faa244d Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 1 Apr 2024 03:51:06 +0200 Subject: [PATCH 04/10] Refactor: eliminate unnecessary signal --- src/framework/dockwindow/internal/dockbase.cpp | 4 ---- src/framework/dockwindow/internal/dockbase.h | 2 -- src/framework/dockwindow/view/dockpageview.cpp | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/framework/dockwindow/internal/dockbase.cpp b/src/framework/dockwindow/internal/dockbase.cpp index fe8e8ccd1effb..e0c8007da1717 100644 --- a/src/framework/dockwindow/internal/dockbase.cpp +++ b/src/framework/dockwindow/internal/dockbase.cpp @@ -586,10 +586,6 @@ void DockBase::componentComplete() connect(this, &DockBase::minimumSizeChanged, this, &DockBase::applySizeConstraints); connect(this, &DockBase::maximumSizeChanged, this, &DockBase::applySizeConstraints); - connect(this, &DockBase::visibleChanged, [this](){ - emit reorderNavigationRequested(); - }); - m_defaultVisibility = isVisible(); } diff --git a/src/framework/dockwindow/internal/dockbase.h b/src/framework/dockwindow/internal/dockbase.h index bd64cc2e937a7..157905b2fe69f 100644 --- a/src/framework/dockwindow/internal/dockbase.h +++ b/src/framework/dockwindow/internal/dockbase.h @@ -158,8 +158,6 @@ public slots: void contentNavigationPanelChanged(); - void reorderNavigationRequested(); - protected: friend class DockWindow; friend class DropController; diff --git a/src/framework/dockwindow/view/dockpageview.cpp b/src/framework/dockwindow/view/dockpageview.cpp index e1a123ffa337b..b4ef7fcbf4118 100644 --- a/src/framework/dockwindow/view/dockpageview.cpp +++ b/src/framework/dockwindow/view/dockpageview.cpp @@ -60,7 +60,7 @@ void DockPageView::init() reorderSections(); }); - connect(dock, &DockBase::reorderNavigationRequested, [this](){ + connect(dock, &DockBase::visibleChanged, [this](){ reorderSections(); }); } From 3bdcf3bf03498688617f97cd6855d9fd9f254fa4 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 1 Apr 2024 05:58:02 +0200 Subject: [PATCH 05/10] Fix keyboard navigation order for dock panels Old situation: you tell the docking system a navigation panel for each dock panel, and the docking system will mess with the order of this panel. Problems: if a dock panel contains multiple navigation panels, you need to chain those other panels to the first one. And if the first panel is not really available, as in the case of the mixer toolbar, you can't tell the docking system about it. New situation: you tell the docking system about the navigation section directly, instead of the navigation panel. The docking system will give you a `contentNavigationPanelOrderStart` property back, which you can use to correctly set the order of all navigation panels in your dock panel. --- .../qml/NotationPage/NotationPage.qml | 10 +++++- .../qml/NotationPage/NotationStatusBar.qml | 15 ++++---- .../dockwindow/internal/dockbase.cpp | 27 ++++++++++---- src/framework/dockwindow/internal/dockbase.h | 19 ++++++---- .../dockwindow/qml/Muse/Dock/DockPage.qml | 4 +-- .../dockwindow/qml/Muse/Dock/DockPanel.qml | 4 +-- .../dockwindow/qml/Muse/Dock/DockToolBar.qml | 4 +-- .../dockwindow/view/dockpageview.cpp | 17 ++++----- .../dockwindow/view/dockpanelview.cpp | 15 -------- src/framework/dockwindow/view/dockpanelview.h | 5 --- .../qml/MuseScore/Inspector/InspectorForm.qml | 8 +---- .../InstrumentsScene/InstrumentsPanel.qml | 5 +-- .../MuseScore/NotationScene/NotationView.qml | 4 +-- .../NotationScene/PianoKeyboardPanel.qml | 8 +++-- .../NotationScene/SelectionFilterPanel.qml | 9 +++-- .../qml/MuseScore/NotationScene/Timeline.qml | 8 +++-- .../qml/MuseScore/Palette/DrumsetPanel.qml | 8 +++-- .../qml/MuseScore/Palette/PalettesPanel.qml | 4 +-- .../qml/MuseScore/Playback/MixerPanel.qml | 9 ++--- src/playback/view/mixerpanelmodel.cpp | 36 +++++++++---------- src/playback/view/mixerpanelmodel.h | 6 ++++ 21 files changed, 120 insertions(+), 105 deletions(-) diff --git a/src/appshell/qml/NotationPage/NotationPage.qml b/src/appshell/qml/NotationPage/NotationPage.qml index 7bb7e1548ccd9..fa166dcc91d4a 100644 --- a/src/appshell/qml/NotationPage/NotationPage.qml +++ b/src/appshell/qml/NotationPage/NotationPage.qml @@ -220,6 +220,7 @@ DockPage { PalettesPanel { navigationSection: palettesPanel.navigationSection + navigationOrderStart: palettesPanel.contentNavigationPanelOrderStart Component.onCompleted: { palettesPanel.contextMenuModel = contextMenuModel @@ -245,6 +246,7 @@ DockPage { InstrumentsPanel { navigationSection: instrumentsPanel.navigationSection + navigationOrderStart: instrumentsPanel.contentNavigationPanelOrderStart Component.onCompleted: { instrumentsPanel.contextMenuModel = contextMenuModel @@ -270,6 +272,7 @@ DockPage { InspectorForm { navigationSection: inspectorPanel.navigationSection + navigationOrderStart: inspectorPanel.contentNavigationPanelOrderStart notationView: root.notationView } }, @@ -295,6 +298,7 @@ DockPage { SelectionFilterPanel { navigationSection: selectionFilterPanel.navigationSection + navigationOrderStart: selectionFilterPanel.contentNavigationPanelOrderStart } }, @@ -325,6 +329,7 @@ DockPage { MixerPanel { navigationSection: mixerPanel.navigationSection + contentNavigationPanelOrderStart: mixerPanel.contentNavigationPanelOrderStart Component.onCompleted: { mixerPanel.contextMenuModel = contextMenuModel @@ -360,6 +365,7 @@ DockPage { PianoKeyboardPanel { navigationSection: pianoKeyboardPanel.navigationSection + contentNavigationPanelOrderStart: pianoKeyboardPanel.contentNavigationPanelOrderStart Component.onCompleted: { pianoKeyboardPanel.contextMenuModel = contextMenuModel @@ -390,6 +396,7 @@ DockPage { Timeline { navigationSection: timelinePanel.navigationSection + contentNavigationPanelOrderStart: timelinePanel.contentNavigationPanelOrderStart } }, @@ -415,6 +422,7 @@ DockPage { DrumsetPanel { navigationSection: timelinePanel.navigationSection + contentNavigationPanelOrderStart: drumsetPanel.contentNavigationPanelOrderStart } } ] @@ -441,7 +449,7 @@ DockPage { statusBar: DockStatusBar { objectName: pageModel.statusBarName() - contentNavigationPanel: content.navigationPanel + navigationSection: content.navigationSection NotationStatusBar { id: content diff --git a/src/appshell/qml/NotationPage/NotationStatusBar.qml b/src/appshell/qml/NotationPage/NotationStatusBar.qml index 0065a62ded903..7bc34cc1ee65c 100644 --- a/src/appshell/qml/NotationPage/NotationStatusBar.qml +++ b/src/appshell/qml/NotationPage/NotationStatusBar.qml @@ -36,14 +36,15 @@ Item { id: model } - NavigationSection { + property NavigationSection navigationSection: NavigationSection { id: navSec name: "NotationStatusBar" enabled: root.enabled && root.visible order: 8 } - property NavigationPanel navigationPanel: NavigationPanel { + NavigationPanel { + id: navPanel name: "NotationStatusBar" enabled: root.enabled && root.visible order: 0 @@ -112,7 +113,7 @@ Item { transparent: true visible: statusBarRow.remainingSpace > width + concertPitchControl.width - navigation.panel: root.navigationPanel + navigation.panel: navPanel navigation.order: 1 onClicked: { @@ -133,7 +134,7 @@ Item { enabled: model.concertPitchItem.enabled visible: statusBarRow.remainingSpace > width - navigation.panel: root.navigationPanel + navigation.panel: navPanel navigation.order: 2 onToggleConcertPitchRequested: { @@ -151,7 +152,7 @@ Item { currentViewMode: model.currentViewMode availableViewModeList: model.availableViewModeList - navigation.panel: root.navigationPanel + navigation.panel: navPanel navigation.order: 3 onChangeCurrentViewModeRequested: function(newViewMode) { @@ -170,7 +171,7 @@ Item { maxZoomPercentage: model.maxZoomPercentage() availableZoomList: model.availableZoomList - navigationPanel: root.navigationPanel + navigationPanel: navPanel navigationOrderMin: 4 onChangeZoomPercentageRequested: function(newZoomPercentage) { @@ -200,7 +201,7 @@ Item { visible: !concertPitchControl.visible || !workspaceControl.visible - navigation.panel: root.navigationPanel + navigation.panel: navPanel navigation.order: zoomControl.navigationOrderMax + 1 menuModel: { diff --git a/src/framework/dockwindow/internal/dockbase.cpp b/src/framework/dockwindow/internal/dockbase.cpp index e0c8007da1717..20a01b3d4e1eb 100644 --- a/src/framework/dockwindow/internal/dockbase.cpp +++ b/src/framework/dockwindow/internal/dockbase.cpp @@ -355,14 +355,24 @@ void DockBase::setFloating(bool floating) m_dockWidget->setFloating(floating); } -void DockBase::setContentNavigationPanel(ui::NavigationPanel* panel) +void DockBase::setNavigationSection(ui::NavigationSection* section) { - if (m_contentNavigationPanel == panel) { + if (m_navigationSection == section) { return; } - m_contentNavigationPanel = panel; - emit contentNavigationPanelChanged(); + m_navigationSection = section; + emit navigationSectionChanged(); +} + +void DockBase::setContentNavigationPanelOrderStart(int order) +{ + if (m_contentNavigationPanelOrderStart == order) { + return; + } + + m_contentNavigationPanelOrderStart = order; + emit contentNavigationPanelOrderStartChanged(); } void DockBase::init() @@ -539,9 +549,14 @@ void DockBase::resize(int width, int height) applySizeConstraints(); } -muse::ui::NavigationPanel* DockBase::contentNavigationPanel() const +muse::ui::NavigationSection* DockBase::navigationSection() const +{ + return m_navigationSection; +} + +int DockBase::contentNavigationPanelOrderStart() const { - return m_contentNavigationPanel; + return m_contentNavigationPanelOrderStart; } void DockBase::componentComplete() diff --git a/src/framework/dockwindow/internal/dockbase.h b/src/framework/dockwindow/internal/dockbase.h index 157905b2fe69f..e27f412c34cd9 100644 --- a/src/framework/dockwindow/internal/dockbase.h +++ b/src/framework/dockwindow/internal/dockbase.h @@ -28,7 +28,7 @@ #include "../docktypes.h" #include "uicomponents/view/qmllistproperty.h" -#include "ui/view/navigationpanel.h" +#include "ui/view/navigationsection.h" namespace KDDockWidgets { class DockWidgetQuick; @@ -61,8 +61,8 @@ class DockBase : public QQuickItem Q_PROPERTY(bool inited READ inited NOTIFY initedChanged) - Q_PROPERTY(muse::ui::NavigationPanel * contentNavigationPanel READ contentNavigationPanel - WRITE setContentNavigationPanel NOTIFY contentNavigationPanelChanged) + Q_PROPERTY(muse::ui::NavigationSection * navigationSection READ navigationSection WRITE setNavigationSection NOTIFY navigationSectionChanged) + Q_PROPERTY(int contentNavigationPanelOrderStart READ contentNavigationPanelOrderStart NOTIFY contentNavigationPanelOrderStartChanged) public: DockBase(DockType type, QQuickItem* parent = nullptr); @@ -113,7 +113,8 @@ class DockBase : public QQuickItem Q_INVOKABLE void resize(int width, int height); - ui::NavigationPanel* contentNavigationPanel() const; + ui::NavigationSection* navigationSection() const; + int contentNavigationPanelOrderStart() const; public slots: void setTitle(const QString& title); @@ -135,7 +136,8 @@ public slots: void setFloating(bool floating); - void setContentNavigationPanel(ui::NavigationPanel* panel); + void setNavigationSection(ui::NavigationSection* section); + void setContentNavigationPanelOrderStart(int order); signals: void titleChanged(); @@ -156,7 +158,8 @@ public slots: void initedChanged(); - void contentNavigationPanelChanged(); + void navigationSectionChanged(); + void contentNavigationPanelOrderStartChanged(); protected: friend class DockWindow; @@ -200,7 +203,9 @@ private slots: bool m_inited = false; KDDockWidgets::DockWidgetQuick* m_dockWidget = nullptr; - ui::NavigationPanel* m_contentNavigationPanel = nullptr; + + ui::NavigationSection* m_navigationSection = nullptr; + int m_contentNavigationPanelOrderStart = 1; }; struct DropDestination diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockPage.qml b/src/framework/dockwindow/qml/Muse/Dock/DockPage.qml index a15ab6dd50772..d7c228bf3b80d 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockPage.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockPage.qml @@ -45,8 +45,8 @@ DockPageView { centralDock: DockCentralView { objectName: root.objectName + "_central" - contentNavigationPanel: Boolean(central.item) && Boolean(central.item.navigationPanel) ? - central.item.navigationPanel : null + navigationSection: Boolean(central.item) && Boolean(central.item.navigationSection) ? + central.item.navigationSection : null Loader { id: central diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockPanel.qml b/src/framework/dockwindow/qml/Muse/Dock/DockPanel.qml index 554527a9315c1..13e950682ae81 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockPanel.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockPanel.qml @@ -28,8 +28,8 @@ DockPanelView { default property alias contentComponent : contentLoader.sourceComponent - contentNavigationPanel: Boolean(contentLoader.item) && Boolean(contentLoader.item.navigationPanel) ? - contentLoader.item.navigationPanel : null + navigationSection: Boolean(contentLoader.item) && Boolean(contentLoader.item.navigationSection) ? + contentLoader.item.navigationSection : null Loader { id: contentLoader diff --git a/src/framework/dockwindow/qml/Muse/Dock/DockToolBar.qml b/src/framework/dockwindow/qml/Muse/Dock/DockToolBar.qml index c61cd9f3a7f71..1e866734e3861 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/DockToolBar.qml +++ b/src/framework/dockwindow/qml/Muse/Dock/DockToolBar.qml @@ -41,8 +41,8 @@ DockToolBarView { minimumWidth: root.inited ? Math.min(root.contentWidth, root.maximumWidth) : prv.minimumLength minimumHeight: root.inited ? Math.min(root.contentHeight, root.maximumHeight) : prv.minimumLength - contentNavigationPanel: Boolean(contentLoader.item) && Boolean(contentLoader.item.navigationPanel) ? - contentLoader.item.navigationPanel : null + navigationSection: Boolean(contentLoader.item) && Boolean(contentLoader.item.navigationSection) ? + contentLoader.item.navigationSection : null onFloatingChanged: { if (!root.floating) { diff --git a/src/framework/dockwindow/view/dockpageview.cpp b/src/framework/dockwindow/view/dockpageview.cpp index b4ef7fcbf4118..068c4eece593c 100644 --- a/src/framework/dockwindow/view/dockpageview.cpp +++ b/src/framework/dockwindow/view/dockpageview.cpp @@ -254,7 +254,7 @@ void DockPageView::doReorderSections() QList docksAvailableForNavigation; for (DockBase* dock: docks) { - if (dock->contentNavigationPanel() && dock->isVisible()) { + if (dock->navigationSection() && dock->isVisible()) { docksAvailableForNavigation.append(dock); } } @@ -265,7 +265,7 @@ void DockPageView::doReorderSections() void DockPageView::reorderDocksNavigationSections(QList& docks) { std::sort(docks.begin(), docks.end(), [this](DockBase* dock1, DockBase* dock2) { - if (!dock1->contentNavigationPanel() || !dock2->contentNavigationPanel()) { + if (!dock1->navigationSection() || !dock2->navigationSection()) { return false; } @@ -288,12 +288,7 @@ void DockPageView::reorderDocksNavigationSections(QList& docks) int i = 0; QHash > orderedSections; for (DockBase* dock: docks) { - muse::ui::NavigationPanel* panel = dock->contentNavigationPanel(); - if (!panel) { - continue; - } - - muse::ui::INavigationSection* section = panel->section(); + ui::INavigationSection* section = dock->navigationSection(); if (section && !orderedSections.contains(section)) { auto index = section->index(); index.setOrder(i++); @@ -311,7 +306,7 @@ void DockPageView::reorderDocksNavigationSections(QList& docks) void DockPageView::reorderNavigationSectionPanels(QList& sectionDocks) { std::sort(sectionDocks.begin(), sectionDocks.end(), [](DockBase* dock1, DockBase* dock2) { - if (!dock1->contentNavigationPanel() || !dock2->contentNavigationPanel()) { + if (!dock1->navigationSection() || !dock2->navigationSection()) { return false; } @@ -341,7 +336,7 @@ void DockPageView::reorderNavigationSectionPanels(QList& sectionDocks for (DockBase* dock: sectionDocks) { //!NOTE: It is possible that the dock contains multiple panels. //! Reserve n panels for each dock. - int order = i++ *100; + int order = i++ *1000; //! NOTE: If a panel is inside a frame with another panel, //! there is no need to set the order for the frame panel, as it is already set. @@ -357,7 +352,7 @@ void DockPageView::reorderNavigationSectionPanels(QList& sectionDocks dock->setFramePanelOrder(order); } - dock->contentNavigationPanel()->setOrder(order + 1); + dock->setContentNavigationPanelOrderStart(order + 1); } } diff --git a/src/framework/dockwindow/view/dockpanelview.cpp b/src/framework/dockwindow/view/dockpanelview.cpp index 89c483d89cf8f..faca506f003a8 100644 --- a/src/framework/dockwindow/view/dockpanelview.cpp +++ b/src/framework/dockwindow/view/dockpanelview.cpp @@ -210,21 +210,6 @@ void DockPanelView::componentComplete() }); } -QObject* DockPanelView::navigationSection() const -{ - return m_navigationSection; -} - -void DockPanelView::setNavigationSection(QObject* newNavigation) -{ - if (m_navigationSection == newNavigation) { - return; - } - - m_navigationSection = newNavigation; - emit navigationSectionChanged(); -} - AbstractMenuModel* DockPanelView::contextMenuModel() const { return m_menuModel->customMenuModel(); diff --git a/src/framework/dockwindow/view/dockpanelview.h b/src/framework/dockwindow/view/dockpanelview.h index 35c18ac06fad0..03823f71ac202 100644 --- a/src/framework/dockwindow/view/dockpanelview.h +++ b/src/framework/dockwindow/view/dockpanelview.h @@ -39,7 +39,6 @@ class DockPanelView : public DockBase Q_OBJECT Q_PROPERTY(QString groupName READ groupName WRITE setGroupName NOTIFY groupNameChanged) - Q_PROPERTY(QObject * navigationSection READ navigationSection WRITE setNavigationSection NOTIFY navigationSectionChanged) Q_PROPERTY( muse::uicomponents::AbstractMenuModel * contextMenuModel READ contextMenuModel WRITE setContextMenuModel NOTIFY contextMenuModelChanged) @@ -50,7 +49,6 @@ class DockPanelView : public DockBase ~DockPanelView() override; QString groupName() const; - QObject* navigationSection() const; uicomponents::AbstractMenuModel* contextMenuModel() const; QQmlComponent* toolbarComponent() const; @@ -60,13 +58,11 @@ class DockPanelView : public DockBase public slots: void setGroupName(const QString& name); - void setNavigationSection(QObject* newNavigation); void setContextMenuModel(uicomponents::AbstractMenuModel* model); void setToolbarComponent(QQmlComponent* component); signals: void groupNameChanged(); - void navigationSectionChanged(); void contextMenuModelChanged(); void toolbarComponentChanged(); @@ -74,7 +70,6 @@ public slots: void componentComplete() override; QString m_groupName; - QObject* m_navigationSection = nullptr; class DockPanelMenuModel; DockPanelMenuModel* m_menuModel = nullptr; diff --git a/src/inspector/view/qml/MuseScore/Inspector/InspectorForm.qml b/src/inspector/view/qml/MuseScore/Inspector/InspectorForm.qml index 8d6c5de2b0eab..d499a862948a3 100644 --- a/src/inspector/view/qml/MuseScore/Inspector/InspectorForm.qml +++ b/src/inspector/view/qml/MuseScore/Inspector/InspectorForm.qml @@ -35,8 +35,7 @@ Rectangle { property alias notationView: popupController.notationView property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: inspectorRepeater.count > 0 ? inspectorRepeater.itemAt(0).navigationPanel : null // first panel - property int navigationOrderStart: 0 + property int navigationOrderStart: 1 color: ui.theme.backgroundPrimaryColor @@ -126,11 +125,6 @@ Rectangle { anchorItem: root navigationPanel.section: root.navigationSection navigationPanel.order: root.navigationOrderStart + model.index - navigationPanel.onOrderChanged: { - if (model.index === 0) { - root.navigationOrderStart = navigationPanel.order - } - } onReturnToBoundsRequested: { flickableArea.returnToBounds() diff --git a/src/instrumentsscene/qml/MuseScore/InstrumentsScene/InstrumentsPanel.qml b/src/instrumentsscene/qml/MuseScore/InstrumentsScene/InstrumentsPanel.qml index 46824203a9df6..7c3ea22520853 100644 --- a/src/instrumentsscene/qml/MuseScore/InstrumentsScene/InstrumentsPanel.qml +++ b/src/instrumentsscene/qml/MuseScore/InstrumentsScene/InstrumentsPanel.qml @@ -34,7 +34,8 @@ Item { id: root property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: controlPanel.navigation // first panel + property int navigationOrderStart: 1 + property alias contextMenuModel: contextMenuModel onVisibleChanged: { @@ -92,7 +93,7 @@ Item { Layout.rightMargin: contentColumn.sideMargin navigation.section: root.navigationSection - navigation.order: 2 + navigation.order: root.navigationOrderStart isMovingUpAvailable: instrumentsTreeModel.isMovingUpAvailable isMovingDownAvailable: instrumentsTreeModel.isMovingDownAvailable diff --git a/src/notation/qml/MuseScore/NotationScene/NotationView.qml b/src/notation/qml/MuseScore/NotationScene/NotationView.qml index 462243156a279..9ed5bef34d0c4 100644 --- a/src/notation/qml/MuseScore/NotationScene/NotationView.qml +++ b/src/notation/qml/MuseScore/NotationScene/NotationView.qml @@ -44,7 +44,7 @@ FocusScope { property alias defaultNavigationControl: fakeNavCtrl - property NavigationPanel navigationPanel: tabPanel.navigationPanel // first panel + readonly property alias navigationSection: navSec NavigationSection { id: navSec @@ -116,7 +116,7 @@ FocusScope { if (fakeNavCtrl.active) { notationView.forceFocusIn() - if (navigationPanel.highlight) { + if (notationView.navigationPanel.highlight) { notationView.selectOnNavigationActive() } } else { diff --git a/src/notation/qml/MuseScore/NotationScene/PianoKeyboardPanel.qml b/src/notation/qml/MuseScore/NotationScene/PianoKeyboardPanel.qml index c4200382a56a8..afc78b8873c16 100644 --- a/src/notation/qml/MuseScore/NotationScene/PianoKeyboardPanel.qml +++ b/src/notation/qml/MuseScore/NotationScene/PianoKeyboardPanel.qml @@ -30,10 +30,12 @@ Item { property alias contextMenuModel: contextMenuModel - property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: NavigationPanel { + property alias navigationSection: navPanel.section + property alias contentNavigationPanelOrderStart: navPanel.order + + NavigationPanel { + id: navPanel name: "PianoKeyboardSection" - section: root.navigationSection direction: NavigationPanel.Vertical enabled: root.enabled && root.visible } diff --git a/src/notation/qml/MuseScore/NotationScene/SelectionFilterPanel.qml b/src/notation/qml/MuseScore/NotationScene/SelectionFilterPanel.qml index f215895c190d4..237fc6c84401a 100644 --- a/src/notation/qml/MuseScore/NotationScene/SelectionFilterPanel.qml +++ b/src/notation/qml/MuseScore/NotationScene/SelectionFilterPanel.qml @@ -31,12 +31,15 @@ Item { enabled: selectionFilterModel.enabled property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: NavigationPanel { + property int navigationOrderStart: 1 + + NavigationPanel { + id: navPanel name: "SelectionFilter" section: root.navigationSection direction: NavigationPanel.Vertical enabled: root.enabled && root.visible - order: 2 + order: root.navigationOrderStart } Component.onCompleted: { @@ -62,7 +65,7 @@ Item { text: model.title - navigation.panel: root.navigationPanel + navigation.panel: navPanel navigation.order: model.index checked: model.isSelected diff --git a/src/notation/qml/MuseScore/NotationScene/Timeline.qml b/src/notation/qml/MuseScore/NotationScene/Timeline.qml index fd47465e64cc9..fef308264f92d 100644 --- a/src/notation/qml/MuseScore/NotationScene/Timeline.qml +++ b/src/notation/qml/MuseScore/NotationScene/Timeline.qml @@ -28,10 +28,12 @@ import MuseScore.NotationScene 1.0 Item { id: root - property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: NavigationPanel { + property alias navigationSection: navPanel.section + property alias contentNavigationPanelOrderStart: navPanel.order + + NavigationPanel { + id: navPanel name: "TimelineSection" - section: root.navigationSection direction: NavigationPanel.Vertical enabled: root.enabled && root.visible } diff --git a/src/palette/qml/MuseScore/Palette/DrumsetPanel.qml b/src/palette/qml/MuseScore/Palette/DrumsetPanel.qml index 4caa9114fb7ce..122110d328593 100644 --- a/src/palette/qml/MuseScore/Palette/DrumsetPanel.qml +++ b/src/palette/qml/MuseScore/Palette/DrumsetPanel.qml @@ -29,10 +29,12 @@ import MuseScore.Palette 1.0 Item { id: root - property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: NavigationPanel { + property alias navigationSection: navPanel.section + property alias contentNavigationPanelOrderStart: navPanel.order + + NavigationPanel { + id: navPanel name: "DrumsetSection" - section: root.navigationSection direction: NavigationPanel.Vertical enabled: root.enabled && root.visible } diff --git a/src/palette/qml/MuseScore/Palette/PalettesPanel.qml b/src/palette/qml/MuseScore/Palette/PalettesPanel.qml index e214803c13839..fb9d96d3ea137 100644 --- a/src/palette/qml/MuseScore/Palette/PalettesPanel.qml +++ b/src/palette/qml/MuseScore/Palette/PalettesPanel.qml @@ -34,7 +34,7 @@ Item { id: root property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: palettesPanelHeader.navigation // first panel + property int navigationOrderStart: 1 property alias contextMenuModel: contextMenuModel @@ -93,7 +93,7 @@ Item { popupAnchorItem: root navigation.section: root.navigationSection - navigation.order: 2 + navigation.order: root.navigationOrderStart onAddCustomPaletteRequested: function(paletteName) { paletteTree.insertCustomPalette(0, paletteName) diff --git a/src/playback/qml/MuseScore/Playback/MixerPanel.qml b/src/playback/qml/MuseScore/Playback/MixerPanel.qml index 0ec15834d5e70..ff1248f2239ff 100644 --- a/src/playback/qml/MuseScore/Playback/MixerPanel.qml +++ b/src/playback/qml/MuseScore/Playback/MixerPanel.qml @@ -33,15 +33,15 @@ import "internal" ColumnLayout { id: root + property NavigationSection navigationSection: null + property int contentNavigationPanelOrderStart: 1 + property alias contextMenuModel: contextMenuModel property Component toolbarComponent: MixerPanelToolbar { navigation.section: root.navigationSection - navigation.order: 1 + navigation.order: root.contentNavigationPanelOrderStart } - property NavigationSection navigationSection: null - property NavigationPanel navigationPanel: mixerPanelModel.count > 0 ? mixerPanelModel.get(0).channelItem.panel : null // first panel - signal resizeRequested(var newWidth, var newHeight) spacing: 0 @@ -76,6 +76,7 @@ ColumnLayout { id: mixerPanelModel navigationSection: root.navigationSection + navigationOrderStart: root.contentNavigationPanelOrderStart + 1 // +1 for toolbar Component.onCompleted: { mixerPanelModel.load() diff --git a/src/playback/view/mixerpanelmodel.cpp b/src/playback/view/mixerpanelmodel.cpp index 09bc55ee593c7..d4dd2887abc3b 100644 --- a/src/playback/view/mixerpanelmodel.cpp +++ b/src/playback/view/mixerpanelmodel.cpp @@ -236,25 +236,8 @@ void MixerPanelModel::updateItemsPanelsOrder() { TRACEFUNC; - muse::ui::NavigationPanel* previousPanel = nullptr; - for (MixerChannelItem* item : m_mixerChannelList) { - disconnect(item->panel(), &muse::ui::NavigationPanel::orderChanged, this, nullptr); - } - for (int i = 0; i < m_mixerChannelList.size(); i++) { - m_mixerChannelList[i]->setPanelOrder(i); - - if (previousPanel) { - disconnect(previousPanel, &muse::ui::NavigationPanel::orderChanged, this, nullptr); - - connect(previousPanel, &muse::ui::NavigationPanel::orderChanged, this, [this, i](int order){ - if (i < m_mixerChannelList.count()) { - m_mixerChannelList[i]->setPanelOrder(order + 1); - } - }); - } - - previousPanel = m_mixerChannelList[i]->panel(); + m_mixerChannelList[i]->setPanelOrder(m_navigationOrderStart + i); } } @@ -659,3 +642,20 @@ void MixerPanelModel::setNavigationSection(muse::ui::NavigationSection* navigati m_navigationSection = navigationSection; emit navigationSectionChanged(); } + +int MixerPanelModel::navigationOrderStart() const +{ + return m_navigationOrderStart; +} + +void MixerPanelModel::setNavigationOrderStart(int navigationOrderStart) +{ + if (m_navigationOrderStart == navigationOrderStart) { + return; + } + + m_navigationOrderStart = navigationOrderStart; + emit navigationOrderStartChanged(); + + updateItemsPanelsOrder(); +} diff --git a/src/playback/view/mixerpanelmodel.h b/src/playback/view/mixerpanelmodel.h index cccc6bbdda701..d068501c0b9fc 100644 --- a/src/playback/view/mixerpanelmodel.h +++ b/src/playback/view/mixerpanelmodel.h @@ -49,6 +49,7 @@ class MixerPanelModel : public QAbstractListModel, public muse::async::Asyncable Q_PROPERTY( muse::ui::NavigationSection * navigationSection READ navigationSection WRITE setNavigationSection NOTIFY navigationSectionChanged) + Q_PROPERTY(int navigationOrderStart READ navigationOrderStart WRITE setNavigationOrderStart NOTIFY navigationOrderStartChanged) Q_PROPERTY(int count READ rowCount NOTIFY rowCountChanged) @@ -65,8 +66,12 @@ class MixerPanelModel : public QAbstractListModel, public muse::async::Asyncable muse::ui::NavigationSection* navigationSection() const; void setNavigationSection(muse::ui::NavigationSection* navigationSection); + int navigationOrderStart() const; + void setNavigationOrderStart(int navigationOrderStart); + signals: void navigationSectionChanged(); + void navigationOrderStartChanged(); void rowCountChanged(); private: @@ -107,6 +112,7 @@ class MixerPanelModel : public QAbstractListModel, public muse::async::Asyncable muse::audio::TrackSequenceId m_currentTrackSequenceId = -1; muse::ui::NavigationSection* m_navigationSection = nullptr; + int m_navigationOrderStart = 1; }; } From 0b8c496281e9914e0610e5f5f01a9e667a3f9077 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 1 Apr 2024 06:02:10 +0200 Subject: [PATCH 06/10] Fix typo --- src/appshell/qml/NotationPage/NotationPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appshell/qml/NotationPage/NotationPage.qml b/src/appshell/qml/NotationPage/NotationPage.qml index fa166dcc91d4a..4c04b35d279c1 100644 --- a/src/appshell/qml/NotationPage/NotationPage.qml +++ b/src/appshell/qml/NotationPage/NotationPage.qml @@ -421,7 +421,7 @@ DockPage { navigationSection: root.navigationPanelSec(drumsetPanel.location) DrumsetPanel { - navigationSection: timelinePanel.navigationSection + navigationSection: drumsetPanel.navigationSection contentNavigationPanelOrderStart: drumsetPanel.contentNavigationPanelOrderStart } } From 203c4a8e4a17cd73a6330920adfb63883a842032 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 1 Apr 2024 06:05:22 +0200 Subject: [PATCH 07/10] Fix navigation in toolbars --- .../qml/NotationPage/NotationPage.qml | 17 ++++++++++---- src/appshell/qml/PublishPage/PublishPage.qml | 23 +++++++++++++++---- src/appshell/qml/WindowContent.qml | 4 +++- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/appshell/qml/NotationPage/NotationPage.qml b/src/appshell/qml/NotationPage/NotationPage.qml index 4c04b35d279c1..03475a7f814c1 100644 --- a/src/appshell/qml/NotationPage/NotationPage.qml +++ b/src/appshell/qml/NotationPage/NotationPage.qml @@ -115,6 +115,8 @@ DockPage { objectName: "notationToolBar" title: qsTrc("appshell", "Notation toolbar") + navigationSection: root.topToolKeyNavSec + floatable: false closable: false resizable: false @@ -124,7 +126,7 @@ DockPage { contentBottomPadding: 2 NotationToolBar { - navigationPanel.section: root.topToolKeyNavSec + navigationPanel.section: notationToolBar.navigationSection navigationPanel.order: 2 } }, @@ -135,6 +137,8 @@ DockPage { objectName: pageModel.playbackToolBarName() title: qsTrc("appshell", "Playback controls") + navigationSection: root.topToolKeyNavSec + separatorsVisible: false alignment: DockToolBarAlignment.Right @@ -146,7 +150,7 @@ DockPage { ] PlaybackToolBar { - navigationPanelSection: root.topToolKeyNavSec + navigationPanelSection: playbackToolBar.navigationSection navigationPanelOrder: 3 floating: playbackToolBar.floating @@ -154,9 +158,12 @@ DockPage { }, DockToolBar { + id: undoRedoToolBar objectName: pageModel.undoRedoToolBarName() title: qsTrc("appshell", "Undo/redo") + navigationSection: root.topToolKeyNavSec + floatable: false closable: false resizable: false @@ -166,7 +173,7 @@ DockPage { contentBottomPadding: 2 UndoRedoToolBar { - navigationPanel.section: root.topToolKeyNavSec + navigationPanel.section: undoRedoToolBar.navigationSection navigationPanel.order: 4 } } @@ -179,6 +186,8 @@ DockPage { objectName: pageModel.noteInputBarName() title: qsTrc("appshell", "Note input") + navigationSection: root.noteInputKeyNavSec + dropDestinations: [ root.toolBarTopDropDestination, root.toolBarBottomDropDestination, @@ -195,7 +204,7 @@ DockPage { maximumWidth: noteInputBar.width maximumHeight: noteInputBar.height - navigationPanel.section: root.noteInputKeyNavSec + navigationPanel.section: noteInputBar.navigationSection navigationPanel.order: 1 } } diff --git a/src/appshell/qml/PublishPage/PublishPage.qml b/src/appshell/qml/PublishPage/PublishPage.qml index 84498e560fdd3..a48773d87b306 100644 --- a/src/appshell/qml/PublishPage/PublishPage.qml +++ b/src/appshell/qml/PublishPage/PublishPage.qml @@ -54,6 +54,8 @@ DockPage { objectName: root.objectName + "_notationToolBar" title: qsTrc("appshell", "Notation toolbar") + navigationSection: root.topToolKeyNavSec + floatable: false closable: false resizable: false @@ -63,7 +65,7 @@ DockPage { contentBottomPadding: 2 NotationToolBar { - navigationPanel.section: root.topToolKeyNavSec + navigationPanel.section: notationToolBar.navigationSection navigationPanel.order: 2 } }, @@ -74,12 +76,14 @@ DockPage { objectName: root.objectName + "_playbackToolBar" title: qsTrc("appshell", "Playback controls") + navigationSection: root.topToolKeyNavSec + separatorsVisible: false alignment: DockToolBarAlignment.Right contentBottomPadding: 2 PlaybackToolBar { - navigationPanelSection: root.topToolKeyNavSec + navigationPanelSection: playbackToolBar.navigationSection navigationPanelOrder: 3 floating: playbackToolBar.floating @@ -92,6 +96,8 @@ DockPage { objectName: root.objectName + "_undoRedoToolBar" title: qsTrc("appshell", "Undo/redo toolbar") + navigationSection: root.topToolKeyNavSec + floatable: false closable: false resizable: false @@ -101,7 +107,7 @@ DockPage { contentBottomPadding: 2 UndoRedoToolBar { - navigationPanel.section: root.topToolKeyNavSec + navigationPanel.section: undoRedoToolBar.navigationSection navigationPanel.order: 4 } } @@ -109,12 +115,15 @@ DockPage { toolBars: [ DockToolBar { + id: publishToolBar objectName: "publishToolBar" + navigationSection: root.publishToolBarKeyNavSec + floatable: false PublishToolBar { - navigationPanel.section: root.publishToolBarKeyNavSec + navigationPanel.section: publishToolBar.navigationSection navigationPanel.order: 1 } } @@ -128,6 +137,10 @@ DockPage { statusBar: DockStatusBar { objectName: "publishStatusBar" - NotationStatusBar {} + navigationSection: content.navigationSection + + NotationStatusBar { + id: content + } } } diff --git a/src/appshell/qml/WindowContent.qml b/src/appshell/qml/WindowContent.qml index ae871f06bae43..7593b4b20fdd3 100644 --- a/src/appshell/qml/WindowContent.qml +++ b/src/appshell/qml/WindowContent.qml @@ -65,9 +65,11 @@ DockWindow { floatable: false closable: false + navigationSection: root.topToolKeyNavSec + MainToolBar { id: toolBar - navigation.section: root.topToolKeyNavSec + navigation.section: mainToolBar.navigationSection navigation.order: 1 currentUri: root.currentPageUri From 82ecf34cb86706480aa8e7680f87efa269ecbc3c Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 1 Apr 2024 06:10:08 +0200 Subject: [PATCH 08/10] Hide Mixer toolbar button until it's fully implemented --- .../qml/MuseScore/Playback/internal/MixerPanelToolbar.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml b/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml index 490ae9f5a5aa2..1ba72381ef099 100644 --- a/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml +++ b/src/playback/qml/MuseScore/Playback/internal/MixerPanelToolbar.qml @@ -37,6 +37,8 @@ Item { enabled: root.enabled && root.visible } + // TODO: https://github.com/musescore/MuseScore/issues/16722 + /* FlatButton { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right @@ -49,4 +51,5 @@ Item { navigation.panel: navPanel navigation.row: 0 } + */ } From c2ab2d76d31967d84ac34118cd9c907b0c7e4d69 Mon Sep 17 00:00:00 2001 From: Eism Date: Thu, 8 Aug 2024 16:32:23 +0200 Subject: [PATCH 09/10] Fixed crash reset toolbarComponent when destroying panel --- src/appshell/qml/NotationPage/NotationPage.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/appshell/qml/NotationPage/NotationPage.qml b/src/appshell/qml/NotationPage/NotationPage.qml index 03475a7f814c1..6f4d671618e0f 100644 --- a/src/appshell/qml/NotationPage/NotationPage.qml +++ b/src/appshell/qml/NotationPage/NotationPage.qml @@ -345,6 +345,11 @@ DockPage { mixerPanel.toolbarComponent = toolbarComponent } + Component.onDestruction: { + mixerPanel.contextMenuModel = null + mixerPanel.toolbarComponent = null + } + onResizeRequested: function(newWidth, newHeight) { mixerPanel.resize(newWidth, newHeight) } From f40721a6410de29cdcac134cfd0296cb41923b8c Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Sat, 10 Aug 2024 01:49:35 +0200 Subject: [PATCH 10/10] Add new components to Muse/Dock/qmldir Turns out to be necessary after rebase --- src/framework/dockwindow/qml/Muse/Dock/qmldir | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/framework/dockwindow/qml/Muse/Dock/qmldir b/src/framework/dockwindow/qml/Muse/Dock/qmldir index b4033341e3937..3f107c0b819f3 100644 --- a/src/framework/dockwindow/qml/Muse/Dock/qmldir +++ b/src/framework/dockwindow/qml/Muse/Dock/qmldir @@ -1,7 +1,9 @@ module Muse.Dock DockPage 1.0 DockPage.qml -DockToolBar 1.0 DockToolBar.qml DockPanel 1.0 DockPanel.qml DockPanelTab 1.0 DockPanelTab.qml -DockingHolder 1.0 DockingHolder.qml +DockTabBar 1.0 DockTabBar.qml DockTitleBar 1.0 DockTitleBar.qml +DockTitleBarMouseArea 1.0 DockTitleBarMouseArea.qml +DockToolBar 1.0 DockToolBar.qml +DockingHolder 1.0 DockingHolder.qml