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,47 +109,57 @@ 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 {
|
||||||
}
|
Item {
|
||||||
|
width: copyBtn.width
|
||||||
|
height: copyBtn.height
|
||||||
|
|
||||||
Component {
|
Timer {
|
||||||
id: copyToClipboardComponent
|
id: timer
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
StyledButton {
|
||||||
width: copyBtn.width
|
property bool copied: false
|
||||||
height: copyBtn.height
|
id: copyBtn
|
||||||
|
label: {
|
||||||
|
if (copied) {
|
||||||
|
return inputBox.copyToClipboard ?
|
||||||
|
//% "Copied"
|
||||||
|
qsTrId("sharing-copied-to-clipboard") :
|
||||||
|
qsTr("Pasted")
|
||||||
|
}
|
||||||
|
return inputBox.copyToClipboard ?
|
||||||
|
//% "Copy"
|
||||||
|
qsTrId("copy-to-clipboard") :
|
||||||
|
qsTr("Paste")
|
||||||
|
|
||||||
Timer {
|
}
|
||||||
id: timer
|
height: 28
|
||||||
}
|
textSize: 12
|
||||||
|
btnBorderColor: Style.current.blue
|
||||||
|
btnBorderWidth: 1
|
||||||
|
onClicked: {
|
||||||
|
if (inputBox.copyToClipboard) {
|
||||||
|
chatsModel.copyToClipboard(inputValue.text)
|
||||||
|
} else {
|
||||||
|
if (inputValue.canPaste) {
|
||||||
|
inputValue.paste()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StyledButton {
|
copyBtn.copied = true
|
||||||
id: copyBtn
|
timer.setTimeout(function() {
|
||||||
//% "Copy"
|
copyBtn.copied = false
|
||||||
label: qsTrId("copy-to-clipboard")
|
}, 2000);
|
||||||
height: 28
|
}
|
||||||
textSize: 12
|
|
||||||
btnBorderColor: Style.current.blue
|
|
||||||
btnBorderWidth: 1
|
|
||||||
onClicked: {
|
|
||||||
chatsModel.copyToClipboard(inputValue.text)
|
|
||||||
//% "Copied"
|
|
||||||
copyBtn.label = qsTrId("sharing-copied-to-clipboard")
|
|
||||||
timer.setTimeout(function(){
|
|
||||||
//% "Copy"
|
|
||||||
copyBtn.label = qsTrId("copy-to-clipboard")
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
|
|
Loading…
Reference in New Issue