summaryrefslogtreecommitdiff
path: root/src/editorui/paths.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/editorui/paths.py112
1 files changed, 15 insertions, 97 deletions
diff --git a/src/editorui/paths.py b/src/editorui/paths.py
index 4110188..a0e65d6 100644
--- a/src/editorui/paths.py
+++ b/src/editorui/paths.py
@@ -538,93 +538,6 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
self.setPalette(palette)
- class UnlockButton(QtGui.QPushButton):
- def __init__(self, pathRef):
- QtGui.QPushButton.__init__(self)
-
- self.setFixedSize(48,48)
-
- self.iconList = [QtGui.QIcon("Resources/Key.png"),
- QtGui.QIcon("Resources/SecretKey.png")]
-
- self.unlockIcon = QtGui.QIcon("Resources/Unlock.png")
- self.arrowIcon = [QtGui.QIcon("Resources/KeyArrow.png"),
- QtGui.QIcon("Resources/SecretKeyArrow.png")]
-
-
- self._pathRef = pathRef
-
- self.secret = 0
- self.path = 0
-
- if not hasattr(KPEditorPath.UnlockButton, 'PALETTE'):
- KPEditorPath.UnlockButton.PALETTE = QtGui.QPalette(Qt.transparent)
-
- self.setPalette(self.PALETTE)
-
- self.released.connect(self.toggle)
-
-
- def toggle(self):
-
- path = self._pathRef()
-
- if KP.app.keyboardModifiers() == Qt.ShiftModifier:
- if self.secret == 1:
- self.secret = 0
- else:
- self.secret = 1
-
- path.secret = self.secret
-
- else:
- self.path += 1
-
- if self.path > 2:
- self.path = 0
-
- path.unlocks = self.path
-
-
- def paintEvent(self, event):
- painter = QtGui.QPainter(self)
- contentsRect = self.contentsRect()
- smallRect = QtCore.QRect(12, 12, 24, 24)
- painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)
-
- if self.path > 0:
- painter.save()
-
- displaceX, displaceY = contentsRect.width() / 2, contentsRect.height() / 2
-
- pathItem = self._pathRef().qtItem.line()
-
- if self.path == 1:
- angle = 90 - pathItem.angle()
- else:
- angle = 270 - pathItem.angle()
-
- painter.translate(displaceX, displaceY)
- painter.rotate(angle)
- painter.translate(-displaceX, -displaceY)
- self.arrowIcon[self.secret].paint(painter, contentsRect, Qt.AlignCenter)
-
- painter.restore()
-
- if self.isDown():
- self.iconList[self.secret].paint(painter, smallRect, Qt.AlignCenter, QtGui.QIcon.Disabled)
- else:
- self.iconList[self.secret].paint(painter, smallRect, Qt.AlignCenter)
-
- else:
- if self.isDown():
- self.unlockIcon.paint(painter, smallRect, Qt.AlignCenter, QtGui.QIcon.Disabled)
- else:
- self.unlockIcon.paint(painter, smallRect, Qt.AlignCenter)
-
- painter.end()
-
-
class HiddenProxy(QtGui.QGraphicsProxyWidget):
def __init__(self, button, parent, x, y):
QtGui.QGraphicsProxyWidget.__init__(self, parent)
@@ -663,12 +576,6 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
if not hasattr(KPEditorPath, 'SELECTION_PEN'):
KPEditorPath.SELECTION_PEN = QtGui.QPen(Qt.blue, 1, Qt.DotLine)
- self.unlock = self.UnlockButton(self._pathRef)
- self.unlockProxy = self.HiddenProxy(self.unlock, self, -24, -24)
-
- self.unlock.secret = path.secret
- self.unlock.path = path.unlocks
-
self.options = self.PathOptionsMenuButton(self._pathRef)
self.optionsProxy = self.HiddenProxy(self.options, self, -54, +24)
@@ -677,6 +584,20 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
self.updatePosition()
+ def mousePressEvent(self, event):
+ if event.button() != Qt.LeftButton:
+ return
+ if QtGui.QApplication.keyboardModifiers() != QtCore.Qt.ControlModifier:
+ return
+
+ # modify the unlock settings
+ from unlock import KPUnlockSpecDialog
+
+ # todo: set the existing thing there
+ result = KPUnlockSpecDialog.exec_()
+ if result == QtGui.QDialog.Accepted:
+ print "OK!"
+
def updatePosition(self):
path = self._pathRef()
@@ -720,12 +641,9 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
painter.setPen(self.SELECTION_PEN)
painter.setBrush(QtGui.QColor(0,0,0,0))
painter.drawPath(self.shape())
-
- self.unlockProxy.show()
self.optionsProxy.show()
else:
- self.unlockProxy.hide()
self.optionsProxy.hide()
@@ -753,4 +671,4 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
self.scene().removeItem(self)
- \ No newline at end of file
+