From 857a724afe58ae25da6bf32c2a0bf227c57a7616 Mon Sep 17 00:00:00 2001 From: Lucas Brown <54835354+imlucasbrown@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:31:40 -0600 Subject: [PATCH 1/3] `+` Added user preference to "Frame all nodes on open". As the name suggests, turn this on to have all your nodes automatically framed in view when you open a graph. Closes #203 --- nxt_editor/__init__.py | 3 +++ nxt_editor/actions.py | 15 +++++++++++++++ nxt_editor/integration/blender/__init__.py | 3 +++ nxt_editor/integration/maya/plug-ins/nxt_maya.py | 3 +++ nxt_editor/main_window.py | 10 ++++++++++ nxt_editor/user_dir.py | 1 + 6 files changed, 35 insertions(+) diff --git a/nxt_editor/__init__.py b/nxt_editor/__init__.py index a9d778a..720a9c5 100644 --- a/nxt_editor/__init__.py +++ b/nxt_editor/__init__.py @@ -107,6 +107,9 @@ def launch_editor(paths=None, start_rpc=True): app = _new_qapp() instance = show_new_editor(paths, start_rpc) app.setActiveWindow(instance) + idle_detector = QtCore.QTimer() + idle_detector.timeout.connect(instance.startup_done.emit) + idle_detector.start() if not existing: app.exec_() return instance diff --git a/nxt_editor/actions.py b/nxt_editor/actions.py index 5b9c8e9..c1f7c72 100644 --- a/nxt_editor/actions.py +++ b/nxt_editor/actions.py @@ -1372,8 +1372,23 @@ def toggle_tooltip(): tt_state = user_dir.user_prefs.get(user_dir.USER_PREF.NODE_TOOLTIPS, True) self.tooltip_action.setChecked(tt_state) + + # Toggle node tooltips + def toggle_frame_all_on_new(): + pref_key = user_dir.USER_PREF.FRAME_ALL_ON_NEW + frame_all_on_new_state = self.frame_all_on_new_action.isChecked() + user_dir.user_prefs[pref_key] = frame_all_on_new_state + + self.frame_all_on_new_action = NxtAction('Frame all nodes on open', parent=self) + self.frame_all_on_new_action.setAutoRepeat(False) + self.frame_all_on_new_action.setCheckable(True) + state = user_dir.user_prefs.get(user_dir.USER_PREF.FRAME_ALL_ON_NEW, False) + self.frame_all_on_new_action.setChecked(state) + self.frame_all_on_new_action.toggled.connect(toggle_frame_all_on_new) + self.action_display_order = [self.tooltip_action, self.frame_all_action, + self.frame_all_on_new_action, self.frame_selection_action, self.hide_attrs_action, self.disp_local_attrs_action, diff --git a/nxt_editor/integration/blender/__init__.py b/nxt_editor/integration/blender/__init__.py index 09f83bb..a5ff2a4 100644 --- a/nxt_editor/integration/blender/__init__.py +++ b/nxt_editor/integration/blender/__init__.py @@ -76,6 +76,9 @@ def unregister_nxt(): nxt_win.show() atexit.register(nxt_win.close) self.instance = nxt_win + idle_detector = QtCore.QTimer() + idle_detector.timeout.connect(nxt_win.startup_done.emit) + idle_detector.start() return self def quit_nxt(self): diff --git a/nxt_editor/integration/maya/plug-ins/nxt_maya.py b/nxt_editor/integration/maya/plug-ins/nxt_maya.py index c42ee49..2ec4e64 100644 --- a/nxt_editor/integration/maya/plug-ins/nxt_maya.py +++ b/nxt_editor/integration/maya/plug-ins/nxt_maya.py @@ -146,6 +146,9 @@ def remove_callback(): nxt_win.close_signal.connect(remove_callback) nxt_win.show() __NXT_INSTANCE__ = nxt_win + idle_detector = QtCore.QTimer() + idle_detector.timeout.connect(nxt_win.startup_done.emit) + idle_detector.start() # PLUGIN BOILERPLATE # diff --git a/nxt_editor/main_window.py b/nxt_editor/main_window.py index 3dbb666..b0500d8 100644 --- a/nxt_editor/main_window.py +++ b/nxt_editor/main_window.py @@ -46,6 +46,7 @@ class MainWindow(QtWidgets.QMainWindow): """The main window of the nxt UI. Includes the menu bar, tool bar, and dock widgets.""" + startup_done = QtCore.Signal() tab_changed = QtCore.Signal() close_signal = QtCore.Signal() new_log_signal = QtCore.Signal(logging.LogRecord) @@ -273,6 +274,8 @@ def failure_check(): app = QtWidgets.QApplication.instance() app.aboutToQuit.connect(self.shutdown_rpc_server) + if user_dir.user_prefs.get(user_dir.USER_PREF.FRAME_ALL_ON_NEW, False): + self.startup_done.connect(self.view_actions.frame_all_action.trigger) # RPC def startup_rpc_server(self, join=True): @@ -343,6 +346,10 @@ def event(self, event): self.zoom_keys_down = False return super(MainWindow, self).event(event) + def resizeEvent(self, event): + super(MainWindow, self).resizeEvent(event) + + @staticmethod def set_waiting_cursor(state=True): if state: @@ -479,6 +486,8 @@ def new_tab(self, initial_stage=None, update=True): self.update_grid_action() self.update() # TODO: Make this better self.set_waiting_cursor(False) + if not self.in_startup and user_dir.user_prefs.get(user_dir.USER_PREF.FRAME_ALL_ON_NEW, False): + self.view_actions.frame_all_action.trigger() @staticmethod def ding(): @@ -1092,6 +1101,7 @@ def __init__(self, parent=None): self.view_opt_menu = self.view_menu.addMenu('Options') self.view_opt_menu.setTearOffEnabled(True) self.view_opt_menu.addAction(self.view_actions.tooltip_action) + self.view_opt_menu.addAction(self.view_actions.frame_all_on_new_action) self.view_opt_menu.addAction(self.layer_actions.lay_manger_table_action) self.view_opt_menu.addAction(self.ce_actions.overlay_message_action) diff --git a/nxt_editor/user_dir.py b/nxt_editor/user_dir.py index 82ee6af..c0fe934 100644 --- a/nxt_editor/user_dir.py +++ b/nxt_editor/user_dir.py @@ -74,6 +74,7 @@ class USER_PREF(): SHOW_DBL_CLICK_MSG = 'show_double_click_message' SHOW_CE_DATA_STATE = 'show_code_editor_data_state' DING = 'ding' + FRAME_ALL_ON_NEW = 'frame_all_on_new' class EDITOR_CACHE(): From 8085c7a478b42ac22013793ee3119434331410b7 Mon Sep 17 00:00:00 2001 From: Lucas Brown <54835354+imlucasbrown@users.noreply.github.com> Date: Thu, 23 Dec 2021 11:24:16 -0600 Subject: [PATCH 2/3] Removed idle detector timer in favor of spontaneous event detection. Works in standalone and Blender, have not tested Maya. --- nxt_editor/integration/blender/__init__.py | 5 +---- nxt_editor/integration/maya/plug-ins/nxt_maya.py | 3 --- nxt_editor/main_window.py | 5 +++++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/nxt_editor/integration/blender/__init__.py b/nxt_editor/integration/blender/__init__.py index a5ff2a4..77ff675 100644 --- a/nxt_editor/integration/blender/__init__.py +++ b/nxt_editor/integration/blender/__init__.py @@ -56,7 +56,7 @@ def launch_nxt(cls): self = __NXT_INTEGRATION__ if self.instance: self.instance.show() - return + return self if not self.nxt_qapp: self.nxt_qapp = nxt_editor._new_qapp() nxt_win = nxt_editor.show_new_editor(start_rpc=False) @@ -76,9 +76,6 @@ def unregister_nxt(): nxt_win.show() atexit.register(nxt_win.close) self.instance = nxt_win - idle_detector = QtCore.QTimer() - idle_detector.timeout.connect(nxt_win.startup_done.emit) - idle_detector.start() return self def quit_nxt(self): diff --git a/nxt_editor/integration/maya/plug-ins/nxt_maya.py b/nxt_editor/integration/maya/plug-ins/nxt_maya.py index 2ec4e64..c42ee49 100644 --- a/nxt_editor/integration/maya/plug-ins/nxt_maya.py +++ b/nxt_editor/integration/maya/plug-ins/nxt_maya.py @@ -146,9 +146,6 @@ def remove_callback(): nxt_win.close_signal.connect(remove_callback) nxt_win.show() __NXT_INSTANCE__ = nxt_win - idle_detector = QtCore.QTimer() - idle_detector.timeout.connect(nxt_win.startup_done.emit) - idle_detector.start() # PLUGIN BOILERPLATE # diff --git a/nxt_editor/main_window.py b/nxt_editor/main_window.py index b0500d8..f98b0d9 100644 --- a/nxt_editor/main_window.py +++ b/nxt_editor/main_window.py @@ -344,6 +344,11 @@ def event(self, event): if event.type() == QtCore.QEvent.WindowDeactivate: self._held_keys = [] self.zoom_keys_down = False + if QtCore.QEvent.spontaneous(event): + frame_pref = user_dir.USER_PREF.FRAME_ALL_ON_NEW + if user_dir.user_prefs.get(frame_pref, False): + self.view_actions.frame_all_action.trigger() + return super(MainWindow, self).event(event) def resizeEvent(self, event): From b5d3a8b934c016310ff6cfbba744ce15b4af0ac0 Mon Sep 17 00:00:00 2001 From: Lucas Brown <54835354+imlucasbrown@users.noreply.github.com> Date: Thu, 23 Dec 2021 11:39:20 -0600 Subject: [PATCH 3/3] removed all the junk that tries to frame the graph when you start the editor with a graph path supplied. Nothing I do works in every case and I've wasted enough time. --- nxt_editor/__init__.py | 3 --- nxt_editor/main_window.py | 6 ------ 2 files changed, 9 deletions(-) diff --git a/nxt_editor/__init__.py b/nxt_editor/__init__.py index 720a9c5..a9d778a 100644 --- a/nxt_editor/__init__.py +++ b/nxt_editor/__init__.py @@ -107,9 +107,6 @@ def launch_editor(paths=None, start_rpc=True): app = _new_qapp() instance = show_new_editor(paths, start_rpc) app.setActiveWindow(instance) - idle_detector = QtCore.QTimer() - idle_detector.timeout.connect(instance.startup_done.emit) - idle_detector.start() if not existing: app.exec_() return instance diff --git a/nxt_editor/main_window.py b/nxt_editor/main_window.py index f98b0d9..51e2fda 100644 --- a/nxt_editor/main_window.py +++ b/nxt_editor/main_window.py @@ -274,8 +274,6 @@ def failure_check(): app = QtWidgets.QApplication.instance() app.aboutToQuit.connect(self.shutdown_rpc_server) - if user_dir.user_prefs.get(user_dir.USER_PREF.FRAME_ALL_ON_NEW, False): - self.startup_done.connect(self.view_actions.frame_all_action.trigger) # RPC def startup_rpc_server(self, join=True): @@ -344,10 +342,6 @@ def event(self, event): if event.type() == QtCore.QEvent.WindowDeactivate: self._held_keys = [] self.zoom_keys_down = False - if QtCore.QEvent.spontaneous(event): - frame_pref = user_dir.USER_PREF.FRAME_ALL_ON_NEW - if user_dir.user_prefs.get(frame_pref, False): - self.view_actions.frame_all_action.trigger() return super(MainWindow, self).event(event)