Settings dialog is owned by app.

startup
Ben Niemann 4 years ago
parent 6d67e2a7c5
commit 876d8f5066
  1. 2
      noisicaa/ui/CMakeLists.txt
  2. 30
      noisicaa/ui/editor_app.py
  3. 57
      noisicaa/ui/editor_window.py
  4. 0
      noisicaa/ui/settings_dialog.py

@ -51,7 +51,7 @@ add_python_package(
render_dialog_test.py
selection_set.py
session_helpers.py
settings.py
settings_dialog.py
slots.py
stat_monitor.py
svg_symbol_filetest.py

@ -29,6 +29,7 @@ import traceback
import types
from typing import Any, Optional, Callable, Sequence, List, Type
from PyQt5.QtCore import Qt
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
@ -48,6 +49,7 @@ from . import device_list
from . import project_registry
from . import pipeline_perf_monitor
from . import stat_monitor
from . import settings_dialog
from . import ui_base
logger = logging.getLogger('ui.editor_app')
@ -122,6 +124,8 @@ class EditorApp(ui_base.AbstractEditorApp):
self.default_style = None # type: str
self.devices = None # type: device_list.DeviceList
self.setup_complete = None # type: asyncio.Event
self.__settings_dialog = None # type: settings_dialog.SettingsDialog
self.__player_state_listeners = core.CallbackMap[str, audioproc.EngineNotification]()
@property
@ -134,13 +138,24 @@ class EditorApp(ui_base.AbstractEditorApp):
sys.excepthook = ExceptHook(self) # type: ignore
self.setup_complete = asyncio.Event(loop=self.process.event_loop)
self.default_style = self.qt_app.style().objectName()
self.default_style = self.qt_app.style().objectName()
style_name = self.settings.value('appearance/qtStyle', '')
if style_name:
# TODO: something's wrong with the QtWidgets stubs...
self.qt_app.setStyle(QtWidgets.QStyleFactory.create(style_name)) # type: ignore
self.show_settings_dialog_action = QtWidgets.QAction("Settings", self.qt_app)
self.show_settings_dialog_action.setStatusTip("Open the settings dialog.")
self.show_settings_dialog_action.setEnabled(False)
self.show_settings_dialog_action.triggered.connect(self.__showSettingsDialog)
self.quit_action = QtWidgets.QAction("Quit", self.qt_app)
self.quit_action.setShortcut(QtGui.QKeySequence.Quit)
self.quit_action.setShortcutContext(Qt.ApplicationShortcut)
self.quit_action.setStatusTip("Quit the application")
self.quit_action.triggered.connect(self.quit)
logger.info("Creating initial window...")
win = await self.createWindow()
tab_page = win.addProjectTab("Open project")
@ -170,6 +185,7 @@ class EditorApp(ui_base.AbstractEditorApp):
finally:
win.deleteSetupProgress()
self.show_settings_dialog_action.setEnabled(True)
self.setup_complete.set()
# self.__audio_thread_profiler = audio_thread_profiler.AudioThreadProfiler(
@ -214,6 +230,11 @@ class EditorApp(ui_base.AbstractEditorApp):
# self.__audio_thread_profiler.hide()
# self.__audio_thread_profiler = None
if self.__settings_dialog is not None:
self.__settings_dialog.storeState()
self.__settings_dialog.close()
self.__settings_dialog = None
while self.__windows:
win = self.__windows.pop(0)
win.storeState()
@ -348,6 +369,13 @@ class EditorApp(ui_base.AbstractEditorApp):
else:
raise ValueError(action)
def __showSettingsDialog(self) -> None:
if self.__settings_dialog is None:
# TODO: use current window as parent?
self.__settings_dialog = settings_dialog.SettingsDialog(context=self.context)
self.__settings_dialog.show()
self.__settings_dialog.activateWindow()
# pylint: disable=line-too-long
# def onPlayerStatus(self, player_state: audioproc.PlayerState):
# if pipeline_disabled:

@ -37,7 +37,6 @@ from noisicaa import constants
from noisicaa import audioproc
from noisicaa import music
from ..exceptions import RestartAppException, RestartAppCleanException
from .settings import SettingsDialog
from . import project_view
from . import ui_base
from . import instrument_library
@ -174,8 +173,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# self.__engine_state_listener = None # type: core.Listener[audioproc.EngineStateChange]
# self._settings_dialog = SettingsDialog(parent=self, context=self.context)
# self._instrument_library_dialog = instrument_library.InstrumentLibraryDialog(
# context=self.context, parent=self)
@ -188,7 +185,7 @@ class EditorWindow(ui_base.AbstractEditorWindow):
self.__setup_progress_fade_task = None # type: asyncio.Task
# self.createActions()
# self.createMenus()
self.createMenus()
# self.createToolBar()
# self.createStatusBar()
@ -255,7 +252,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# if isinstance(view, ProjectView):
# await view.cleanup()
# self._project_tabs.removeTab(0)
# self._settings_dialog.close()
self.close()
def createSetupProgress(self) -> SetupProgressWidget:
@ -385,12 +381,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# self._restart_clean_action.setStatusTip("Restart the application in a clean state")
# self._restart_clean_action.triggered.connect(self.restart_clean)
# self._quit_action = QtWidgets.QAction("Quit", self)
# self._quit_action.setShortcut(QtGui.QKeySequence.Quit)
# self._quit_action.setShortcutContext(Qt.ApplicationShortcut)
# self._quit_action.setStatusTip("Quit the application")
# self._quit_action.triggered.connect(self.quit)
# self._crash_action = QtWidgets.QAction("Crash", self)
# self._crash_action.triggered.connect(self.crash)
@ -405,10 +395,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_settings_action = QtWidgets.QAction("Settings", self)
# self._open_settings_action.setStatusTip("Open the settings dialog.")
# self._open_settings_action.triggered.connect(self.openSettings)
# 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)
@ -466,10 +452,10 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# # self.app.stat_monitor.visibilityChanged.connect(
# # self._show_stat_monitor_action.setChecked)
# def createMenus(self) -> None:
# menu_bar = self.menuBar()
def createMenus(self) -> None:
menu_bar = self.menuBar()
# self._project_menu = menu_bar.addMenu("Project")
self._project_menu = menu_bar.addMenu("Project")
# self._project_menu.addAction(self._new_project_action)
# self._project_menu.addAction(self._open_project_action)
# self._project_menu.addAction(self._close_current_project_action)
@ -477,12 +463,12 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# 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._open_settings_action)
# self._project_menu.addSeparator()
# self._project_menu.addAction(self._quit_action)
self._project_menu.addSeparator()
self._project_menu.addAction(self.app.show_settings_dialog_action)
self._project_menu.addSeparator()
self._project_menu.addAction(self.app.quit_action)
# self._edit_menu = menu_bar.addMenu("Edit")
self._edit_menu = menu_bar.addMenu("Edit")
# self._edit_menu.addAction(self._undo_action)
# self._edit_menu.addAction(self._redo_action)
# self._project_menu.addSeparator()
@ -494,11 +480,11 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# #self._edit_menu.addAction(self._set_num_measures_action)
# self._edit_menu.addAction(self._set_bpm_action)
# self._view_menu = menu_bar.addMenu("View")
self._view_menu = menu_bar.addMenu("View")
# if self.app.runtime_settings.dev_mode:
# menu_bar.addSeparator()
# self._dev_menu = menu_bar.addMenu("Dev")
if self.app.runtime_settings.dev_mode:
menu_bar.addSeparator()
self._dev_menu = menu_bar.addMenu("Dev")
# self._dev_menu.addAction(self._dump_project_action)
# self._dev_menu.addAction(self._restart_action)
# self._dev_menu.addAction(self._restart_clean_action)
@ -508,11 +494,11 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# #self._dev_menu.addAction(self.app.profile_audio_thread_action)
# #self._dev_menu.addAction(self.app.dump_audioproc)
# menu_bar.addSeparator()
menu_bar.addSeparator()
# self._help_menu = menu_bar.addMenu("Help")
# self._help_menu.addAction(self._about_action)
# self._help_menu.addAction(self._aboutqt_action)
self._help_menu = menu_bar.addMenu("Help")
# self._help_menu.addAction(self._about_action)
# self._help_menu.addAction(self._aboutqt_action)
# def createToolBar(self) -> None:
# self.toolbar = QtWidgets.QToolBar()
@ -544,8 +530,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
self.app.settings.setValue('mainwindow/geometry', self.saveGeometry())
self.app.settings.setValue('mainwindow/state', self.saveState())
# self._settings_dialog.storeState()
# def __engineStateChanged(self, engine_state: audioproc.EngineStateChange) -> None:
# show_status, show_load = False, False
# if engine_state.state == audioproc.EngineStateChange.SETUP:
@ -591,13 +575,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
# def restart_clean(self) -> None:
# raise RestartAppCleanException("Clean restart requested by user.")
# def quit(self) -> None:
# self.app.quit()
# def openSettings(self) -> None:
# self._settings_dialog.show()
# self._settings_dialog.activateWindow()
# def openInstrumentLibrary(self) -> None:
# self._instrument_library_dialog.show()
# self._instrument_library_dialog.activateWindow()

Loading…
Cancel
Save