2019-04-23 04:21:01 +02:00
|
|
|
// Copyright (c) 2014-2019, The Monero Project
|
2017-12-09 00:02:25 +01:00
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2019-04-11 03:17:29 +02:00
|
|
|
import QtQuick 2.9
|
2017-12-09 00:02:25 +01:00
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
2018-03-31 03:25:20 +02:00
|
|
|
import "../components" as MoneroComponents
|
2017-12-09 00:02:25 +01:00
|
|
|
|
|
|
|
ColumnLayout {
|
2018-07-18 15:00:53 +02:00
|
|
|
id: item
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
property alias text: input.text
|
2018-03-21 23:56:53 +01:00
|
|
|
property alias labelText: inputLabel.text
|
2017-12-09 00:02:25 +01:00
|
|
|
property alias labelButtonText: labelButton.text
|
2018-07-18 15:00:53 +02:00
|
|
|
property alias placeholderText: placeholderLabel.text
|
|
|
|
|
2019-04-25 21:09:23 +02:00
|
|
|
property int inputPaddingLeft: 10
|
|
|
|
property int inputPaddingRight: 10
|
|
|
|
property int inputPaddingTop: 10
|
|
|
|
property int inputPaddingBottom: 10
|
2019-01-14 01:02:44 +01:00
|
|
|
property int inputRadius: 4
|
|
|
|
|
2018-07-18 15:00:53 +02:00
|
|
|
property bool placeholderCenter: false
|
|
|
|
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
|
|
|
|
property bool placeholderFontBold: false
|
2019-04-25 21:09:23 +02:00
|
|
|
property int placeholderFontSize: 18
|
2018-07-18 15:00:53 +02:00
|
|
|
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
|
2018-01-28 00:14:42 +01:00
|
|
|
property bool labelFontBold: false
|
2019-04-25 21:09:23 +02:00
|
|
|
property int labelFontSize: 16
|
2017-12-09 00:02:25 +01:00
|
|
|
property bool labelButtonVisible: false
|
2018-07-18 15:00:53 +02:00
|
|
|
|
2019-04-11 03:17:29 +02:00
|
|
|
property string fontColor: MoneroComponents.Style.defaultFontColor
|
2018-03-24 21:06:12 +01:00
|
|
|
property bool fontBold: false
|
2019-04-25 21:09:23 +02:00
|
|
|
property int fontSize: 16
|
2018-03-19 02:42:46 +01:00
|
|
|
|
2018-07-18 15:00:53 +02:00
|
|
|
property bool mouseSelection: true
|
|
|
|
property alias readOnly: input.readOnly
|
|
|
|
property bool copyButton: false
|
2018-11-30 04:51:03 +01:00
|
|
|
property bool pasteButton: false
|
|
|
|
property var onPaste: function(clipboardText) {
|
|
|
|
item.text = clipboardText;
|
|
|
|
}
|
2018-12-21 07:21:41 +01:00
|
|
|
property bool showingHeader: labelText != "" || copyButton || pasteButton
|
2018-07-18 15:00:53 +02:00
|
|
|
property var wrapMode: Text.NoWrap
|
|
|
|
property alias addressValidation: input.addressValidation
|
|
|
|
property string backgroundColor: "" // mock
|
|
|
|
|
2018-12-12 22:31:24 +01:00
|
|
|
property alias inlineButton: inlineButtonId
|
|
|
|
property bool inlineButtonVisible: false
|
|
|
|
|
2017-12-09 00:02:25 +01:00
|
|
|
signal labelButtonClicked();
|
|
|
|
signal inputLabelLinkActivated();
|
2018-07-18 15:00:53 +02:00
|
|
|
signal editingFinished();
|
2017-12-09 00:02:25 +01:00
|
|
|
|
|
|
|
spacing: 0
|
2017-12-27 00:53:21 +01:00
|
|
|
Rectangle {
|
2017-12-09 00:02:25 +01:00
|
|
|
id: inputLabelRect
|
|
|
|
color: "transparent"
|
|
|
|
Layout.fillWidth: true
|
2019-04-25 21:09:23 +02:00
|
|
|
height: (inputLabel.height + 10)
|
2018-03-19 02:42:46 +01:00
|
|
|
visible: showingHeader ? true : false
|
2017-12-09 00:02:25 +01:00
|
|
|
|
2019-04-11 03:17:29 +02:00
|
|
|
MoneroComponents.TextPlain {
|
2017-12-09 00:02:25 +01:00
|
|
|
id: inputLabel
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2018-03-31 03:25:20 +02:00
|
|
|
font.family: MoneroComponents.Style.fontRegular.name
|
2018-07-18 15:00:53 +02:00
|
|
|
font.pixelSize: item.labelFontSize
|
2017-12-09 00:02:25 +01:00
|
|
|
font.bold: labelFontBold
|
|
|
|
textFormat: Text.RichText
|
2018-07-18 15:00:53 +02:00
|
|
|
color: item.labelFontColor
|
2017-12-09 00:02:25 +01:00
|
|
|
onLinkActivated: inputLabelLinkActivated()
|
2018-07-18 15:00:53 +02:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.NoButton
|
|
|
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
|
|
}
|
2017-12-09 00:02:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-30 04:51:03 +01:00
|
|
|
RowLayout {
|
|
|
|
anchors.right: parent.right
|
2019-04-25 21:09:23 +02:00
|
|
|
spacing: 16
|
2018-11-30 04:51:03 +01:00
|
|
|
|
|
|
|
MoneroComponents.LabelButton {
|
|
|
|
id: labelButton
|
|
|
|
onClicked: labelButtonClicked()
|
|
|
|
visible: labelButtonVisible
|
|
|
|
}
|
2017-12-09 00:02:25 +01:00
|
|
|
|
2018-11-30 04:51:03 +01:00
|
|
|
MoneroComponents.LabelButton {
|
|
|
|
id: copyButtonId
|
|
|
|
visible: copyButton && input.text !== ""
|
2019-04-16 16:35:30 +02:00
|
|
|
text: qsTr("Copy") + translationManager.emptyString
|
2018-11-30 04:51:03 +01:00
|
|
|
onClicked: {
|
|
|
|
if (input.text.length > 0) {
|
|
|
|
console.log("Copied to clipboard");
|
|
|
|
clipboard.setText(input.text);
|
|
|
|
appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3);
|
|
|
|
}
|
2017-12-09 00:02:25 +01:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 04:51:03 +01:00
|
|
|
|
|
|
|
MoneroComponents.LabelButton {
|
|
|
|
id: pasteButtonId
|
|
|
|
onClicked: item.onPaste(clipboard.text())
|
2019-04-16 16:35:30 +02:00
|
|
|
text: qsTr("Paste") + translationManager.emptyString
|
2018-11-30 04:51:03 +01:00
|
|
|
visible: pasteButton
|
|
|
|
}
|
2017-12-09 00:02:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 03:25:20 +02:00
|
|
|
MoneroComponents.InputMulti {
|
2018-07-18 15:00:53 +02:00
|
|
|
id: input
|
2017-12-09 00:02:25 +01:00
|
|
|
readOnly: false
|
2018-07-18 15:00:53 +02:00
|
|
|
addressValidation: false
|
2017-12-09 00:02:25 +01:00
|
|
|
Layout.fillWidth: true
|
2019-01-14 01:02:44 +01:00
|
|
|
|
|
|
|
leftPadding: item.inputPaddingLeft
|
|
|
|
rightPadding: item.inputPaddingRight
|
|
|
|
topPadding: item.inputPaddingTop
|
|
|
|
bottomPadding: item.inputPaddingBottom
|
|
|
|
|
2018-07-18 15:00:53 +02:00
|
|
|
wrapMode: item.wrapMode
|
|
|
|
fontSize: item.fontSize
|
|
|
|
fontBold: item.fontBold
|
|
|
|
fontColor: item.fontColor
|
|
|
|
mouseSelection: item.mouseSelection
|
|
|
|
onEditingFinished: item.editingFinished()
|
|
|
|
error: item.error
|
2017-12-09 00:02:25 +01:00
|
|
|
|
2019-04-11 03:17:29 +02:00
|
|
|
MoneroComponents.TextPlain {
|
2017-12-09 00:02:25 +01:00
|
|
|
id: placeholderLabel
|
2018-07-18 15:00:53 +02:00
|
|
|
visible: input.text ? false : true
|
2017-12-09 00:02:25 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
2019-04-25 21:09:23 +02:00
|
|
|
anchors.leftMargin: 10
|
2018-07-18 15:00:53 +02:00
|
|
|
opacity: item.placeholderOpacity
|
|
|
|
color: item.placeholderColor
|
|
|
|
font.family: item.placeholderFontFamily
|
|
|
|
font.bold: item.placeholderFontBold
|
|
|
|
font.pixelSize: item.placeholderFontSize
|
2017-12-09 00:02:25 +01:00
|
|
|
text: ""
|
|
|
|
z: 3
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
border.width: 1
|
2018-07-18 15:00:53 +02:00
|
|
|
border.color: item.borderColor
|
2019-01-14 01:02:44 +01:00
|
|
|
radius: item.inputRadius
|
2017-12-09 00:02:25 +01:00
|
|
|
anchors.fill: parent
|
2018-07-18 15:00:53 +02:00
|
|
|
visible: !item.borderDisabled
|
2017-12-09 00:02:25 +01:00
|
|
|
}
|
2018-12-12 22:31:24 +01:00
|
|
|
|
|
|
|
MoneroComponents.InlineButton {
|
|
|
|
id: inlineButtonId
|
|
|
|
visible: (inlineButtonId.text || inlineButtonId.icon) && inlineButtonVisible ? true : false
|
|
|
|
anchors.right: parent.right
|
2019-04-25 21:09:23 +02:00
|
|
|
anchors.rightMargin: 8
|
2018-12-12 22:31:24 +01:00
|
|
|
}
|
2017-12-09 00:02:25 +01:00
|
|
|
}
|
|
|
|
}
|