LineEdit: use ColumnLayout instead of Item (also used in LineEditMulti)

This commit is contained in:
rating89us
2021-06-09 05:42:43 +02:00
committed by rating89us
parent 7c379e2cda
commit 52aef114fa
6 changed files with 150 additions and 123 deletions

View File

@@ -33,14 +33,21 @@ import QtQuick.Layouts 1.1
import "../components" as MoneroComponents import "../components" as MoneroComponents
Item { ColumnLayout {
id: item id: item
Layout.fillWidth: true
default property alias content: inlineButtons.children default property alias content: inlineButtons.children
property alias input: input property alias input: input
property alias text: input.text property alias text: input.text
property int inputPaddingLeft: 10
property int inputPaddingRight: 10
property int inputPaddingTop: 10
property int inputPaddingBottom: 10
property int inputRadius: 4
property bool password: false property bool password: false
property bool passwordHidden: true property bool passwordHidden: true
property var passwordLinked: null property var passwordLinked: null
@@ -55,10 +62,8 @@ Item {
property real placeholderLeftMargin: { property real placeholderLeftMargin: {
if (placeholderCenter) { if (placeholderCenter) {
return undefined; return undefined;
} else if (inlineIcon.visible) {
return inlineIcon.width + inlineIcon.anchors.leftMargin + inputPadding;
} else { } else {
return inputPadding; return inputPaddingLeft;
} }
} }
@@ -66,8 +71,8 @@ Item {
property alias validator: input.validator property alias validator: input.validator
property alias readOnly : input.readOnly property alias readOnly : input.readOnly
property alias cursorPosition: input.cursorPosition property alias cursorPosition: input.cursorPosition
property alias inlineIcon: inlineIcon.visible
property bool copyButton: false property bool copyButton: false
property bool pasteButton: false
property alias copyButtonText: copyButtonId.text property alias copyButtonText: copyButtonId.text
property alias copyButtonEnabled: copyButtonId.enabled property alias copyButtonEnabled: copyButtonId.enabled
@@ -97,16 +102,13 @@ Item {
property alias labelWrapMode: inputLabel.wrapMode property alias labelWrapMode: inputLabel.wrapMode
property alias labelHorizontalAlignment: inputLabel.horizontalAlignment property alias labelHorizontalAlignment: inputLabel.horizontalAlignment
property bool showingHeader: inputLabel.text !== "" || copyButton property bool showingHeader: inputLabel.text !== "" || copyButton
property int inputHeight: 42 property int inputHeight: 39
property int inputPadding: 10
signal labelLinkActivated(); // input label, rich text <a> signal signal labelLinkActivated(); // input label, rich text <a> signal
signal editingFinished(); signal editingFinished();
signal accepted(); signal accepted();
signal textUpdated(); signal textUpdated();
height: showingHeader ? (inputLabel.height + inputItem.height + 2) : inputHeight
onActiveFocusChanged: activeFocus && input.forceActiveFocus() onActiveFocusChanged: activeFocus && input.forceActiveFocus()
onTextUpdated: { onTextUpdated: {
// check to remove placeholder text when there is content // check to remove placeholder text when there is content
@@ -152,6 +154,14 @@ Item {
} }
} }
spacing: 0
Rectangle {
id: inputLabelRect
color: "transparent"
Layout.fillWidth: true
height: (inputLabel.height + 10)
visible: showingHeader ? true : false
MoneroComponents.TextPlain { MoneroComponents.TextPlain {
id: inputLabel id: inputLabel
anchors.top: parent.top anchors.top: parent.top
@@ -170,10 +180,13 @@ Item {
} }
} }
RowLayout {
anchors.right: parent.right
spacing: 16
MoneroComponents.LabelButton { MoneroComponents.LabelButton {
id: copyButtonId id: copyButtonId
text: qsTr("Copy") + translationManager.emptyString text: qsTr("Copy") + translationManager.emptyString
anchors.right: parent.right
onClicked: { onClicked: {
if (input.text.length > 0) { if (input.text.length > 0) {
console.log("Copied to clipboard"); console.log("Copied to clipboard");
@@ -184,13 +197,57 @@ Item {
visible: copyButton && input.text !== "" visible: copyButton && input.text !== ""
} }
Item{ MoneroComponents.LabelButton {
id: inputItem id: pasteButtonId
height: inputHeight onClicked: {
anchors.top: showingHeader ? inputLabel.bottom : parent.top input.clear();
anchors.topMargin: showingHeader ? 12 : 0 input.paste();
width: parent.width }
clip: true text: qsTr("Paste") + translationManager.emptyString
visible: pasteButton
}
}
}
MoneroComponents.Input {
id: input
KeyNavigation.backtab: item.KeyNavigation.backtab
KeyNavigation.tab: item.KeyNavigation.tab
Layout.fillWidth: true
Layout.preferredHeight: inputHeight
leftPadding: item.inputPaddingLeft
rightPadding: (inlineButtons.width > 0 ? inlineButtons.width + inlineButtons.spacing : 0) + inputPaddingRight
topPadding: item.inputPaddingTop
bottomPadding: item.inputPaddingBottom
font.family: item.fontFamily
font.pixelSize: item.fontSize
font.bold: item.fontBold
onEditingFinished: item.editingFinished()
onAccepted: item.accepted();
onTextChanged: item.textUpdated()
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
MoneroComponents.Label {
visible: password || passwordLinked
fontSize: 20
text: isPasswordHidden() ? FontAwesome.eye : FontAwesome.eyeSlash
opacity: eyeMouseArea.containsMouse ? 0.9 : 0.7
fontFamily: FontAwesome.fontFamily
anchors.right: parent.right
anchors.rightMargin: 15
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 1
MouseArea {
id: eyeMouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: passwordToggle()
}
}
MoneroComponents.TextPlain { MoneroComponents.TextPlain {
id: placeholderLabel id: placeholderLabel
@@ -221,69 +278,15 @@ Item {
anchors.fill: parent anchors.fill: parent
border.width: borderDisabled ? 0 : 1 border.width: borderDisabled ? 0 : 1
border.color: borderColor border.color: borderColor
radius: 4 radius: item.inputRadius
}
Image {
id: inlineIcon
width: 26
height: 26
anchors.top: parent.top
anchors.topMargin: 8
anchors.left: parent.left
anchors.leftMargin: 12
source: "qrc:///images/moneroIcon-28x28.png"
visible: false
}
MoneroComponents.Input {
id: input
anchors.fill: parent
anchors.leftMargin: inlineIcon.visible ? 44 : 0
font.family: item.fontFamily
font.pixelSize: item.fontSize
font.bold: item.fontBold
KeyNavigation.backtab: item.KeyNavigation.backtab
KeyNavigation.tab: item.KeyNavigation.tab
onEditingFinished: item.editingFinished()
onAccepted: item.accepted();
onTextChanged: item.textUpdated()
leftPadding: inputPadding
rightPadding: (inlineButtons.width > 0 ? inlineButtons.width + inlineButtons.spacing : 0) + inputPadding
topPadding: inputPadding
bottomPadding: inputPadding
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
MoneroComponents.Label {
visible: password || passwordLinked
fontSize: 20
text: isPasswordHidden() ? FontAwesome.eye : FontAwesome.eyeSlash
opacity: eyeMouseArea.containsMouse ? 0.9 : 0.7
fontFamily: FontAwesome.fontFamily
anchors.right: parent.right
anchors.rightMargin: 15
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 1
MouseArea {
id: eyeMouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: passwordToggle()
}
} }
RowLayout { RowLayout {
id: inlineButtons id: inlineButtons
anchors.bottom: parent.bottom anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: inputPadding anchors.rightMargin: inputPaddingRight
anchors.bottomMargin: inputPadding
anchors.rightMargin: inputPadding
spacing: 4 spacing: 4
} }
} }
} }
}

View File

@@ -82,9 +82,9 @@ GridLayout {
return addr + ":" + port; return addr + ":" + port;
} }
LineEdit { MoneroComponents.LineEdit {
id: daemonAddr id: daemonAddr
Layout.fillWidth: true Layout.preferredWidth: root.width/3
placeholderText: qsTr("Remote Node Hostname / IP") + translationManager.emptyString placeholderText: qsTr("Remote Node Hostname / IP") + translationManager.emptyString
placeholderFontFamily: root.placeholderFontFamily placeholderFontFamily: root.placeholderFontFamily
placeholderFontBold: root.placeholderFontBold placeholderFontBold: root.placeholderFontBold
@@ -104,9 +104,9 @@ GridLayout {
text: initialHostPort[1] text: initialHostPort[1]
} }
LineEdit { MoneroComponents.LineEdit {
id: daemonPort id: daemonPort
Layout.fillWidth: true Layout.preferredWidth: root.width/3
placeholderText: qsTr("Port") + translationManager.emptyString placeholderText: qsTr("Port") + translationManager.emptyString
placeholderFontFamily: root.placeholderFontFamily placeholderFontFamily: root.placeholderFontFamily
placeholderFontBold: root.placeholderFontBold placeholderFontBold: root.placeholderFontBold

View File

@@ -171,10 +171,15 @@ Rectangle {
} }
} }
MoneroComponents.InlineButton { Rectangle {
Layout.topMargin: -8 color: "transparent"
height: cleanButton.height
width: cleanButton.width
Layout.rightMargin: -8 Layout.rightMargin: -8
Layout.leftMargin: -2 Layout.leftMargin: -2
MoneroComponents.InlineButton {
id: cleanButton
buttonColor: "transparent" buttonColor: "transparent"
fontFamily: FontAwesome.fontFamilySolid fontFamily: FontAwesome.fontFamilySolid
fontStyleName: "Solid" fontStyleName: "Solid"
@@ -187,6 +192,7 @@ Rectangle {
} }
} }
} }
}
GridLayout { GridLayout {
visible: sortAndFilter.collapsed visible: sortAndFilter.collapsed

View File

@@ -468,10 +468,14 @@ Rectangle {
Layout.bottomMargin: recipientLayout.rowSpacing / 2 Layout.bottomMargin: recipientLayout.rowSpacing / 2
Layout.rightMargin: recipientLayout.colSpacing / 2 Layout.rightMargin: recipientLayout.colSpacing / 2
Layout.preferredWidth: 125 Layout.preferredWidth: 125
Layout.maximumWidth: 125
borderDisabled: true borderDisabled: true
fontFamily: MoneroComponents.Style.fontMonoRegular.name fontFamily: MoneroComponents.Style.fontMonoRegular.name
fontSize: 14 fontSize: 14
inputPadding: 0 inputPaddingLeft: 0
inputPaddingRight: 0
inputPaddingTop: 0
inputPaddingBottom: 0
placeholderFontFamily: MoneroComponents.Style.fontMonoRegular.name placeholderFontFamily: MoneroComponents.Style.fontMonoRegular.name
placeholderFontSize: 14 placeholderFontSize: 14
placeholderLeftMargin: 0 placeholderLeftMargin: 0
@@ -586,11 +590,15 @@ Rectangle {
Layout.column: 1 Layout.column: 1
Layout.row: 0 Layout.row: 0
Layout.preferredWidth: recipientLayout.secondRowWidth Layout.preferredWidth: recipientLayout.secondRowWidth
Layout.maximumWidth: recipientLayout.secondRowWidth
borderDisabled: true borderDisabled: true
fontFamily: MoneroComponents.Style.fontMonoRegular.name fontFamily: MoneroComponents.Style.fontMonoRegular.name
fontSize: 14 fontSize: 14
inputHeight: 30 inputHeight: 30
inputPadding: 0 inputPaddingLeft: 0
inputPaddingRight: 0
inputPaddingTop: 0
inputPaddingBottom: 0
readOnly: true readOnly: true
text: Utils.removeTrailingZeros(walletManager.displayAmount(recipientModel.getAmountTotal())) text: Utils.removeTrailingZeros(walletManager.displayAmount(recipientModel.getAmountTotal()))
visible: recipientModel.count > 1 visible: recipientModel.count > 1
@@ -600,6 +608,7 @@ Rectangle {
Layout.column: 2 Layout.column: 2
Layout.row: 0 Layout.row: 0
Layout.preferredWidth: recipientLayout.thirdRowWidth Layout.preferredWidth: recipientLayout.thirdRowWidth
Layout.maximumWidth: recipientLayout.thirdRowWidth
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
font.family: MoneroComponents.Style.fontRegular.name font.family: MoneroComponents.Style.fontRegular.name
text: "XMR" text: "XMR"
@@ -611,11 +620,15 @@ Rectangle {
Layout.row: recipientModel.count > 1 ? 1 : 0 Layout.row: recipientModel.count > 1 ? 1 : 0
Layout.preferredWidth: recipientLayout.secondRowWidth Layout.preferredWidth: recipientLayout.secondRowWidth
Layout.topMargin: recipientModel.count > 1 ? 0 : 5 Layout.topMargin: recipientModel.count > 1 ? 0 : 5
Layout.maximumWidth: recipientLayout.secondRowWidth
borderDisabled: true borderDisabled: true
fontFamily: MoneroComponents.Style.fontMonoRegular.name fontFamily: MoneroComponents.Style.fontMonoRegular.name
fontSize: 14 fontSize: 14
inputHeight: 30 inputHeight: 30
inputPadding: 0 inputPaddingLeft: 0
inputPaddingRight: 0
inputPaddingTop: 0
inputPaddingBottom: 0
opacity: 0.7 opacity: 0.7
readOnly: true readOnly: true
text: fiatApiConvertToFiat(walletManager.displayAmount(recipientModel.getAmountTotal())) text: fiatApiConvertToFiat(walletManager.displayAmount(recipientModel.getAmountTotal()))
@@ -627,6 +640,7 @@ Rectangle {
Layout.row: recipientModel.count > 1 ? 1 : 0 Layout.row: recipientModel.count > 1 ? 1 : 0
Layout.preferredWidth: recipientLayout.thirdRowWidth Layout.preferredWidth: recipientLayout.thirdRowWidth
Layout.topMargin: recipientModel.count > 1 ? 0 : 5 Layout.topMargin: recipientModel.count > 1 ? 0 : 5
Layout.maximumWidth: recipientLayout.thirdRowWidth
font.family: MoneroComponents.Style.fontRegular.name font.family: MoneroComponents.Style.fontRegular.name
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
opacity: 0.7 opacity: 0.7

View File

@@ -226,10 +226,13 @@ Rectangle {
MoneroComponents.LineEdit { MoneroComponents.LineEdit {
id: sendCommandText id: sendCommandText
Layout.fillWidth: true Layout.fillWidth: true
inputPaddingTop: 0
inputPaddingBottom: 0
property var lastCommands: [] property var lastCommands: []
property int currentCommandIndex property int currentCommandIndex
enabled: !persistentSettings.useRemoteNode enabled: !persistentSettings.useRemoteNode
fontBold: false fontBold: false
fontSize: 16
placeholderText: qsTr("Type a command (e.g '%1' or '%2') and press Enter").arg("help").arg("status") + translationManager.emptyString placeholderText: qsTr("Type a command (e.g '%1' or '%2') and press Enter").arg("help").arg("status") + translationManager.emptyString
placeholderFontSize: 16 placeholderFontSize: 16
Keys.onUpPressed: { Keys.onUpPressed: {

View File

@@ -36,6 +36,7 @@ import "../components"
import "../components" as MoneroComponents import "../components" as MoneroComponents
GridLayout { GridLayout {
id: grid
Layout.fillWidth: true Layout.fillWidth: true
property alias walletName: walletName property alias walletName: walletName
property alias walletLocation: walletLocation property alias walletLocation: walletLocation
@@ -61,7 +62,7 @@ GridLayout {
MoneroComponents.LineEdit { MoneroComponents.LineEdit {
id: walletName id: walletName
Layout.fillWidth: true Layout.preferredWidth: grid.width/3
function verify(){ function verify(){
if(walletLocation === "" || /[\\\/]/.test(walletName.text)) return false; if(walletLocation === "" || /[\\\/]/.test(walletName.text)) return false;
@@ -82,7 +83,7 @@ GridLayout {
MoneroComponents.LineEdit { MoneroComponents.LineEdit {
id: walletLocation id: walletLocation
Layout.fillWidth: true Layout.preferredWidth: grid.width/3
labelText: qsTr("Wallet location") + translationManager.emptyString labelText: qsTr("Wallet location") + translationManager.emptyString
labelFontSize: 14 labelFontSize: 14