feat: enable showing a paste button in the Input
This commit is contained in:
parent
a13f1f2043
commit
7242409bfa
|
@ -18,6 +18,7 @@ Item {
|
||||||
property int iconHeight: 24
|
property int iconHeight: 24
|
||||||
property int iconWidth: 24
|
property int iconWidth: 24
|
||||||
property bool copyToClipboard: false
|
property bool copyToClipboard: false
|
||||||
|
property bool pasteFromClipboard: false
|
||||||
property bool readOnly: false
|
property bool readOnly: false
|
||||||
|
|
||||||
readonly property bool hasIcon: icon.toString() !== ""
|
readonly property bool hasIcon: icon.toString() !== ""
|
||||||
|
@ -108,16 +109,11 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
active: inputBox.copyToClipboard
|
active: inputBox.copyToClipboard || inputBox.pasteFromClipboard
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 8
|
anchors.rightMargin: 8
|
||||||
sourceComponent: copyToClipboardComponent
|
sourceComponent: Component {
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: copyToClipboardComponent
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: copyBtn.width
|
width: copyBtn.width
|
||||||
height: copyBtn.height
|
height: copyBtn.height
|
||||||
|
@ -127,28 +123,43 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledButton {
|
StyledButton {
|
||||||
|
property bool copied: false
|
||||||
id: copyBtn
|
id: copyBtn
|
||||||
|
label: {
|
||||||
|
if (copied) {
|
||||||
|
return inputBox.copyToClipboard ?
|
||||||
|
//% "Copied"
|
||||||
|
qsTrId("sharing-copied-to-clipboard") :
|
||||||
|
qsTr("Pasted")
|
||||||
|
}
|
||||||
|
return inputBox.copyToClipboard ?
|
||||||
//% "Copy"
|
//% "Copy"
|
||||||
label: qsTrId("copy-to-clipboard")
|
qsTrId("copy-to-clipboard") :
|
||||||
|
qsTr("Paste")
|
||||||
|
|
||||||
|
}
|
||||||
height: 28
|
height: 28
|
||||||
textSize: 12
|
textSize: 12
|
||||||
btnBorderColor: Style.current.blue
|
btnBorderColor: Style.current.blue
|
||||||
btnBorderWidth: 1
|
btnBorderWidth: 1
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (inputBox.copyToClipboard) {
|
||||||
chatsModel.copyToClipboard(inputValue.text)
|
chatsModel.copyToClipboard(inputValue.text)
|
||||||
//% "Copied"
|
} else {
|
||||||
copyBtn.label = qsTrId("sharing-copied-to-clipboard")
|
if (inputValue.canPaste) {
|
||||||
timer.setTimeout(function(){
|
inputValue.paste()
|
||||||
//% "Copy"
|
}
|
||||||
copyBtn.label = qsTrId("copy-to-clipboard")
|
}
|
||||||
|
|
||||||
|
copyBtn.copied = true
|
||||||
|
timer.setTimeout(function() {
|
||||||
|
copyBtn.copied = false
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
|
|
Loading…
Reference in New Issue