Source

thg-qt-mq / fontsetting-visible.diff

# HG changeset patch
# Parent acee25225f8e02f76e19c514eb1748e489d8fd26

diff --git a/tortoisehg/hgqt/settings.py b/tortoisehg/hgqt/settings.py
--- a/tortoisehg/hgqt/settings.py
+++ b/tortoisehg/hgqt/settings.py
@@ -135,20 +135,32 @@ class PasswordEntry(QLineEdit):
     def isDirty(self):
         return self.value() != self.curvalue
 
-class FontEntry(QPushButton):
+class FontEntry(QWidget):
     def __init__(self, parent=None, **opts):
-        QPushButton.__init__(self, parent)
+        QWidget.__init__(self, parent)
         self.opts = opts
         self.curvalue = None
         self.setDisabled(opts['readonly'])
-        self.clicked.connect(self.on_clicked)
+
+        layout = QHBoxLayout(self)
+        layout.setContentsMargins(0, 0, 0, 0)
+        self.setLayout(layout)
+
+        self._nameedit = QLineEdit(self, readOnly=True, focusPolicy=Qt.NoFocus,
+                                   styleSheet='QLineEdit { background: transparent; }')
+        layout.addWidget(self._nameedit)
+
+        self._choosebtn = QPushButton(_('Choose'), self)
+        self._choosebtn.clicked.connect(self.on_clicked)
+        layout.addWidget(self._choosebtn)
+
         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)
+        QWidget.focusInEvent(self, e)
 
     def on_clicked(self, checked):
         thgf = qtlib.getfont(ui.ui(), self.fname)
@@ -156,7 +168,7 @@ class FontEntry(QPushButton):
         dlg.setCurrentFont(self.currentFont() or thgf.font())
         if dlg.exec_() == QDialog.Accepted:
             thgf.setFont(dlg.selectedFont())
-            self.setText(thgf.font().toString())
+            self.setValue(thgf.font().toString())
 
     def currentFont(self):
         """currently selected QFont if specified"""
@@ -171,12 +183,15 @@ class FontEntry(QPushButton):
     def setValue(self, curvalue):
         self.curvalue = curvalue
         if curvalue:
-            self.setText(hglib.tounicode(curvalue))
+            self._nameedit.setText(hglib.tounicode(curvalue))
         else:
-            self.setText(_unspecstr)
+            self._nameedit.setText(_unspecstr)
+
+        thgf = qtlib.getfont(ui.ui(), self.fname)
+        self._nameedit.setFont(self.currentFont() or thgf.font())
 
     def value(self):
-        utext = self.text()
+        utext = self._nameedit.text()
         if utext == _unspecstr:
             return None
         else:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.