Skip to content

Commit

Permalink
+ Added user preference to "Frame all nodes on open". As the name s…
Browse files Browse the repository at this point in the history
…uggests, turn this on to have all your nodes automatically framed in view when you open a graph.

Closes #203
  • Loading branch information
ImLucasBrown committed Dec 15, 2021
1 parent 5f2c9e1 commit 857a724
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nxt_editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions nxt_editor/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions nxt_editor/integration/blender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions nxt_editor/integration/maya/plug-ins/nxt_maya.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
10 changes: 10 additions & 0 deletions nxt_editor/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions nxt_editor/user_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 857a724

Please sign in to comment.