mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 17:01:34 +00:00
Qt: show fee combo next to fee slider, and remove it from settings
This commit is contained in:
parent
959af0065b
commit
c035bfcc46
5 changed files with 60 additions and 44 deletions
|
@ -38,7 +38,7 @@ from electrum.wallet import InternalAddressCorruption
|
||||||
from .util import (WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton,
|
from .util import (WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton,
|
||||||
BlockingWaitingDialog, PasswordLineEdit)
|
BlockingWaitingDialog, PasswordLineEdit)
|
||||||
|
|
||||||
from .fee_slider import FeeSlider
|
from .fee_slider import FeeSlider, FeeComboBox
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .main_window import ElectrumWindow
|
from .main_window import ElectrumWindow
|
||||||
|
@ -146,7 +146,10 @@ class ConfirmTxDialog(TxEditor, WindowModalDialog):
|
||||||
grid.addWidget(self.extra_fee_value, 2, 1)
|
grid.addWidget(self.extra_fee_value, 2, 1)
|
||||||
|
|
||||||
self.fee_slider = FeeSlider(self, self.config, self.fee_slider_callback)
|
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_slider, 5, 1)
|
||||||
|
grid.addWidget(self.fee_combo, 5, 2)
|
||||||
|
|
||||||
self.message_label = QLabel(self.default_message())
|
self.message_label = QLabel(self.default_message())
|
||||||
grid.addWidget(self.message_label, 6, 0, 1, -1)
|
grid.addWidget(self.message_label, 6, 0, 1, -1)
|
||||||
|
|
|
@ -2,10 +2,31 @@ import threading
|
||||||
|
|
||||||
from PyQt5.QtGui import QCursor
|
from PyQt5.QtGui import QCursor
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QSlider, QToolTip
|
from PyQt5.QtWidgets import QSlider, QToolTip, QComboBox
|
||||||
|
|
||||||
from electrum.i18n import _
|
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):
|
class FeeSlider(QSlider):
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ from .amountedit import AmountEdit, BTCAmountEdit, FreezableLineEdit, FeerateEdi
|
||||||
from .qrcodewidget import QRCodeWidget, QRDialog
|
from .qrcodewidget import QRCodeWidget, QRDialog
|
||||||
from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
|
from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
|
||||||
from .transaction_dialog import show_transaction
|
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,
|
from .util import (read_QIcon, ColorScheme, text_dialog, icon_path, WaitingDialog,
|
||||||
WindowModalDialog, ChoicesLayout, HelpLabel, Buttons,
|
WindowModalDialog, ChoicesLayout, HelpLabel, Buttons,
|
||||||
OkButton, InfoButton, WWLabel, TaskThread, CancelButton,
|
OkButton, InfoButton, WWLabel, TaskThread, CancelButton,
|
||||||
|
@ -3041,8 +3041,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
fee = get_child_fee_from_total_feerate(fee_rate)
|
fee = get_child_fee_from_total_feerate(fee_rate)
|
||||||
fee_e.setAmount(fee)
|
fee_e.setAmount(fee)
|
||||||
fee_slider = FeeSlider(self, self.config, on_rate)
|
fee_slider = FeeSlider(self, self.config, on_rate)
|
||||||
|
fee_combo = FeeComboBox(fee_slider)
|
||||||
fee_slider.update()
|
fee_slider.update()
|
||||||
grid.addWidget(fee_slider, 4, 1)
|
grid.addWidget(fee_slider, 4, 1)
|
||||||
|
grid.addWidget(fee_combo, 4, 2)
|
||||||
grid.addWidget(QLabel(_('Total fee') + ':'), 5, 0)
|
grid.addWidget(QLabel(_('Total fee') + ':'), 5, 0)
|
||||||
grid.addWidget(combined_fee, 5, 1)
|
grid.addWidget(combined_fee, 5, 1)
|
||||||
grid.addWidget(QLabel(_('Total feerate') + ':'), 6, 0)
|
grid.addWidget(QLabel(_('Total feerate') + ':'), 6, 0)
|
||||||
|
@ -3074,24 +3076,32 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
d = WindowModalDialog(self, _('Bump Fee'))
|
d = WindowModalDialog(self, _('Bump Fee'))
|
||||||
vbox = QVBoxLayout(d)
|
vbox = QVBoxLayout(d)
|
||||||
vbox.addWidget(WWLabel(_("Increase your transaction's fee to improve its position in mempool.")))
|
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():
|
def on_textedit_rate():
|
||||||
fee_slider.deactivate()
|
fee_slider.deactivate()
|
||||||
feerate_e = FeerateEdit(lambda: 0)
|
feerate_e = FeerateEdit(lambda: 0)
|
||||||
feerate_e.setAmount(max(old_fee_rate * 1.5, old_fee_rate + 1))
|
feerate_e.setAmount(max(old_fee_rate * 1.5, old_fee_rate + 1))
|
||||||
feerate_e.textEdited.connect(on_textedit_rate)
|
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):
|
def on_slider_rate(dyn, pos, fee_rate):
|
||||||
fee_slider.activate()
|
fee_slider.activate()
|
||||||
if fee_rate is not None:
|
if fee_rate is not None:
|
||||||
feerate_e.setAmount(fee_rate / 1000)
|
feerate_e.setAmount(fee_rate / 1000)
|
||||||
fee_slider = FeeSlider(self, self.config, on_slider_rate)
|
fee_slider = FeeSlider(self, self.config, on_slider_rate)
|
||||||
|
fee_combo = FeeComboBox(fee_slider)
|
||||||
fee_slider.deactivate()
|
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'))
|
cb = QCheckBox(_('Final'))
|
||||||
vbox.addWidget(cb)
|
vbox.addWidget(cb)
|
||||||
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
|
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
|
||||||
|
|
|
@ -59,7 +59,6 @@ class SettingsDialog(WindowModalDialog):
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
tabs = QTabWidget()
|
tabs = QTabWidget()
|
||||||
gui_widgets = []
|
gui_widgets = []
|
||||||
fee_widgets = []
|
|
||||||
tx_widgets = []
|
tx_widgets = []
|
||||||
oa_widgets = []
|
oa_widgets = []
|
||||||
|
|
||||||
|
@ -103,21 +102,6 @@ class SettingsDialog(WindowModalDialog):
|
||||||
nz.valueChanged.connect(on_nz)
|
nz.valueChanged.connect(on_nz)
|
||||||
gui_widgets.append((nz_label, 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 = bool(self.config.get('use_rbf', True))
|
||||||
use_rbf_cb = QCheckBox(_('Use Replace-By-Fee'))
|
use_rbf_cb = QCheckBox(_('Use Replace-By-Fee'))
|
||||||
use_rbf_cb.setChecked(use_rbf)
|
use_rbf_cb.setChecked(use_rbf)
|
||||||
|
@ -129,7 +113,7 @@ class SettingsDialog(WindowModalDialog):
|
||||||
self.config.set_key('use_rbf', bool(x))
|
self.config.set_key('use_rbf', bool(x))
|
||||||
batch_rbf_cb.setEnabled(bool(x))
|
batch_rbf_cb.setEnabled(bool(x))
|
||||||
use_rbf_cb.stateChanged.connect(on_use_rbf)
|
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 = QCheckBox(_('Batch RBF transactions'))
|
||||||
batch_rbf_cb.setChecked(bool(self.config.get('batch_rbf', False)))
|
batch_rbf_cb.setChecked(bool(self.config.get('batch_rbf', False)))
|
||||||
|
@ -140,7 +124,7 @@ class SettingsDialog(WindowModalDialog):
|
||||||
def on_batch_rbf(x):
|
def on_batch_rbf(x):
|
||||||
self.config.set_key('batch_rbf', bool(x))
|
self.config.set_key('batch_rbf', bool(x))
|
||||||
batch_rbf_cb.stateChanged.connect(on_batch_rbf)
|
batch_rbf_cb.stateChanged.connect(on_batch_rbf)
|
||||||
fee_widgets.append((batch_rbf_cb, None))
|
tx_widgets.append((batch_rbf_cb, None))
|
||||||
|
|
||||||
# lightning
|
# lightning
|
||||||
lightning_widgets = []
|
lightning_widgets = []
|
||||||
|
@ -455,7 +439,6 @@ you close all your wallet windows. Use this to keep your local watchtower runnin
|
||||||
|
|
||||||
tabs_info = [
|
tabs_info = [
|
||||||
(gui_widgets, _('General')),
|
(gui_widgets, _('General')),
|
||||||
(fee_widgets, _('Fees')),
|
|
||||||
(tx_widgets, _('Transactions')),
|
(tx_widgets, _('Transactions')),
|
||||||
(lightning_widgets, _('Lightning')),
|
(lightning_widgets, _('Lightning')),
|
||||||
(fiat_widgets, _('Fiat')),
|
(fiat_widgets, _('Fiat')),
|
||||||
|
|
|
@ -34,7 +34,7 @@ from decimal import Decimal
|
||||||
|
|
||||||
from PyQt5.QtCore import QSize, Qt
|
from PyQt5.QtCore import QSize, Qt
|
||||||
from PyQt5.QtGui import QTextCharFormat, QBrush, QFont, QPixmap
|
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)
|
QTextEdit, QFrame, QAction, QToolButton, QMenu, QCheckBox)
|
||||||
import qrcode
|
import qrcode
|
||||||
from qrcode import exceptions
|
from qrcode import exceptions
|
||||||
|
@ -55,7 +55,7 @@ from .util import (MessageBoxMixin, read_QIcon, Buttons, icon_path,
|
||||||
TRANSACTION_FILE_EXTENSION_FILTER_ONLY_PARTIAL_TX,
|
TRANSACTION_FILE_EXTENSION_FILTER_ONLY_PARTIAL_TX,
|
||||||
BlockingWaitingDialog)
|
BlockingWaitingDialog)
|
||||||
|
|
||||||
from .fee_slider import FeeSlider
|
from .fee_slider import FeeSlider, FeeComboBox
|
||||||
from .confirm_tx_dialog import TxEditor
|
from .confirm_tx_dialog import TxEditor
|
||||||
from .amountedit import FeerateEdit, BTCAmountEdit
|
from .amountedit import FeerateEdit, BTCAmountEdit
|
||||||
from .locktimeedit import LockTimeEdit
|
from .locktimeedit import LockTimeEdit
|
||||||
|
@ -711,6 +711,7 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
|
||||||
self.feerate_e.textChanged.connect(self.entry_changed)
|
self.feerate_e.textChanged.connect(self.entry_changed)
|
||||||
|
|
||||||
self.fee_slider = FeeSlider(self, self.config, self.fee_slider_callback)
|
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())
|
self.fee_slider.setFixedWidth(self.fee_e.width())
|
||||||
|
|
||||||
def feerounding_onclick():
|
def feerounding_onclick():
|
||||||
|
@ -728,21 +729,19 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
|
||||||
self.feerounding_icon.clicked.connect(feerounding_onclick)
|
self.feerounding_icon.clicked.connect(feerounding_onclick)
|
||||||
self.feerounding_icon.setVisible(False)
|
self.feerounding_icon.setVisible(False)
|
||||||
|
|
||||||
self.fee_adv_controls = QWidget()
|
|
||||||
hbox = QHBoxLayout(self.fee_adv_controls)
|
|
||||||
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)
|
|
||||||
hbox.addStretch(1)
|
|
||||||
|
|
||||||
self.feecontrol_fields = QWidget()
|
self.feecontrol_fields = QWidget()
|
||||||
vbox_feecontrol = QVBoxLayout(self.feecontrol_fields)
|
hbox = QHBoxLayout(self.feecontrol_fields)
|
||||||
vbox_feecontrol.setContentsMargins(0, 0, 0, 0)
|
hbox.setContentsMargins(0, 0, 0, 0)
|
||||||
vbox_feecontrol.addWidget(QLabel(_("Target fee:")))
|
grid = QGridLayout()
|
||||||
vbox_feecontrol.addWidget(self.fee_adv_controls)
|
grid.addWidget(QLabel(_("Target fee:")), 0, 0)
|
||||||
vbox_feecontrol.addWidget(self.fee_slider)
|
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)
|
||||||
|
|
||||||
def fee_slider_callback(self, dyn, pos, fee_rate):
|
def fee_slider_callback(self, dyn, pos, fee_rate):
|
||||||
super().fee_slider_callback(dyn, pos, fee_rate)
|
super().fee_slider_callback(dyn, pos, fee_rate)
|
||||||
|
@ -868,7 +867,7 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
|
||||||
self.finalized = True
|
self.finalized = True
|
||||||
self.tx.set_rbf(self.rbf_cb.isChecked())
|
self.tx.set_rbf(self.rbf_cb.isChecked())
|
||||||
self.tx.locktime = self.locktime_e.get_locktime()
|
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]:
|
self.locktime_setter_widget, self.locktime_e]:
|
||||||
widget.setEnabled(False)
|
widget.setEnabled(False)
|
||||||
widget.setVisible(False)
|
widget.setVisible(False)
|
||||||
|
|
Loading…
Add table
Reference in a new issue