Extra properties for components LineEditMulti and RemoteNodeEdit

This commit is contained in:
Sander Ferdinand 2018-07-18 15:00:53 +02:00
parent 15c5269e35
commit 4f4d969416
6 changed files with 103 additions and 59 deletions

View file

@ -32,31 +32,25 @@ import QtQuick 2.7
import "../js/TxUtils.js" as TxUtils import "../js/TxUtils.js" as TxUtils
import "../components" as MoneroComponents import "../components" as MoneroComponents
TextArea { TextArea {
property bool error: false
property bool addressValidation: false
property bool wrapAnywhere: true
property int fontSize: 18 * scaleRatio property int fontSize: 18 * scaleRatio
property bool fontBold: false property bool fontBold: false
property string fontColor: MoneroComponents.Style.defaultFontColor
property bool mouseSelection: true
property bool error: false
property bool addressValidation: false
id: textArea id: textArea
font.family: MoneroComponents.Style.fontRegular.name font.family: MoneroComponents.Style.fontRegular.name
color: fontColor
font.pixelSize: fontSize font.pixelSize: fontSize
font.bold: fontBold font.bold: fontBold
horizontalAlignment: TextInput.AlignLeft horizontalAlignment: TextInput.AlignLeft
selectByMouse: true selectByMouse: mouseSelection
color: MoneroComponents.Style.defaultFontColor
selectionColor: MoneroComponents.Style.dimmedFontColor selectionColor: MoneroComponents.Style.dimmedFontColor
selectedTextColor: MoneroComponents.Style.defaultFontColor selectedTextColor: MoneroComponents.Style.defaultFontColor
wrapMode: {
if(wrapAnywhere){
return Text.WrapAnywhere;
} else {
return Text.WordWrap;
}
}
onTextChanged: { onTextChanged: {
if(addressValidation){ if(addressValidation){
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }` // js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`

View file

@ -50,6 +50,8 @@ Item {
property alias inlineButtonText: inlineButtonId.text property alias inlineButtonText: inlineButtonId.text
property alias inlineIcon: inlineIcon.visible property alias inlineIcon: inlineIcon.visible
property bool copyButton: false property bool copyButton: false
property bool borderDisabled: false
property string borderColor: { property string borderColor: {
if(input.activeFocus){ if(input.activeFocus){
return MoneroComponents.Style.inputBorderColorActive; return MoneroComponents.Style.inputBorderColorActive;
@ -57,9 +59,8 @@ Item {
return MoneroComponents.Style.inputBorderColorInActive; return MoneroComponents.Style.inputBorderColorInActive;
} }
} }
property bool borderDisabled: false
property int fontSize: 18 * scaleRatio property int fontSize: 18 * scaleRatio
property bool showBorder: true
property bool fontBold: false property bool fontBold: false
property alias fontColor: input.color property alias fontColor: input.color
property bool error: false property bool error: false
@ -140,6 +141,7 @@ Item {
anchors.top: showingHeader ? inputLabel.bottom : parent.top anchors.top: showingHeader ? inputLabel.bottom : parent.top
anchors.topMargin: showingHeader ? 12 * scaleRatio : 2 * scaleRatio anchors.topMargin: showingHeader ? 12 * scaleRatio : 2 * scaleRatio
width: parent.width width: parent.width
clip: true
Text { Text {
id: placeholderLabel id: placeholderLabel
@ -200,6 +202,8 @@ Item {
onEditingFinished: item.editingFinished() onEditingFinished: item.editingFinished()
onAccepted: item.accepted(); onAccepted: item.accepted();
onTextChanged: item.textUpdated() onTextChanged: item.textUpdated()
topPadding: 10 * scaleRatio
bottomPadding: 10 * scaleRatio
} }
MoneroComponents.InlineButton { MoneroComponents.InlineButton {

View file

@ -32,25 +32,56 @@ import QtQuick.Layouts 1.1
import "../components" as MoneroComponents import "../components" as MoneroComponents
ColumnLayout { ColumnLayout {
id: lineditmulti id: item
property alias text: multiLine.text
property alias placeholderText: placeholderLabel.text Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height
property alias text: input.text
property alias labelText: inputLabel.text property alias labelText: inputLabel.text
property alias error: multiLine.error
property alias readOnly: multiLine.readOnly
property alias addressValidation: multiLine.addressValidation
property alias labelButtonText: labelButton.text property alias labelButtonText: labelButton.text
property alias placeholderText: placeholderLabel.text
property bool placeholderCenter: false
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
property bool placeholderFontBold: false
property int placeholderFontSize: 18 * scaleRatio
property string placeholderColor: MoneroComponents.Style.defaultFontColor
property real placeholderOpacity: 0.35
property bool borderDisabled: false
property string borderColor: {
if(input.error && input.text !== ""){
return MoneroComponents.Style.inputBorderColorInvalid;
} else if(input.activeFocus){
return MoneroComponents.Style.inputBorderColorActive;
} else {
return MoneroComponents.Style.inputBorderColorInActive;
}
}
property bool error: false
property string labelFontColor: MoneroComponents.Style.defaultFontColor
property bool labelFontBold: false property bool labelFontBold: false
property int labelFontSize: 16 * scaleRatio
property bool labelButtonVisible: false property bool labelButtonVisible: false
property bool copyButton: false
property bool wrapAnywhere: true property string fontColor: "white"
property bool showingHeader: true
property bool showBorder: true
property bool fontBold: false property bool fontBold: false
property int fontSize: 16 * scaleRatio property int fontSize: 16 * scaleRatio
property bool mouseSelection: true
property alias readOnly: input.readOnly
property bool copyButton: false
property bool showingHeader: true
property var wrapMode: Text.NoWrap
property alias addressValidation: input.addressValidation
property string backgroundColor: "" // mock
signal labelButtonClicked(); signal labelButtonClicked();
signal inputLabelLinkActivated(); signal inputLabelLinkActivated();
signal editingFinished();
spacing: 0 spacing: 0
Rectangle { Rectangle {
@ -65,11 +96,17 @@ ColumnLayout {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
font.family: MoneroComponents.Style.fontRegular.name font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 16 * scaleRatio font.pixelSize: item.labelFontSize
font.bold: labelFontBold font.bold: labelFontBold
textFormat: Text.RichText textFormat: Text.RichText
color: MoneroComponents.Style.defaultFontColor color: item.labelFontColor
onLinkActivated: inputLabelLinkActivated() onLinkActivated: inputLabelLinkActivated()
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
} }
MoneroComponents.LabelButton { MoneroComponents.LabelButton {
@ -80,14 +117,14 @@ ColumnLayout {
MoneroComponents.LabelButton { MoneroComponents.LabelButton {
id: copyButtonId id: copyButtonId
visible: copyButton && multiLine.text !== "" visible: copyButton && input.text !== ""
text: qsTr("Copy") text: qsTr("Copy")
anchors.right: labelButton.visible ? inputLabel.right : parent.right anchors.right: labelButton.visible ? inputLabel.right : parent.right
anchors.rightMargin: labelButton.visible? 4 : 0 anchors.rightMargin: labelButton.visible? 4 : 0
onClicked: { onClicked: {
if (multiLine.text.length > 0) { if (input.text.length > 0) {
console.log("Copied to clipboard"); console.log("Copied to clipboard");
clipboard.setText(multiLine.text); clipboard.setText(input.text);
appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3); appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3);
} }
} }
@ -95,27 +132,32 @@ ColumnLayout {
} }
MoneroComponents.InputMulti { MoneroComponents.InputMulti {
id: multiLine id: input
readOnly: false readOnly: false
addressValidation: true addressValidation: false
anchors.top: parent.showingHeader ? inputLabelRect.bottom : parent.top anchors.top: item.showingHeader ? inputLabelRect.bottom : item.top
Layout.fillWidth: true Layout.fillWidth: true
topPadding: parent.showingHeader ? 10 * scaleRatio : 0 topPadding: item.showingHeader ? 10 * scaleRatio : 0
bottomPadding: 10 * scaleRatio bottomPadding: 10 * scaleRatio
wrapAnywhere: parent.wrapAnywhere wrapMode: item.wrapMode
fontSize: parent.fontSize fontSize: item.fontSize
fontBold: parent.fontBold fontBold: item.fontBold
fontColor: item.fontColor
mouseSelection: item.mouseSelection
onEditingFinished: item.editingFinished()
error: item.error
Text { Text {
id: placeholderLabel id: placeholderLabel
visible: multiLine.text ? false : true visible: input.text ? false : true
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 10 * scaleRatio anchors.leftMargin: 10 * scaleRatio
opacity: 0.35 opacity: item.placeholderOpacity
color: MoneroComponents.Style.defaultFontColor color: item.placeholderColor
font.family: MoneroComponents.Style.fontRegular.name font.family: item.placeholderFontFamily
font.pixelSize: 18 * scaleRatio font.bold: item.placeholderFontBold
font.pixelSize: item.placeholderFontSize
text: "" text: ""
z: 3 z: 3
} }
@ -123,18 +165,10 @@ ColumnLayout {
Rectangle { Rectangle {
color: "transparent" color: "transparent"
border.width: 1 border.width: 1
border.color: { border.color: item.borderColor
if(multiLine.error && multiLine.text !== ""){
return MoneroComponents.Style.inputBorderColorInvalid;
} else if(multiLine.activeFocus){
return MoneroComponents.Style.inputBorderColorActive;
} else {
return MoneroComponents.Style.inputBorderColorInActive;
}
}
radius: 4 radius: 4
anchors.fill: parent anchors.fill: parent
visible: lineditmulti.showBorder visible: !item.borderDisabled
} }
} }
} }

View file

@ -53,6 +53,8 @@ GridLayout {
property string lineEditBorderColor: Qt.rgba(0, 0, 0, 0.15) property string lineEditBorderColor: Qt.rgba(0, 0, 0, 0.15)
property string lineEditBackgroundColor: "white" property string lineEditBackgroundColor: "white"
property string lineEditFontColor: "black" property string lineEditFontColor: "black"
property int lineEditFontSize: 18 * scaleRatio
property int labelFontSize: 16 * scaleRatio
property bool lineEditFontBold: true property bool lineEditFontBold: true
signal editingFinished() signal editingFinished()
@ -61,7 +63,7 @@ GridLayout {
return daemonAddr.text.trim() + ":" + daemonPort.text.trim() return daemonAddr.text.trim() + ":" + daemonPort.text.trim()
} }
LineEdit { LineEditMulti {
id: daemonAddr id: daemonAddr
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Remote Node Hostname / IP") + translationManager.emptyString placeholderText: qsTr("Remote Node Hostname / IP") + translationManager.emptyString
@ -70,14 +72,16 @@ GridLayout {
placeholderFontSize: root.placeholderFontSize placeholderFontSize: root.placeholderFontSize
placeholderColor: root.placeholderColor placeholderColor: root.placeholderColor
placeholderOpacity: root.placeholderOpacity placeholderOpacity: root.placeholderOpacity
onEditingFinished: root.editingFinished() labelFontSize: root.labelFontSize
borderColor: lineEditBorderColor borderColor: lineEditBorderColor
backgroundColor: lineEditBackgroundColor backgroundColor: lineEditBackgroundColor
fontColor: lineEditFontColor fontColor: lineEditFontColor
fontBold: lineEditFontBold fontBold: lineEditFontBold
fontSize: lineEditFontSize
onEditingFinished: root.editingFinished()
} }
LineEdit { LineEditMulti {
id: daemonPort id: daemonPort
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Port") + translationManager.emptyString placeholderText: qsTr("Port") + translationManager.emptyString
@ -86,10 +90,13 @@ GridLayout {
placeholderFontSize: root.placeholderFontSize placeholderFontSize: root.placeholderFontSize
placeholderColor: root.placeholderColor placeholderColor: root.placeholderColor
placeholderOpacity: root.placeholderOpacity placeholderOpacity: root.placeholderOpacity
onEditingFinished: root.editingFinished() labelFontSize: root.labelFontSize
borderColor: lineEditBorderColor borderColor: lineEditBorderColor
backgroundColor: lineEditBackgroundColor backgroundColor: lineEditBackgroundColor
fontColor: lineEditFontColor fontColor: lineEditFontColor
fontBold: lineEditFontBold fontBold: lineEditFontBold
fontSize: lineEditFontSize
onEditingFinished: root.editingFinished()
} }
} }

View file

@ -128,7 +128,8 @@ Rectangle {
copyButton: true copyButton: true
addressValidation: false addressValidation: false
readOnly: true readOnly: true
wrapAnywhere: false wrapMode: Text.WordWrap
fontColor: "white"
} }
} }

View file

@ -255,6 +255,8 @@ Rectangle {
+ translationManager.emptyString + translationManager.emptyString
labelButtonText: qsTr("Resolve") + translationManager.emptyString labelButtonText: qsTr("Resolve") + translationManager.emptyString
placeholderText: "4.. / 8.." placeholderText: "4.. / 8.."
wrapMode: Text.WrapAnywhere
addressValidation: true
onInputLabelLinkActivated: { appWindow.showPageRequest("AddressBook") } onInputLabelLinkActivated: { appWindow.showPageRequest("AddressBook") }
} }
@ -319,17 +321,19 @@ Rectangle {
RowLayout { RowLayout {
// payment id input // payment id input
LineEdit { LineEditMulti {
id: paymentIdLine id: paymentIdLine
fontBold: true fontBold: true
labelText: qsTr("Payment ID <font size='2'>( Optional )</font>") + translationManager.emptyString labelText: qsTr("Payment ID <font size='2'>( Optional )</font>") + translationManager.emptyString
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
addressValidation: false
} }
} }
RowLayout { RowLayout {
LineEdit { LineEditMulti {
id: descriptionLine id: descriptionLine
labelText: qsTr("Description <font size='2'>( Optional )</font>") + translationManager.emptyString labelText: qsTr("Description <font size='2'>( Optional )</font>") + translationManager.emptyString
placeholderText: qsTr("Saved to local wallet history") + translationManager.emptyString placeholderText: qsTr("Saved to local wallet history") + translationManager.emptyString