Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1.2 and tip

stable settings: improve font selection widget

The settings dialog now displays the font name with set and clear buttons so
that the selected font can be reset to <unspecified>. The cancel button in the
font selection dialog box is also now properly handled.

Changeset e9e3df5f576c

Parent f1a78f976bb0

by David Golub

Changes to one file · Browse files at e9e3df5f576c Showing diff from parent f1a78f976bb0 Diff from another changeset...

 
126
127
128
129
 
130
131
 
132
133
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
136
137
138
139
140
 
141
142
143
 
146
147
148
149
 
 
 
150
151
 
 
 
152
153
154
 
163
164
165
166
 
167
168
 
169
170
171
 
172
173
174
 
126
127
128
 
129
130
 
131
132
133
 
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 
155
156
157
158
 
161
162
163
 
164
165
166
167
168
169
170
171
172
173
174
 
183
184
185
 
186
187
 
188
189
190
 
191
192
193
194
@@ -126,18 +126,33 @@
  def isDirty(self):   return self.value() != self.curvalue   -class FontEntry(QPushButton): +class FontEntry(QWidget):   def __init__(self, parent=None, **opts): - QPushButton.__init__(self, parent, toolTip=opts['tooltip']) + QWidget.__init__(self, parent, toolTip=opts['tooltip'])   self.opts = opts   self.curvalue = None - self.clicked.connect(self.on_clicked) + + self.label = QLabel() + self.setButton = QPushButton(_('&Set...')) + self.clearButton = QPushButton(_('&Clear')) + + layout = QHBoxLayout() + layout.setContentsMargins(0, 0, 0, 0) + layout.addWidget(self.label) + layout.addStretch() + layout.addWidget(self.setButton) + layout.addWidget(self.clearButton) + self.setLayout(layout) + + self.setButton.clicked.connect(self.onSetClicked) + self.clearButton.clicked.connect(self.onClearClicked) +   cpath = self.opts['cpath']   assert cpath.startswith('tortoisehg.')   self.fname = cpath[11:]   self.setMinimumWidth(ENTRY_WIDTH)   - def on_clicked(self, checked): + def onSetClicked(self, checked):   def newFont(font):   self.setText(font.toString())   thgf.setFont(font) @@ -146,9 +161,14 @@
  dlg = QFontDialog(self)   dlg.currentFontChanged.connect(newFont)   font, isok = dlg.getFont(origfont, self) - self.setText(font.toString()) + if not isok: + return + self.label.setText(font.toString())   thgf.setFont(font)   + def onClearClicked(self, checked): + self.label.setText(_unspecstr) +   def currentFont(self):   """currently selected QFont if specified"""   if not self.value(): @@ -163,12 +183,12 @@
  def setValue(self, curvalue):   self.curvalue = curvalue   if curvalue: - self.setText(hglib.tounicode(curvalue)) + self.label.setText(hglib.tounicode(curvalue))   else: - self.setText(_unspecstr) + self.label.setText(_unspecstr)     def value(self): - utext = self.text() + utext = self.label.text()   if utext == _unspecstr:   return None   else: