diff --git a/src/gui/Base/HToolTip.qml b/src/gui/Base/HToolTip.qml index 04b50c6a..8bbb399b 100644 --- a/src/gui/Base/HToolTip.qml +++ b/src/gui/Base/HToolTip.qml @@ -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 } diff --git a/src/gui/Pages/AddAccount/SignInSso.qml b/src/gui/Pages/AddAccount/SignInSso.qml index 2aaccb72..46718e2d 100644 --- a/src/gui/Pages/AddAccount/SignInSso.qml +++ b/src/gui/Pages/AddAccount/SignInSso.qml @@ -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 + } } }