StandardDropdown, Transfer: adjust dropdown width based on content; display estimating fee label, adjust fee text

This commit is contained in:
rating89us 2021-07-26 18:08:28 +02:00 committed by rating89us
parent b6682330a6
commit a5b8e71399
2 changed files with 41 additions and 7 deletions

View file

@ -56,6 +56,7 @@ ColumnLayout {
property bool showingHeader: dropdownLabel.text !== ""
property int labelFontSize: 14
property bool labelFontBold: false
property bool dropdownFillWidth: true
property int dropdownHeight: 39
property int fontSize: 14
property int fontItemSize: 14
@ -94,7 +95,15 @@ ColumnLayout {
border.width: dropdown.headerBorder ? 1 : 0
border.color: dropdown.colorBorder
radius: 4
Layout.fillWidth: true
Layout.fillWidth: {
if (dropdown.dropdownFillWidth) {
return true;
} else {
dropdown.Layout.maximumWidth = repeater.implicitWidth;
head.Layout.preferredWidth = repeater.implicitWidth;
return false;
}
}
Layout.preferredHeight: dropdownHeight
MoneroComponents.TextPlain {
@ -149,7 +158,7 @@ ColumnLayout {
Rectangle {
id: droplist
anchors.left: parent.left
width: dropdown.width
width: dropdown.dropdownFillWidth ? dropdown.width : repeater.implicitWidth
y: head.y + head.height
clip: true
height: dropdown.expanded ? columnid.height : 0
@ -168,6 +177,7 @@ ColumnLayout {
Repeater {
id: repeater
implicitWidth: getMaximumWidth()
// Workaround for translations in listElements. All translated strings needs to be listed in this file.
property string stringAutomatic: qsTr("Automatic") + translationManager.emptyString
@ -176,6 +186,17 @@ ColumnLayout {
property string stringFast: qsTr("Fast (x5 fee)") + translationManager.emptyString
property string stringFastest: qsTr("Fastest (x200 fee)") + translationManager.emptyString
function getMaximumWidth() {
var maximumWidthInList = 0;
for (var i = 0; i < repeater.count; i++) {
var listItemWidth = repeater.itemAt(i).children[0].contentWidth
if (listItemWidth > maximumWidthInList) {
maximumWidthInList = listItemWidth;
}
}
return 12 + maximumWidthInList + 12 + 24;
}
delegate: Rectangle {
anchors.left: parent.left
anchors.right: parent.right
@ -186,6 +207,7 @@ ColumnLayout {
MoneroComponents.TextPlain {
id: col1Text
anchors.verticalCenter: parent.verticalCenter
width: 12 + col1Text.contentWidth + 12 + 24
anchors.left: parent.left
anchors.right: col2Text.left
anchors.leftMargin: 12

View file

@ -698,8 +698,8 @@ Rectangle {
spacing: 10
StandardDropdown {
Layout.maximumWidth: 200
id: priorityDropdown
dropdownFillWidth: false
currentIndex: 0
dataModel: priorityModelV5
labelText: qsTr("Transaction priority") + translationManager.emptyString
@ -709,6 +709,7 @@ Rectangle {
MoneroComponents.TextPlain {
id: feeLabel
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Layout.bottomMargin: 11
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 14
@ -751,16 +752,27 @@ Rectangle {
if (!sendButton.enabled || estimatedFee == null) {
return ""
}
return "~%1 XMR%2 %3".arg(estimatedFee)
.arg(estimatedFeeFiat)
.arg(qsTr("fee") + translationManager.emptyString);
return "%1: ~%2 XMR%3".arg(qsTr("Fee") + translationManager.emptyString)
.arg(estimatedFee)
.arg(estimatedFeeFiat);
}
BusyIndicator {
anchors.left: parent.left
Layout.fillWidth: true
running: feeLabel.estimating
height: parent.height
width: height
MoneroComponents.TextPlain {
anchors.left: parent.right
anchors.leftMargin: 8
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 14
color: MoneroComponents.Style.defaultFontColor
opacity: 0.7
text: qsTr("Estimating fee") + "..." + translationManager.emptyString
visible: parent.running
}
}
}
}