예제 #1
0
 def delete(self):
     modifiers = QApplication.keyboardModifiers()
     widget = self.stackWidget.currentWidget()
     if self.isGlyphTab():
         glyph = widget.activeGlyph()
         # TODO: fuse more the two methods, they're similar and delete is
         # Cut except not putting in the clipboard
         if modifiers & Qt.AltModifier:
             deleteUISelection(glyph)
         else:
             preserveShape = not modifiers & Qt.ShiftModifier
             removeUIGlyphElements(glyph, preserveShape)
     else:
         erase = modifiers & Qt.ShiftModifier
         if self._proceedWithDeletion(erase):
             glyphs = widget.glyphsForIndexes(widget.selection())
             for glyph in glyphs:
                 font = glyph.font
                 for layer in font.layers:
                     if glyph.name in layer:
                         defaultLayer = layer[glyph.name] == glyph
                         if defaultLayer and not erase:
                             # TODO: clear in glyph.template setter?
                             glyph.clear()
                             glyph.template = True
                         else:
                             del layer[glyph.name]
예제 #2
0
 def keyPressEvent(self, event):
     key = event.key()
     if platformSpecific.isDeleteEvent(event):
         glyph = self._glyph
         # TODO: fuse more the two methods, they're similar and delete is
         # Cut except not putting in the clipboard
         if event.modifiers() & Qt.AltModifier:
             deleteUISelection(glyph)
         else:
             preserveShape = not event.modifiers() & Qt.ShiftModifier
             # TODO: prune
             glyph.prepareUndo()
             removeUIGlyphElements(glyph, preserveShape)
     elif key in arrowKeys:
         # TODO: prune
         self._glyph.prepareUndo()
         dx, dy = self._moveForEvent(event)
         # TODO: seems weird that glyph.selection and selected don't incl.
         # anchors and components while glyph.move does... see what glyphs
         # does
         moveUIGlyphElements(self._glyph, dx, dy)
     elif key in navKeys:
         pack = self._getSelectedCandidatePoint()
         if pack is not None:
             point, contour = pack
             point.selected = False
             index = contour.index(point)
             offset = int(key == Qt.Key_Greater) or -1
             newPoint = contour.getPoint(index + offset)
             newPoint.selected = True
             contour.postNotification(
                 notification="Contour.SelectionChanged")