Skip to content

Commit

Permalink
Py2 compatibility fixes
Browse files Browse the repository at this point in the history
Old Qt compatibility fixes
  • Loading branch information
ImLucasBrown committed Feb 9, 2021
1 parent 809335c commit 0afa98c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nxt_editor/dockwidgets/widget_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def update_window(self, changed_paths=None):
return

update = False if changed_paths else True
if not isinstance(changed_paths, collections.abc.Iterable):
if not isinstance(changed_paths, Iterable):
changed_paths = []
for path in changed_paths:
node_path, _ = nxt_path.path_attr_partition(path)
Expand Down
21 changes: 16 additions & 5 deletions nxt_editor/node_graphics_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Qt import QtWidgets
from Qt import QtGui
from Qt import QtCore
from PySide2 import __version_info__ as qt_version

# Internal
import nxt_editor
Expand All @@ -24,8 +25,16 @@

MIN_LOD = user_prefs.get(USER_PREF.LOD, .4)

_pyside_version = qt_version

class NodeGraphicsItem(QtWidgets.QGraphicsObject):

if _pyside_version[1] < 11:
graphic_type = QtWidgets.QGraphicsItem
else:
graphic_type = QtWidgets.QGraphicsObject


class NodeGraphicsItem(graphic_type):
"""The graphics item used to represent nodes in the graph. Contains
instances of NodeGraphicsPlug for each attribute on the associated node.
Contains functionality for arranging children into stacks.
Expand Down Expand Up @@ -139,8 +148,9 @@ def anim_into_place(self, end_pos):
if end_pos == self.pos():
return
self.view._animating.append(self)
self.setup_in_anim()
if not self.view.do_animations:
if self.view.do_animations:
self.setup_in_anim()
else:
self.setPos(end_pos)
self.in_anim_group.finished.emit()
return
Expand All @@ -161,8 +171,9 @@ def anim_out(self):
if self.get_is_animating():
return
self.view._animating.append(self)
self.setup_out_anim()
if not self.view.do_animations:
if self.view.do_animations:
self.setup_out_anim()
else:
self.out_anim_group.finished.emit()
return
self.setCacheMode(QtWidgets.QGraphicsItem.ItemCoordinateCache)
Expand Down
5 changes: 4 additions & 1 deletion nxt_editor/stage_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# Interal
import nxt_editor
from nxt import nxt_node, tokens
from nxt_editor.node_graphics_item import NodeGraphicsItem, NodeGraphicsPlug
from nxt_editor.node_graphics_item import (NodeGraphicsItem, NodeGraphicsPlug,
_pyside_version)
from nxt_editor.connection_graphics_item import AttrConnectionGraphic
from nxt_editor.commands import *
from .user_dir import USER_PREF, user_prefs
Expand All @@ -39,6 +40,8 @@ def __init__(self, model, parent=None):
super(StageView, self).__init__(parent=parent)
self.main_window = parent
self._do_anim_pref = user_prefs.get(USER_PREF.ANIMATION, True)
if _pyside_version[1] < 11:
self._do_anim_pref = False
self.do_animations = self._do_anim_pref
self.once_sec_timer = QtCore.QTimer(self)
self.once_sec_timer.timeout.connect(self.calculate_fps)
Expand Down

0 comments on commit 0afa98c

Please sign in to comment.