SignInSso: add a copy URL button

This commit is contained in:
miruka 2020-07-26 20:56:42 -04:00
parent ddee50f28a
commit 3ab2864f22
2 changed files with 36 additions and 13 deletions

View File

@ -15,10 +15,10 @@ ToolTip {
readonly property bool hideNow: ! window.hovered readonly property bool hideNow: ! window.hovered
function instantShow() { function instantShow(timeout=-1) {
if (visible) return if (visible) return
instant = true instant = true
open() timeout === -1 ? open() : show(text, timeout)
instant = false instant = false
} }

View File

@ -8,14 +8,14 @@ import "../../Base/Buttons"
SignInBase { SignInBase {
id: page id: page
function takeFocus() { urlField.forceActiveFocus() } function takeFocus() { copyUrlButton.forceActiveFocus() }
function startSignIn() { function startSignIn() {
errorMessage.text = "" errorMessage.text = ""
page.loginFuture = py.callCoro("start_sso_auth", [serverUrl], url => { page.loginFuture = py.callCoro("start_sso_auth", [serverUrl], url => {
urlField.text = url urlArea.text = url
urlField.cursorPosition = 0 urlArea.cursorPosition = 0
Qt.openUrlExternally(url) Qt.openUrlExternally(url)
@ -42,8 +42,9 @@ SignInBase {
Layout.fillWidth: true Layout.fillWidth: true
} }
HRowLayout {
HTextArea { HTextArea {
id: urlField id: urlArea
width: parent.width width: parent.width
readOnly: true readOnly: true
radius: 0 radius: 0
@ -52,4 +53,26 @@ SignInBase {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
} }
HButton {
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
}
}
} }