aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/layerSetList.py
diff options
context:
space:
mode:
authorAdrien Tétar2015-10-17 13:16:24 +0200
committerAdrien Tétar2015-10-17 13:19:43 +0200
commit816748b6d6b14b8b9f80fc904dc2654fd3e0f7c1 (patch)
tree534aaf2468d2e712e9dc1a9a1637787818c6a9d5 /Lib/defconQt/layerSetList.py
parent7cc2a144bdbb73b81ffcd4b8ac7fef8b94ee82b6 (diff)
downloadtrufont-816748b6d6b14b8b9f80fc904dc2654fd3e0f7c1.tar.bz2
glyphView: add startPoints support, consolidate notifications
Diffstat (limited to 'Lib/defconQt/layerSetList.py')
-rw-r--r--Lib/defconQt/layerSetList.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/Lib/defconQt/layerSetList.py b/Lib/defconQt/layerSetList.py
index b2d3c9f..485477b 100644
--- a/Lib/defconQt/layerSetList.py
+++ b/Lib/defconQt/layerSetList.py
@@ -1,15 +1,16 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QKeySequence, QColor, QPixmap, QIcon
-from PyQt5.QtWidgets import QWidget, QMenu, QListWidget, QListWidgetItem, \
- QAbstractItemView, QVBoxLayout, QAction, QColorDialog
+from PyQt5.QtWidgets import (QApplication, QWidget, QMenu, QListWidget,
+ QListWidgetItem, QAbstractItemView, QVBoxLayout, QAction, QColorDialog)
from defconQt import icons_db
from defconQt.glyphView import AddLayerDialog
class LayerSetList(QListWidget):
- def __init__(self, font, parent=None, *args, **kwds):
- super().__init__(parent, *args, **kwds)
+ def __init__(self, parent=None, *args, **kwargs):
+ super().__init__(parent, *args, **kwargs)
- self._layerSet = font.layers
+ app = QApplication.instance()
+ self._layerSet = app.currentFont().layers
self.setDragDropMode(QAbstractItemView.InternalMove)
@@ -45,13 +46,13 @@ class LayerSetList(QListWidget):
self.addAction(action)
self._layerSet.addObserver(self, '_update', 'LayerSet.Changed')
-
self._update()
+ app.currentFontChanged.connect(self.updateFont)
+
def _update(self, *args):
index = self.currentRow()
- while self.count():
- self.takeItem(self.count()-1)
+ self.clear()
for i, layer in enumerate(self._layerSet):
item = self._makeItem(layer)
self.addItem(item)
@@ -133,3 +134,11 @@ class LayerSetList(QListWidget):
if not layer:
return
layer.color = None
+
+ def updateFont(self):
+ if self._layerSet is not None:
+ self._layerSet.removeObserver(self, 'LayerSet.Changed')
+ currentFont = QApplication.instance().currentFont()
+ self._layerSet = currentFont.layers
+ self._layerSet.addObserver(self, '_update', 'LayerSet.Changed')
+ self._update()