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

settings: add a simple fonts page

Feel free to back-port the font sets idea from the gtk version of the settings
tool. Just keep these live updates functional.

Changeset 91ff5e0a53dc

Parent 1f3e73c4d3cf

by Steve Borho

Changes to 2 files · Browse files at 91ff5e0a53dc Showing diff from parent 1f3e73c4d3cf Diff from another changeset...

 
111
112
113
114
 
115
116
117
 
111
112
113
 
114
115
116
117
@@ -111,7 +111,7 @@
  msgte.setLineWrapMode(QPlainTextEdit.NoWrap)   msgfont = qtlib.getfont(self.stwidget.repo.ui, 'fontcomment')   msgte.setFont(msgfont.font()) - self.connect(msgfont, SIGNAL('changed'), msgte.setFont) + msgfont.changed.connect(lambda fnt: msgte.setFont(fnt))   msgte.textChanged.connect(self.msgChanged)   msgte.setContextMenuPolicy(Qt.CustomContextMenu)   self.connect(msgte,
 
135
136
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
139
140
 
169
170
171
 
 
 
172
173
174
 
412
413
414
 
 
 
 
 
 
 
 
 
 
 
 
415
416
417
 
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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
 
210
211
212
213
214
215
216
217
218
 
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
@@ -135,6 +135,47 @@
  def isDirty(self):   return self.value() != self.curvalue   +class FontEntry(QPushButton): + def __init__(self, parent=None, **opts): + QPushButton.__init__(self, parent) + self.opts = opts + self.curvalue = None + self.setDisabled(opts['readonly']) + self.clicked.connect(self.on_clicked) + cpath = self.opts['cpath'] + assert cpath.startswith('tortoisehg.') + self.fname = cpath[11:] + + def focusInEvent(self, e): + self.opts['descwidget'].setHtml(self.opts['tooltip']) + QPushButton.focusInEvent(self, e) + + def on_clicked(self, checked): + thgf = qtlib.getfont(ui.ui(), self.fname) + dlg = QFontDialog(self) + dlg.setCurrentFont(QFont(self.value() or thgf.font())) + if dlg.exec_() == QDialog.Accepted: + thgf.setFont(dlg.selectedFont()) + self.setText(thgf.font().toString()) + + ## common APIs for all edit widgets + + def setValue(self, curvalue): + self.curvalue = curvalue + if curvalue: + self.setText(hglib.tounicode(curvalue)) + else: + self.setText(_unspecstr) + + def value(self): + utext = self.text() + if utext == _unspecstr: + return None + else: + return hglib.fromunicode(utext) + + def isDirty(self): + return self.value() != self.curvalue    def genEditCombo(opts, defaults=[]):   opts['canedit'] = True @@ -169,6 +210,9 @@
  opts['nohist'] = True   return SettingsCombo(**opts)   +def genFontEdit(opts): + return FontEntry(**opts) +  def findDiffTools():   return hglib.difftools(ui.ui())   @@ -412,6 +456,18 @@
  _('Ignore changes whose lines are all blank.'   ' Default: False')),   )), + +({'name': 'fonts', 'label': _('Fonts'), + 'icon': QStyle.SP_DesktopIcon}, ( # crap icon, I know + (_('Message Font'), 'tortoisehg.fontcomment', genFontEdit, + _('Font used to display commit messages. Default: monospace 10')), + (_('Diff Font'), 'tortoisehg.fontdiff', genFontEdit, + _('Font used to display text differences. Default: monospace 10')), + (_('List Font'), 'tortoisehg.fontlist', genFontEdit, + _('Font used to display file lists. Default: sans 9')), + (_('Log Font'), 'tortoisehg.fontlog', genFontEdit, + _('Font used to display changelog data. Default: monospace 10')), + )),  )    CONF_GLOBAL = 0