Skip to content
Snippets Groups Projects
ScoreMenuContent.qml 4.38 KiB
Newer Older
/** This file is part of Nootka (http://nootka.sf.net)               *
 * Copyright (C) 2017-2021 by Tomasz Bojczuk (seelook@gmail.com)     *
 * on the terms of GNU GPLv3 license (http://www.gnu.org/licenses)   */

SeeLook's avatar
SeeLook committed
import Nootka 1.0
import QtQuick 2.12
import QtQuick.Controls 2.12
SeeLook's avatar
SeeLook committed
Tmenu {
    id: menu
SeeLook's avatar
SeeLook committed
    property var rGlyphs: ["#", "b", "C", "D", "E", "F", "G", "\ue109", ".", "\ue18c"]

    x: NOO.isAndroid() ? (nootkaWindow.width - width) / 2 : toolBar.scoreAct.x
    y: NOO.isAndroid() ? (nootkaWindow.height - height) / 2 : score.y
    onAboutToShow: SOUND.stopListen()
    onAboutToHide: SOUND.startListen()

    Repeater {
        model: score.scoreActions

        MenuItem {
            padding: 0
            width: menu.width
            enabled: modelData.enabled

            contentItem: MenuButton {
                action: modelData
                onClicked: close()

                Rectangle {
                    width: parent.width
                    height: index === score.scoreActions.length - 1 ? 0 : 1
                    color: activPal.text
                    y: parent.height - 1
                }

            }

        }
SeeLook's avatar
SeeLook committed

    Connections {
        target: score.notesMenuAct
        function onTriggered() : void {
SeeLook's avatar
SeeLook committed
            notesLoader.active = true;
            notesLoader.item.open();
            close();
        }
SeeLook's avatar
SeeLook committed

    Loader {
        id: notesLoader

        sourceComponent: notesComp
        active: false
    }

    Component {
        id: notesComp

        Tmenu {
            id: noteMenu

            parent: menu.parent
            x: menu.x + menu.width / 4
            y: score.y + menu.width / 8

            Repeater {
                model: score.noteActions

                MenuItem {
                    padding: 0
                    width: menu.width

                    contentItem: MenuButton {
                        id: mb

                        action: modelData
                        onClicked: close()

                        Rectangle {
                            width: parent.width
                            height: index === score.noteActions.length - 1 ? 0 : 1
                            color: activPal.text
                            y: parent.height - 1
                        }

                        Text {
                            text: rGlyphs[index]
                            color: activPal.text
                            x: (NOO.factor() * 3.2 - width) / 2
                            anchors.verticalCenter: parent.verticalCenter
                            scale: GLOB.useAnimations && !mb.containsPress && mb.containsMouse ? 1.4 : 1

                            font {
                                pixelSize: NOO.factor() * 1.5
                                family: "nootka"
                            }

                            Behavior on scale {
                                enabled: GLOB.useAnimations

                                NumberAnimation {
                                    duration: 150
                                }

                            }

                        }

                    }

                }

SeeLook's avatar
SeeLook committed
        // Component
SeeLook's avatar
SeeLook committed

    Connections {
        target: score.transposeAct
        function onTriggered() : void {
            let tPop = transComp.createObject(nootkaWindow);
SeeLook's avatar
SeeLook committed
            tPop.initKey = score.keySignature;
            close();
        }
SeeLook's avatar
SeeLook committed

    Component {
        id: transComp

        TpopupDialog {
            id: transPopup

            property alias initKey: transpose.initialKey

            visible: true
            modal: true
            width: transpose.width + NOO.factor()
            height: transpose.height + NOO.factor() * 8
            caption: NOO.TR("Transpose", "Transpose")
            onClosed: destroy()
            onAccepted: {
                if (transpose.toKey || transpose.byInterval) {
                    if (transpose.toKey)
                        score.keySignature = transpose.selectedKey;

                    var sObj = score.scoreObj;
                    sObj.transpose(transpose.outShift, transpose.outScaleToRest, transpose.inInstrumentScale ? GLOB.loNote() : sObj.lowestNote(), transpose.inInstrumentScale ? GLOB.hiNote() : sObj.highestNote());
                }
            }

            Transpose {
                id: transpose

                headerVisible: false
            }