Skip to content
Snippets Groups Projects
MainScore.qml 5.73 KiB
Newer Older
/** This file is part of Nootka (http://nootka.sf.net)               *
 * Copyright (C) 2017-2018 by Tomasz Bojczuk (seelook@gmail.com)     *
 * on the terms of GNU GPLv3 license (http://www.gnu.org/licenses)   */
SeeLook's avatar
SeeLook committed
import QtQuick 2.9
import QtQuick.Controls 2.2
  property alias showNamesAct: mainObj.showNamesAct
  property alias extraAccidsAct: mainObj.extraAccidsAct
  property alias zoomInAct: mainObj.zoomInAct
  property alias zoomOutAct: mainObj.zoomOutAct
  property alias openXmlAct: mainObj.openXmlAct
  property alias saveXmlAct: mainObj.saveXmlAct
  property alias deleteLastAct: mainObj.deleteLastAct
  property alias clearScoreAct: mainObj.clearScoreAct
  property alias recModeAct: mainObj.recModeAct
  property alias playAct: mainObj.playAct
  property alias scoreActions: mainObj.scoreActions
  scoreObj.meter: GLOB.rhythmsEnabled && !GLOB.singleNoteMode ? Tmeter.Meter_4_4 : Tmeter.NoMeter
  onFocusChanged: {
    if (!focus) // FIXME: space key is stolen if any dialog/popup is invoked, this workaround avoids that but side effects are unknown yet
      focus = true
  }

  enableDoubleAccids: GLOB.enableDoubleAccids
  scoreObj.showNoteNames: GLOB.namesOnScore
  scoreObj.nameColor: GLOB.nameColor
  scoreObj.nameStyle: GLOB.noteNameStyle
  scoreObj.enableDoubleAccidentals: GLOB.enableDoubleAccids
  scoreObj.enharmNotesEnabled: GLOB.showEnharmNotes
  scoreObj.enableTechnical: GLOB.instrument.type === Tinstrument.Bandoneon
    deleteLastAct.shortcut: Shortcut { sequence: "Del"; enabled: !GLOB.singleNoteMode && !readOnly }
    clearScoreAct.shortcut: Shortcut { sequence: "Shift+Del"; enabled: !GLOB.singleNoteMode && !readOnly }
    openXmlAct.shortcut: Shortcut { sequence: StandardKey.Open; enabled: !GLOB.singleNoteMode && !GLOB.isExam }
    saveXmlAct.shortcut: Shortcut { sequence: StandardKey.Save; enabled: !GLOB.singleNoteMode && !GLOB.isExam }
    zoomOutAct.shortcut: Shortcut { sequence: StandardKey.ZoomOut; enabled: !GLOB.singleNoteMode }
    zoomInAct.shortcut: Shortcut { sequence: StandardKey.ZoomIn; enabled: !GLOB.singleNoteMode }
    recModeAct.text: recordMode ? qsTr("Note by note") : qsTr("Edit")
    recModeAct.icon: recordMode ? "record" : "stopMelody"
  }

  Timer { id: zoomTimer; interval: 500 }
  MouseArea {
    anchors.fill: parent
    z: -1
    onWheel: {
      if (wheel.modifiers & Qt.ControlModifier) {
          if (wheel.angleDelta.y > 0) {
              if (!zoomTimer.running) {
                zoomInAct.trigger()
                zoomTimer.running = true
              }
          } else if (wheel.angleDelta.y < 0) {
              if (!zoomTimer.running) {
                zoomOutAct.trigger()
                zoomTimer.running = true
              }
          }
      } else
          wheel.accepted = false
  Text {
    id: keyName
    parent: firstStaff
    visible: GLOB.showKeyName && enableKeySign
    x: clef === Tclef.PianoStaffClefs ? 7.5 : 5.5
    y: clef === Tclef.PianoStaffClefs ? 3.7 : 6.2
    text: GLOB.showKeyName && enableKeySign ? mainObj.keyNameText : ""
  Connections {
    target: SOUND
    onInitialized: {
      singleNote = Qt.binding(function() { return GLOB.singleNoteMode })
      scoreObj.allowAdding = Qt.binding(function() { return !GLOB.singleNoteMode })
      enableKeySign = Qt.binding(function() { return GLOB.keySignatureEnabled })
    onClefTypeChanged: score.clef = GLOB.clefType
  Connections {
    target: GLOB.tuning
    onScordatureChanged: updateScord()
  }
  function updateScord() {
    if (scordature) {
      scordature.destroy()
      scordature = null
    }
    if (GLOB.tuning.scordature && GLOB.instrument.isGuitar && GLOB.instrument.type !== Tinstrument.BassGuitar) {
        var c = Qt.createComponent("qrc:/score/Scordature.qml")
        scordature = c.createObject(firstStaff)
        firstStaff.scordSpace = scordature.height
    } else
        firstStaff.scordSpace = 0
  }
        var c = Qt.createComponent("qrc:/score/NotePrompt.qml")
        notePrompt = c.createObject(scoreObj.note(0))
    } else
        notePrompt.destroy()
  }

    visible: currentNote != null && !singleNote
    width: currentNote ? (currentNote.width - currentNote.alterWidth) * 1.5 : 0
    height: currentNote ? Math.min(12.0, currentNote.notePosY + 6.0) : 0
    x: currentNote ? -width * 0.25 : 0
    y: currentNote ? Math.min(currentNote.height - height, Math.max(0.0, currentNote.notePosY - height / 2.0)) : 0
    color: Noo.alpha(activPal.highlight, 75)
    sequence: StandardKey.MoveToNextChar;
    onActivated: {
      if (currentNote)
        currentNote = scoreObj.getNext(currentNote)
      else
        currentNote = scoreObj.note(0)
    sequence: StandardKey.MoveToPreviousChar;
    onActivated: {
      if (currentNote)
        currentNote = scoreObj.getPrev(currentNote)
      else
        currentNote = scoreObj.note(notesCount - 1)
  Keys.onSpacePressed: {
    if (!GLOB.singleNoteMode && !GLOB.isExam) {
      if (event.modifiers & Qt.ControlModifier)
        recModeAct.triggered()
      else
        playAct.triggered()
    }