Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

qtlib: make getfont and FontEntry handle attributes correctly

qfont.toString() generates font description, which should be loaded by
qfont.fromString() to set size, style, etc. correctly.

Also updated _fontdefaults to be a valid font description.

Changeset f87ac85f2ae4

Parent 2ec2dca59aa0

by Yuya Nishihara

Changes to 2 files · Browse files at f87ac85f2ae4 Showing diff from parent 2ec2dca59aa0 Diff from another changeset...

 
157
158
159
160
 
 
161
162
163
 
165
166
167
168
169
170
171
 
 
 
 
172
173
174
 
157
158
159
 
160
161
162
163
164
 
166
167
168
 
 
 
 
169
170
171
172
173
174
175
@@ -157,7 +157,8 @@
  changed = pyqtSignal(QFont)   def __init__(self, name):   QObject.__init__(self) - self.myfont = QFont(name) + self.myfont = QFont() + self.myfont.fromString(name)   def font(self):   return self.myfont   def setFont(self, f): @@ -165,10 +166,10 @@
  self.changed.emit(f)    _fontdefaults = { - 'fontcomment': 'monospace 10', - 'fontdiff': 'monospace 10', - 'fontlist': 'sans 9', - 'fontlog': 'monospace 10' + 'fontcomment': 'monospace,10', + 'fontdiff': 'monospace,10', + 'fontlist': 'sans,9', + 'fontlog': 'monospace,10'  }  _fontcache = {}  def getfont(ui, name):
 
153
154
155
156
 
157
158
159
160
 
 
 
 
 
 
 
 
161
162
163
 
153
154
155
 
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@@ -153,11 +153,19 @@
  def on_clicked(self, checked):   thgf = qtlib.getfont(ui.ui(), self.fname)   dlg = QFontDialog(self) - dlg.setCurrentFont(QFont(self.value() or thgf.font())) + dlg.setCurrentFont(self.currentFont() or thgf.font())   if dlg.exec_() == QDialog.Accepted:   thgf.setFont(dlg.selectedFont())   self.setText(thgf.font().toString())   + def currentFont(self): + """currently selected QFont if specified""" + if not self.value(): + return None + + f = QFont() + f.fromString(self.value()) +   ## common APIs for all edit widgets     def setValue(self, curvalue):