Browse Source

Settings: improvements to dynamic fee slider

Fixes #1595
283
Neil Booth 9 years ago
parent
commit
c02e3621f3
  1. 26
      gui/qt/main_window.py

26
gui/qt/main_window.py

@ -2626,7 +2626,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
])
fee_label = HelpLabel(_('Transaction fee per kb') + ':', msg)
fee_e = BTCkBEdit(self.get_decimal_point)
fee_e.setAmount(self.config.get('fee_per_kb', bitcoin.RECOMMENDED_FEE))
def on_fee(is_done):
if self.config.get('dynamic_fees'):
return
@ -2637,15 +2636,22 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
fee_e.textEdited.connect(lambda: on_fee(False))
tx_widgets.append((fee_label, fee_e))
def slider_moved():
mins = timeout_slider.sliderPosition()
timeout_minutes.setText(_("%2d minutes") % mins)
dynfee_cb = QCheckBox(_('Dynamic fees'))
dynfee_cb.setChecked(self.config.get('dynamic_fees', False))
dynfee_cb.setToolTip(_("Use a fee per kB value recommended by the server."))
dynfee_sl = QSlider(Qt.Horizontal, self)
dynfee_sl.setRange(50, 150)
dynfee_sl.setTickInterval(10)
dynfee_sl.setTickPosition(QSlider.TicksBelow)
dynfee_sl.setValue(self.config.get('fee_factor', 50))
dynfee_sl.setToolTip("Min = 50%, Max = 150%")
tx_widgets.append((dynfee_cb, None))
multiplier_label = HelpLabel(_('Fee multiplier'), _("Multiply the recommended fee/kb value by a constant factor. Min = 50%, Max = 150%"))
tx_widgets.append((multiplier_label, dynfee_sl))
multiplier_label = HelpLabel("", _("Multiply the recommended fee/kb value by a constant factor. Min = 50%, Max = 150%"))
tx_widgets.append((dynfee_cb, dynfee_sl))
tx_widgets.append((None, multiplier_label))
def update_feeperkb():
fee_e.setAmount(self.wallet.fee_per_kb(self.config))
@ -2653,16 +2659,21 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
dynfee_sl.setEnabled(b)
multiplier_label.setEnabled(b)
fee_e.setEnabled(not b)
def fee_factor_changed(b):
self.config.set_key('fee_factor', b, False)
def slider_moved():
multiplier_label.setText(_('Fee multiplier: %3d%%')
% dynfee_sl.sliderPosition())
def slider_released():
self.config.set_key('fee_factor', dynfee_sl.sliderPosition(), False)
update_feeperkb()
def on_dynfee(x):
dynfee = x == Qt.Checked
self.config.set_key('dynamic_fees', dynfee)
update_feeperkb()
dynfee_cb.stateChanged.connect(on_dynfee)
dynfee_sl.valueChanged[int].connect(fee_factor_changed)
dynfee_sl.valueChanged.connect(slider_moved)
dynfee_sl.sliderReleased.connect(slider_released)
update_feeperkb()
slider_moved()
msg = _('OpenAlias record, used to receive coins and to sign payment requests.') + '\n\n'\
+ _('The following alias providers are available:') + '\n'\
@ -2849,6 +2860,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
for a,b in widgets:
i = grid.rowCount()
if b:
if a:
grid.addWidget(a, i, 0)
grid.addWidget(b, i, 1)
else:

Loading…
Cancel
Save