This commit is contained in:
Wayne Chen 2018-10-23 23:10:16 -07:00
parent 3522fe5263
commit eb36abbff6
2 changed files with 142 additions and 178 deletions

View file

@ -12,14 +12,17 @@ import Hifi 1.0
import QtQuick 2.4 import QtQuick 2.4
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import controlsUit 1.0 import controlsUit 1.0 as HifiControlsUit
import stylesUit 1.0 import stylesUit 1.0 as HifiStylesUit
Item { Item {
id: usernameCollisionBody id: usernameCollisionBody
clip: true clip: true
width: root.pane.width width: root.pane.width
height: root.pane.height height: root.pane.height
readonly property string fontFamily: "Cairo"
readonly property int fontSize: 24
readonly property bool fontBold: true
function create() { function create() {
mainTextContainer.visible = false mainTextContainer.visible = false
@ -36,31 +39,74 @@ Item {
QtObject { QtObject {
id: d id: d
readonly property int minWidth: 480 readonly property int minWidth: 480
readonly property int maxWidth: 1280 readonly property int minWidthButton: !root.isTablet ? 256 : 174
property int maxWidth: root.isTablet ? 1280 : Window.innerWidth
readonly property int minHeight: 120 readonly property int minHeight: 120
readonly property int maxHeight: 720 readonly property int minHeightButton: !root.isTablet ? 56 : 42
property int maxHeight: root.isTablet ? 720 : Window.innerHeight
function resize() { function resize() {
var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth) maxWidth = root.isTablet ? 1280 : Window.innerWidth;
maxHeight = root.isTablet ? 720 : Window.innerHeight;
var targetWidth = Math.max(Math.max(titleWidth, mainTextContainer.contentWidth), mainContainer.width)
var targetHeight = mainTextContainer.height + var targetHeight = mainTextContainer.height +
hifi.dimensions.contentSpacing.y + textField.height + hifi.dimensions.contentSpacing.y + textField.height +
hifi.dimensions.contentSpacing.y + buttons.height hifi.dimensions.contentSpacing.y + buttons.height
parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth))
parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) parent.height = root.height = Math.max(Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)), mainContainer.height)
+ (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y) + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y)
} }
} }
ShortcutText { Item {
id: mainContainer
width: root.pane.width
height: root.pane.height
onHeightChanged: d.resize(); onWidthChanged: d.resize();
Rectangle {
id: opaqueRect
height: parent.height
width: parent.width
opacity: 0.9
color: "black"
}
Item {
id: bannerContainer
width: parent.width
height: banner.height
anchors {
top: parent.top
topMargin: 85
}
Image {
id: banner
anchors.centerIn: parent
source: "../../images/high-fidelity-banner.svg"
horizontalAlignment: Image.AlignHCenter
}
}
TextMetrics {
id: mainTextContainerTextMetrics
font: mainTextContainer.font
text: mainTextContainer.text
}
Text {
id: mainTextContainer id: mainTextContainer
anchors { anchors {
top: parent.top top: parent.top
left: parent.left left: parent.left
margins: 0 leftMargin: (parent.width - mainTextContainer.width) / 2
topMargin: hifi.dimensions.contentSpacing.y topMargin: parent.height/2 - buttons.anchors.topMargin - textField.height - mainTextContainerTextMetrics.height
} }
font.family: usernameCollisionBody.fontFamily
font.pixelSize: usernameCollisionBody.fontSize - 10
font.bold: usernameCollisionBody.fontBold
text: qsTr("Your Steam username is not available.") text: qsTr("Your Steam username is not available.")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
color: hifi.colors.redAccent color: hifi.colors.redAccent
@ -70,21 +116,38 @@ Item {
} }
TextField { HifiControlsUit.TextField {
id: textField id: textField
anchors { anchors {
top: mainTextContainer.bottom top: mainTextContainer.bottom
left: parent.left left: parent.left
margins: 0 leftMargin: (parent.width - width) / 2
topMargin: hifi.dimensions.contentSpacing.y topMargin: hifi.dimensions.contentSpacing.y
} }
width: parent.width font.family: usernameCollisionBody.fontFamily
font.pixelSize: usernameCollisionBody.fontSize - 10
font.bold: usernameCollisionBody.fontBold
width: banner.width
placeholderText: "Choose your own" placeholderText: "Choose your own"
Keys.onPressed: {
if (!visible) {
return;
}
switch (event.key) {
case Qt.Key_Enter:
case Qt.Key_Return:
event.accepted = true;
usernameCollisionBody.create();
break;
}
}
} }
// Override ScrollingWindow's keyboard that would be at very bottom of dialog. // Override ScrollingWindow's keyboard that would be at very bottom of dialog.
Keyboard { HifiControlsUit.Keyboard {
raised: keyboardEnabled && keyboardRaised raised: keyboardEnabled && keyboardRaised
numeric: punctuationMode numeric: punctuationMode
anchors { anchors {
@ -94,40 +157,46 @@ Item {
bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0
} }
} }
Row { Row {
id: buttons id: buttons
anchors { anchors {
bottom: parent.bottom top: textField.bottom
right: parent.right topMargin: 5 * hifi.dimensions.contentSpacing.y
horizontalCenter: parent.horizontalCenter
margins: 0 margins: 0
bottomMargin: hifi.dimensions.contentSpacing.y
} }
spacing: hifi.dimensions.contentSpacing.x spacing: hifi.dimensions.contentSpacing.x
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onHeightChanged: d.resize(); onWidthChanged: d.resize();
HifiControlsUit.Button {
Button { id: profileButton
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 200 width: 256
text: qsTr("Create your profile") text: qsTr("Create your profile")
color: hifi.buttons.blue color: hifi.buttons.blue
onClicked: usernameCollisionBody.create() fontFamily: usernameCollisionBody.fontFamily
fontSize: usernameCollisionBody.fontSize
fontBold: usernameCollisionBody.fontBold
onClicked: {
usernameCollisionBody.create()
} }
}
Button { HifiControlsUit.Button {
id: cancelButton
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: qsTr("Cancel") text: qsTr("Cancel")
fontFamily: usernameCollisionBody.fontFamily
onClicked: root.tryDestroy() fontSize: usernameCollisionBody.fontSize
fontBold: usernameCollisionBody.fontBold
onClicked: {
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
}
}
} }
} }
Component.onCompleted: { Component.onCompleted: {
root.title = qsTr("Complete Your Profile")
root.iconText = "<"
//dont rise local keyboard //dont rise local keyboard
keyboardEnabled = !root.isTablet && HMD.active; keyboardEnabled = !root.isTablet && HMD.active;
//but rise Tablet's one instead for Tablet interface //but rise Tablet's one instead for Tablet interface
@ -155,26 +224,11 @@ Item {
onHandleLoginCompleted: { onHandleLoginCompleted: {
console.log("Login Succeeded") console.log("Login Succeeded")
bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : false })
bodyLoader.item.width = root.pane.width
bodyLoader.item.height = root.pane.height
} }
onHandleLoginFailed: { onHandleLoginFailed: {
console.log("Login Failed") console.log("Login Failed")
} }
} }
Keys.onPressed: {
if (!visible) {
return
}
switch (event.key) {
case Qt.Key_Enter:
case Qt.Key_Return:
event.accepted = true
usernameCollisionBody.create()
break
}
}
} }

View file

@ -1,90 +0,0 @@
//
// WelcomeBody.qml
//
// Created by Clement on 7/18/16
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import Hifi 1.0
import QtQuick 2.4
import controlsUit 1.0
import stylesUit 1.0
Item {
id: welcomeBody
clip: true
width: root.pane.width
height: root.pane.height
property bool welcomeBack: false
function setTitle() {
root.title = (welcomeBack ? qsTr("Welcome back <b>") : qsTr("Welcome <b>")) + Account.username + qsTr("</b>!")
root.iconText = ""
d.resize();
}
QtObject {
id: d
readonly property int minWidth: 480
readonly property int maxWidth: 1280
readonly property int minHeight: 120
readonly property int maxHeight: 720
function resize() {
var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth)
var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y + buttons.height
parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth))
parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight))
}
}
InfoItem {
id: mainTextContainer
anchors {
top: parent.top
horizontalCenter: parent.horizontalCenter
margins: 0
topMargin: hifi.dimensions.contentSpacing.y
}
text: qsTr("You are now signed into High Fidelity")
wrapMode: Text.WordWrap
color: hifi.colors.baseGrayHighlight
lineHeight: 2
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
}
Row {
id: buttons
anchors {
top: mainTextContainer.bottom
horizontalCenter: parent.horizontalCenter
margins: 0
topMargin: 2 * hifi.dimensions.contentSpacing.y
}
spacing: hifi.dimensions.contentSpacing.x
onHeightChanged: d.resize(); onWidthChanged: d.resize();
Button {
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Close");
onClicked: root.tryDestroy()
}
}
Component.onCompleted: welcomeBody.setTitle()
Connections {
target: Account
onUsernameChanged: welcomeBody.setTitle()
}
}