# Path: lazylyst/CustomWidgets.py
# class HoverLineEdit(QtWidgets.QLineEdit):
#     hoverOut = QtCore.pyqtSignal()
#     
#     def __init__(self, parent=None):
#         super(HoverLineEdit, self).__init__(parent)   
#         self.changeState=False        
#         self.textChanged.connect(self.updateChangeState)
#         
#     def leaveEvent(self, ev):
#         # Only emit if the text was changed
#         if self.changeState:
#             self.hoverOut.emit()
#             self.changeState=False
#     
#     def updateChangeState(self,ev):
#         self.changeState=True
# 
# class KeyBindLineEdit(QtWidgets.QLineEdit):
#     keyPressed=QtCore.pyqtSignal(str)
#     
#     def __init__(self, parent=None):
#         super(KeyBindLineEdit, self).__init__(parent)    
#         self.MOD_MASK = (Qt.CTRL | Qt.ALT | Qt.SHIFT | Qt.META)
#     
#     # If any usual key bind was pressed, return the human recognizable string
#     def keyPressEvent(self, ev):
#         keyname = keyPressToString(ev)
#         if keyname==None:
#             return
#         self.keyPressed.emit(keyname)
# 
# class KeyListWidget(QtWidgets.QListWidget):       
#     # Return signal if key was pressed while in focus
#     keyPressedSignal = QtCore.pyqtSignal()  
#     
#     def __init__(self, parent=None):
#         super(KeyListWidget, self).__init__(parent)
#     
#     # Update this widgets last pressed key, and return a signal
#     def keyPressEvent(self, ev):
#         self.key=ev.key()
#         if self.key not in [Qt.Key_Delete]:
#             return
#         self.keyPressedSignal.emit()
#         
#     # Deselect all items if in a blank space
#     def mousePressEvent(self, ev):
#         if self.itemAt(ev.pos()) is None:
#             self.clearSelection()
#         QtWidgets.QListWidget.mousePressEvent(self, ev)
#     
#     # Ensure that key presses are sent to the widget which the mouse is hovering over
#     def enterEvent(self,ev):
#         super(KeyListWidget, self).enterEvent(ev)
#         self.setFocus()
# 
#     # Return a lists entries in the order which is appears
#     def visualListOrder(self):
#         txt=np.array([self.item(i).text() for i in range(self.count())])
#         args=np.array([self.indexFromItem(self.item(i)).row() for i in range(self.count())])
#         return list(txt[np.argsort(args)])


from PyQt5 import QtCore, QtGui, QtWidgets
from lazylyst.CustomWidgets import HoverLineEdit, KeyBindLineEdit, KeyListWidget

        self.retranslateUi(actionDialog)
        self.actButtonBox.accepted.connect(actionDialog.accept)
        self.actButtonBox.rejected.connect(actionDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(actionDialog)
        actionDialog.setTabOrder(self.actTagLineEdit, self.actNameLineEdit)
        actionDialog.setTabOrder(self.actNameLineEdit, self.actPathLineEdit)
        actionDialog.setTabOrder(self.actPathLineEdit, self.actOptionalsLineEdit)
        actionDialog.setTabOrder(self.actOptionalsLineEdit, self.actActiveRadio)
        actionDialog.setTabOrder(self.actActiveRadio, self.actTriggerLineEdit)
        actionDialog.setTabOrder(self.actTriggerLineEdit, self.actIntervalLineEdit)
        actionDialog.setTabOrder(self.actIntervalLineEdit, self.actPassiveRadio)
        actionDialog.setTabOrder(self.actPassiveRadio, self.passiveBeforeCheck)
        actionDialog.setTabOrder(self.passiveBeforeCheck, self.actSelectTriggerList)
        actionDialog.setTabOrder(self.actSelectTriggerList, self.actAvailTriggerList)
        actionDialog.setTabOrder(self.actAvailTriggerList, self.actSelectInputList)
        actionDialog.setTabOrder(self.actSelectInputList, self.actAvailInputList)
        actionDialog.setTabOrder(self.actAvailInputList, self.actSelectReturnList)
        actionDialog.setTabOrder(self.actSelectReturnList, self.actAvailReturnList)
        actionDialog.setTabOrder(self.actAvailReturnList, self.actButtonBox)

    def retranslateUi(self, actionDialog):
        _translate = QtCore.QCoreApplication.translate
        actionDialog.setWindowTitle(_translate("actionDialog", "Setup Action"))
        self.actOptionalsLabel.setToolTip(_translate("actionDialog", "Optionals to send to function"))
        self.actOptionalsLabel.setText(_translate("actionDialog", "Optionals"))
        self.actTagLabel.setToolTip(_translate("actionDialog", "Human readable name of action"))
        self.actTagLabel.setText(_translate("actionDialog", "Tag "))
        self.actNameLabel.setToolTip(_translate("actionDialog", "Function name of action"))
        self.actNameLabel.setText(_translate("actionDialog", "Name"))

# Path: lazylyst/CustomWidgets.py
# class HoverLineEdit(QtWidgets.QLineEdit):
#     hoverOut = QtCore.pyqtSignal()
#     
#     def __init__(self, parent=None):
#         super(HoverLineEdit, self).__init__(parent)   
#         self.changeState=False        
#         self.textChanged.connect(self.updateChangeState)
#         
#     def leaveEvent(self, ev):
#         # Only emit if the text was changed
#         if self.changeState:
#             self.hoverOut.emit()
#             self.changeState=False
#     
#     def updateChangeState(self,ev):
#         self.changeState=True
# 
# class KeyBindLineEdit(QtWidgets.QLineEdit):
#     keyPressed=QtCore.pyqtSignal(str)
#     
#     def __init__(self, parent=None):
#         super(KeyBindLineEdit, self).__init__(parent)    
#         self.MOD_MASK = (Qt.CTRL | Qt.ALT | Qt.SHIFT | Qt.META)
#     
#     # If any usual key bind was pressed, return the human recognizable string
#     def keyPressEvent(self, ev):
#         keyname = keyPressToString(ev)
#         if keyname==None:
#             return
#         self.keyPressed.emit(keyname)
# 
# class KeyListWidget(QtWidgets.QListWidget):       
#     # Return signal if key was pressed while in focus
#     keyPressedSignal = QtCore.pyqtSignal()  
#     
#     def __init__(self, parent=None):
#         super(KeyListWidget, self).__init__(parent)
#     
#     # Update this widgets last pressed key, and return a signal
#     def keyPressEvent(self, ev):
#         self.key=ev.key()
#         if self.key not in [Qt.Key_Delete]:
#             return
#         self.keyPressedSignal.emit()
#         
#     # Deselect all items if in a blank space
#     def mousePressEvent(self, ev):
#         if self.itemAt(ev.pos()) is None:
#             self.clearSelection()
#         QtWidgets.QListWidget.mousePressEvent(self, ev)
#     
#     # Ensure that key presses are sent to the widget which the mouse is hovering over
#     def enterEvent(self,ev):
#         super(KeyListWidget, self).enterEvent(ev)
#         self.setFocus()
# 
#     # Return a lists entries in the order which is appears
#     def visualListOrder(self):
#         txt=np.array([self.item(i).text() for i in range(self.count())])
#         args=np.array([self.indexFromItem(self.item(i)).row() for i in range(self.count())])
#         return list(txt[np.argsort(args)])


# Path: lazylyst/UI/ActionSetup.py
from PyQt5 import QtCore, QtGui, QtWidgets
from lazylyst.CustomWidgets import HoverLineEdit, KeyBindLineEdit, KeyListWidget


        self.retranslateUi(actionDialog)
        self.actButtonBox.accepted.connect(actionDialog.accept)
        self.actButtonBox.rejected.connect(actionDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(actionDialog)
        actionDialog.setTabOrder(self.actTagLineEdit, self.actNameLineEdit)
        actionDialog.setTabOrder(self.actNameLineEdit, self.actPathLineEdit)
        actionDialog.setTabOrder(self.actPathLineEdit, self.actOptionalsLineEdit)
        actionDialog.setTabOrder(self.actOptionalsLineEdit, self.actActiveRadio)
        actionDialog.setTabOrder(self.actActiveRadio, self.actTriggerLineEdit)
        actionDialog.setTabOrder(self.actTriggerLineEdit, self.actIntervalLineEdit)
        actionDialog.setTabOrder(self.actIntervalLineEdit, self.actPassiveRadio)
        actionDialog.setTabOrder(self.actPassiveRadio, self.passiveBeforeCheck)
        actionDialog.setTabOrder(self.passiveBeforeCheck, self.actSelectTriggerList)
        actionDialog.setTabOrder(self.actSelectTriggerList, self.actAvailTriggerList)
        actionDialog.setTabOrder(self.actAvailTriggerList, self.actSelectInputList)
        actionDialog.setTabOrder(self.actSelectInputList, self.actAvailInputList)
        actionDialog.setTabOrder(self.actAvailInputList, self.actSelectReturnList)
        actionDialog.setTabOrder(self.actSelectReturnList, self.actAvailReturnList)
        actionDialog.setTabOrder(self.actAvailReturnList, self.actButtonBox)

    def retranslateUi(self, actionDialog):
        _translate = QtCore.QCoreApplication.translate
        actionDialog.setWindowTitle(_translate("actionDialog", "Setup Action"))
        self.actOptionalsLabel.setToolTip(_translate("actionDialog", "Optionals to send to function"))
        self.actOptionalsLabel.setText(_translate("actionDialog", "Optionals"))
        self.actTagLabel.setToolTip(_translate("actionDialog", "Human readable name of action"))
        self.actTagLabel.setText(_translate("actionDialog", "Tag "))
        self.actNameLabel.setToolTip(_translate("actionDialog", "Function name of action"))
        self.actNameLabel.setText(_translate("actionDialog", "Name"))

        self.actPassiveRadio.setToolTip(_translate("actionDialog", "Action is triggered by an active action"))