2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
2023-03-14 02:52:16 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
// TODO: Use https://github.com/status-im/status-desktop/issues/6136
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
WriteMode,
|
|
|
|
ReadMode
|
|
|
|
}
|
|
|
|
|
2023-08-21 10:58:21 +00:00
|
|
|
required property int mode
|
2023-03-14 02:52:16 +00:00
|
|
|
property bool readOnly: false
|
|
|
|
|
|
|
|
input.edit.readOnly: root.readOnly
|
2024-10-15 19:26:12 +00:00
|
|
|
input.font: Theme.monoFont.name
|
2023-03-14 02:52:16 +00:00
|
|
|
input.placeholderFont: root.input.font
|
|
|
|
|
|
|
|
input.rightComponent: {
|
|
|
|
switch (root.mode) {
|
|
|
|
case StatusSyncCodeInput.Mode.WriteMode:
|
|
|
|
return root.valid ? validCodeIconComponent
|
|
|
|
: pasteButtonComponent
|
|
|
|
case StatusSyncCodeInput.Mode.ReadMode:
|
|
|
|
return copyButtonComponent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: copyButtonComponent
|
|
|
|
|
|
|
|
StatusButton {
|
2024-04-18 15:45:49 +00:00
|
|
|
objectName: "syncCodeCopyButton"
|
2023-03-14 02:52:16 +00:00
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
text: qsTr("Copy")
|
|
|
|
onClicked: {
|
|
|
|
root.input.edit.selectAll();
|
|
|
|
root.input.edit.copy();
|
|
|
|
root.input.edit.deselect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: pasteButtonComponent
|
|
|
|
|
|
|
|
StatusButton {
|
2024-04-18 15:45:49 +00:00
|
|
|
objectName: "syncCodePasteButton"
|
2023-03-14 02:52:16 +00:00
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
enabled: !root.readOnly && root.input.edit.canPaste
|
|
|
|
text: qsTr("Paste")
|
|
|
|
onClicked: {
|
|
|
|
root.input.edit.selectAll();
|
|
|
|
root.input.edit.paste();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: validCodeIconComponent
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
icon: "tiny/checkmark"
|
|
|
|
color: Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|