Skip to content

Commit

Permalink
add custom string tuning entry to all the plucked string instruments
Browse files Browse the repository at this point in the history
TODO: test all instruments and remember entered values using a completion
  • Loading branch information
wbsoft committed Feb 11, 2014
1 parent 214be18 commit af4452f
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions frescobaldi_app/scorewiz/parts/plucked_strings.py
Expand Up @@ -25,7 +25,10 @@

import __builtin__

from PyQt4.QtGui import QCheckBox, QComboBox, QGridLayout, QHBoxLayout, QLabel, QSpinBox
from PyQt4.QtGui import (
QCheckBox, QComboBox, QGridLayout, QHBoxLayout, QLabel,
QLineEdit, QSpinBox,
)

import listmodel
import ly.dom
Expand Down Expand Up @@ -64,13 +67,17 @@ def createTuningWidgets(self, layout):
self.tuningLabel.setBuddy(self.tuning)
tunings = [('', lambda: _("Default"))]
tunings.extend(self.tunings)
tunings.append(('', lambda: _("Custom")))
self.tuning.setModel(listmodel.ListModel(tunings, self.tuning,
display=listmodel.translate_index(1)))
self.tuning.setCurrentIndex(1)
self.customTuning = QLineEdit(enabled=False)
self.tuning.currentIndexChanged.connect(self.slotCustomTuningEnable)
box = QHBoxLayout()
layout.addLayout(box)
box.addWidget(self.tuningLabel)
box.addWidget(self.tuning)
layout.addWidget(self.customTuning)

def translateWidgets(self):
self.staffTypeLabel.setText(_("Staff type:"))
Expand All @@ -80,6 +87,15 @@ def translateWidgets(self):

def translateTuningWidgets(self):
self.tuningLabel.setText(_("Tuning:"))
self.customTuning.setToolTip('<qt>' + _(
"Select custom tuning in the combobox and "
"enter a custom tuning here, e.g. <code>e, a d g b e'</code>. "
"Use the same language for note names as you want to use in your "
"document (by default: \"nederlands\")."))
try:
self.customTuning.setPlaceholderText(_("Custom tuning..."))
except AttributeError:
pass # only in Qt 4.7+
self.tuning.model().update()

def slotTabEnable(self, enable):
Expand All @@ -89,6 +105,13 @@ def slotTabEnable(self, enable):
"""
self.tuning.setEnabled(bool(enable))
if enable:
self.slotCustomTuningEnable(self.tuning.currentIndex())
else:
self.customTuning.setEnabled(False)

def slotCustomTuningEnable(self, index):
self.customTuning.setEnabled(index > len(self.tunings))

def voiceCount(self):
"""Returns the number of voices.
Expand Down Expand Up @@ -163,9 +186,16 @@ def build(self, data, builder):
data.nodes.append(p)

def setTunings(self, tab):
if self.tunings and self.tuning.currentIndex() > 0:
tuning = self.tunings[self.tuning.currentIndex() - 1][0]
tab.getWith()['stringTunings'] = ly.dom.Scheme(tuning)
if self.tunings:
i = self.tuning.currentIndex()
if i == 0:
return
elif i > len(self.tunings):
value = ly.dom.Text("\\stringTuning <{0}>".format(self.customTuning.text()))
else:
tuning = self.tunings[self.tuning.currentIndex() - 1][0]
value = ly.dom.Scheme(tuning)
tab.getWith()['stringTunings'] = value


tablatureStaffTypes = (
Expand Down

1 comment on commit af4452f

@fedelibre
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, it works great!
You may want to add in the tooltip that notes must be entered in absolute mode.

Please sign in to comment.