123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- import QtQuick 2.4
- import QtQuick.Controls 2.3
- import QtQuick.Layouts 1.3
- Popup {
- id: popup
- height: 450
- dim: true
- clip: false
- width: 400
- modal: true
- focus: true
- closePolicy: Popup.NoAutoClose
- anchors.centerIn: Overlay.overlay
- signal resetOnClose
- onClosed: {
- resetOnClose()
- }
- Overlay.modal: Rectangle {
- color: "#b5c5c5c5"
- }
- Connections {
- target: _qmlHandler
- onLoginSignupPopupClose: {
- popup.close()
- }
- onLoginSignupPopupOpen: {
- popup.open()
- }
- onLoginSetUsername: {
- loginUsernameInput.text = username
- }
- onLoginSetStatus: {
- loginStatusText.text = status
- }
- onLoginEnableLoginButton: {
- loginLoginButton.enabled = true
- }
- onLoginDisableLoginButton: {
- loginLoginButton.enabled = false
- }
- onLoginSignupCheckSaveCheckbox: {
- loginSetDefaultCheckbox.checked = true
- signupSetDefaultCheckbox.checked = true
- }
- onSignupSetStatus: {
- signupStatusText.text = status
- }
- onSignupEnableRegisterButton: {
- signupRegisterButton.enabled = true
- }
- onSignupDisableRegisterButton: {
- signupRegisterButton.enabled = false
- }
- }
- Page {
- anchors.fill: parent
- header: TabBar {
- id: header
- currentIndex: swipeView.currentIndex
- contentHeight: 50
- TabButton {
- text: qsTr("Login")
- }
- TabButton {
- text: qsTr("Signup")
- }
- }
- SwipeView {
- id: swipeView
- anchors.fill: parent
- currentIndex: header.currentIndex
- clip: true
- // Login
- Page {
- width: 400
- height: 400
- title: ""
- ColumnLayout {
- anchors.fill: parent
- Text {
- Layout.alignment: Qt.AlignCenter
- id: loginTitle
- text: qsTr("Login")
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: 20
- }
- TextField {
- Layout.alignment: Qt.AlignCenter
- id: loginUsernameInput
- selectByMouse: true
- focus: true
- text: qsTr("")
- placeholderText: "Username"
- horizontalAlignment: Text.AlignHCenter
- // @disable-check M222
- Keys.onReturnPressed: loginLoginButton.activate()
- // @disable-check M222
- Keys.onEnterPressed: loginLoginButton.activate()
- onTextEdited: loginLoginButton.enabled
- = (loginUsernameInput.text != ""
- && loginPasswordInput.text != "")
- Connections {
- target: popup
- onResetOnClose: loginUsernameInput.text = ""
- }
- }
- TextField {
- Layout.alignment: Qt.AlignCenter
- id: loginPasswordInput
- selectByMouse: true
- text: qsTr("")
- placeholderText: "Password"
- horizontalAlignment: Text.AlignHCenter
- // @disable-check M222
- Keys.onReturnPressed: loginLoginButton.activate()
- // @disable-check M222
- Keys.onEnterPressed: loginLoginButton.activate()
- echoMode: TextInput.Password
- onTextEdited: loginLoginButton.enabled
- = (loginUsernameInput.text != ""
- && loginPasswordInput.text != "")
- Connections {
- target: popup
- onResetOnClose: loginPasswordInput.text = ""
- }
- }
- CheckBox {
- id: loginSetDefaultCheckbox
- Layout.alignment: Qt.AlignCenter
- checked: false
- text: "Save as default user"
- Connections {
- target: popup
- onResetOnClose: loginSetDefaultCheckbox.checked = false
- }
- }
- Text {
- id: loginStatusText
- color: "#df3f3f"
- text: qsTr("")
- wrapMode: Text.WordWrap
- Layout.preferredWidth: parent.width
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- Layout.alignment: Qt.AlignCenter
- font.pixelSize: 20
- Connections {
- target: popup
- onResetOnClose: loginStatusText.text = ""
- }
- }
- Button {
- Layout.alignment: Qt.AlignCenter
- id: loginLoginButton
- text: qsTr("Login")
- enabled: false
- font.pointSize: 16
- // @disable-check M223
- onClicked: {
- // @disable-check M222
- loginLoginButton.activate()
- }
- // @disable-check M222
- function activate() {
- // @disable-check M223
- if (loginLoginButton.enabled) {
- // @disable-check M222
- _qmlHandler.onLoginLoginButton(
- loginUsernameInput.text,
- loginPasswordInput.text,
- loginSetDefaultCheckbox.checked)
- }
- }
- }
- }
- }
- // Signup
- Page {
- width: 400
- height: 400
- ColumnLayout {
- anchors.fill: parent
- Text {
- Layout.alignment: Qt.AlignCenter
- id: signupTitle
- text: qsTr("Signup")
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: 20
- }
- TextField {
- Layout.alignment: Qt.AlignCenter
- id: signupUsernameInput
- selectByMouse: true
- focus: true
- text: qsTr("")
- placeholderText: "Username"
- horizontalAlignment: Text.AlignHCenter
- // @disable-check M222
- Keys.onReturnPressed: signupRegisterButton.activate()
- // @disable-check M222
- Keys.onEnterPressed: signupRegisterButton.activate()
- onTextEdited: {
- signupStatusText.text = ""
- signupRegisterButton.enabled
- = (signupUsernameInput.text != ""
- && signupPasswordOneInput.text != ""
- && signupPasswordTwoInput.text != "")
- }
- Connections {
- target: popup
- onResetOnClose: signupUsernameInput.text = ""
- }
- }
- TextField {
- Layout.alignment: Qt.AlignCenter
- id: signupPasswordOneInput
- selectByMouse: true
- focus: true
- text: qsTr("")
- placeholderText: "Password"
- horizontalAlignment: Text.AlignHCenter
- // @disable-check M222
- Keys.onReturnPressed: signupRegisterButton.activate()
- // @disable-check M222
- Keys.onEnterPressed: signupRegisterButton.activate()
- echoMode: TextInput.Password
- onTextEdited: {
- signupStatusText.text = ""
- signupRegisterButton.enabled
- = (signupUsernameInput.text != ""
- && signupPasswordOneInput.text != ""
- && signupPasswordTwoInput.text != "")
- }
- Connections {
- target: popup
- onResetOnClose: signupPasswordOneInput.text = ""
- }
- }
- TextField {
- Layout.alignment: Qt.AlignCenter
- id: signupPasswordTwoInput
- selectByMouse: true
- focus: true
- text: qsTr("")
- placeholderText: "Repeat Passw."
- horizontalAlignment: Text.AlignHCenter
- // @disable-check M222
- Keys.onReturnPressed: signupRegisterButton.activate()
- // @disable-check M222
- Keys.onEnterPressed: signupRegisterButton.activate()
- echoMode: TextInput.Password
- onTextEdited: {
- signupStatusText.text = ""
- signupRegisterButton.enabled
- = (signupUsernameInput.text != ""
- && signupPasswordOneInput.text != ""
- && signupPasswordTwoInput.text != "")
- }
- Connections {
- target: popup
- onResetOnClose: signupPasswordTwoInput.text = ""
- }
- }
- CheckBox {
- id: signupSetDefaultCheckbox
- Layout.alignment: Qt.AlignCenter
- checked: false
- text: "Save as default user"
- Connections {
- target: popup
- onResetOnClose: signupSetDefaultCheckbox.checked = false
- }
- }
- Text {
- id: signupStatusText
- color: "#df3f3f"
- text: qsTr("")
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- Layout.alignment: Qt.AlignCenter
- wrapMode: Text.WordWrap
- Layout.preferredWidth: parent.width
- font.pixelSize: 20
- Connections {
- target: popup
- onResetOnClose: signupStatusText.text = ""
- }
- }
- Button {
- Layout.alignment: Qt.AlignCenter
- id: signupRegisterButton
- text: qsTr("Register")
- enabled: false
- font.pointSize: 16
- // @disable-check M223
- onClicked: {
- // @disable-check M222
- signupRegisterButton.activate()
- }
- // @disable-check M222
- function activate() {
- // @disable-check M223
- if (signupRegisterButton.enabled) {
- // @disable-check M222
- _qmlHandler.onSignupRegisterButton(
- signupUsernameInput.text,
- signupPasswordOneInput.text,
- signupPasswordTwoInput.text,
- signupSetDefaultCheckbox.checked)
- }
- }
- }
- }
- }
- }
- }
- Component.onCompleted: {
- swipeView.interactive = false
- }
- }
|