updating qml, adding new glyphs font

This commit is contained in:
Wayne Chen 2018-10-23 16:22:42 -07:00
parent d5b7fe62db
commit c28f0fd232
14 changed files with 733 additions and 231 deletions

View file

@ -154,4 +154,5 @@
<glyph glyph-name="40-reload" unicode="&#70;" d="M365 261c-9 1-17-5-18-15-4-45-43-80-89-80-49 0-89 40-89 89 0 19 4 45 25 65 16 15 39 23 68 25l-15-16c-6-6-6-17 0-24 4-3 8-4 12-4 4 0 9 1 12 5l43 44c2 2 3 4 4 6 2 6 1 13-4 18l-44 44c-6 6-17 6-23 0-7-7-7-17 0-24l15-15c-38-2-69-14-91-35-23-21-36-53-36-88 0-68 55-123 123-123 64 0 116 47 122 110 1 9-5 18-15 18"/>
<glyph glyph-name="forward" unicode="&#68;" d="M330 278l-95 70c-5 4-12 5-18 2-5-3-9-9-9-16l0-150c0-7 4-13 10-16 2-1 5-2 7-2 4 0 8 2 11 5l95 79c4 4 6 9 6 14-1 5-3 10-7 14"/>
<glyph glyph-name="avatar-1" unicode="&#84;" d="M396 344l-2 2c-4 4-9 5-15 5-1 0-88-13-124-14-1 0-2 0-3 0-37 0-126 15-127 15-7 1-14-2-18-8l-2-4c-3-4-3-9-2-14 2-5 5-9 10-11 16-7 69-22 85-29 3-1 10-4 10-14 1-11-4-67-10-93-7-26-18-60-19-60-3-9 2-19 11-22l11-4c4-2 9-1 13 1 5 2 8 6 9 10l31 94 28-96c2-5 5-9 9-11 3-1 5-2 8-2 2 0 4 0 7 1l10 4c8 3 12 12 10 20 0 1-8 36-16 65-4 17-6 43-7 64-1 13-1 21-3 30 0 1 2 11 10 14 10 4 81 29 80 28 6 2 10 7 11 13 1 6-1 12-5 16z m-98 54c0-24-19-43-43-43-24 0-43 19-43 43 0 23 19 42 43 42 24 0 43-19 43-42z"/>
<glyph glyph-name="steam-square" unicode="&#57397;" d="M391 327c0 15-5 28-16 39-11 11-24 16-39 16-15 0-28-5-39-16-11-11-16-24-16-39 0-15 5-28 16-39 11-11 24-16 39-16 15 0 28 5 39 16 11 11 16 24 16 39z m-174-168c0-16-5-29-16-40-11-11-25-16-40-16-11 0-21 2-30 8-9 5-16 13-20 22 9-4 19-8 28-12 11-4 22-4 34 1 11 5 19 13 24 25 5 11 5 22 0 34-5 11-13 19-25 24l-23 9c4 1 8 2 12 2 15 0 29-6 40-17 11-11 16-24 16-40z m258 234l0-274c0-23-8-42-24-58-16-16-35-24-58-24l-274 0c-23 0-42 8-58 24-16 16-24 35-24 58l0 44 49-20c4-18 12-32 26-44 14-11 30-17 49-17 19 0 37 7 51 20 15 14 23 30 25 50l99 72c28 0 53 10 73 30 20 20 30 44 30 73 0 28-10 52-30 73-20 20-45 30-73 30-28 0-53-10-73-30-20-20-30-44-30-72l-64-92c-2 0-5 0-8 0-15 0-28-4-40-11l-84 34 0 134c0 23 8 42 24 58 16 16 35 24 58 24l274 0c23 0 42-8 58-24 16-16 24-35 24-58z m-70-66c0-19-7-36-20-49-14-14-30-20-49-20-19 0-36 6-49 20-13 13-20 30-20 49 0 19 7 35 20 48 13 14 30 21 49 21 19 0 35-7 49-20 13-14 20-30 20-49z"/>
</font></defs></svg>

Before

(image error) Size: 83 KiB

After

(image error) Size: 84 KiB

View file

@ -603,6 +603,10 @@
<div class="icon icon-avatar-1"></div>
<input type="text" readonly="readonly" value="avatar-1">
</li>
<li>
<div class="icon icon-steam-square"></div>
<input type="text" readonly="readonly" value="steam-square">
</li>
</ul>
<h2>Character mapping</h2>
<ul class="glyphs character-mapping">
@ -1194,6 +1198,10 @@
<div data-icon="T" class="icon"></div>
<input type="text" readonly="readonly" value="T">
</li>
<li>
<div data-icon="&#xe035;" class="icon"></div>
<input type="text" readonly="readonly" value="&amp;#xe035;">
</li>
</ul>
</div>
<script>(function() {

View file

@ -479,3 +479,6 @@
.icon-avatar-1:before {
content: "\54";
}
.icon-steam-square:before {
content: "\e035";
}

View file

Before

(image error) Size: 1.7 KiB

After

(image error) Size: 1.7 KiB

View file

@ -86,7 +86,7 @@ Windows.ModalWindow {
}
Component.onCompleted: {
bodyLoader.setSource("LoginDialog/LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root });
bodyLoader.setSource("LoginDialog/LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
}
}

View file

@ -1,8 +1,8 @@
//
// LinkAccountBody.qml
//
// Created by Clement on 7/18/16
// Copyright 2015 High Fidelity, Inc.
// Created by Wayne Chen on 10/18/18
// Copyright 2018 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
@ -23,9 +23,9 @@ Item {
clip: true
height: root.pane.height
width: root.pane.width
property bool isTablet: root.isTablet
property bool failAfterSignUp: false
property string fontFamily: "Cairo"
property int fontSize: 24
property bool fontBold: true
property bool keyboardEnabled: false
@ -33,6 +33,7 @@ Item {
property bool punctuationMode: false
property bool isLogIn: false
property bool atSignIn: false
property bool withSteam: false
onKeyboardRaisedChanged: d.resize();
@ -54,7 +55,7 @@ Item {
4 * hifi.dimensions.contentSpacing.y;
var newWidth = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth));
if(!isNaN(newWidth)) {
if (!isNaN(newWidth)) {
parent.width = root.width = newWidth;
}
@ -63,27 +64,84 @@ Item {
}
}
// timer to kill the dialog upon login success
Timer {
id: successTimer
interval: 500;
running: false;
repeat: false;
onTriggered: {
root.tryDestroy();
}
}
// timer to kill the dialog upon login failure
Timer {
id: failureTimer
interval: 1000;
running: false;
repeat: false;
onTriggered: {
resetContainers();
loginContainer.visible = true;
}
}
function login() {
linkAccountBody.toggleLoading();
if (linkAccountBody.isLogIn) {
loginDialog.login(emailField.text, passwordField.text);
} else {
loginDialog.signup(emailField.text, usernameField.text, passwordField.text);
loginDialog.signup(usernameField.text, emailField.text, passwordField.text);
}
linkAccountBody.toggleLoggingIn(false);
}
function resetContainers() {
splashContainer.visible = false;
loggingInContainer.visible = false;
loginContainer.visible = false;
}
function toggleLoggingIn(loggedIn) {
function toggleLoading() {
// For the process of logging in.
linkAccountBody.resetContainers();
loggingInContainer.visible = true;
if (linkAccountBody.withSteam) {
loginContainer.visible = false;
loggingInGlyph.visible = true;
loggingInText.text = "Logging in to Steam";
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
} else {
loggingInText.text = "Logging in";
loggingInText.anchors.bottom = loggingInHeader.bottom;
loggingInText.anchors.bottomMargin = hifi.dimensions.contentSpacing.y;
}
else {
linkAccountSpinner.visible = true;
}
function loadingSuccess(success, errorString) {
linkAccountSpinner.visible = false;
if (!success) {
loginErrorMessage.visible = true;
loginErrorMessage.text = errorString !== "" ? errorString : linkAccountBody.isLogIn ? "bad user/pass combo." : "unknown error.";
loginErrorMessage.anchors.bottom = linkAccountBody.isLogIn ? emailField.top : usernameField.top;
failureTimer.start();
return;
}
if (linkAccountBody.withSteam) {
// reset the flag.
linkAccountBody.withSteam = false;
loggingInGlyph.visible = false;
loggingInText.text = "You are now logged into Steam!"
loggingInText.anchors.centerIn = loggingInHeader;
loggingInText.anchors.bottom = loggingInHeader.bottom;
loggedInGlyph.visible = true;
} else {
loggingInText.text = "You are now logged in!";
}
successTimer.start();
}
function toggleSignIn(signIn, isLogIn) {
// going to/from sign in/up dialog.
linkAccountBody.atSignIn = signIn;
linkAccountBody.isLogIn = isLogIn;
if (signIn) {
usernameField.visible = !isLogIn;
@ -92,6 +150,8 @@ Item {
loginButtonAtSignIn.text = "Log In";
loginButtonAtSignIn.color = hifi.buttons.black;
emailField.placeholderText = "Username or Email";
var savedUsername = Settings.getValue("wallet/savedUsername", "");
emailField.text = savedUsername === "Unknown user" ? "" : savedUsername;
emailField.anchors.top = loginContainer.top;
emailField.anchors.topMargin = !root.isTablet ? 0.2 * root.pane.height : 0.24 * root.pane.height;
cantAccessContainer.anchors.topMargin = !root.isTablet ? 3.5 * hifi.dimensions.contentSpacing.y : hifi.dimensions.contentSpacing.y;
@ -99,9 +159,12 @@ Item {
loginButtonAtSignIn.text = "Sign Up";
loginButtonAtSignIn.color = hifi.buttons.blue;
emailField.placeholderText = "Email";
emailField.text = "";
emailField.anchors.top = usernameField.bottom;
emailField.anchors.topMargin = 1.5 * hifi.dimensions.contentSpacing.y;
passwordField.text = "";
}
loginErrorMessage.visible = false;
}
splashContainer.visible = !signIn;
@ -113,15 +176,6 @@ Item {
}
function toggleLoading(isLoading) {
linkAccountSpinner.visible = isLoading
form.visible = !isLoading
if (loginDialog.isSteamRunning()) {
additionalInformation.visible = !isLoading
}
}
Item {
id: topContainer
width: root.pane.width
@ -152,6 +206,105 @@ Item {
horizontalAlignment: Image.AlignHCenter
}
}
Item {
id: loggingInContainer
width: parent.width
height: parent.height
onHeightChanged: d.resize(); onWidthChanged: d.resize();
visible: false
Item {
id: loggingInHeader
width: parent.width
height: 0.5 * parent.height
anchors {
top: parent.top
}
TextMetrics {
id: loggingInGlyphTextMetrics;
font: loggingInGlyph.font;
text: loggingInGlyph.text;
}
HifiStylesUit.HiFiGlyphs {
id: loggingInGlyph;
text: hifi.glyphs.steamSquare;
// Color
color: "white";
// Size
size: 31;
// Anchors
anchors.right: loggingInText.left;
anchors.rightMargin: linkAccountBody.loggingInGlyphRightMargin
anchors.bottom: parent.bottom;
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: loginDialog.isSteamRunning();
}
TextMetrics {
id: loggingInTextMetrics;
font: loggingInText.font;
text: loggingInText.text;
}
Text {
id: loggingInText;
width: loggingInTextMetrics.width
anchors.bottom: parent.bottom;
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggingInTextMetrics.width) / 2
color: "white";
font.family: linkAccountBody.fontFamily
font.pixelSize: linkAccountBody.fontSize
font.bold: linkAccountBody.fontBold
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: "Logging in"
}
}
Item {
id: loggingInFooter
width: parent.width
height: 0.5 * parent.height
anchors {
top: loggingInHeader.bottom
}
AnimatedImage {
id: linkAccountSpinner
source: "../../icons/loader-snake-64-w.gif"
width: 128
height: width
anchors.left: parent.left;
anchors.leftMargin: (parent.width - width) / 2;
anchors.top: parent.top
anchors.topMargin: hifi.dimensions.contentSpacing.y
}
TextMetrics {
id: loggedInGlyphTextMetrics;
font: loggedInGlyph.font;
text: loggedInGlyph.text;
}
HifiStylesUit.HiFiGlyphs {
id: loggedInGlyph;
text: hifi.glyphs.steamSquare;
// Size
size: 78;
// Anchors
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggedInGlyph.size) / 2;
anchors.top: parent.top
anchors.topMargin: hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: loginDialog.isSteamRunning();
}
}
}
Item {
id: loginContainer
width: parent.width
@ -162,6 +315,20 @@ Item {
}
visible: false
Text {
id: loginErrorMessage;
anchors.bottom: emailField.top;
anchors.bottomMargin: 2
anchors.left: emailField.left;
color: "red";
font.family: linkAccountBody.fontFamily
font.pixelSize: 12
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: ""
visible: false
}
HifiControlsUit.TextField {
id: usernameField
width: banner.width
@ -190,11 +357,6 @@ Item {
placeholderText: "Username or Email"
activeFocusOnPress: true
onHeightChanged: d.resize(); onWidthChanged: d.resize();
Component.onCompleted: {
var savedUsername = Settings.getValue("wallet/savedUsername", "");
emailField.text = savedUsername === "Unknown user" ? "" : savedUsername;
}
}
HifiControlsUit.TextField {
id: passwordField
@ -296,7 +458,7 @@ Item {
lineHeight: 1
color: "white"
font.family: linkAccountBody.fontFamily
font.pixelSize: 24
font.pixelSize: linkAccountBody.fontSize
font.capitalization: Font.AllUppercase;
font.bold: linkAccountBody.fontBold
lineHeightMode: Text.ProportionalHeight
@ -307,6 +469,7 @@ Item {
acceptedButtons: Qt.LeftButton
onClicked: {
toggleSignIn(false, true);
linkAccountBody.isLogIn = false;
}
}
}
@ -316,7 +479,7 @@ Item {
height: d.minHeightButton
text: qsTr("Log In")
fontFamily: linkAccountBody.fontFamily
fontSize: signUpButton.fontSize
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
anchors {
top: cancelContainer.top
@ -370,10 +533,10 @@ Item {
topMargin: 0.1 * parent.height
}
wrapMode: Text.WordWrap
lineHeight: 1
lineHeight: 0.5
color: "white"
font.family: linkAccountBody.fontFamily
font.pixelSize: 48
font.pixelSize: 2 * linkAccountBody.fontSize
font.bold: linkAccountBody.fontBold
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
@ -386,15 +549,14 @@ Item {
height: d.minHeightButton
color: hifi.buttons.blue
fontFamily: linkAccountBody.fontFamily
fontSize: 24
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
anchors {
bottom: parent.bottom
bottomMargin: 0.1 * parent.height
left: parent.left
leftMargin: (parent.width - signUpButton.width) / 2
leftMargin: (parent.width - d.minWidthButton) / 2
}
onClicked: {
toggleSignIn(true, false);
}
@ -423,11 +585,11 @@ Item {
HifiControlsUit.Button {
id: loginButton
width: signUpButton.width
height: signUpButton.height
width: d.minWidthButton
height: d.minHeightButton
text: qsTr("Log In")
fontFamily: linkAccountBody.fontFamily
fontSize: signUpButton.fontSize
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
anchors {
top: parent.top
@ -440,104 +602,29 @@ Item {
toggleSignIn(true, true);
}
}
Button {
HifiControlsUit.Button {
id: steamLoginButton;
width: signUpButton.width
height: signUpButton.height
property int color: hifi.buttons.black;
property int colorScheme: hifi.colorSchemes.light;
width: d.minWidthButton
height: d.minHeightButton
color: hifi.buttons.black;
anchors {
top: loginButton.bottom
topMargin: hifi.dimensions.contentSpacing.y
left: parent.left
leftMargin: (parent.width - steamLoginButton.width) / 2
}
onHoveredChanged: {
if (hovered) {
Tablet.playSound(TabletEnums.ButtonHover);
}
}
onFocusChanged: {
if (focus) {
Tablet.playSound(TabletEnums.ButtonHover);
}
}
text: qsTr("Steam Log In")
fontFamily: linkAccountBody.fontFamily
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
buttonGlyph: hifi.glyphs.steamSquare
buttonGlyphRightMargin: 10
onClicked: {
Tablet.playSound(TabletEnums.ButtonClick);
}
style: OriginalStyles.ButtonStyle {
background: Rectangle {
radius: 4;
gradient: Gradient {
GradientStop {
position: 0.2
color: {
if (!control.enabled) {
hifi.buttons.disabledColorStart[control.colorScheme]
} else if (control.pressed) {
hifi.buttons.pressedColor[control.color]
} else if (control.hovered) {
hifi.buttons.hoveredColor[control.color]
} else {
hifi.buttons.colorStart[control.color]
}
}
}
GradientStop {
position: 1.0
color: {
if (!control.enabled) {
hifi.buttons.disabledColorFinish[control.colorScheme]
} else if (control.pressed) {
hifi.buttons.pressedColor[control.color]
} else if (control.hovered) {
hifi.buttons.hoveredColor[control.color]
} else {
hifi.buttons.colorFinish[control.color]
}
}
}
}
}
label: Item {
Image {
id: steamIcon;
anchors.right: steamIconLabel.left;
anchors.rightMargin: 5;
anchors.verticalCenter: parent.verticalCenter;
source: "../../images/steam.svg";
horizontalAlignment: Image.AlignHCenter;
sourceSize.width: signUpButton.fontSize + 3
sourceSize.height: signUpButton.fontSize + 3
}
TextMetrics {
id: steamIconLabelTextMetrics;
font: steamIconLabel.font;
text: steamIconLabel.text;
}
Text {
id: steamIconLabel;
text: "Steam Log In"
anchors.verticalCenter: parent.verticalCenter;
width: steamIconLabelTextMetrics.width;
x: parent.width/2 - steamIconLabelTextMetrics.width/2 + steamIcon.width/2;
font.capitalization: Font.AllUppercase;
verticalAlignment: Text.AlignVCenter;
horizontalAlignment: Text.AlignHCenter;
font.family: linkAccountBody.fontFamily
font.pixelSize: signUpButton.fontSize;
font.bold: linkAccountBody.fontBold
color: enabled ? hifi.buttons.textColor[control.color]
: hifi.buttons.disabledTextColor[control.colorScheme]
}
}
linkAccountBody.withSteam = true;
linkAccountBody.toggleLoading();
loginDialog.linkSteam();
}
visible: loginDialog.isSteamRunning();
}
}
Item {
@ -556,7 +643,7 @@ Item {
lineHeight: 1
color: "white"
font.family: linkAccountBody.fontFamily
font.pixelSize: 24
font.pixelSize: linkAccountBody.fontSize
font.bold: linkAccountBody.fontBold
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
@ -581,11 +668,24 @@ Item {
root.keyboardRaised = Qt.binding( function() { return keyboardRaised; })
}
d.resize();
}
Connections {
target: loginDialog
onHandleCreateFailed: {
console.log("Create Failed")
}
onHandleCreateCompleted: {
console.log("Create Completed")
}
onHandleSignupFailed: {
console.log("Sign Up Failed")
loadingSuccess(false, errorString)
}
onHandleSignupCompleted: {
console.log("Sign Up Completed")
loadingSuccess(true)
}
onHandleLoginCompleted: {
console.log("Login Succeeded")
var poppedUp = Settings.getValue("loginDialogPoppedUp", false);
@ -598,10 +698,9 @@ Item {
Settings.setValue("loginDialogPoppedUp", false);
}
if (loginDialog.isSteamRunning()) {
loginDialog.linkSteam()
} else {
// TODO you are now logged in
loginDialog.linkSteam();
}
loadingSuccess(true)
}
onHandleLoginFailed: {
console.log("Login Failed")
@ -614,22 +713,21 @@ Item {
UserActivityLogger.logAction("encourageLoginDialog", data);
Settings.setValue("loginDialogPoppedUp", false);
}
toggleLoading(false)
loadingSuccess(false)
}
onHandleLinkCompleted: {
console.log("Link Succeeded")
bodyLoader.item.width = root.pane.width
bodyLoader.item.height = root.pane.height
loadingSuccess(true)
}
onHandleLinkFailed: {
console.log("Link Failed")
toggleLoading(false)
var error = "There was an unknown error while creating your account. Please try again later.";
loadingSuccess(false, error);
}
}
Keys.onPressed: {
if (!visible) {
if (!visible && !atSignIn) {
return;
}

View file

@ -1,8 +1,8 @@
//
// SignInBody.qml
//
// Created by Clement on 7/18/16
// Copyright 2015 High Fidelity, Inc.
// Created by Wayne Chen on 10/18/18
// Copyright 2018 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
@ -10,70 +10,188 @@
import Hifi 1.0
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4 as OriginalStyles
import controlsUit 1.0 as HifiControlsUit
import stylesUit 1.0 as HifiStylesUit
import TabletScriptingInterface 1.0
Item {
id: signInBody
clip: true
height: root.pane.height
width: root.pane.width
property bool failAfterSignUp: false
property string fontFamily: "Cairo"
property int fontSize: 24
property bool fontBold: true
property bool required: false
property bool keyboardEnabled: false
property bool keyboardRaised: false
property bool punctuationMode: false
function login() {
bodyLoader.setSource("LoggingInBody.qml");
if (!root.isTablet) {
bodyLoader.item.width = root.pane.width;
bodyLoader.item.height = root.pane.height;
}
loginDialog.login(usernameField.text, passwordField.text);
}
property bool logIn: isLogIn
property bool signIn: atSignIn
property bool withSteam: loginDialog.isSteamRunning()
function cancel() {
bodyLoader.setSource("LinkAccountBody.qml");
if (!root.isTablet) {
bodyLoader.item.width = root.pane.width;
bodyLoader.item.height = root.pane.height;
}
}
onKeyboardRaisedChanged: d.resize();
QtObject {
id: d
readonly property int minWidth: 480
readonly property int minWidthButton: !root.isTablet ? 256 : 174
property int maxWidth: root.isTablet ? 1280 : Window.innerWidth
readonly property int minHeight: 120
readonly property int minHeightButton: !root.isTablet ? 56 : 42
property int maxHeight: root.isTablet ? 720 : Window.innerHeight
function resize() {
maxWidth = root.isTablet ? 1280 : Window.innerWidth;
maxHeight = root.isTablet ? 720 : Window.innerHeight;
var targetWidth = Math.max(titleWidth, form.contentWidth)
var targetHeight = 4 * hifi.dimensions.contentSpacing.y + form.height
var targetWidth = Math.max(titleWidth, topContainer.width);
var targetHeight = hifi.dimensions.contentSpacing.y + topContainer.height +
4 * hifi.dimensions.contentSpacing.y;
var newWidth = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth));
if (!isNaN(newWidth)) {
parent.width = root.width = newWidth;
}
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))
+ (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y);
}
}
// timer to kill the dialog upon login success
Timer {
id: successTimer
interval: 500;
running: false;
repeat: false;
onTriggered: {
root.tryDestroy();
}
}
// timer to kill the dialog upon login failure
Timer {
id: failureTimer
interval: 1000;
running: false;
repeat: false;
onTriggered: {
resetContainers();
loginContainer.visible = true;
}
}
function login() {
signInBody.toggleLoading();
if (signInBody.isLogIn) {
loginDialog.login(emailField.text, passwordField.text);
} else {
loginDialog.signup(usernameField.text, emailField.text, passwordField.text);
}
}
function resetContainers() {
loggingInContainer.visible = false;
loginContainer.visible = false;
}
function toggleLoading() {
// For the process of logging in.
signInBody.resetContainers();
loggingInContainer.visible = true;
if (signInBody.withSteam) {
loggingInGlyph.visible = true;
loggingInText.text = "Logging in to Steam";
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
} else {
loggingInText.text = "Logging in";
loggingInText.anchors.bottom = loggingInHeader.bottom;
loggingInText.anchors.bottomMargin = hifi.dimensions.contentSpacing.y;
}
linkAccountSpinner.visible = true;
}
function loadingSuccess(success, errorString) {
linkAccountSpinner.visible = false;
if (!success) {
loginErrorMessage.visible = true;
loginErrorMessage.text = errorString !== "" ? errorString : signInBody.isLogIn ? "bad user/pass combo." : "unknown error.";
loginErrorMessage.anchors.bottom = signInBody.isLogIn ? emailField.top : usernameField.top;
failureTimer.start();
return;
}
if (signInBody.withSteam) {
// reset the flag.
signInBody.withSteam = false;
loggingInGlyph.visible = false;
loggingInText.text = "You are now logged into Steam!"
loggingInText.anchors.centerIn = loggingInHeader;
loggingInText.anchors.bottom = loggingInHeader.bottom;
loggedInGlyph.visible = true;
} else {
loggingInText.text = "You are now logged in!";
}
successTimer.start();
}
function toggleSignIn(signIn, isLogIn) {
// going to/from sign in/up dialog.
// signInBody.atSignIn = signIn;
// signInBody.isLogIn = isLogIn;
if (signIn) {
usernameField.visible = !isLogIn;
cantAccessContainer.visible = isLogIn;
if (isLogIn) {
loginButtonAtSignIn.text = "Log In";
loginButtonAtSignIn.color = hifi.buttons.black;
emailField.placeholderText = "Username or Email";
var savedUsername = Settings.getValue("wallet/savedUsername", "");
emailField.text = savedUsername === "Unknown user" ? "" : savedUsername;
emailField.anchors.top = loginContainer.top;
emailField.anchors.topMargin = !root.isTablet ? 0.2 * root.pane.height : 0.24 * root.pane.height;
cantAccessContainer.anchors.topMargin = !root.isTablet ? 3.5 * hifi.dimensions.contentSpacing.y : hifi.dimensions.contentSpacing.y;
} else {
loginButtonAtSignIn.text = "Sign Up";
loginButtonAtSignIn.color = hifi.buttons.blue;
emailField.placeholderText = "Email";
emailField.text = "";
emailField.anchors.top = usernameField.bottom;
emailField.anchors.topMargin = 1.5 * hifi.dimensions.contentSpacing.y;
passwordField.text = "";
}
loginErrorMessage.visible = false;
}
loginContainer.visible = signIn;
}
Item {
width: parent.width
height: parent.height
id: topContainer
width: root.pane.width
height: root.pane.height
onHeightChanged: d.resize(); onWidthChanged: d.resize();
Rectangle {
width: parent.width
id: topOpaqueRect
height: parent.height
opacity: 0.7
width: parent.width
opacity: 0.9
color: "black"
}
Item {
id: bannerContainer
width: parent.width
height: banner.height
anchors {
top: parent.top
topMargin: 0.17 * parent.height
topMargin: 85
}
Image {
id: banner
@ -82,48 +200,177 @@ Item {
horizontalAlignment: Image.AlignHCenter
}
}
Column {
id: form
width: parent.width
onHeightChanged: d.resize(); onWidthChanged: d.resize();
Item {
id: loggingInContainer
width: parent.width
height: parent.height
onHeightChanged: d.resize(); onWidthChanged: d.resize();
visible: false
Item {
id: loggingInHeader
width: parent.width
height: 0.5 * parent.height
anchors {
top: parent.top
}
TextMetrics {
id: loggingInGlyphTextMetrics;
font: loggingInGlyph.font;
text: loggingInGlyph.text;
}
HifiStylesUit.HiFiGlyphs {
id: loggingInGlyph;
text: hifi.glyphs.steamSquare;
// Color
color: "white";
// Size
size: 31;
// Anchors
anchors.right: loggingInText.left;
anchors.rightMargin: signInBody.loggingInGlyphRightMargin
anchors.bottom: parent.bottom;
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: loginDialog.isSteamRunning();
}
TextMetrics {
id: loggingInTextMetrics;
font: loggingInText.font;
text: loggingInText.text;
}
Text {
id: loggingInText;
width: loggingInTextMetrics.width
anchors.bottom: parent.bottom;
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggingInTextMetrics.width) / 2
color: "white";
font.family: signInBody.fontFamily
font.pixelSize: signInBody.fontSize
font.bold: signInBody.fontBold
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: "Logging in"
}
}
Item {
id: loggingInFooter
width: parent.width
height: 0.5 * parent.height
anchors {
top: loggingInHeader.bottom
}
AnimatedImage {
id: linkAccountSpinner
source: "../../icons/loader-snake-64-w.gif"
width: 128
height: width
anchors.left: parent.left;
anchors.leftMargin: (parent.width - width) / 2;
anchors.top: parent.top
anchors.topMargin: hifi.dimensions.contentSpacing.y
}
TextMetrics {
id: loggedInGlyphTextMetrics;
font: loggedInGlyph.font;
text: loggedInGlyph.text;
}
HifiStylesUit.HiFiGlyphs {
id: loggedInGlyph;
text: hifi.glyphs.steamSquare;
// Size
size: 78;
// Anchors
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggedInGlyph.size) / 2;
anchors.top: parent.top
anchors.topMargin: hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: loginDialog.isSteamRunning();
}
}
}
Item {
id: loginContainer
width: parent.width
height: parent.height - (bannerContainer.height + 1.5 * hifi.dimensions.contentSpacing.y)
anchors {
top: bannerContainer.bottom
topMargin: 1.5 * hifi.dimensions.contentSpacing.y
}
spacing: 2 * hifi.dimensions.contentSpacing.y
visible: true
Text {
id: loginErrorMessage;
anchors.bottom: emailField.top;
anchors.bottomMargin: 2
anchors.left: emailField.left;
color: "red";
font.family: signInBody.fontFamily
font.pixelSize: 12
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: ""
visible: false
}
HifiControlsUit.TextField {
id: usernameField
width: 0.254 * parent.width
width: banner.width
font.family: signInBody.fontFamily
placeholderText: "Username"
anchors {
top: parent.top
topMargin: 0.2 * parent.height
left: parent.left
leftMargin: (parent.width - usernameField.width) / 2
}
visible: false
}
HifiControlsUit.TextField {
id: emailField
width: banner.width
font.family: signInBody.fontFamily
text: Settings.getValue("wallet/savedUsername", "");
anchors {
top: parent.top
left: parent.left
leftMargin: (parent.width - emailField.width) / 2
}
focus: true
placeholderText: "Username or Email"
activeFocusOnPress: true
onHeightChanged: d.resize(); onWidthChanged: d.resize();
onFocusChanged: {
root.text = "";
}
Component.onCompleted: {
var savedUsername = Settings.getValue("wallet/savedUsername", "");
usernameField.text = savedUsername === "Unknown user" ? "" : savedUsername;
}
}
HifiControlsUit.TextField {
id: passwordField
width: 0.254 * parent.width
width: banner.width
font.family: signInBody.fontFamily
placeholderText: "Password"
activeFocusOnPress: true
echoMode: passwordFieldMouseArea.showPassword ? TextInput.Normal : TextInput.Password
onHeightChanged: d.resize(); onWidthChanged: d.resize();
anchors {
top: emailField.bottom
topMargin: 1.5 * hifi.dimensions.contentSpacing.y
left: parent.left
leftMargin: (parent.width - emailField.width) / 2
}
onFocusChanged: {
root.text = "";
root.isPassword = true;
}
Rectangle {
Item {
id: showPasswordHitbox
z: 10
x: passwordField.width - ((passwordField.height) * 31 / 23)
@ -132,7 +379,6 @@ Item {
anchors {
right: parent.right
}
color: "transparent"
Image {
id: showPasswordImage
@ -157,71 +403,194 @@ Item {
}
}
}
}
Keys.onReturnPressed: {
signInBody.login()
}
}
HifiControlsUit.CheckBox {
id: autoLogoutCheckbox
checked: !Settings.getValue("wallet/autoLogout", false);
text: qsTr("Keep Me Logged In")
boxSize: 18;
labelFontFamily: signInBody.fontFamily
labelFontSize: 18;
color: hifi.colors.white;
anchors {
top: passwordField.bottom;
topMargin: hifi.dimensions.contentSpacing.y;
right: passwordField.right;
}
onCheckedChanged: {
Settings.setValue("wallet/autoLogout", !checked);
if (checked) {
Settings.setValue("wallet/savedUsername", Account.username);
} else {
Settings.setValue("wallet/savedUsername", "");
}
}
Component.onDestruction: {
Settings.setValue("wallet/autoLogout", !checked);
}
}
Item {
id: cancelContainer
width: cancelText.width
height: d.minHeightButton
anchors {
top: autoLogoutCheckbox.bottom
topMargin: hifi.dimensions.contentSpacing.y
left: parent.left
leftMargin: (parent.width - passwordField.width) / 2
}
Text {
id: cancelText
anchors.centerIn: parent
text: qsTr("Cancel");
lineHeight: 1
color: "white"
font.family: signInBody.fontFamily
font.pixelSize: signInBody.fontSize
font.capitalization: Font.AllUppercase;
font.bold: signInBody.fontBold
lineHeightMode: Text.ProportionalHeight
}
MouseArea {
id: cancelArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
bodyLoader.setSource("LinkAccountBody0.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
}
}
}
HifiControlsUit.Button {
id: loginButtonAtSignIn
width: d.minWidthButton
height: d.minHeightButton
text: qsTr("Log In")
fontFamily: signInBody.fontFamily
fontSize: signInBody.fontSize
fontBold: signInBody.fontBold
anchors {
top: cancelContainer.top
right: passwordField.right
}
Keys.onReturnPressed: signInBody.login()
onClicked: {
signInBody.login()
}
}
Item {
id: cantAccessContainer
width: parent.width
y: usernameField.height
anchors {
top: cancelContainer.bottom
topMargin: 3.5 * hifi.dimensions.contentSpacing.y
}
visible: false
HifiStylesUit.ShortcutText {
id: cantAccessText
z: 10
anchors.centerIn: parent
font.family: signInBody.fontFamily
font.pixelSize: 14
text: "<a href='https://highfidelity.com/users/password/new'> Can't access your account?</a>"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
linkColor: hifi.colors.blueAccent
onLinkActivated: loginDialog.openUrl(link)
}
}
}
}
// 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
//
// width: undefined // invalidate so that the image's size sets the width
// height: undefined // invalidate so that the image's size sets the height
// focus: true
//
// background: Image {
// id: buttonImage
// source: "../../images/steam-sign-in.png"
// }
// onClicked: signInBody.login()
// }
// Button {
// anchors.verticalCenter: parent.verticalCenter
//
// text: qsTr("Cancel");
//
// onClicked: signInBody.cancel()
// }
// }
// Component.onCompleted: {
// root.title = required ? qsTr("Sign In Required")
// : qsTr("Sign In")
// root.iconText = ""
// d.resize();
// }
Component.onCompleted: {
//dont rise local keyboard
keyboardEnabled = !root.isTablet && HMD.active;
//but rise Tablet's one instead for Tablet interface
if (root.isTablet) {
root.keyboardEnabled = HMD.active;
root.keyboardRaised = Qt.binding( function() { return keyboardRaised; })
}
d.resize();
print(signIn, logIn)
toggleSignIn(signIn, logIn)
}
Connections {
target: loginDialog
onHandleCreateFailed: {
console.log("Create Failed")
}
onHandleCreateCompleted: {
console.log("Create Completed")
}
onHandleSignupFailed: {
console.log("Sign Up Failed")
loadingSuccess(false, errorString)
}
onHandleSignupCompleted: {
console.log("Sign Up Completed")
loadingSuccess(true)
}
onHandleLoginCompleted: {
console.log("Login Succeeded")
bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true })
bodyLoader.item.width = root.pane.width
bodyLoader.item.height = root.pane.height
var poppedUp = Settings.getValue("loginDialogPoppedUp", false);
if (poppedUp) {
console.log("[ENCOURAGELOGINDIALOG]: logging in")
var data = {
"action": "user logged in"
};
UserActivityLogger.logAction("encourageLoginDialog", data);
Settings.setValue("loginDialogPoppedUp", false);
}
if (loginDialog.isSteamRunning()) {
loginDialog.linkSteam();
}
loadingSuccess(true)
}
onHandleLoginFailed: {
console.log("Login Failed")
bodyLoader.source = "CompleteProfileBody.qml"
if (!root.isTablet) {
bodyLoader.item.width = root.pane.width
bodyLoader.item.height = root.pane.height
var poppedUp = Settings.getValue("loginDialogPoppedUp", false);
if (poppedUp) {
console.log("[ENCOURAGELOGINDIALOG]: failed logging in")
var data = {
"action": "user failed logging in"
};
UserActivityLogger.logAction("encourageLoginDialog", data);
Settings.setValue("loginDialogPoppedUp", false);
}
loadingSuccess(false)
}
onHandleLinkCompleted: {
console.log("Link Succeeded")
loadingSuccess(true)
}
onHandleLinkFailed: {
console.log("Link Failed")
var error = "There was an unknown error while creating your account. Please try again later.";
loadingSuccess(false, error);
}
}
Keys.onPressed: {
if (!visible && !atSignIn) {
return;
}
switch (event.key) {
case Qt.Key_Enter:
case Qt.Key_Return:
event.accepted = true
signInBody.login()
break
}
}
}

View file

@ -25,6 +25,7 @@ Original.Button {
property int radius: hifi.buttons.radius
property alias implicitTextWidth: buttonText.implicitWidth
property string buttonGlyph: "";
property int buttonGlyphRightMargin: 0;
property int fontCapitalization: Font.AllUppercase
width: hifi.dimensions.buttonWidth
@ -91,6 +92,12 @@ Original.Button {
}
contentItem: Item {
id: buttonContentItem
TextMetrics {
id: buttonGlyphTextMetrics;
font: buttonGlyph.font;
text: buttonGlyph.text;
}
HiFiGlyphs {
id: buttonGlyph;
visible: control.buttonGlyph !== "";
@ -99,6 +106,7 @@ Original.Button {
size: 34;
// Anchors
anchors.right: buttonText.left;
anchors.rightMargin: control.buttonGlyphRightMargin
anchors.top: parent.top;
anchors.bottom: parent.bottom;
// Style
@ -108,9 +116,16 @@ Original.Button {
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
}
TextMetrics {
id: buttonTextMetrics;
font: buttonText.font;
text: buttonText.text;
}
Text {
id: buttonText;
anchors.centerIn: parent;
width: buttonTextMetrics.width
anchors.verticalCenter: parent.verticalCenter;
font.capitalization: control.fontCapitalization
color: enabled ? hifi.buttons.textColor[control.color]
: hifi.buttons.disabledTextColor[control.colorScheme]
@ -120,6 +135,13 @@ Original.Button {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: control.text
Component.onCompleted: {
if (control.buttonGlyph !== "") {
buttonText.x = buttonContentItem.width/2 - buttonTextMetrics.width/2 + buttonGlyphTextMetrics.width/2;
} else {
buttonText.anchors.centerIn = parent;
}
}
}
}
}

View file

@ -349,5 +349,6 @@ QtObject {
readonly property string update: "\ue032"
readonly property string uninstall: "\ue033"
readonly property string verticalEllipsis: "\ue034"
readonly property string steamSquare: "\ue035"
}
}