mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 16:53:16 +02:00
add a LoginDialog and pass credentials to AccountManager
This commit is contained in:
parent
e07ce23825
commit
64fda3253e
6 changed files with 123 additions and 3 deletions
|
@ -12,6 +12,8 @@
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QtGui/QKeyEvent>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtWidgets/QInputDialog>
|
#include <QtWidgets/QInputDialog>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QLineEdit>
|
||||||
#include <QtWidgets/QMenuBar>
|
#include <QtWidgets/QMenuBar>
|
||||||
#include <QtWidgets/QVBoxLayout>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ const float LIBOVR_LONG_PRESS_DURATION = 0.75f;
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
|
|
||||||
#include "InterfaceView.h"
|
#include "InterfaceView.h"
|
||||||
|
#include "LoginDialog.h"
|
||||||
#include "RenderingClient.h"
|
#include "RenderingClient.h"
|
||||||
|
|
||||||
#include "GVRMainWindow.h"
|
#include "GVRMainWindow.h"
|
||||||
|
@ -110,6 +113,10 @@ void GVRMainWindow::setupMenuBar() {
|
||||||
connect(goToAddress, &QAction::triggered, this, &GVRMainWindow::showAddressBar);
|
connect(goToAddress, &QAction::triggered, this, &GVRMainWindow::showAddressBar);
|
||||||
fileMenu->addAction(goToAddress);
|
fileMenu->addAction(goToAddress);
|
||||||
|
|
||||||
|
QAction* login = new QAction("Login", fileMenu);
|
||||||
|
connect(login, &QAction::triggered, this, &GVRMainWindow::showLoginDialog);
|
||||||
|
fileMenu->addAction(login);
|
||||||
|
|
||||||
QAction* aboutQt = new QAction("About Qt", helpMenu);
|
QAction* aboutQt = new QAction("About Qt", helpMenu);
|
||||||
connect(aboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
|
connect(aboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
|
||||||
helpMenu->addAction(aboutQt);
|
helpMenu->addAction(aboutQt);
|
||||||
|
@ -128,3 +135,13 @@ void GVRMainWindow::showAddressBar() {
|
||||||
connect(addressDialog, &QInputDialog::textValueSelected,
|
connect(addressDialog, &QInputDialog::textValueSelected,
|
||||||
DependencyManager::get<AddressManager>().data(), &AddressManager::handleLookupString);
|
DependencyManager::get<AddressManager>().data(), &AddressManager::handleLookupString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GVRMainWindow::showLoginDialog() {
|
||||||
|
LoginDialog* loginDialog = new LoginDialog(this);
|
||||||
|
|
||||||
|
// have the acccount manager handle credentials from LoginDialog
|
||||||
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
connect(loginDialog, &LoginDialog::credentialsEntered, &accountManager, &AccountManager::requestAccessToken);
|
||||||
|
|
||||||
|
_mainLayout->addWidget(loginDialog);
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
~GVRMainWindow();
|
~GVRMainWindow();
|
||||||
public slots:
|
public slots:
|
||||||
void showAddressBar();
|
void showAddressBar();
|
||||||
|
void showLoginDialog();
|
||||||
|
|
||||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||||
OVR::KeyState& getBackKeyState() { return _backKeyState; }
|
OVR::KeyState& getBackKeyState() { return _backKeyState; }
|
||||||
|
|
69
gvr-interface/src/LoginDialog.cpp
Normal file
69
gvr-interface/src/LoginDialog.cpp
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
//
|
||||||
|
// LoginDialog.cpp
|
||||||
|
// gvr-interface/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2015-02-03.
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QtWidgets/QDialogButtonBox>
|
||||||
|
#include <QtWidgets/QGridLayout>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QLineEdit>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
|
||||||
|
#include "LoginDialog.h"
|
||||||
|
|
||||||
|
LoginDialog::LoginDialog(QWidget* parent) :
|
||||||
|
QDialog(parent)
|
||||||
|
{
|
||||||
|
setupGUI();
|
||||||
|
setWindowTitle("Login");
|
||||||
|
setModal(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoginDialog::setupGUI() {
|
||||||
|
// setup a grid layout
|
||||||
|
QGridLayout* formGridLayout = new QGridLayout(this);
|
||||||
|
|
||||||
|
_usernameLineEdit = new QLineEdit(this);
|
||||||
|
|
||||||
|
QLabel* usernameLabel = new QLabel(this);
|
||||||
|
usernameLabel->setText("Username");
|
||||||
|
usernameLabel->setBuddy(_usernameLineEdit);
|
||||||
|
|
||||||
|
formGridLayout->addWidget(usernameLabel, 0, 0);
|
||||||
|
formGridLayout->addWidget(_usernameLineEdit, 1, 0);
|
||||||
|
|
||||||
|
_passwordLineEdit = new QLineEdit(this);
|
||||||
|
_passwordLineEdit->setEchoMode(QLineEdit::Password);
|
||||||
|
|
||||||
|
QLabel* passwordLabel = new QLabel(this);
|
||||||
|
passwordLabel->setText("Password");
|
||||||
|
passwordLabel->setBuddy(_passwordLineEdit);
|
||||||
|
|
||||||
|
formGridLayout->addWidget(passwordLabel, 2, 0);
|
||||||
|
formGridLayout->addWidget(_passwordLineEdit, 3, 0);
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons = new QDialogButtonBox(this);
|
||||||
|
|
||||||
|
QPushButton* okButton = buttons->addButton(QDialogButtonBox::Ok);
|
||||||
|
QPushButton* cancelButton = buttons->addButton(QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
okButton->setText("Login");
|
||||||
|
|
||||||
|
connect(cancelButton, &QPushButton::clicked, this, &QDialog::close);
|
||||||
|
connect(okButton, &QPushButton::clicked, this, &LoginDialog::loginButtonClicked);
|
||||||
|
|
||||||
|
formGridLayout->addWidget(buttons, 4, 0, 1, 2);
|
||||||
|
|
||||||
|
setLayout(formGridLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoginDialog::loginButtonClicked() {
|
||||||
|
emit credentialsEntered(_usernameLineEdit->text(), _passwordLineEdit->text());
|
||||||
|
close();
|
||||||
|
}
|
34
gvr-interface/src/LoginDialog.h
Normal file
34
gvr-interface/src/LoginDialog.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
//
|
||||||
|
// LoginDialog.h
|
||||||
|
// gvr-interface/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2015-02-03.
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_LoginDialog_h
|
||||||
|
#define hifi_LoginDialog_h
|
||||||
|
|
||||||
|
#include <QtWidgets/QDialog>
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
|
class LoginDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
LoginDialog(QWidget* parent = 0);
|
||||||
|
signals:
|
||||||
|
void credentialsEntered(const QString& username, const QString& password);
|
||||||
|
private slots:
|
||||||
|
void loginButtonClicked();
|
||||||
|
private:
|
||||||
|
void setupGUI();
|
||||||
|
|
||||||
|
QLineEdit* _usernameLineEdit;
|
||||||
|
QLineEdit* _passwordLineEdit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_LoginDialog_h
|
|
@ -108,7 +108,6 @@ void RenderingClient::processVerifiedPacket(const HifiSockAddr& senderSockAddr,
|
||||||
|
|
||||||
if (audioMixer) {
|
if (audioMixer) {
|
||||||
audioMixer->setLastHeardMicrostamp(usecTimestampNow());
|
audioMixer->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
audioMixer->recordBytesReceived(incomingPacket.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -122,7 +121,6 @@ void RenderingClient::processVerifiedPacket(const HifiSockAddr& senderSockAddr,
|
||||||
|
|
||||||
if (avatarMixer) {
|
if (avatarMixer) {
|
||||||
avatarMixer->setLastHeardMicrostamp(usecTimestampNow());
|
avatarMixer->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
avatarMixer->recordBytesReceived(incomingPacket.size());
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AvatarHashMap>().data(),
|
QMetaObject::invokeMethod(DependencyManager::get<AvatarHashMap>().data(),
|
||||||
"processAvatarMixerDatagram",
|
"processAvatarMixerDatagram",
|
||||||
|
|
|
@ -69,12 +69,13 @@ public:
|
||||||
Q_INVOKABLE bool checkAndSignalForAccessToken();
|
Q_INVOKABLE bool checkAndSignalForAccessToken();
|
||||||
void setAccessTokenForCurrentAuthURL(const QString& accessToken);
|
void setAccessTokenForCurrentAuthURL(const QString& accessToken);
|
||||||
|
|
||||||
void requestAccessToken(const QString& login, const QString& password);
|
|
||||||
void requestProfile();
|
void requestProfile();
|
||||||
|
|
||||||
DataServerAccountInfo& getAccountInfo() { return _accountInfo; }
|
DataServerAccountInfo& getAccountInfo() { return _accountInfo; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void requestAccessToken(const QString& login, const QString& password);
|
||||||
|
|
||||||
void requestAccessTokenFinished();
|
void requestAccessTokenFinished();
|
||||||
void requestProfileFinished();
|
void requestProfileFinished();
|
||||||
void requestAccessTokenError(QNetworkReply::NetworkError error);
|
void requestAccessTokenError(QNetworkReply::NetworkError error);
|
||||||
|
|
Loading…
Reference in a new issue