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
function instantShow() {
function instantShow(timeout=-1) {
if (visible) return
instant = true
open()
timeout === -1 ? open() : show(text, timeout)
instant = false
}

View File

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