Skip to content

Commit

Permalink
Revert "Fix Input ( plus lfs shit )"
Browse files Browse the repository at this point in the history
This reverts commit 551cc22.
  • Loading branch information
pedroCabrera committed Feb 7, 2024
1 parent 551cc22 commit dcec2c5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 49 deletions.
63 changes: 26 additions & 37 deletions PyFlow/Input.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
## limitations under the License.


from collections import Counter
from collections import defaultdict
from enum import Enum

from qtpy import QtCore, QtGui
from Qt import QtCore, QtGui

from PyFlow.Core.Common import *

Expand All @@ -27,26 +27,16 @@ class InputActionType(Enum):


class InputAction(object):
def __init__(
self,
name="defaultName",
actionType=InputActionType.Keyboard,
group="default",
mouse=QtCore.Qt.NoButton,
key=None,
modifiers=QtCore.Qt.NoModifier,
):
def __init__(self, name="defaultName", actionType=InputActionType.Keyboard, group="default", mouse=QtCore.Qt.NoButton, key=None, modifiers=QtCore.Qt.NoModifier):
self.__actionType = actionType
self._name = name
self._group = group
self.__data = {"mouse": mouse, "key": key, "modifiers": modifiers}

def __str__(self):
return "{0} {1} {2}".format(
QtGui.QKeySequence(self.getModifiers()).toString(),
self.getMouseButton().name.decode("utf=8"),
QtGui.QKeySequence(self.getKey()).toString(),
)
return "{0} {1} {2}".format(QtGui.QKeySequence(self.getModifiers()).toString(),
self.getMouseButton().name.decode('utf=8'),
QtGui.QKeySequence(self.getKey()).toString())

@property
def group(self):
Expand All @@ -63,7 +53,10 @@ def __eq__(self, other):
om = other.getData()["mouse"]
ok = other.getData()["key"]
omod = other.getData()["modifiers"]
return all([sm == om, sk == ok, smod == omod])
smod == omod
return all([sm == om,
sk == ok,
smod == omod])

def __ne__(self, other):
sm = self.__data["mouse"]
Expand All @@ -72,7 +65,9 @@ def __ne__(self, other):
om = other.getData()["mouse"]
ok = other.getData()["key"]
omod = other.getData()["modifiers"]
return not all([sm == om, sk == ok, smod == omod])
return not all([sm == om,
sk == ok,
smod == omod])

def getName(self):
return self._name
Expand All @@ -81,16 +76,14 @@ def getData(self):
return self.__data

def setMouseButton(self, btn):
assert isinstance(btn, QtCore.Qt.MouseButton)
assert(isinstance(btn, QtCore.Qt.MouseButton))
self.__data["mouse"] = btn

def getMouseButton(self):
return self.__data["mouse"]

def setKey(self, key=None):
if key is None:
key = []
assert isinstance(key, QtCore.Qt.Key)
def setKey(self, key=[]):
assert(isinstance(key, QtCore.Qt.Key))
self.__data["key"] = key

def getKey(self):
Expand Down Expand Up @@ -119,24 +112,24 @@ def _modifiersToList(mods):
result.append(QtCore.Qt.GroupSwitchModifier)
return result

@staticmethod
def _listOfModifiersToEnum(modifiersList):
def _listOfModifiersToEnum(self, modifiersList):
result = QtCore.Qt.NoModifier
for mod in modifiersList:
result = result | mod
return result

def toJson(self):
saveData = {"name": self._name,
"group": self._group,
"mouse": int(self.__data["mouse"].value),
"actionType": self.actionType.value}
saveData = {}
saveData["name"] = self._name
saveData["group"] = self._group
saveData["mouse"] = int(self.__data["mouse"])
saveData["actionType"] = self.actionType.value

key = self.__data["key"]
saveData["key"] = int(key) if key is not None else None

modifiersList = self._modifiersToList(self.__data["modifiers"])

saveData["modifiers"] = [i.value for i in modifiersList]
saveData["modifiers"] = [int(i) for i in modifiersList]
return saveData

def fromJson(self, jsonData):
Expand All @@ -145,12 +138,8 @@ def fromJson(self, jsonData):
self._group = jsonData["group"]
self.__data["mouse"] = QtCore.Qt.MouseButton(jsonData["mouse"])
keyJson = jsonData["key"]
self.__data["key"] = (
QtCore.Qt.Key(keyJson) if isinstance(keyJson, int) else None
)
self.__data["modifiers"] = self._listOfModifiersToEnum(
[QtCore.Qt.KeyboardModifier(i) for i in jsonData["modifiers"]]
)
self.__data["key"] = QtCore.Qt.Key(keyJson) if isinstance(keyJson, int) else None
self.__data["modifiers"] = self._listOfModifiersToEnum([QtCore.Qt.KeyboardModifier(i) for i in jsonData["modifiers"]])
self.__actionType = InputActionType(jsonData["actionType"])
return self
except:
Expand Down
3 changes: 0 additions & 3 deletions hooks/post-checkout

This file was deleted.

3 changes: 0 additions & 3 deletions hooks/post-commit

This file was deleted.

3 changes: 0 additions & 3 deletions hooks/post-merge

This file was deleted.

3 changes: 0 additions & 3 deletions hooks/pre-push

This file was deleted.

Binary file not shown.

0 comments on commit dcec2c5

Please sign in to comment.