-
Notifications
You must be signed in to change notification settings - Fork 0
/
overloadedQtClasses.py
62 lines (52 loc) · 2.13 KB
/
overloadedQtClasses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import *
class QComboBoxWithKeyEvents(QtWidgets.QComboBox):
def __init__(self, parent):
super().__init__(parent)
notesOrIntervals, chordOrScale, nut, root, mode, tuning, majmin, help = [ pyqtSignal() for i in range(8) ]
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_I:
self.notesOrIntervals.emit()
elif event.key() == QtCore.Qt.Key_Space:
self.chordOrScale.emit()
elif event.key() == QtCore.Qt.Key_N:
self.nut.emit()
elif event.key() == QtCore.Qt.Key_R:
self.root.emit()
elif event.key() == QtCore.Qt.Key_Right:
self.mode.emit()
elif event.key() == QtCore.Qt.Key_Left:
self.root.emit()
elif event.key() == QtCore.Qt.Key_T:
self.tuning.emit()
elif event.key() == QtCore.Qt.Key_M:
self.majmin.emit()
elif event.key() == QtCore.Qt.Key_Question:
self.help.emit()
else:
super(QComboBoxWithKeyEvents, self).keyPressEvent(event)
class QLineEditTabReact(QtWidgets.QLineEdit):
def __init__(self, parent):
super().__init__(parent)
escape = pyqtSignal()
def event(self,event):
if event.type() == QtCore.QEvent.KeyPress and event.key() == QtCore.Qt.Key_Tab:
self.returnPressed.emit()
super(QLineEditTabReact, self).keyPressEvent(event)
return True
elif event.type() == QtCore.QEvent.KeyPress and event.key() == QtCore.Qt.Key_Escape:
self.escape.emit()
super(QLineEditTabReact, self).keyPressEvent(event)
return True
else:
return QtWidgets.QLineEdit.event(self,event)
class QLabelClickable(QtWidgets.QLabel):
def __init__(self, parent, **kwargs):
super().__init__(parent, **kwargs)
self.transparency = False
clicked, selected = [ pyqtSignal() for i in range(2) ]
def mousePressEvent(self, ev):
if ev.button() == Qt.RightButton:
self.selected.emit()
else:
self.clicked.emit()