Browse Source

Instrument library is owned by app.

startup
Ben Niemann 3 years ago
parent
commit
0a07ac9040
  1. 25
      noisicaa/ui/editor_app.py
  2. 19
      noisicaa/ui/editor_window.py

25
noisicaa/ui/editor_app.py

@ -50,6 +50,7 @@ from . import project_registry
from . import pipeline_perf_monitor
from . import stat_monitor
from . import settings_dialog
from . import instrument_library
from . import ui_base
logger = logging.getLogger('ui.editor_app')
@ -125,6 +126,7 @@ class EditorApp(ui_base.AbstractEditorApp):
self.devices = None # type: device_list.DeviceList
self.setup_complete = None # type: asyncio.Event
self.__settings_dialog = None # type: settings_dialog.SettingsDialog
self.__instrument_library_dialog = None # type: instrument_library.InstrumentLibraryDialog
self.__player_state_listeners = core.CallbackMap[str, audioproc.EngineNotification]()
@ -150,6 +152,11 @@ class EditorApp(ui_base.AbstractEditorApp):
self.show_settings_dialog_action.setEnabled(False)
self.show_settings_dialog_action.triggered.connect(self.__showSettingsDialog)
self.show_instrument_library_action = QtWidgets.QAction("Instrument Library", self.qt_app)
self.show_instrument_library_action.setStatusTip("Open the instrument library dialog.")
self.show_instrument_library_action.setEnabled(False)
self.show_instrument_library_action.triggered.connect(self.__showInstrumentLibrary)
self.quit_action = QtWidgets.QAction("Quit", self.qt_app)
self.quit_action.setShortcut(QtGui.QKeySequence.Quit)
self.quit_action.setShortcutContext(Qt.ApplicationShortcut)
@ -172,9 +179,6 @@ class EditorApp(ui_base.AbstractEditorApp):
with progress.step("Scanning nodes and plugins..."):
await self.createNodeDB()
with progress.step("Scanning instruments..."):
await self.createInstrumentDB()
with progress.step("Creating URID mapper..."):
await self.createURIDMapper()
@ -182,10 +186,17 @@ class EditorApp(ui_base.AbstractEditorApp):
self.devices = device_list.DeviceList()
await self.createAudioProcProcess()
with progress.step("Scanning instruments..."):
await self.createInstrumentDB()
self.__instrument_library_dialog = instrument_library.InstrumentLibraryDialog(
context=self.context)
await self.__instrument_library_dialog.setup()
finally:
win.deleteSetupProgress()
self.show_settings_dialog_action.setEnabled(True)
self.show_instrument_library_action.setEnabled(True)
self.setup_complete.set()
# self.__audio_thread_profiler = audio_thread_profiler.AudioThreadProfiler(
@ -230,6 +241,10 @@ class EditorApp(ui_base.AbstractEditorApp):
# self.__audio_thread_profiler.hide()
# self.__audio_thread_profiler = None
if self.__instrument_library_dialog is not None:
await self.__instrument_library_dialog.cleanup()
self.__instrument_library_dialog = None
if self.__settings_dialog is not None:
self.__settings_dialog.storeState()
self.__settings_dialog.close()
@ -369,6 +384,10 @@ class EditorApp(ui_base.AbstractEditorApp):
else:
raise ValueError(action)
def __showInstrumentLibrary(self) -> None:
self.__instrument_library_dialog.show()
self.__instrument_library_dialog.activateWindow()
def __showSettingsDialog(self) -> None:
if self.__settings_dialog is None:
# TODO: use current window as parent?

19
noisicaa/ui/editor_window.py

@ -39,7 +39,6 @@ from noisicaa import music
from ..exceptions import RestartAppException, RestartAppCleanException
from . import project_view
from . import ui_base
from . import instrument_library
from . import qprogressindicator
from . import project_registry as project_registry_lib
from . import load_history
@ -173,9 +172,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# self.__engine_state_listener = None # type: core.Listener[audioproc.EngineStateChange]
# self._instrument_library_dialog = instrument_library.InstrumentLibraryDialog(
# context=self.context, parent=self)
# self._current_project_view = None # type: Optional[ProjectView]
self.setWindowTitle("noisicaä")
@ -227,7 +223,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# self.__engine_state_listener = self.audioproc_client.engine_state_changed.add(
# self.__engineStateChanged)
# await self._instrument_library_dialog.setup()
pass
async def cleanup(self) -> None:
@ -239,8 +234,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
pass
self.__setup_progress_fade_task = None
# await self._instrument_library_dialog.cleanup()
# if self.__engine_state_listener is not None:
# self.__engine_state_listener.remove()
# self.__engine_state_listener = None
@ -395,10 +388,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# self._aboutqt_action.setStatusTip("Show the Qt library's About box")
# self._aboutqt_action.triggered.connect(self.qt_app.aboutQt)
# self._open_instrument_library_action = QtWidgets.QAction("Instrument Library", self)
# self._open_instrument_library_action.setStatusTip("Open the instrument library dialog.")
# self._open_instrument_library_action.triggered.connect(self.openInstrumentLibrary)
# self._player_move_to_start_action = QtWidgets.QAction("Move to start", self)
# self._player_move_to_start_action.setIcon(QtGui.QIcon.fromTheme('media-skip-backward'))
# self._player_move_to_start_action.setShortcut(QtGui.QKeySequence('Home'))
@ -461,8 +450,8 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# self._project_menu.addAction(self._close_current_project_action)
# self._project_menu.addSeparator()
# self._project_menu.addAction(self._render_action)
# self._project_menu.addSeparator()
# self._project_menu.addAction(self._open_instrument_library_action)
self._project_menu.addSeparator()
self._project_menu.addAction(self.app.show_instrument_library_action)
self._project_menu.addSeparator()
self._project_menu.addAction(self.app.show_settings_dialog_action)
self._project_menu.addSeparator()
@ -575,10 +564,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# def restart_clean(self) -> None:
# raise RestartAppCleanException("Clean restart requested by user.")
# def openInstrumentLibrary(self) -> None:
# self._instrument_library_dialog.show()
# self._instrument_library_dialog.activateWindow()
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
logger.info("CloseEvent received")
event.accept()

Loading…
Cancel
Save