Browse Source

Remember pianos and flat/nested

master
Nils 2 years ago
parent
commit
6613bdd594
  1. 13
      qtgui/instrument.py
  2. 33
      qtgui/mainwindow.py

13
qtgui/instrument.py

@ -45,8 +45,6 @@ class InstrumentTreeController(object):
Why is this not a QTableWidget? As in Agordejo, a TableWidget is a complex item, and inconvenient
to use. You need to add an Item to each cell. While in TreeWidget you just create one item.
And we might use the TreeView to group by manufacturer etc. Eventhough we have a Filter.
"""
def __init__(self, parentMainWindow):
@ -135,7 +133,7 @@ class InstrumentTreeController(object):
def buildTree(self, data:dict, nested:bool=None):
def buildTree(self, data:dict, nested:bool=True):
"""
Create the tree. Can be called multiple times and it will re-create itself destructively.
If you call it with data, once at program start, data will get cached. If you call
@ -209,12 +207,6 @@ class InstrumentTreeController(object):
assert self._cachedData
data = self._cachedData
if nested is None:
if "nestedView" in api.session.guiSharedDataToSave:
nested = api.session.guiSharedDataToSave["nestedView"]
else:
nested = True
api.session.guiSharedDataToSave["nestedView"] = nested
self.currentlyNested = nested
for libraryId, libraryDict in data.items():
@ -244,9 +236,6 @@ class InstrumentTreeController(object):
self._adjustColumnSize()
def toggleNestedFlat(self, newCheckStateIsNested):
"""We receive newCheckState as automatic parameter from Qt from the calling menu action"""
self.buildTree(data=None, nested=newCheckStateIsNested) #with data=None it will used the cache data we received once, at startup
def setAllExpanded(self, state:bool):
"""We do not use the qt function collapseAll and expandAll because they do not trigger

33
qtgui/mainwindow.py

@ -143,18 +143,25 @@ class MainWindow(TemplateMainWindow):
if settings.contains("pianoRollVisible"):
self.pianoRollToggleVisibleAndRemember(settings.value("pianoRollVisible", type=bool))
if settings.contains("pianoVisible"):
self.pianoToggleVisibleAndRemember(settings.value("pianoVisible", type=bool))
self.start(additionalData) #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.
api.callbacks.rescanSampleDir.append(self.react_rescanSampleDir) #This only happens on actual, manually instructed rescanning through the api. We instruct this through our Rescan-Dialog.
if settings.contains("instrumentTreeIsNested"): #Only call after the instruments got parsed
self.toggleNestedFlatAndRemember(settings.value("instrumentTreeIsNested", type=bool))
#Statusbar will show possible actions, such as "use scrollwheel to transpose"
#self.statusBar().showMessage(QtCore.QCoreApplication.translate("Statusbar", ""))
self.statusBar().showMessage("")
def setupMenu(self):
"""In its own function purely for readability"""
"""In its own function purely for readability
This is called before loading saved values for widget visibility etc.
These are the defaults."""
#New menu entries and template-menu overrides
#self.menu.connectMenuEntry("actionAbout", lambda: print("About Dialog Menu deactivated")) #deactivates the original function
#self.menu.addMenuEntry("menuEdit", "actionNils", "Nils", lambda: print("Merle"))
@ -166,13 +173,11 @@ class MainWindow(TemplateMainWindow):
self.menu.addMenuEntry("menuView", "actionExpandAll", QtCore.QCoreApplication.translate("Menu", "Expand all Libraries"), lambda: self.instrumentTreeController.setAllExpanded(True))
self.menu.addMenuEntry("menuView", "actionCollapseAll", QtCore.QCoreApplication.translate("Menu", "Collapse all Libraries"), lambda: self.instrumentTreeController.setAllExpanded(False))
if "nestedView" in api.session.guiSharedDataToSave:
nested = api.session.guiSharedDataToSave["nestedView"]
else:
nested = True
self.menu.addMenuEntry("menuView", "actionFlatNested", QtCore.QCoreApplication.translate("Menu", "Nested Instrument List"), self.instrumentTreeController.toggleNestedFlat, checkable=True, startChecked=nested) #function receives check state as automatic parameter
self.menu.addMenuEntry("menuView", "actionPianoRollVisible", QtCore.QCoreApplication.translate("Menu", "Piano Roll"), self.pianoRollToggleVisibleAndRemember, shortcut="Ctrl+R", checkable=True, startChecked=nested) #function receives check state as automatic parameter
self.menu.addMenuEntry("menuView", "actionPianoVisible", QtCore.QCoreApplication.translate("Menu", "Piano"), self.pianoToggleVisibleAndRemember, shortcut="Ctrl+P", checkable=True, startChecked=nested) #function receives check state as automatic parameter
self.menu.addMenuEntry("menuView", "actionFlatNested", QtCore.QCoreApplication.translate("Menu", "Nested Instrument List"), self.toggleNestedFlatAndRemember, checkable=True, startChecked=True) #function receives check state as automatic parameter
self.menu.addMenuEntry("menuView", "actionPianoRollVisible", QtCore.QCoreApplication.translate("Menu", "Piano Roll"), self.pianoRollToggleVisibleAndRemember, shortcut="Ctrl+R", checkable=True, startChecked=True) #function receives check state as automatic parameter
self.menu.addMenuEntry("menuView", "actionPianoVisible", QtCore.QCoreApplication.translate("Menu", "Piano"), self.pianoToggleVisibleAndRemember, shortcut="Ctrl+P", checkable=True, startChecked=True) #function receives check state as automatic parameter
self.menu.orderSubmenus(["menuFile", "menuEdit", "menuView", "menuHelp"])
@ -182,9 +187,19 @@ class MainWindow(TemplateMainWindow):
This only happens on actual, manually instructed rescanning through the api.
The program start happens without that and just sends data into a prepared but empty GUI."""
self.instrumentTreeController.reset()
def toggleNestedFlatAndRemember(self, state:bool):
"""We receive state as automatic parameter from Qt from the calling menu action.
This function can only be called after the instrument tree has been build.
instrumentTreeController.buildTree(data=None) relies on cached data.
"""
self.instrumentTreeController.buildTree(data=None, nested=state) #with data=None it will used the cache data we received once, at startup
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"])
settings.setValue("instrumentTreeIsNested", state)
self.ui.actionFlatNested.setChecked(state) #if called from outside the menu, e.g. load
def pianoRollToggleVisibleAndRemember(self, state:bool):
self.ui.verticalPianoFrame.setVisible(state)
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"])

Loading…
Cancel
Save