diff options
| author | Adrien Tétar | 2015-10-17 13:16:24 +0200 | 
|---|---|---|
| committer | Adrien Tétar | 2015-10-17 13:19:43 +0200 | 
| commit | 816748b6d6b14b8b9f80fc904dc2654fd3e0f7c1 (patch) | |
| tree | 534aaf2468d2e712e9dc1a9a1637787818c6a9d5 /Lib/defconQt/fontView.py | |
| parent | 7cc2a144bdbb73b81ffcd4b8ac7fef8b94ee82b6 (diff) | |
| download | trufont-816748b6d6b14b8b9f80fc904dc2654fd3e0f7c1.tar.bz2 | |
glyphView: add startPoints support, consolidate notifications
Diffstat (limited to 'Lib/defconQt/fontView.py')
| -rw-r--r-- | Lib/defconQt/fontView.py | 30 | 
1 files changed, 28 insertions, 2 deletions
| diff --git a/Lib/defconQt/fontView.py b/Lib/defconQt/fontView.py index 001d2ea..15f4489 100644 --- a/Lib/defconQt/fontView.py +++ b/Lib/defconQt/fontView.py @@ -48,11 +48,13 @@ latinDefault = GlyphSet(  "uni0327","quoteleft","quoteright","minus"],"Latin-default")  class Application(QApplication): +    currentFontChanged = pyqtSignal()      currentGlyphChanged = pyqtSignal()      def __init__(self, *args, **kwargs):          super(Application, self).__init__(*args, **kwargs)          self._currentGlyph = None +        self._currentMainWindow = None      def allFonts(self):          fonts = [] @@ -62,7 +64,7 @@ class Application(QApplication):                  return fonts      def currentFont(self): -        return self.currentMainWindow._font +        return self._currentMainWindow._font      def currentGlyph(self):          return self._currentGlyph @@ -72,6 +74,27 @@ class Application(QApplication):              return          self._currentGlyph = glyph          self.currentGlyphChanged.emit() +        # update currentMainWindow if we need to. +        # XXX: find a way to update currentMainWindow when we switch to any +        # child of a MainWindow instead of the MainWindow itself. +        # Currently, what's below serves for the glyphView but should probably +        # be expanded. +        font = glyph.getParent() +        if font != self.currentFont(): +            for window in QApplication.topLevelWidgets(): +                if isinstance(window, MainWindow): +                    if window._font == font: +                        self.setCurrentMainWindow(window) +                        break + +    def currentMainWindow(self): +        return self._currentMainWindow + +    def setCurrentMainWindow(self, mainWindow): +        if mainWindow == self._currentMainWindow: +            return +        self._currentMainWindow = mainWindow +        self.currentFontChanged.emit()  MAX_RECENT_FILES = 6 @@ -630,6 +653,7 @@ class MainWindow(QMainWindow):          windowMenu = QMenu("&Windows", self)          action = windowMenu.addAction("&Inspector", self.inspector, "Ctrl+I") +        # XXX: we're getting duplicate shortcut when we spawn a new window...          action.setShortcutContext(Qt.ApplicationShortcut)          windowMenu.addAction("&Space center", self.spaceCenter, "Ctrl+Alt+S")          windowMenu.addAction("&Groups window", self.fontGroups, "Ctrl+Alt+G") @@ -972,7 +996,7 @@ class MainWindow(QMainWindow):      def event(self, event):          if event.type() == QEvent.WindowActivate:              app = QApplication.instance() -            app.currentMainWindow = self +            app.setCurrentMainWindow(self)              lastSelectedGlyph = self.collectionWidget.lastSelectedGlyph()              if lastSelectedGlyph is not None:                  app.setCurrentGlyph(lastSelectedGlyph) @@ -1051,6 +1075,8 @@ class MainWindow(QMainWindow):              app.inspectorWindow = InspectorWindow()              app.inspectorWindow.show()          elif app.inspectorWindow.isVisible(): +            # TODO: do this only if the widget is user-visible, otherwise the +            # key press feels as if it did nothing              # toggle              app.inspectorWindow.close()          else: | 
