Add FieldCopyButton.qml, split from SignInSso.qml
This commit is contained in:
parent
32484c3ae5
commit
6af4cca315
31
src/gui/Base/Buttons/FieldCopyButton.qml
Normal file
31
src/gui/Base/Buttons/FieldCopyButton.qml
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import ".."
|
||||
|
||||
HButton {
|
||||
property Item textControl // HTextField or HTextArea
|
||||
|
||||
|
||||
icon.name: "copy-text"
|
||||
iconItem.small: true
|
||||
|
||||
toolTip.text: qsTr("Copy")
|
||||
toolTip.onClosed: toolTip.text = qsTr("Copy")
|
||||
toolTip.label.wrapMode: HLabel.NoWrap
|
||||
|
||||
onClicked: {
|
||||
textControl.selectAll()
|
||||
textControl.copy()
|
||||
textControl.deselect()
|
||||
|
||||
toolTip.text = qsTr("Copied!")
|
||||
toolTip.instantShow(2000)
|
||||
}
|
||||
|
||||
onActiveFocusChanged: if (! activeFocus && toolTip.visible) toolTip.hide()
|
||||
|
||||
Layout.fillHeight: true
|
||||
}
|
|
@ -65,25 +65,9 @@ SignInBase {
|
|||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
HButton {
|
||||
FieldCopyButton {
|
||||
id: copyUrlButton
|
||||
icon.name: "copy-text"
|
||||
iconItem.small: true
|
||||
|
||||
toolTip.text: qsTr("Copy")
|
||||
toolTip.onClosed: toolTip.text = qsTr("Copy")
|
||||
toolTip.label.wrapMode: HLabel.NoWrap
|
||||
|
||||
onClicked: {
|
||||
urlArea.selectAll()
|
||||
urlArea.copy()
|
||||
urlArea.deselect()
|
||||
|
||||
toolTip.text = qsTr("Copied!")
|
||||
toolTip.instantShow(2000)
|
||||
}
|
||||
|
||||
Layout.fillHeight: true
|
||||
textControl: urlArea
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user