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. 34
      electrum/gui/qml/components/SwapDialog.qml
  2. 8
      electrum/gui/qml/qeswaphelper.py

34
electrum/gui/qml/components/SwapDialog.qml

@ -23,14 +23,23 @@ ElDialog {
ColumnLayout {
width: parent.width
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 {
id: layout
columns: 2
Layout.preferredWidth: parent.width
Layout.leftMargin: constants.paddingLarge
Layout.rightMargin: constants.paddingLarge
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
RowLayout {
Layout.preferredWidth: 1
@ -207,13 +216,22 @@ ElDialog {
}
}
InfoTextArea {
RowLayout {
Layout.fillWidth: true
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
visible: swaphelper.userinfo != ''
text: swaphelper.userinfo
Label {
text: '<-- ' + qsTr('Add receiving capacity')
font.pixelSize: constants.fontSizeXSmall
color: Material.accentColor
}
Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
text: qsTr('Add sending capacity') + ' -->'
font.pixelSize: constants.fontSizeXSmall
color: Material.accentColor
}
}
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._tx = None
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._toreceive = QEAmount()
self._serverfeeperc = ''
@ -277,7 +280,6 @@ class QESwapHelper(AuthMixin, QObject):
# pay_amount and receive_amounts are always with fees already included
# so they reflect the net balance change after the swap
if position < 0: # reverse swap
self.userinfo = _('Adds Lightning receiving capacity.')
self.isReverse = True
self._send_amount = abs(position)
@ -295,7 +297,6 @@ class QESwapHelper(AuthMixin, QObject):
self.check_valid(self._send_amount, self._receive_amount)
else: # forward (normal) swap
self.userinfo = _('Adds Lightning sending capacity.')
self.isReverse = False
self._send_amount = position
self.tosend = QEAmount(amount_sat=self._send_amount)
@ -318,7 +319,6 @@ class QESwapHelper(AuthMixin, QObject):
self.valid = True
else:
# add more nuanced error reporting?
self.userinfo = _('Swap below minimal swap size, change the slider.')
self.valid = False
def fwd_swap_updatetx(self):

Loading…
Cancel
Save