diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index c73aab08c3..a710c76477 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -119,6 +119,7 @@ Item { width: parent.width focus: true label: "Username or Email" + activeFocusOnPress: true ShortcutText { anchors { @@ -135,6 +136,10 @@ Item { onLinkActivated: loginDialog.openUrl(link) } + onFocusChanged: { + console.log("-------> setting variable <-------"); + root.text = ""; + } } TextField { @@ -143,6 +148,7 @@ Item { label: "Password" echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password + activeFocusOnPress: true ShortcutText { anchors { @@ -159,6 +165,10 @@ Item { onLinkActivated: loginDialog.openUrl(link) } + onFocusChanged: { + root.text = ""; + root.isPassword = true; + } } CheckBoxQQC2 { @@ -233,18 +243,6 @@ Item { } } - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - Component.onCompleted: { root.title = qsTr("Sign Into High Fidelity") root.iconText = "<" diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index f6cf40db8e..9d55998b40 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -108,12 +108,17 @@ Item { id: emailField width: parent.width label: "Email" + activeFocusOnPress: true + onFocusChanged: { + root.text = ""; + } } TextField { id: usernameField width: parent.width label: "Username" + activeFocusOnPress: true ShortcutText { anchors { @@ -128,6 +133,9 @@ Item { horizontalAlignment: Text.AlignHCenter color: hifi.colors.blueAccent + onFocusChanged: { + root.text = ""; + } } } @@ -136,6 +144,7 @@ Item { width: parent.width label: "Password" echoMode: TextInput.Password + activeFocusOnPress: true ShortcutText { anchors { @@ -151,6 +160,11 @@ Item { color: hifi.colors.blueAccent } + + onFocusChanged: { + root.text = ""; + root.isPassword = focus + } } Row { @@ -202,18 +216,6 @@ Item { } } - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - Component.onCompleted: { root.title = qsTr("Create an Account") root.iconText = "<" diff --git a/interface/resources/qml/controls-uit/Keyboard.qml b/interface/resources/qml/controls-uit/Keyboard.qml index 8d6634c9b4..66a61742c9 100644 --- a/interface/resources/qml/controls-uit/Keyboard.qml +++ b/interface/resources/qml/controls-uit/Keyboard.qml @@ -39,6 +39,10 @@ Rectangle { property bool shiftMode: false property bool numericShiftMode: false + onRaisedChanged: { + mirroredText = ""; + } + function resetShiftMode(mode) { shiftMode = mode; shiftKey.resetToggledMode(mode); diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml index 9722f31144..269788a808 100644 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ b/interface/resources/qml/dialogs/TabletLoginDialog.qml @@ -37,6 +37,8 @@ TabletModalWindow { property bool keyboardEnabled: false property bool keyboardRaised: false property bool punctuationMode: false + property bool isPassword: false + property alias text: loginKeyboard.mirroredText readonly property bool isTablet: true @@ -130,6 +132,7 @@ TabletModalWindow { id: loginKeyboard raised: root.keyboardEnabled && root.keyboardRaised numeric: root.punctuationMode + password: root.isPassword anchors { left: parent.left right: parent.right diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index 8646bee3ca..ddc9c2e5f3 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -1082,36 +1082,6 @@ void OffscreenQmlSurface::synthesizeKeyPress(QString key, QObject* targetOverrid } } -static void forEachKeyboard(QQuickItem* parent, std::function function) { - if (!function) { - return; - } - - auto keyboards = parent->findChildren("keyboard"); - - for (auto keyboardObject : keyboards) { - auto keyboard = qobject_cast(keyboardObject); - if (keyboard) { - function(keyboard); - } - } -} - -static const int TEXTINPUT_PASSWORD = 2; - -static QQuickItem* getTopmostParent(QQuickItem* item) { - QObject* itemObject = item; - while (itemObject) { - if (itemObject->parent()) { - itemObject = itemObject->parent(); - } else { - break; - } - } - - return qobject_cast (itemObject); -} - void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool numeric) { #if Q_OS_ANDROID return; @@ -1128,21 +1098,6 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n return; } - auto echoMode = item->property("echoMode"); - bool isPasswordField = echoMode.isValid() && echoMode.toInt() == TEXTINPUT_PASSWORD; - - // we need to somehow pass 'isPasswordField' to visible keyboard so it will change its 'mirror text' to asterixes - // the issue in some cases there might be more than one keyboard in object tree and it is hard to understand which one is being used at the moment - // unfortunately attempts to check for visibility failed becuase visibility is not updated yet. So... I don't see other way than just update properties for all the keyboards - - auto topmostParent = getTopmostParent(item); - if (topmostParent) { - forEachKeyboard(topmostParent, [&](QQuickItem* keyboard) { - keyboard->setProperty("mirroredText", QVariant::fromValue(QString(""))); - keyboard->setProperty("password", isPasswordField); - }); - } - // for future probably makes sense to consider one of the following: // 1. make keyboard a singleton, which will be dynamically re-parented before showing // 2. track currently visible keyboard somewhere, allow to subscribe for this signal @@ -1153,10 +1108,6 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n numeric = numeric || QString(item->metaObject()->className()).left(7) == "SpinBox"; if (item->property("keyboardRaised").isValid()) { - forEachKeyboard(item, [&](QQuickItem* keyboard) { - keyboard->setProperty("mirroredText", QVariant::fromValue(QString(""))); - keyboard->setProperty("password", isPasswordField); - }); // FIXME - HMD only: Possibly set value of "keyboardEnabled" per isHMDMode() for use in WebView.qml. if (item->property("punctuationMode").isValid()) {