commit c035bfcc46920a05770b802789b79e18cc8012c8
parent 959af0065bcec52a6e5832d47fe76f70dfba1421
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 26 May 2020 18:34:48 +0200
Qt: show fee combo next to fee slider, and remove it from settings
Diffstat:
5 files changed, 59 insertions(+), 43 deletions(-)
diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/electrum/gui/qt/confirm_tx_dialog.py
@@ -38,7 +38,7 @@ from electrum.wallet import InternalAddressCorruption
from .util import (WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton,
BlockingWaitingDialog, PasswordLineEdit)
-from .fee_slider import FeeSlider
+from .fee_slider import FeeSlider, FeeComboBox
if TYPE_CHECKING:
from .main_window import ElectrumWindow
@@ -146,7 +146,10 @@ class ConfirmTxDialog(TxEditor, WindowModalDialog):
grid.addWidget(self.extra_fee_value, 2, 1)
self.fee_slider = FeeSlider(self, self.config, self.fee_slider_callback)
+ self.fee_combo = FeeComboBox(self.fee_slider)
+ grid.addWidget(HelpLabel(_("Fee rate") + ": ", self.fee_combo.help_msg), 5, 0)
grid.addWidget(self.fee_slider, 5, 1)
+ grid.addWidget(self.fee_combo, 5, 2)
self.message_label = QLabel(self.default_message())
grid.addWidget(self.message_label, 6, 0, 1, -1)
diff --git a/electrum/gui/qt/fee_slider.py b/electrum/gui/qt/fee_slider.py
@@ -2,10 +2,31 @@ import threading
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QSlider, QToolTip
+from PyQt5.QtWidgets import QSlider, QToolTip, QComboBox
from electrum.i18n import _
+class FeeComboBox(QComboBox):
+
+ def __init__(self, fee_slider):
+ QComboBox.__init__(self)
+ self.config = fee_slider.config
+ self.fee_slider = fee_slider
+ self.addItems([_('Static'), _('ETA'), _('Mempool')])
+ self.setCurrentIndex((2 if self.config.use_mempool_fees() else 1) if self.config.is_dynfee() else 0)
+ self.currentIndexChanged.connect(self.on_fee_type)
+ self.help_msg = '\n'.join([
+ _('Static: the fee slider uses static values'),
+ _('ETA: fee rate is based on average confirmation time estimates'),
+ _('Mempool based: fee rate is targeting a depth in the memory pool')
+ ]
+ )
+
+ def on_fee_type(self, x):
+ self.config.set_key('mempool_fees', x==2)
+ self.config.set_key('dynamic_fees', x>0)
+ self.fee_slider.update()
+
class FeeSlider(QSlider):
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -83,7 +83,7 @@ from .amountedit import AmountEdit, BTCAmountEdit, FreezableLineEdit, FeerateEdi
from .qrcodewidget import QRCodeWidget, QRDialog
from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
from .transaction_dialog import show_transaction
-from .fee_slider import FeeSlider
+from .fee_slider import FeeSlider, FeeComboBox
from .util import (read_QIcon, ColorScheme, text_dialog, icon_path, WaitingDialog,
WindowModalDialog, ChoicesLayout, HelpLabel, Buttons,
OkButton, InfoButton, WWLabel, TaskThread, CancelButton,
@@ -3041,8 +3041,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
fee = get_child_fee_from_total_feerate(fee_rate)
fee_e.setAmount(fee)
fee_slider = FeeSlider(self, self.config, on_rate)
+ fee_combo = FeeComboBox(fee_slider)
fee_slider.update()
grid.addWidget(fee_slider, 4, 1)
+ grid.addWidget(fee_combo, 4, 2)
grid.addWidget(QLabel(_('Total fee') + ':'), 5, 0)
grid.addWidget(combined_fee, 5, 1)
grid.addWidget(QLabel(_('Total feerate') + ':'), 6, 0)
@@ -3074,24 +3076,32 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
d = WindowModalDialog(self, _('Bump Fee'))
vbox = QVBoxLayout(d)
vbox.addWidget(WWLabel(_("Increase your transaction's fee to improve its position in mempool.")))
- vbox.addWidget(QLabel(_('Current Fee') + ': %s'% self.format_amount(fee) + ' ' + self.base_unit()))
- vbox.addWidget(QLabel(_('Current Fee rate') + ': %s' % self.format_fee_rate(1000 * old_fee_rate)))
- vbox.addWidget(QLabel(_('New Fee rate') + ':'))
+ grid = QGridLayout()
+ grid.addWidget(QLabel(_('Current Fee') + ':'), 0, 0)
+ grid.addWidget(QLabel(self.format_amount(fee) + ' ' + self.base_unit()), 0, 1)
+ grid.addWidget(QLabel(_('Current Fee rate') + ':'), 1, 0)
+ grid.addWidget(QLabel(self.format_fee_rate(1000 * old_fee_rate)), 1, 1)
+
+ grid.addWidget(QLabel(_('New Fee rate') + ':'), 2, 0)
def on_textedit_rate():
fee_slider.deactivate()
feerate_e = FeerateEdit(lambda: 0)
feerate_e.setAmount(max(old_fee_rate * 1.5, old_fee_rate + 1))
feerate_e.textEdited.connect(on_textedit_rate)
- vbox.addWidget(feerate_e)
+ grid.addWidget(feerate_e, 2, 1)
def on_slider_rate(dyn, pos, fee_rate):
fee_slider.activate()
if fee_rate is not None:
feerate_e.setAmount(fee_rate / 1000)
fee_slider = FeeSlider(self, self.config, on_slider_rate)
+ fee_combo = FeeComboBox(fee_slider)
fee_slider.deactivate()
- vbox.addWidget(fee_slider)
+ grid.addWidget(fee_slider, 3, 1)
+ grid.addWidget(fee_combo, 3, 2)
+
+ vbox.addLayout(grid)
cb = QCheckBox(_('Final'))
vbox.addWidget(cb)
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
diff --git a/electrum/gui/qt/settings_dialog.py b/electrum/gui/qt/settings_dialog.py
@@ -59,7 +59,6 @@ class SettingsDialog(WindowModalDialog):
vbox = QVBoxLayout()
tabs = QTabWidget()
gui_widgets = []
- fee_widgets = []
tx_widgets = []
oa_widgets = []
@@ -103,21 +102,6 @@ class SettingsDialog(WindowModalDialog):
nz.valueChanged.connect(on_nz)
gui_widgets.append((nz_label, nz))
- msg = '\n'.join([
- _('Time based: fee rate is based on average confirmation time estimates'),
- _('Mempool based: fee rate is targeting a depth in the memory pool')
- ]
- )
- fee_type_label = HelpLabel(_('Fee estimation') + ':', msg)
- fee_type_combo = QComboBox()
- fee_type_combo.addItems([_('Static'), _('ETA'), _('Mempool')])
- fee_type_combo.setCurrentIndex((2 if self.config.use_mempool_fees() else 1) if self.config.is_dynfee() else 0)
- def on_fee_type(x):
- self.config.set_key('mempool_fees', x==2)
- self.config.set_key('dynamic_fees', x>0)
- fee_type_combo.currentIndexChanged.connect(on_fee_type)
- fee_widgets.append((fee_type_label, fee_type_combo))
-
use_rbf = bool(self.config.get('use_rbf', True))
use_rbf_cb = QCheckBox(_('Use Replace-By-Fee'))
use_rbf_cb.setChecked(use_rbf)
@@ -129,7 +113,7 @@ class SettingsDialog(WindowModalDialog):
self.config.set_key('use_rbf', bool(x))
batch_rbf_cb.setEnabled(bool(x))
use_rbf_cb.stateChanged.connect(on_use_rbf)
- fee_widgets.append((use_rbf_cb, None))
+ tx_widgets.append((use_rbf_cb, None))
batch_rbf_cb = QCheckBox(_('Batch RBF transactions'))
batch_rbf_cb.setChecked(bool(self.config.get('batch_rbf', False)))
@@ -140,7 +124,7 @@ class SettingsDialog(WindowModalDialog):
def on_batch_rbf(x):
self.config.set_key('batch_rbf', bool(x))
batch_rbf_cb.stateChanged.connect(on_batch_rbf)
- fee_widgets.append((batch_rbf_cb, None))
+ tx_widgets.append((batch_rbf_cb, None))
# lightning
lightning_widgets = []
@@ -455,7 +439,6 @@ you close all your wallet windows. Use this to keep your local watchtower runnin
tabs_info = [
(gui_widgets, _('General')),
- (fee_widgets, _('Fees')),
(tx_widgets, _('Transactions')),
(lightning_widgets, _('Lightning')),
(fiat_widgets, _('Fiat')),
diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py
@@ -34,7 +34,7 @@ from decimal import Decimal
from PyQt5.QtCore import QSize, Qt
from PyQt5.QtGui import QTextCharFormat, QBrush, QFont, QPixmap
-from PyQt5.QtWidgets import (QDialog, QLabel, QPushButton, QHBoxLayout, QVBoxLayout, QWidget,
+from PyQt5.QtWidgets import (QDialog, QLabel, QPushButton, QHBoxLayout, QVBoxLayout, QWidget, QGridLayout,
QTextEdit, QFrame, QAction, QToolButton, QMenu, QCheckBox)
import qrcode
from qrcode import exceptions
@@ -55,7 +55,7 @@ from .util import (MessageBoxMixin, read_QIcon, Buttons, icon_path,
TRANSACTION_FILE_EXTENSION_FILTER_ONLY_PARTIAL_TX,
BlockingWaitingDialog)
-from .fee_slider import FeeSlider
+from .fee_slider import FeeSlider, FeeComboBox
from .confirm_tx_dialog import TxEditor
from .amountedit import FeerateEdit, BTCAmountEdit
from .locktimeedit import LockTimeEdit
@@ -711,6 +711,7 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
self.feerate_e.textChanged.connect(self.entry_changed)
self.fee_slider = FeeSlider(self, self.config, self.fee_slider_callback)
+ self.fee_combo = FeeComboBox(self.fee_slider)
self.fee_slider.setFixedWidth(self.fee_e.width())
def feerounding_onclick():
@@ -728,22 +729,20 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
self.feerounding_icon.clicked.connect(feerounding_onclick)
self.feerounding_icon.setVisible(False)
- self.fee_adv_controls = QWidget()
- hbox = QHBoxLayout(self.fee_adv_controls)
+ self.feecontrol_fields = QWidget()
+ hbox = QHBoxLayout(self.feecontrol_fields)
hbox.setContentsMargins(0, 0, 0, 0)
- hbox.addWidget(self.feerate_e)
- hbox.addWidget(self.size_e)
- hbox.addWidget(self.fee_e)
- hbox.addWidget(self.feerounding_icon, Qt.AlignLeft)
+ grid = QGridLayout()
+ grid.addWidget(QLabel(_("Target fee:")), 0, 0)
+ grid.addWidget(self.feerate_e, 0, 1)
+ grid.addWidget(self.size_e, 0, 2)
+ grid.addWidget(self.fee_e, 0, 3)
+ grid.addWidget(self.feerounding_icon, 0, 4)
+ grid.addWidget(self.fee_slider, 1, 1)
+ grid.addWidget(self.fee_combo, 1, 2)
+ hbox.addLayout(grid)
hbox.addStretch(1)
- self.feecontrol_fields = QWidget()
- vbox_feecontrol = QVBoxLayout(self.feecontrol_fields)
- vbox_feecontrol.setContentsMargins(0, 0, 0, 0)
- vbox_feecontrol.addWidget(QLabel(_("Target fee:")))
- vbox_feecontrol.addWidget(self.fee_adv_controls)
- vbox_feecontrol.addWidget(self.fee_slider)
-
def fee_slider_callback(self, dyn, pos, fee_rate):
super().fee_slider_callback(dyn, pos, fee_rate)
self.fee_slider.activate()
@@ -868,7 +867,7 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
self.finalized = True
self.tx.set_rbf(self.rbf_cb.isChecked())
self.tx.locktime = self.locktime_e.get_locktime()
- for widget in [self.fee_slider, self.feecontrol_fields, self.rbf_cb,
+ for widget in [self.fee_slider, self.fee_combo, self.feecontrol_fields, self.rbf_cb,
self.locktime_setter_widget, self.locktime_e]:
widget.setEnabled(False)
widget.setVisible(False)