import QtQuick 2.6 import QtQuick.Controls 2.1 import QtQuick.Window 2.2 import MuseScore 3.0 import MuseScore.Dock 1.0 as MUDock MuseScore { id: dockplugin title: "Dock plugin (test)" categoryCode: "test"; version: "0.5.0" description: "Simple guitar fretboard to visualise and edit tablature scores" requiresScore: false // pluginType: "dock" // dockArea: "bottom" readonly property string pluginPanelObjectName: "DockPluginDockPanel" Component { id: pluginDockComponent MUDock.DockPanelView { id: dockPanelView property var root: null objectName: pluginPanelObjectName title: "Dock plugin" height: 300 minimumHeight: root.horizontalPanelMinHeight maximumHeight: root.horizontalPanelMaxHeight groupName: root.horizontalPanelsGroup visible: false location: MUDock.Location.Bottom dropDestinations: root.horizontalPanelDropDestinations navigationSection: root.navigationPanelSec(dockPanelView.location) Text { anchors.fill: parent text: "Dock plugin content!" } } } function findChild(item, objectName) { var children = item.children; for (var i = 0; i < children.length; ++i) { if (children[i].objectName == objectName) { return children[i]; } } for (var i = 0; i < children.length; ++i) { var obj = findChild(children[i], objectName); if (obj) { return obj; } } return null; } onRun: { //openLog("dock-plugin.log"); //log2("ui ", (ui ? ui.toString() : "null")); //log2("api ", (api ? api.toString() : "null")); var root = ui.rootItem; var windowContent = findChild(root, "WindowContent"); var notationPage = null; if (windowContent) { for (var i = 0; i < windowContent.pages.length; ++i) { var page = windowContent.pages[i]; if (page.objectName == "Notation") { notationPage = page; break; } } } //log2("root ", (root ? root.toString() : "null")); //log2("WindowContent ", (windowContent ? windowContent.toString() : "null")); //log2("notationPage ", (notationPage ? notationPage.toString() : "null")); if (notationPage) { var pluginDockPanel = null; var pianoKeyboard = null; var pianoKeyboardObjectName = notationPage.pageModel.pianoKeyboardPanelName(); for (var i = 0; i < notationPage.panels.length; ++i) { var panel = notationPage.panels[i]; if (panel.objectName == pluginPanelObjectName) { pluginDockPanel = panel; } else if (panel.objectName == pianoKeyboardObjectName) { pianoKeyboard = panel; } } //log2("piano ", (pianoKeyboard ? pianoKeyboard.toString() : "null")); if (!pluginDockPanel) { pluginDockPanel = pluginDockComponent.createObject(notationPage, {root: notationPage}); notationPage.panels.push(pluginDockPanel); } if (pluginDockPanel.visible) { // Already visible. } else if (pianoKeyboard) { var wasPianoKeyboardHidden = !pianoKeyboard.visible; // Need to show a dock widget at the bottom. Otherwise our dock widget would start with a floating state. if (wasPianoKeyboardHidden) { cmd("toggle-piano-keyboard"); } var pluginDockPanelObjectName = pluginDockPanel.objectName; pianoKeyboard.objectName = "tmp"; pluginDockPanel.objectName = pianoKeyboardObjectName; cmd("toggle-piano-keyboard"); pluginDockPanel.objectName = pluginDockPanelObjectName; pianoKeyboard.objectName = pianoKeyboardObjectName; if (wasPianoKeyboardHidden) { cmd("toggle-piano-keyboard"); } } } //closeLog(); } }