Browse Source

qml SwapDialog: move userinfo to the top, make it constant, add padding and labels below the slider

master
ThomasV 3 years ago
parent
commit
02f093c2d2
  1. 32
      electrum/gui/qml/components/SwapDialog.qml
  2. 8
      electrum/gui/qml/qeswaphelper.py

32
electrum/gui/qml/components/SwapDialog.qml

@ -23,14 +23,23 @@ ElDialog {
ColumnLayout { ColumnLayout {
width: parent.width width: parent.width
height: parent.height height: parent.height
spacing: 0 spacing: constants.paddingLarge
InfoTextArea {
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
visible: swaphelper.userinfo != ''
text: swaphelper.userinfo
}
GridLayout { GridLayout {
id: layout id: layout
columns: 2 columns: 2
Layout.preferredWidth: parent.width Layout.preferredWidth: parent.width
Layout.leftMargin: constants.paddingLarge Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingLarge Layout.rightMargin: constants.paddingXXLarge
RowLayout { RowLayout {
Layout.preferredWidth: 1 Layout.preferredWidth: 1
@ -207,13 +216,22 @@ ElDialog {
} }
} }
InfoTextArea { RowLayout {
Layout.fillWidth: true
Layout.leftMargin: constants.paddingXXLarge Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge Layout.rightMargin: constants.paddingXXLarge
Label {
text: '<-- ' + qsTr('Add receiving capacity')
font.pixelSize: constants.fontSizeXSmall
color: Material.accentColor
}
Label {
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter horizontalAlignment: Text.AlignRight
visible: swaphelper.userinfo != '' text: qsTr('Add sending capacity') + ' -->'
text: swaphelper.userinfo font.pixelSize: constants.fontSizeXSmall
color: Material.accentColor
}
} }
Item { Layout.fillHeight: true; Layout.preferredWidth: 1 } Item { Layout.fillHeight: true; Layout.preferredWidth: 1 }

8
electrum/gui/qml/qeswaphelper.py

@ -33,7 +33,10 @@ class QESwapHelper(AuthMixin, QObject):
self._rangeMax = 0 self._rangeMax = 0
self._tx = None self._tx = None
self._valid = False self._valid = False
self._userinfo = '' self._userinfo = ' '.join([
_('Move the slider to set the amount and direction of the swap.'),
_('Swapping lightning funds for onchain funds will increase your capacity to receive lightning payments.'),
])
self._tosend = QEAmount() self._tosend = QEAmount()
self._toreceive = QEAmount() self._toreceive = QEAmount()
self._serverfeeperc = '' self._serverfeeperc = ''
@ -277,7 +280,6 @@ class QESwapHelper(AuthMixin, QObject):
# pay_amount and receive_amounts are always with fees already included # pay_amount and receive_amounts are always with fees already included
# so they reflect the net balance change after the swap # so they reflect the net balance change after the swap
if position < 0: # reverse swap if position < 0: # reverse swap
self.userinfo = _('Adds Lightning receiving capacity.')
self.isReverse = True self.isReverse = True
self._send_amount = abs(position) self._send_amount = abs(position)
@ -295,7 +297,6 @@ class QESwapHelper(AuthMixin, QObject):
self.check_valid(self._send_amount, self._receive_amount) self.check_valid(self._send_amount, self._receive_amount)
else: # forward (normal) swap else: # forward (normal) swap
self.userinfo = _('Adds Lightning sending capacity.')
self.isReverse = False self.isReverse = False
self._send_amount = position self._send_amount = position
self.tosend = QEAmount(amount_sat=self._send_amount) self.tosend = QEAmount(amount_sat=self._send_amount)
@ -318,7 +319,6 @@ class QESwapHelper(AuthMixin, QObject):
self.valid = True self.valid = True
else: else:
# add more nuanced error reporting? # add more nuanced error reporting?
self.userinfo = _('Swap below minimal swap size, change the slider.')
self.valid = False self.valid = False
def fwd_swap_updatetx(self): def fwd_swap_updatetx(self):

Loading…
Cancel
Save