Browse Source

Use german note names when German locale is used

master
Nils 3 years ago
parent
commit
1fa4a67324
  1. 2
      engine/api.py
  2. 16
      engine/main.py
  3. 1
      qtgui/mainwindow.py
  4. 1
      template/qtgui/mainwindow.py

2
engine/api.py

@ -230,7 +230,7 @@ def updatePlayback():
cbox.Document.get_song().update_playback()
def startEngine(nsmClient):
_templateStartEngine(nsmClient)
_templateStartEngine(nsmClient) #loads save files or creates empty structure.
session.inLoopMode = None # remember if we are in loop mode or not. Positive value is None or a tuple with start and end

16
engine/main.py

@ -66,6 +66,7 @@ class Data(template.engine.sequencer.Score):
#Create three tracks with their first pattern activated, so 'play' after startup already produces sounding notes. This is less confusing for a new user.
#self.tracks is created in the template.
self._emptyFile = True
self.addTrack(name="Melody A", color="#ffff00")
self.addTrack(name="Chords A", color="#0055ff")
self.addTrack(name="Bass A", color="#00ff00")
@ -107,6 +108,19 @@ class Data(template.engine.sequencer.Score):
self.sortTracks()
self._duringFileLoadGroupIndicator = False
def setLanguageForEmptyFile(self, language):
"""Only use in api.startEngine. Overrides the empty.
language is the summarized language string from Qt, like "German" which covers
de_DE, _AT and _CH. If another GUI is used in the future it needs to send these as well."""
if self._emptyFile:
if language in simpleNoteNames:
logger.info("Setting language for empty / new file to " + language)
self.lastUsedNotenames = simpleNoteNames[language]
self.tracks[0].pattern.simpleNoteNames = simpleNoteNames[language]
self.tracks[1].pattern.simpleNoteNames = simpleNoteNames[language]
self.tracks[2].pattern.simpleNoteNames = simpleNoteNames[language]
#not drums.
def cacheOffsetInTicks(self):
oneMeasureInTicks = (self.howManyUnits * self.whatTypeOfUnit) / self.subdivisions
oneMeasureInTicks = int(oneMeasureInTicks)
@ -442,6 +456,8 @@ class Data(template.engine.sequencer.Score):
else:
self.globalOffsetTicks = 0
self._emptyFile = False
#Tracks depend on the rest of the data already in place because they create a cache on creation.
super().copyFromSerializedData(parentSession, serializedData, self) #Tracks, parentSession and tempoMap

1
qtgui/mainwindow.py

@ -207,6 +207,7 @@ class MainWindow(TemplateMainWindow):
#Toolbar, which needs the widgets above already established
self._populateToolbar()
api.session.data.setLanguageForEmptyFile(language = QtCore.QLocale().languageToString(QtCore.QLocale().language())) #TODO: this is a hack because we access the session directly. But this is also a function tied to Qts language string. Two wrongs...
self.start() #This shows the GUI, or not, depends on the NSM gui save setting. We need to call that after the menu, otherwise the about dialog will block and then we get new menu entries, which looks strange.
#There is always a track. Forcing that to be active is better than having to hide all the pattern widgets, or to disable them.

1
template/qtgui/mainwindow.py

@ -57,6 +57,7 @@ api.session.eventLoop = EventLoop()
#Setup the translator before classes are set up. Otherwise we can't use non-template translation.
#to test use LANGUAGE=de_DE.UTF-8 . not LANG=
#Language variants like de_AT.UTF-8 will be detected automatically and will result in Qt language detection as "German"
language = QtCore.QLocale().languageToString(QtCore.QLocale().language())
logger.info("{}: Language set to {}".format(METADATA["name"], language))
if language in METADATA["supportedLanguages"]:

Loading…
Cancel
Save