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

qtlib: add a font cache built around QObject wrapper w/ changed signal

Changeset 6d632d2e16ab

Parent 316ae123a413

by Steve Borho

Changes to one file · Browse files at 6d632d2e16ab Showing diff from parent 316ae123a413 Diff from another changeset...

 
153
154
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
157
158
 
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
@@ -153,6 +153,31 @@
  _pixmapcache[key] = pixmap   return pixmap   +class ThgFont(QObject): + changed = pyqtSignal(QFont) + def __init__(self, name): + QObject.__init__(self) + self.myfont = QFont(name) + def font(self): + return self.myfont + def setFont(self, f): + self.myfont = f + self.changed.emit(f) + +_fontdefaults = { + 'fontcomment': 'monospace 10', + 'fontdiff': 'monospace 10', + 'fontlist': 'sans 9', + 'fontlog': 'monospace 10' +} +_fontcache = {} +def getfont(ui, name): + assert name in _fontdefaults + if name not in _fontcache: + fname = ui.config('tortoisehg', name, _fontdefaults[name]) + _fontcache[name] = ThgFont(fname) + return _fontcache[name] +  def CommonMsgBox(icon, title, main, text='', buttons=QMessageBox.Close,   labels=[], parent=None, defaultbutton=None):   msg = QMessageBox(parent)