mirror of
https://github.com/wassname/sloth.git
synced 2026-07-03 15:45:08 +08:00
Use the Enter key to finish the polygon
Using abort() (aka Escape) is not the right way to finish the polygon. Use the Enter key instead. It works this way in Inkscape. Display a message to instruct the user to use the Enter key to finish the polygon.
This commit is contained in:
@@ -336,6 +336,8 @@ class PolygonItemInserter(ItemInserter):
|
||||
self._item.setPen(self.pen())
|
||||
self._scene.addItem(item)
|
||||
self._current_image_item = image_item
|
||||
|
||||
self._scene.setMessage("Press Enter to finish the polygon.")
|
||||
else:
|
||||
polygon = self._item.polygon()
|
||||
polygon.append(pos)
|
||||
@@ -353,9 +355,11 @@ class PolygonItemInserter(ItemInserter):
|
||||
|
||||
event.accept()
|
||||
|
||||
def abort(self):
|
||||
# XXX Is it abuse to handle the end of inserting here in abort()?
|
||||
if self._item is not None:
|
||||
def keyPressEvent(self, event, image_item):
|
||||
"""
|
||||
When the user presses Enter, the polygon is finished.
|
||||
"""
|
||||
if event.key() == Qt.Key_Return and self._item is not None:
|
||||
polygon = self._item.polygon()
|
||||
assert polygon.size() > 0
|
||||
|
||||
@@ -377,5 +381,6 @@ class PolygonItemInserter(ItemInserter):
|
||||
self._init_pos = None
|
||||
self._item = None
|
||||
self._current_image_item = None
|
||||
self._scene.clearMessage()
|
||||
|
||||
self.inserterFinished.emit()
|
||||
|
||||
Reference in New Issue
Block a user