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,45 +154,100 @@ Item {
} }
} }
MoneroComponents.TextPlain { spacing: 0
id: inputLabel Rectangle {
anchors.top: parent.top id: inputLabelRect
anchors.left: parent.left color: "transparent"
font.family: MoneroComponents.Style.fontRegular.name Layout.fillWidth: true
font.pixelSize: labelFontSize height: (inputLabel.height + 10)
font.bold: labelFontBold visible: showingHeader ? true : false
textFormat: Text.RichText
color: MoneroComponents.Style.defaultFontColor
onLinkActivated: item.labelLinkActivated()
MouseArea { MoneroComponents.TextPlain {
anchors.fill: parent id: inputLabel
acceptedButtons: Qt.NoButton anchors.top: parent.top
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor anchors.left: parent.left
} font.family: MoneroComponents.Style.fontRegular.name
} font.pixelSize: labelFontSize
font.bold: labelFontBold
textFormat: Text.RichText
color: MoneroComponents.Style.defaultFontColor
onLinkActivated: item.labelLinkActivated()
MoneroComponents.LabelButton { MouseArea {
id: copyButtonId anchors.fill: parent
text: qsTr("Copy") + translationManager.emptyString acceptedButtons: Qt.NoButton
anchors.right: parent.right cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: { }
if (input.text.length > 0) { }
console.log("Copied to clipboard");
clipboard.setText(input.text); RowLayout {
appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3); anchors.right: parent.right
spacing: 16
MoneroComponents.LabelButton {
id: copyButtonId
text: qsTr("Copy") + translationManager.emptyString
onClicked: {
if (input.text.length > 0) {
console.log("Copied to clipboard");
clipboard.setText(input.text);
appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3);
}
}
visible: copyButton && input.text !== ""
}
MoneroComponents.LabelButton {
id: pasteButtonId
onClicked: {
input.clear();
input.paste();
}
text: qsTr("Paste") + translationManager.emptyString
visible: pasteButton
} }
} }
visible: copyButton && input.text !== ""
} }
Item{ MoneroComponents.Input {
id: inputItem id: input
height: inputHeight KeyNavigation.backtab: item.KeyNavigation.backtab
anchors.top: showingHeader ? inputLabel.bottom : parent.top KeyNavigation.tab: item.KeyNavigation.tab
anchors.topMargin: showingHeader ? 12 : 0 Layout.fillWidth: true
width: parent.width Layout.preferredHeight: inputHeight
clip: true
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 { RowLayout {
id: inlineIcon id: inlineButtons
width: 26 anchors.verticalCenter: parent.verticalCenter
height: 26 anchors.right: parent.right
anchors.top: parent.top anchors.rightMargin: inputPaddingRight
anchors.topMargin: 8 spacing: 4
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 {
id: inlineButtons
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: inputPadding
anchors.bottomMargin: inputPadding
anchors.rightMargin: inputPadding
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,19 +171,25 @@ 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
buttonColor: "transparent"
fontFamily: FontAwesome.fontFamilySolid MoneroComponents.InlineButton {
fontStyleName: "Solid" id: cleanButton
fontPixelSize: 18 buttonColor: "transparent"
text: FontAwesome.times fontFamily: FontAwesome.fontFamilySolid
tooltip: qsTr("Clean") + translationManager.emptyString fontStyleName: "Solid"
tooltipLeft: true fontPixelSize: 18
visible: searchInput.text != "" text: FontAwesome.times
onClicked: searchInput.text = "" tooltip: qsTr("Clean") + translationManager.emptyString
tooltipLeft: true
visible: searchInput.text != ""
onClicked: searchInput.text = ""
}
} }
} }
} }

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