changing login overlay size + add keyboard

This commit is contained in:
Wayne Chen 2018-11-06 12:56:50 -08:00
parent 235df365aa
commit 9beedf9292
11 changed files with 133 additions and 170 deletions

View file

@ -13,7 +13,6 @@ import QtQuick 2.4
import "qrc:////qml//controls-uit" as HifiControlsUit
import "qrc:////qml//styles-uit" as HifiStylesUit
import "windows" as Windows
import "LoginDialog"
@ -26,11 +25,16 @@ FocusScope {
anchors.fill: parent
readonly property bool isTablet: false
readonly property bool isOverlay: false
property string iconText: ""
property int iconSize: 50
property bool keyboardEnabled: false
property bool keyboardRaised: false
property bool punctuationMode: false
property bool isPassword: false
property string title: ""
property string text: ""
property int titleWidth: 0
function tryDestroy() {

View file

@ -246,6 +246,11 @@ Item {
}
Component.onCompleted: {
//but rise Tablet's one instead for Tablet interface
if (root.isTablet || root.isOverlay) {
root.keyboardEnabled = HMD.active;
root.keyboardRaised = Qt.binding( function() { return keyboardRaised; })
}
d.resize();
}
}

View file

@ -110,57 +110,44 @@ Item {
horizontalAlignment: Image.AlignHCenter
}
}
Item {
id: splashContainer
width: parent.width
anchors.fill: parent
visible: true
Text {
id: flavorText
text: qsTr("BE ANYWHERE, WITH ANYONE RIGHT NOW")
width: 0.48 * parent.width
anchors.centerIn: parent
anchors {
top: banner.bottom
topMargin: 0.1 * parent.height
}
wrapMode: Text.WordWrap
lineHeight: 0.5
color: "white"
font.family: linkAccountBody.fontFamily
font.pixelSize: !root.isTablet ? 2 * linkAccountBody.fontSize : linkAccountBody.fontSize
font.bold: linkAccountBody.fontBold
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
}
HifiControlsUit.Button {
id: signUpButton
text: qsTr("Sign Up")
width: d.minWidthButton
height: d.minHeightButton
color: hifi.buttons.blue
fontFamily: linkAccountBody.fontFamily
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
anchors {
bottom: parent.bottom
bottomMargin: 0.1 * parent.height
left: parent.left
leftMargin: (parent.width - d.minWidthButton) / 2
}
onClicked: {
linkAccountBody.withSteam = false;
toggleSignIn(false);
}
Text {
id: flavorText
text: qsTr("BE ANYWHERE, WITH ANYONE RIGHT NOW")
width: 0.48 * parent.width
anchors.centerIn: parent
anchors {
top: bannerContainer.bottom
topMargin: 0.1 * parent.height
}
wrapMode: Text.WordWrap
lineHeight: 0.5
color: "white"
font.family: linkAccountBody.fontFamily
font.pixelSize: !root.isTablet ? 2 * linkAccountBody.fontSize : linkAccountBody.fontSize
font.bold: linkAccountBody.fontBold
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
}
Keys.onReturnPressed: {
Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text);
linkAccountBody.login();
HifiControlsUit.Button {
id: signUpButton
text: qsTr("Sign Up")
width: d.minWidthButton
height: d.minHeightButton
color: hifi.buttons.blue
fontFamily: linkAccountBody.fontFamily
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
anchors {
bottom: parent.bottom
bottomMargin: 0.1 * parent.height
left: parent.left
leftMargin: (parent.width - d.minWidthButton) / 2
}
onClicked: {
linkAccountBody.withSteam = false;
toggleSignIn(false);
}
}
}
Item {
@ -279,13 +266,6 @@ Item {
}
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();
}
Component.onDestruction: {

View file

@ -212,6 +212,9 @@ Item {
break;
}
}
onFocusChanged: {
root.text = "";
}
}
HifiControlsUit.TextField {
@ -255,6 +258,9 @@ Item {
break;
}
}
onFocusChanged: {
root.text = "";
}
}
HifiControlsUit.TextField {
id: passwordField
@ -272,6 +278,7 @@ Item {
}
onFocusChanged: {
root.text = "";
root.isPassword = true;
}
@ -442,13 +449,9 @@ Item {
}
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; })
}
root.keyboardEnabled = HMD.active;
root.keyboardRaised = Qt.binding( function() { return keyboardRaised; })
d.resize();
init(loginDialog.isLogIn);
}

View file

@ -233,7 +233,7 @@ Item {
//dont rise local keyboard
keyboardEnabled = !root.isTablet && HMD.active;
//but rise Tablet's one instead for Tablet interface
if (root.isTablet) {
if (root.isTablet || root.isOverlay) {
root.keyboardEnabled = HMD.active;
root.keyboardRaised = Qt.binding( function() { return keyboardRaised; })
}

View file

@ -36,6 +36,8 @@ FocusScope {
property bool isPassword: false
readonly property bool isTablet: true
readonly property bool isOverlay: false
property alias text: loginKeyboard.mirroredText
property int titleWidth: 0
property string iconText: hifi.glyphs.avatar
@ -78,6 +80,18 @@ FocusScope {
}
}
HifiControlsUit.Keyboard {
id: loginKeyboard
raised: root.keyboardEnabled && root.keyboardRaised
numeric: root.punctuationMode
password: root.isPassword
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
Keys.onPressed: {
if (!visible) {
return

View file

@ -378,7 +378,7 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda
Setting::Handle<int> maxOctreePacketsPerSecond{"maxOctreePPS", DEFAULT_MAX_OCTREE_PPS};
Setting::Handle<bool> loginDialogPoppedUp{"loginDialogPoppedUp", false};
static const QUrl OVERLAY_LOGIN_DIALOG_URL(PathUtils::qmlUrl("LoginDialog.qml"));
static const QUrl OVERLAY_LOGIN_DIALOG_URL(PathUtils::qmlUrl("OverlayLoginDialog.qml"));
static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com";
static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds
@ -5231,9 +5231,13 @@ void Application::pauseUntilLoginDetermined() {
nodeList->getDomainHandler().disconnect();
auto menu = Menu::getInstance();
menu->getMenu("Edit")->setVisible(false);
menu->getMenu("Edit")->setEnabled(false);
menu->getMenu("View")->setVisible(false);
menu->getMenu("View")->setEnabled(false);
menu->getMenu("Navigate")->setVisible(false);
menu->getMenu("Navigate")->setEnabled(false);
menu->getMenu("Settings")->setVisible(false);
menu->getMenu("Settings")->setEnabled(false);
}
void Application::resumeAfterLoginDialogActionTaken() {
@ -5278,9 +5282,13 @@ void Application::resumeAfterLoginDialogActionTaken() {
auto menu = Menu::getInstance();
menu->getMenu("Edit")->setVisible(true);
menu->getMenu("Edit")->setEnabled(true);
menu->getMenu("View")->setVisible(true);
menu->getMenu("View")->setEnabled(true);
menu->getMenu("Navigate")->setVisible(true);
menu->getMenu("Navigate")->setEnabled(true);
menu->getMenu("Settings")->setVisible(true);
menu->getMenu("Settings")->setEnabled(true);
}
void Application::loadAvatarScripts(const QVector<QString>& urls) {
@ -7351,7 +7359,7 @@ void Application::showScriptLogs() {
}
void Application::showAssetServerWidget(QString filePath) {
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets() || getLoginDialogPoppedUp()) {
return;
}
static const QUrl url { "hifi/AssetServer.qml" };
@ -7990,6 +7998,9 @@ void Application::loadDomainConnectionDialog() {
}
void Application::toggleLogDialog() {
if (getLoginDialogPoppedUp()) {
return;
}
if (! _logDialog) {
_logDialog = new LogDialog(nullptr, getLogger());
}
@ -8519,8 +8530,12 @@ void Application::setShowBulletConstraintLimits(bool value) {
void Application::checkReadyToCreateLoginDialogOverlay() {
if (qApp->isHMDMode() && qApp->getActiveDisplayPlugin()->isDisplayVisible() && qApp->getLoginDialogPoppedUp() && _loginDialogOverlayID.isNull()) {
createLoginDialogOverlay();
} else if (qApp->getLoginDialogPoppedUp() && !qApp->isHMDMode()) {
_loginPointerManager.~LoginPointerManager();
} else if (qApp->getLoginDialogPoppedUp()) {
if (!qApp->isHMDMode()) {
_loginPointerManager.tearDown();
} else if (qApp->isHMDMode() && !_loginPointerManager.isSetUp()) {
_loginPointerManager.setUp();
}
}
}
@ -8529,9 +8544,9 @@ void Application::createLoginDialogOverlay() {
auto myAvatar = avatarManager->getMyAvatar();
Overlays& overlays = qApp->getOverlays();
// DEFAULT_DPI / tablet scale percentage
float overlayDpi = 31.0f / (60 / 100.0f);
float overlayDpi = 31.0f / (75.0f / 100.0f);
QVariantMap overlayProperties {
{ "name", "pleasework" },
{ "name", "LoginDialogOverlay" },
{ "url", OVERLAY_LOGIN_DIALOG_URL },
{ "position", vec3toVariant(myAvatar->getHeadPosition() - glm::vec3(0.0f, -0.1f, 1.0f)) },
{ "orientation", quatToVariant(myAvatar->getWorldOrientation()) },
@ -8539,77 +8554,22 @@ void Application::createLoginDialogOverlay() {
{ "grabbable", false },
{ "ignorePickIntersection", false },
{ "alpha", 1.0 },
{ "dimensions", vec2ToVariant(glm::vec2(0.5f, 0.5f)) },
{ "dpi", overlayDpi },
{ "visible", true }
};
_loginPointerManager.init();
//auto pointer = DependencyManager::get<PointerScriptingInterface>().data();
//auto standard = _controllerScriptingInterface->getStandard();
//glm::vec3 grabPointSphereOffsetLeft { 0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
//glm::vec3 grabPointSphereOffsetRight { -0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
//QList<QVariant> leftPointerTriggerProperties;
//QVariantMap ltClick1 {
// { "action", controller::StandardButtonChannel::LT_CLICK },
// { "button", "Focus" }
//};
//QVariantMap ltClick2 {
// { "action", controller::StandardButtonChannel::LT_CLICK },
// { "button", "Primary" }
//};
//leftPointerTriggerProperties.append(ltClick1);
//leftPointerTriggerProperties.append(ltClick2);
//const unsigned int leftHand = 0;
//QVariantMap leftPointerProperties {
// { "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
// { "filter", PickFilter::PICK_OVERLAYS },
// { "triggers", leftPointerTriggerProperties },
// { "posOffset", vec3toVariant(grabPointSphereOffsetLeft) },
// { "hover", true },
// { "distanceScaleEnd", true },
// { "hand", leftHand }
//};
//_leftLoginPointerID = pointer->createPointer(PickQuery::PickType::Ray, leftPointerProperties);
//pointer->setRenderState(_leftLoginPointerID, "");
//pointer->enablePointer(_leftLoginPointerID);
//const unsigned int rightHand = 1;
//QList<QVariant> rightPointerTriggerProperties;
//QVariantMap rtClick1 {
// { "action", controller::StandardButtonChannel::RT_CLICK },
// { "button", "Focus" }
//};
//QVariantMap rtClick2 {
// { "action", controller::StandardButtonChannel::RT_CLICK },
// { "button", "Primary" }
//};
//rightPointerTriggerProperties.append(rtClick1);
//rightPointerTriggerProperties.append(rtClick2);
//QVariantMap rightPointerProperties{
// { "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
// { "filter", PickFilter::PICK_OVERLAYS },
// { "triggers", rightPointerTriggerProperties },
// { "posOffset", vec3toVariant(grabPointSphereOffsetRight) },
// { "hover", true },
// { "distanceScaleEnd", true },
// { "hand", rightHand }
//};
//_rightLoginPointerID = pointer->createPointer(PickQuery::PickType::Ray, rightPointerProperties);
//pointer->setRenderState(_rightLoginPointerID, "");
//pointer->enablePointer(_rightLoginPointerID);
_loginDialogOverlayID = overlays.addOverlay("web3d", overlayProperties);
_loginDialogOverlayID = overlays.addOverlay("web3d", overlayProperties);
_loginPointerManager.setUp();
}
void Application::onDismissedLoginDialog() {
_loginDialogPoppedUp = false;
loginDialogPoppedUp.set(false);
auto pointer = DependencyManager::get<PointerScriptingInterface>().data();
if (!_loginDialogOverlayID.isNull()) {
// deleting overlay.
qDebug() << "Deleting overlay";
getOverlays().deleteOverlay(_loginDialogOverlayID);
_loginPointerManager.tearDown();
}
resumeAfterLoginDialogActionTaken();
}

View file

@ -43,21 +43,21 @@ static const QVariantMap COLORS_GRAB_DISTANCE_HOLD = {{"red", 238},
LoginPointerManager::~LoginPointerManager() {
void LoginPointerManager::tearDown() {
auto pointers = DependencyManager::get<PointerManager>().data();
if (pointers) {
if (leftLoginPointerID() != PointerEvent::INVALID_POINTER_ID) {
pointers->disablePointer(leftLoginPointerID());
pointers->removePointer(leftLoginPointerID());
if (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) {
pointers->removePointer(_leftLoginPointerID);
_leftLoginPointerID = PointerEvent::INVALID_POINTER_ID;
}
if (rightLoginPointerID() != PointerEvent::INVALID_POINTER_ID) {
pointers->disablePointer(rightLoginPointerID());
pointers->removePointer(rightLoginPointerID());
if (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID) {
pointers->removePointer(_rightLoginPointerID);
_rightLoginPointerID = PointerEvent::INVALID_POINTER_ID;
}
}
}
void LoginPointerManager::init() {
void LoginPointerManager::setUp() {
QVariantMap fullPathRenderState {
{"type", "line3d"},
{"color", COLORS_GRAB_SEARCHING_FULL_SQUEEZE},
@ -163,8 +163,7 @@ void LoginPointerManager::init() {
{ "button", "Primary" }
};
leftPointerTriggerProperties.append(ltClick1);
leftPointerTriggerProperties.append(ltClick2);
leftPointerTriggerProperties = QList<QVariant>({ltClick1, ltClick2});
const unsigned int leftHand = 0;
QVariantMap leftPointerProperties {
{ "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
@ -178,9 +177,9 @@ void LoginPointerManager::init() {
};
leftPointerProperties["renderStates"] = _renderStates;
leftPointerProperties["defaultRenderStates"] = _defaultRenderStates;
withWriteLock([&] { _leftLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, leftPointerProperties); });
pointers->setRenderState(leftLoginPointerID(), "");
pointers->enablePointer(leftLoginPointerID());
_leftLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, leftPointerProperties);
pointers->setRenderState(_leftLoginPointerID, "");
pointers->enablePointer(_leftLoginPointerID);
const unsigned int rightHand = 1;
QList<QVariant> rightPointerTriggerProperties;
@ -192,8 +191,7 @@ void LoginPointerManager::init() {
{ "action", controller->getStandard()["RTClick"] },
{ "button", "Primary" }
};
rightPointerTriggerProperties.append(rtClick1);
rightPointerTriggerProperties.append(rtClick2);
rightPointerTriggerProperties = QList<QVariant>({rtClick1, rtClick2});
QVariantMap rightPointerProperties{
{ "joint", "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" },
{ "filter", PickScriptingInterface::PICK_OVERLAYS() },
@ -206,11 +204,9 @@ void LoginPointerManager::init() {
};
rightPointerProperties["renderStates"] = _renderStates;
rightPointerProperties["defaultRenderStates"] = _defaultRenderStates;
withWriteLock([&] { _rightLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, rightPointerProperties); });
pointers->setRenderState(rightLoginPointerID(), "");
pointers->enablePointer(rightLoginPointerID());
_rightLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, rightPointerProperties);
pointers->setRenderState(_rightLoginPointerID, "");
pointers->enablePointer(_rightLoginPointerID);
}
void LoginPointerManager::update() {
@ -218,11 +214,11 @@ void LoginPointerManager::update() {
if (pointers) {
QString mode = "full";
if (leftLoginPointerID() > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(leftLoginPointerID(), mode);
if (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(_leftLoginPointerID, mode);
}
if (rightLoginPointerID() > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(rightLoginPointerID(), mode);
if (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(_rightLoginPointerID, mode);
}
}
}

View file

@ -11,6 +11,7 @@
#ifndef hifi_LoginPointerManager_h
#define hifi_LoginPointerManager_h
#include <QtCore/QList>
#include <QtCore/QSharedPointer>
#include <QtCore/QVariant>
#include <PointerEvent.h>
@ -20,19 +21,14 @@
class LoginPointerManager : protected ReadWriteLockable {
public:
LoginPointerManager() {}
~LoginPointerManager();
~LoginPointerManager() {}
void init();
void setUp();
void tearDown();
void update();
const unsigned int leftLoginPointerID() const {
return resultWithReadLock<unsigned int>([&] { return _leftLoginPointerID; });
}
const unsigned int rightLoginPointerID() const {
return resultWithReadLock<unsigned int>([&] { return _rightLoginPointerID; });
}
bool isSetUp() const { return (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) && (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID); }
private:
QList<QVariant> _renderStates {};
@ -40,4 +36,5 @@ private:
unsigned int _leftLoginPointerID { PointerEvent::INVALID_POINTER_ID };
unsigned int _rightLoginPointerID { PointerEvent::INVALID_POINTER_ID };
};
#endif // hifi_LoginPointerManager_h
#endif // hifi_LoginPointerManager_h

View file

@ -123,10 +123,12 @@ Menu::Menu() {
// Edit > Running Scripts
auto action = addActionToQMenuAndActionHash(editMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J);
connect(action, &QAction::triggered, [] {
static const QUrl widgetUrl("hifi/dialogs/RunningScripts.qml");
static const QUrl tabletUrl("hifi/dialogs/TabletRunningScripts.qml");
static const QString name("RunningScripts");
qApp->showDialog(widgetUrl, tabletUrl, name);
if (!qApp->getLoginDialogPoppedUp()) {
static const QUrl widgetUrl("hifi/dialogs/RunningScripts.qml");
static const QUrl tabletUrl("hifi/dialogs/TabletRunningScripts.qml");
static const QString name("RunningScripts");
qApp->showDialog(widgetUrl, tabletUrl, name);
}
});
editMenu->addSeparator();
@ -233,8 +235,10 @@ Menu::Menu() {
// Settings > General...
action = addActionToQMenuAndActionHash(settingsMenu, MenuOption::Preferences, Qt::CTRL | Qt::Key_G, nullptr, nullptr);
connect(action, &QAction::triggered, [] {
qApp->showDialog(QString("hifi/dialogs/GeneralPreferencesDialog.qml"),
QString("hifi/tablet/TabletGeneralPreferences.qml"), "GeneralPreferencesDialog");
if (!qApp->getLoginDialogPoppedUp()) {
qApp->showDialog(QString("hifi/dialogs/GeneralPreferencesDialog.qml"),
QString("hifi/tablet/TabletGeneralPreferences.qml"), "GeneralPreferencesDialog");
}
});
// Settings > Controls...

View file

@ -20,7 +20,7 @@
void StandAloneJSConsole::toggleConsole() {
QMainWindow* mainWindow = qApp->getWindow();
if (!_jsConsole) {
if (!_jsConsole && !qApp->getLoginDialogPoppedUp()) {
QDialog* dialog = new QDialog(mainWindow, Qt::WindowStaysOnTopHint);
QVBoxLayout* layout = new QVBoxLayout(dialog);
dialog->setLayout(layout);