Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable qtlib: use icon-title font as the default main window font on Windows

On Windows, main window seems to use "icon-title" font, but Qt doesn't.

Changeset 960d3fa95b8f

Parent e831dfdaa9e9

by Yuya Nishihara

Changes to 2 files · Browse files at 960d3fa95b8f Showing diff from parent e831dfdaa9e9 Diff from another changeset...

 
380
381
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
384
385
 
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
@@ -380,6 +380,27 @@
 def setup_font_substitutions():   QFont.insertSubstitutions('monospace', ['monaco', 'courier new'])   +def fix_application_font(): + if os.name != 'nt': + return + try: + import win32gui, win32con + except ImportError: + return + + # On Windows, the font for main window seems to be determined by "icon" + # font, but Qt chooses uncustomizable system font. + lf = win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT) + f = QFont(hglib.tounicode(lf.lfFaceName)) + f.setItalic(lf.lfItalic) + if lf.lfWeight != win32con.FW_DONTCARE: + weights = [(0, QFont.Light), (400, QFont.Normal), (600, QFont.DemiBold), + (700, QFont.Bold), (800, QFont.Black)] + n, w = filter(lambda e: e[0] <= lf.lfWeight, weights)[-1] + f.setWeight(w) + f.setPixelSize(abs(lf.lfHeight)) + QApplication.setFont(f, 'QMainWindow') +  class PMButton(QPushButton):   """Toggle button with plus/minus icon images"""  
 
450
451
452
 
453
454
455
 
450
451
452
453
454
455
456
@@ -450,6 +450,7 @@
  self._mainapp.setOrganizationDomain('tortoisehg.org')   self._mainapp.setApplicationVersion(thgversion.version())   qtlib.setup_font_substitutions() + qtlib.fix_application_font()   qtlib.configstyles(ui)   qtlib.initfontcache(ui)   self._mainapp.setWindowIcon(qtlib.geticon('thg_logo'))