From 3d65a5d90d4deb6bcd76c5c033137509267d1ad4 Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Wed, 6 Dec 2017 00:54:34 +0100 Subject: [PATCH] LineEdit; included copy button --- components/LineEdit.qml | 49 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/components/LineEdit.qml b/components/LineEdit.qml index 5f636a06..debc396d 100644 --- a/components/LineEdit.qml +++ b/components/LineEdit.qml @@ -40,6 +40,7 @@ Item { property alias inlineButton: inlineButtonId property alias inlineButtonText: inlineButtonId.text property alias inlineIcon: inlineIcon.visible + property alias copyButton: copyButton.visible property int fontSize: 18 * scaleRatio property bool showBorder: true property bool error: false @@ -51,12 +52,12 @@ Item { property bool labelFontBold: false property alias labelWrapMode: inputLabel.wrapMode property alias labelHorizontalAlignment: inputLabel.horizontalAlignment - signal labelLinkActivated(); + signal labelLinkActivated(); // input label, rich text signal signal editingFinished() signal accepted(); signal textUpdated(); - height: (inputLabel.height + inputItem.height + 10) * scaleRatio + height: (inputLabel.height + inputItem.height + 2) * scaleRatio onTextUpdated: { // check to remove placeholder text when there is content @@ -88,8 +89,8 @@ Item { Text { id: inputLabel anchors.top: parent.top - anchors.topMargin: 10 * scaleRatio anchors.left: parent.left + anchors.topMargin: 2 font.family: Style.fontRegular.name font.pixelSize: labelFontSize font.bold: labelFontBold @@ -104,6 +105,48 @@ Item { } } + Rectangle{ + id: copyButton + color: "#808080" + radius: 3 + height: 20 + width: 44 + anchors.right: parent.right + visible: false + + Text { + id: copyButtonText + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + font.family: Style.fontRegular.name + font.pixelSize: 12 + font.bold: true + text: "Copy" + color: "black" + } + + MouseArea { + cursorShape: Qt.PointingHandCursor + anchors.fill: parent + hoverEnabled: true + onClicked: { + if (addressLine.text.length > 0) { + console.log(addressLine.text + " copied to clipboard") + clipboard.setText(addressLine.text) + appWindow.showStatusMessage(qsTr("Address copied to clipboard"),3) + } + } + onEntered: { + copyButton.color = "#707070"; + copyButtonText.opacity = 0.8; + } + onExited: { + copyButtonText.opacity = 1.0; + copyButton.color = "#808080"; + } + } + } + Item{ id: inputItem height: 48 * scaleRatio