2019-04-23 02:21:01 +00:00
|
|
|
// Copyright (c) 2014-2019, The Monero Project
|
2017-12-08 23:02:25 +00: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 01:17:29 +00:00
|
|
|
import QtQuick 2.9
|
2017-12-08 23:02:25 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
2018-03-31 01:25:20 +00:00
|
|
|
import "../components" as MoneroComponents
|
2017-12-08 23:02:25 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
2018-07-18 13:00:53 +00:00
|
|
|
id: item
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
property alias text: input.text
|
2018-03-21 22:56:53 +00:00
|
|
|
property alias labelText: inputLabel.text
|
2017-12-08 23:02:25 +00:00
|
|
|
property alias labelButtonText: labelButton.text
|
2018-07-18 13:00:53 +00:00
|
|
|
property alias placeholderText: placeholderLabel.text
|
|
|
|
|
2019-04-25 19:09:23 +00:00
|
|
|
property int inputPaddingLeft: 10
|
|
|
|
property int inputPaddingRight: 10
|
|
|
|
property int inputPaddingTop: 10
|
|
|
|
property int inputPaddingBottom: 10
|
2019-01-14 00:02:44 +00:00
|
|
|
property int inputRadius: 4
|
|
|
|
|
2018-07-18 13:00:53 +00:00
|
|
|
property bool placeholderCenter: false
|
|
|
|
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
|
|
|
|
property bool placeholderFontBold: false
|
2019-04-25 19:09:23 +00:00
|
|
|
property int placeholderFontSize: 18
|
2018-07-18 13:00:53 +00: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-27 23:14:42 +00:00
|
|
|
property bool labelFontBold: false
|
2019-04-25 19:09:23 +00:00
|
|
|
property int labelFontSize: 16
|
2017-12-08 23:02:25 +00:00
|
|
|
property bool labelButtonVisible: false
|
2018-07-18 13:00:53 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
property string fontColor: MoneroComponents.Style.defaultFontColor
|
2018-03-24 20:06:12 +00:00
|
|
|
property bool fontBold: false
|
2019-04-25 19:09:23 +00:00
|
|
|
property int fontSize: 16
|
2018-03-19 01:42:46 +00:00
|
|
|
|
2018-07-18 13:00:53 +00:00
|
|
|
property bool mouseSelection: true
|
|
|
|
property alias readOnly: input.readOnly
|
|
|
|
property bool copyButton: false
|
2018-11-30 03:51:03 +00:00
|
|
|
property bool pasteButton: false
|
2018-12-21 06:21:41 +00:00
|
|
|
property bool showingHeader: labelText != "" || copyButton || pasteButton
|
2018-07-18 13:00:53 +00:00
|
|
|
property var wrapMode: Text.NoWrap
|
|
|
|
property alias addressValidation: input.addressValidation
|
|
|
|
property string backgroundColor: "" // mock
|
|
|
|
|
2018-12-12 21:31:24 +00:00
|
|
|
property alias inlineButton: inlineButtonId
|
|
|
|
property bool inlineButtonVisible: false
|
2020-04-14 18:47:00 +00:00
|
|
|
property alias inlineButton2: inlineButton2Id
|
|
|
|
property bool inlineButton2Visible: false
|
2018-12-12 21:31:24 +00:00
|
|
|
|
2017-12-08 23:02:25 +00:00
|
|
|
signal labelButtonClicked();
|
|
|
|
signal inputLabelLinkActivated();
|
2018-07-18 13:00:53 +00:00
|
|
|
signal editingFinished();
|
2017-12-08 23:02:25 +00:00
|
|
|
|
2020-12-02 23:55:42 +00:00
|
|
|
onActiveFocusChanged: activeFocus && input.forceActiveFocus()
|
|
|
|
|
2017-12-08 23:02:25 +00:00
|
|
|
spacing: 0
|
2017-12-26 23:53:21 +00:00
|
|
|
Rectangle {
|
2017-12-08 23:02:25 +00:00
|
|
|
id: inputLabelRect
|
|
|
|
color: "transparent"
|
|
|
|
Layout.fillWidth: true
|
2019-04-25 19:09:23 +00:00
|
|
|
height: (inputLabel.height + 10)
|
2018-03-19 01:42:46 +00:00
|
|
|
visible: showingHeader ? true : false
|
2017-12-08 23:02:25 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
MoneroComponents.TextPlain {
|
2017-12-08 23:02:25 +00:00
|
|
|
id: inputLabel
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2018-03-31 01:25:20 +00:00
|
|
|
font.family: MoneroComponents.Style.fontRegular.name
|
2018-07-18 13:00:53 +00:00
|
|
|
font.pixelSize: item.labelFontSize
|
2017-12-08 23:02:25 +00:00
|
|
|
font.bold: labelFontBold
|
|
|
|
textFormat: Text.RichText
|
2018-07-18 13:00:53 +00:00
|
|
|
color: item.labelFontColor
|
2017-12-08 23:02:25 +00:00
|
|
|
onLinkActivated: inputLabelLinkActivated()
|
2018-07-18 13:00:53 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.NoButton
|
|
|
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
|
|
}
|
2017-12-08 23:02:25 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 03:51:03 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.right: parent.right
|
2019-04-25 19:09:23 +00:00
|
|
|
spacing: 16
|
2018-11-30 03:51:03 +00:00
|
|
|
|
|
|
|
MoneroComponents.LabelButton {
|
|
|
|
id: labelButton
|
|
|
|
onClicked: labelButtonClicked()
|
|
|
|
visible: labelButtonVisible
|
|
|
|
}
|
2017-12-08 23:02:25 +00:00
|
|
|
|
2018-11-30 03:51:03 +00:00
|
|
|
MoneroComponents.LabelButton {
|
|
|
|
id: copyButtonId
|
|
|
|
visible: copyButton && input.text !== ""
|
2019-04-16 14:35:30 +00:00
|
|
|
text: qsTr("Copy") + translationManager.emptyString
|
2018-11-30 03:51:03 +00: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-08 23:02:25 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 03:51:03 +00:00
|
|
|
|
|
|
|
MoneroComponents.LabelButton {
|
|
|
|
id: pasteButtonId
|
2019-11-08 00:56:10 +00:00
|
|
|
onClicked: {
|
|
|
|
input.clear();
|
|
|
|
input.paste();
|
|
|
|
}
|
2019-04-16 14:35:30 +00:00
|
|
|
text: qsTr("Paste") + translationManager.emptyString
|
2018-11-30 03:51:03 +00:00
|
|
|
visible: pasteButton
|
|
|
|
}
|
2017-12-08 23:02:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 01:25:20 +00:00
|
|
|
MoneroComponents.InputMulti {
|
2018-07-18 13:00:53 +00:00
|
|
|
id: input
|
2017-12-08 23:02:25 +00:00
|
|
|
readOnly: false
|
2018-07-18 13:00:53 +00:00
|
|
|
addressValidation: false
|
2020-12-02 23:55:42 +00:00
|
|
|
KeyNavigation.priority: KeyNavigation.BeforeItem
|
|
|
|
KeyNavigation.tab: item.KeyNavigation.tab
|
2017-12-08 23:02:25 +00:00
|
|
|
Layout.fillWidth: true
|
2020-12-02 23:55:42 +00:00
|
|
|
|
2019-01-14 00:02:44 +00:00
|
|
|
leftPadding: item.inputPaddingLeft
|
|
|
|
rightPadding: item.inputPaddingRight
|
|
|
|
topPadding: item.inputPaddingTop
|
|
|
|
bottomPadding: item.inputPaddingBottom
|
|
|
|
|
2018-07-18 13:00:53 +00:00
|
|
|
wrapMode: item.wrapMode
|
|
|
|
fontSize: item.fontSize
|
|
|
|
fontBold: item.fontBold
|
|
|
|
fontColor: item.fontColor
|
|
|
|
mouseSelection: item.mouseSelection
|
|
|
|
onEditingFinished: item.editingFinished()
|
|
|
|
error: item.error
|
2017-12-08 23:02:25 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
MoneroComponents.TextPlain {
|
2017-12-08 23:02:25 +00:00
|
|
|
id: placeholderLabel
|
2018-07-18 13:00:53 +00:00
|
|
|
visible: input.text ? false : true
|
2017-12-08 23:02:25 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
2019-04-25 19:09:23 +00:00
|
|
|
anchors.leftMargin: 10
|
2018-07-18 13:00:53 +00:00
|
|
|
opacity: item.placeholderOpacity
|
|
|
|
color: item.placeholderColor
|
|
|
|
font.family: item.placeholderFontFamily
|
|
|
|
font.bold: item.placeholderFontBold
|
|
|
|
font.pixelSize: item.placeholderFontSize
|
2017-12-08 23:02:25 +00:00
|
|
|
text: ""
|
|
|
|
z: 3
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
border.width: 1
|
2018-07-18 13:00:53 +00:00
|
|
|
border.color: item.borderColor
|
2019-01-14 00:02:44 +00:00
|
|
|
radius: item.inputRadius
|
2017-12-08 23:02:25 +00:00
|
|
|
anchors.fill: parent
|
2018-07-18 13:00:53 +00:00
|
|
|
visible: !item.borderDisabled
|
2017-12-08 23:02:25 +00:00
|
|
|
}
|
2018-12-12 21:31:24 +00:00
|
|
|
|
|
|
|
MoneroComponents.InlineButton {
|
|
|
|
id: inlineButtonId
|
|
|
|
visible: (inlineButtonId.text || inlineButtonId.icon) && inlineButtonVisible ? true : false
|
|
|
|
anchors.right: parent.right
|
2019-04-25 19:09:23 +00:00
|
|
|
anchors.rightMargin: 8
|
2018-12-12 21:31:24 +00:00
|
|
|
}
|
2020-04-14 18:47:00 +00:00
|
|
|
|
|
|
|
MoneroComponents.InlineButton {
|
|
|
|
id: inlineButton2Id
|
|
|
|
visible: (inlineButton2Id.text || inlineButton2Id.icon) && inlineButton2Visible ? true : false
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: inlineButtonVisible ? 48 : 8
|
|
|
|
}
|
2017-12-08 23:02:25 +00:00
|
|
|
}
|
|
|
|
}
|