fix sip login page content layout

This commit is contained in:
Gaelle Braud 2023-11-15 14:11:12 +01:00
parent 22724d8cd2
commit 62a9d34e09

View file

@ -57,162 +57,160 @@ LoginLayout {
centerContent: ColumnLayout {
signal useSIPButtonClicked()
RowLayout {
ColumnLayout {
Layout.preferredWidth: 330
Layout.maximumWidth: 340
Control.StackView {
id: rootStackView
initialItem: firstItem
Layout.preferredWidth: parent.width
Layout.preferredHeight: parent.height
Component {
id: firstItem
ColumnLayout {
Layout.alignment: Qt.AlignTop
Layout.fillHeight: true
Layout.maximumWidth: rootStackView.width
clip: true
ColumnLayout {
Text {
Layout.preferredWidth: rootStackView.width
width: rootStackView.width
wrapMode: Text.WordWrap
color: DefaultStyle.darkGrayColor
font.pointSize: DefaultStyle.defaultTextSize
text: "<p>Some features require a Linphone account, such as group messaging, video conferences...</p>
<p>These features are hidden when you register with a third party SIP account.</p>
<p>To enable it in a commercial projet, please contact us. </p>"
}
Button {
text: "linphone.org/contact"
textSize: 8
inversedColors: true
onClicked: {
Qt.openUrlExternally(ConstantsCpp.ContactUrl)
}
}
}
ColumnLayout {
spacing: 10
Layout.bottomMargin: 20
Button {
Layout.fillWidth: true
inversedColors: true
text: "I prefer creating an account"
onClicked: {
console.debug("[SIPLoginPage] User: click register")
mainItem.goToRegister()
}
}
Button {
Layout.fillWidth: true
text: "I understand"
onClicked: {
rootStackView.replace(secondItem)
}
}
Control.StackView {
id: rootStackView
initialItem: firstItem
Layout.preferredWidth: 280
Layout.fillHeight: true
Layout.alignment: Qt.AlignTop
}
Component {
id: firstItem
ColumnLayout {
ColumnLayout {
Layout.bottomMargin: 60
Text {
Layout.fillWidth: true
Layout.preferredWidth: rootStackView.width
width: rootStackView.width
wrapMode: Text.WordWrap
color: DefaultStyle.darkGrayColor
font.pointSize: DefaultStyle.defaultTextSize
text: "<p>Some features require a Linphone account, such as group messaging, video conferences...</p>
<p>These features are hidden when you register with a third party SIP account.</p>
<p>To enable it in a commercial projet, please contact us. </p>"
}
Button {
text: "linphone.org/contact"
textSize: 8
inversedColors: true
leftPadding: 8
rightPadding: 8
topPadding: 5
bottomPadding: 5
onClicked: {
Qt.openUrlExternally(ConstantsCpp.ContactUrl)
}
}
}
Component {
id: secondItem
ColumnLayout {
spacing: 10
TextInput {
id: username
label: "Username"
mandatory: true
textInputWidth: 250
}
TextInput {
id: password
label: "Password"
mandatory: true
hidden: true
textInputWidth: 250
}
TextInput {
id: domain
label: "Domain"
mandatory: true
textInputWidth: 250
}
TextInput {
id: displayName
label: "Display Name"
textInputWidth: 250
}
ComboBox {
label: "Transport"
backgroundWidth: 250
modelList:[ "TCP", "UDP", "TLS"]
}
Text {
id: errorText
text: "Connection has failed. Please verify your credentials"
color: DefaultStyle.errorMessageColor
opacity: 0
states: [
State{
name: "Visible"
PropertyChanges{target: errorText; opacity: 1.0}
},
State{
name:"Invisible"
PropertyChanges{target: errorText; opacity: 0.0}
}
]
transitions: [
Transition {
from: "Visible"
to: "Invisible"
NumberAnimation {
property: "opacity"
duration: 1000
}
}
]
Timer {
id: autoHideErrorMessage
interval: 2500
onTriggered: errorText.state = "Invisible"
}
Connections {
target: LoginPageCpp
onRegistrationStateChanged: {
if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Failed) {
errorText.state = "Visible"
autoHideErrorMessage.restart()
} else if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Ok) {
mainItem.connectionSucceed()
}
}
}
}
Button {
Layout.topMargin: 20
Layout.bottomMargin: 20
text: "Log in"
onClicked: {
console.debug("[SIPLoginPage] User: Log in")
LoginPageCpp.login(username.inputText, password.inputText);
}
}
Item {
Layout.fillHeight: true
ColumnLayout {
spacing: 10
Layout.bottomMargin: 20
Button {
Layout.fillWidth: true
inversedColors: true
text: "I prefer creating an account"
onClicked: {
console.debug("[SIPLoginPage] User: click register")
mainItem.goToRegister()
}
}
Button {
Layout.fillWidth: true
text: "I understand"
onClicked: {
rootStackView.replace(secondItem)
}
}
}
Item {
Layout.fillHeight: true
}
}
}
Component {
id: secondItem
ColumnLayout {
spacing: 10
TextInput {
id: username
label: "Username"
mandatory: true
textInputWidth: 250
}
TextInput {
id: password
label: "Password"
mandatory: true
hidden: true
textInputWidth: 250
}
TextInput {
id: domain
label: "Domain"
mandatory: true
textInputWidth: 250
}
TextInput {
id: displayName
label: "Display Name"
textInputWidth: 250
}
ComboBox {
label: "Transport"
backgroundWidth: 250
modelList:[ "TCP", "UDP", "TLS"]
}
Text {
id: errorText
text: "Connection has failed. Please verify your credentials"
color: DefaultStyle.errorMessageColor
opacity: 0
states: [
State{
name: "Visible"
PropertyChanges{target: errorText; opacity: 1.0}
},
State{
name:"Invisible"
PropertyChanges{target: errorText; opacity: 0.0}
}
]
transitions: [
Transition {
from: "Visible"
to: "Invisible"
NumberAnimation {
property: "opacity"
duration: 1000
}
}
]
Timer {
id: autoHideErrorMessage
interval: 2500
onTriggered: errorText.state = "Invisible"
}
Connections {
target: LoginPageCpp
onRegistrationStateChanged: {
if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Failed) {
errorText.state = "Visible"
autoHideErrorMessage.restart()
} else if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Ok) {
mainItem.connectionSucceed()
}
}
}
}
Button {
Layout.topMargin: 20
Layout.bottomMargin: 20
text: "Log in"
onClicked: {
console.debug("[SIPLoginPage] User: Log in")
LoginPageCpp.login(username.inputText, password.inputText);
}
}
Item {
Layout.fillHeight: true
}
}
}
Item {
Layout.fillWidth: true
}
@ -228,5 +226,4 @@ LoginLayout {
Layout.fillHeight: true
}
}
}
}