aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/groupsView.py
diff options
context:
space:
mode:
authorAdrien Tétar2015-09-11 21:57:09 +0200
committerAdrien Tétar2015-09-11 21:57:09 +0200
commit634c78e0147d95f83415a4f26d5333f60ecba312 (patch)
treeffb2b68e4727403fbfe86f0aba5564e77e17130d /Lib/defconQt/groupsView.py
parent797a6548a18815e1020d792ffda2d8a39ae4d834 (diff)
downloadtrufont-634c78e0147d95f83415a4f26d5333f60ecba312.tar.bz2
groupsView: autoAlignment, change alignment with r/l arrows
Diffstat (limited to 'Lib/defconQt/groupsView.py')
-rw-r--r--Lib/defconQt/groupsView.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/Lib/defconQt/groupsView.py b/Lib/defconQt/groupsView.py
index adf0b9d..02154dd 100644
--- a/Lib/defconQt/groupsView.py
+++ b/Lib/defconQt/groupsView.py
@@ -16,9 +16,14 @@ class GroupListWidget(QListWidget):
#if len(groupNames): self.setCurrentRow(0)
def keyPressEvent(self, event):
- if event.key() == Qt.Key_Delete:
+ key = event.key()
+ if key == Qt.Key_Delete:
self.parent()._groupDelete()
event.accept()
+ elif key == Qt.Key_Left:
+ self.parent().alignLeftBox.setChecked(True)
+ elif key == Qt.Key_Right:
+ self.parent().alignRightBox.setChecked(True)
else:
super(GroupListWidget, self).keyPressEvent(event)
@@ -95,13 +100,18 @@ class GroupCharacterWidget(CharacterWidget):
self.parent().parent().parent().characterDropEvent(event)
class GroupsWindow(QWidget):
+ leftGroups = ["@MMK_L", "public.kern1"]
+ rightGroups = ["@MMK_R", "public.kern2"]
+
def __init__(self, font, parent=None):
super(GroupsWindow, self).__init__(parent, Qt.Window)
self.font = font
groups = self.font.groups.keys()
self.groupsList = GroupListWidget(groups, self)
+ self.groupsList.currentItemChanged.connect(self._groupChanged)
self.groupsList.itemChanged.connect(self._groupRenamed)
+ self.groupsList.setFocus(True)
self.stackWidget = GroupStackWidget(self.font, parent=self)
@@ -115,11 +125,11 @@ class GroupsWindow(QWidget):
self.alignRightBox = QRadioButton("Align right", self)
self.alignLeftBox.setChecked(True)
self.alignLeftBox.toggled.connect(self._alignmentChanged)
+ self._autoDirection = True
self.scrollArea = QScrollArea(self)
self.characterWidget = GroupCharacterWidget(self.font, scrollArea=self.scrollArea, parent=self)
self.scrollArea.setWidget(self.characterWidget)
- self.groupsList.currentItemChanged.connect(self._groupChanged)
self._cachedName = None
layout = QGridLayout(self)
@@ -156,6 +166,15 @@ class GroupsWindow(QWidget):
def _groupChanged(self):
self._cachedName = self.groupsList.currentItem().text()
+ if self._autoDirection:
+ for name in self.leftGroups:
+ if self._cachedName.startswith(name):
+ self.alignRightBox.setChecked(True)
+ break
+ for name in self.rightGroups:
+ if self._cachedName.startswith(name):
+ self.alignLeftBox.setChecked(True)
+ break
glyphs = []
for gName in self.font.groups[self._cachedName]:
if gName in self.font: