aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrien Tétar2015-09-29 20:54:18 +0200
committerAdrien Tétar2015-09-29 20:54:18 +0200
commit18cef5b68f5c1eaa0c4e576f9704ba9175c6b159 (patch)
tree3496aff8816334ac57c9dccd6be691f030ee7622
parent66aa3275652c4e860bb12202586558ceabd2e0e9 (diff)
downloadtrufont-18cef5b68f5c1eaa0c4e576f9704ba9175c6b159.tar.bz2
fontView: don't overwrite naming data on paste, add reload from disk functionality, nits
-rw-r--r--Lib/defconQt/featureTextEditor.py4
-rw-r--r--Lib/defconQt/fontInfo.py2
-rw-r--r--Lib/defconQt/fontView.py21
3 files changed, 22 insertions, 5 deletions
diff --git a/Lib/defconQt/featureTextEditor.py b/Lib/defconQt/featureTextEditor.py
index cadb9d5..5ee9b02 100644
--- a/Lib/defconQt/featureTextEditor.py
+++ b/Lib/defconQt/featureTextEditor.py
@@ -11,12 +11,12 @@ class MainEditWindow(QMainWindow):
self.font = font
self.setupFileMenu()
self.editor = TextEditor(self.font.features.text, self)
- # arm `undoAvailable` to `setWindowModified`
- self.editor.setFileChangedCallback(self.setWindowModified)
self.resize(600, 500)
self.setCentralWidget(self.editor)
self.setWindowTitle("Font features", self.font)
+ # now arm `undoAvailable` to `setWindowModified`
+ self.editor.setFileChangedCallback(self.setWindowModified)
def setWindowTitle(self, title, font):
if font is not None: puts = "[*]%s – %s %s" % (title, self.font.info.familyName, self.font.info.styleName)
diff --git a/Lib/defconQt/fontInfo.py b/Lib/defconQt/fontInfo.py
index cee16f3..4625eec 100644
--- a/Lib/defconQt/fontInfo.py
+++ b/Lib/defconQt/fontInfo.py
@@ -11,7 +11,7 @@ class TabDialog(QDialog):
super(TabDialog, self).__init__(parent)
self.font = font
- self.tabWidget = InfoTabWidget()
+ self.tabWidget = InfoTabWidget(self)
self.tabWidget.addNamedTab(GeneralTab(self.font))
self.tabWidget.addNamedTab(MetricsTab(self.font))
self.tabWidget.addNamedTab(OpenTypeTab(self.font))
diff --git a/Lib/defconQt/fontView.py b/Lib/defconQt/fontView.py
index 0ab05c7..0404e11 100644
--- a/Lib/defconQt/fontView.py
+++ b/Lib/defconQt/fontView.py
@@ -274,6 +274,7 @@ class MainWindow(QMainWindow):
fileMenu.addSeparator()
fileMenu.addAction("&Save", self.saveFile, QKeySequence.Save)
fileMenu.addAction("Save &As…", self.saveFileAs, QKeySequence.SaveAs)
+ fileMenu.addAction("Reload from disk", self.reload)
fileMenu.addAction("E&xit", self.close, QKeySequence.Quit)
menuBar.addMenu(fileMenu)
@@ -333,7 +334,7 @@ class MainWindow(QMainWindow):
self.setCentralWidget(self.collectionWidget.scrollArea())
self.resize(605, 430)
- self.setWindowTitle() # TODO: maybe clean this up
+ self.setWindowTitle()
def newFile(self):
ok = self.maybeSaveBeforeExit()
@@ -401,7 +402,7 @@ class MainWindow(QMainWindow):
currentFont = os.path.basename(self.font.path.rstrip(os.sep))
else:
currentFont = "Untitled.ufo"
- body = "%s%s%s" % ("Do you want to save the changes you made to “", currentFont, "”?")
+ body = "Do you want to save the changes you made to “%s”?" % currentFont
closeDialog = QMessageBox(QMessageBox.Question, title, body,
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel, self)
closeDialog.setInformativeText("Your changes will be lost if you don’t save them.")
@@ -415,6 +416,16 @@ class MainWindow(QMainWindow):
return False
return True
+ def reload(self):
+ font = self._font
+ font.reloadInfo()
+ font.reloadKerning()
+ font.reloadGroups()
+ font.reloadFeatures()
+ font.reloadLib()
+ font.reloadGlyphs(font.keys())
+ self.setWindowModified(False)
+
def _get_font(self):
return self._font
@@ -503,7 +514,13 @@ class MainWindow(QMainWindow):
glyphs = self.collectionWidget.getSelectedGlyphs()
if len(data) == len(glyphs):
for pickled, glyph in zip(data, glyphs):
+ name = glyph.name
+ uni = glyph.unicode
glyph.deserializeFromUndo(pickled)
+ # XXX: after upgrade to ufo3, write a more flexible
+ # serialization system
+ glyph.name = name
+ glyph.unicode = uni
def markColor(self):
color = self.sender().data()