moment/src/gui/Pages/AddAccount/SignInSso.qml

89 lines
2.1 KiB
QML
Raw Normal View History

2020-07-25 23:31:13 -04:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
import "../../Base/Buttons"
SignInBase {
id: page
2020-07-26 20:56:42 -04:00
function takeFocus() { copyUrlButton.forceActiveFocus() }
2020-07-25 23:31:13 -04:00
function startSignIn() {
errorMessage.text = ""
page.loginFuture = py.callCoro("start_sso_auth", [serverUrl], url => {
2020-07-26 20:56:42 -04:00
urlArea.text = url
urlArea.cursorPosition = 0
2020-07-25 23:31:13 -04:00
Qt.openUrlExternally(url)
page.loginFuture = py.callCoro("continue_sso_auth", [], userId => {
page.loginFuture = null
page.finishSignIn(userId)
})
})
}
function cancel() {
if (loginFuture) {
page.loginFuture.cancel()
page.loginFuture = null
}
page.exitRequested()
}
2020-07-25 23:31:13 -04:00
implicitWidth: theme.controls.box.defaultWidth * 1.25
2020-07-25 23:31:13 -04:00
applyButton.text: qsTr("Waiting")
applyButton.loading: true
Component.onCompleted: page.startSignIn()
HLabel {
wrapMode: HLabel.Wrap
text: qsTr(
"Complete the single sign-on process in your web browser to " +
"continue.\n\n" +
"If no page appeared, you can also manually open this address:"
)
Layout.fillWidth: true
}
2020-07-26 20:56:42 -04:00
HRowLayout {
HTextArea {
id: urlArea
width: parent.width
readOnly: true
radius: 0
wrapMode: HTextArea.WrapAnywhere
2020-07-25 23:31:13 -04:00
2020-07-26 20:56:42 -04:00
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
}
2020-07-25 23:31:13 -04:00
}
}