diff --git a/gvr-interface/src/GVRMainWindow.cpp b/gvr-interface/src/GVRMainWindow.cpp index 048a122333..c020b94dc3 100644 --- a/gvr-interface/src/GVRMainWindow.cpp +++ b/gvr-interface/src/GVRMainWindow.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include @@ -31,6 +33,7 @@ const float LIBOVR_LONG_PRESS_DURATION = 0.75f; #include #include "InterfaceView.h" +#include "LoginDialog.h" #include "RenderingClient.h" #include "GVRMainWindow.h" @@ -110,6 +113,10 @@ void GVRMainWindow::setupMenuBar() { connect(goToAddress, &QAction::triggered, this, &GVRMainWindow::showAddressBar); 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); connect(aboutQt, &QAction::triggered, qApp, &QApplication::aboutQt); helpMenu->addAction(aboutQt); @@ -128,3 +135,13 @@ void GVRMainWindow::showAddressBar() { connect(addressDialog, &QInputDialog::textValueSelected, DependencyManager::get().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); +} diff --git a/gvr-interface/src/GVRMainWindow.h b/gvr-interface/src/GVRMainWindow.h index 1e19e6d0af..79017196dd 100644 --- a/gvr-interface/src/GVRMainWindow.h +++ b/gvr-interface/src/GVRMainWindow.h @@ -29,6 +29,7 @@ public: ~GVRMainWindow(); public slots: void showAddressBar(); + void showLoginDialog(); #if defined(ANDROID) && defined(HAVE_LIBOVR) OVR::KeyState& getBackKeyState() { return _backKeyState; } diff --git a/gvr-interface/src/LoginDialog.cpp b/gvr-interface/src/LoginDialog.cpp new file mode 100644 index 0000000000..95b7451bcb --- /dev/null +++ b/gvr-interface/src/LoginDialog.cpp @@ -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 +#include +#include +#include +#include + +#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(); +} \ No newline at end of file diff --git a/gvr-interface/src/LoginDialog.h b/gvr-interface/src/LoginDialog.h new file mode 100644 index 0000000000..13f630818d --- /dev/null +++ b/gvr-interface/src/LoginDialog.h @@ -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 + +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 \ No newline at end of file diff --git a/gvr-interface/src/RenderingClient.cpp b/gvr-interface/src/RenderingClient.cpp index 0b4ce4cb94..6431ece950 100644 --- a/gvr-interface/src/RenderingClient.cpp +++ b/gvr-interface/src/RenderingClient.cpp @@ -108,7 +108,6 @@ void RenderingClient::processVerifiedPacket(const HifiSockAddr& senderSockAddr, if (audioMixer) { audioMixer->setLastHeardMicrostamp(usecTimestampNow()); - audioMixer->recordBytesReceived(incomingPacket.size()); } break; @@ -122,7 +121,6 @@ void RenderingClient::processVerifiedPacket(const HifiSockAddr& senderSockAddr, if (avatarMixer) { avatarMixer->setLastHeardMicrostamp(usecTimestampNow()); - avatarMixer->recordBytesReceived(incomingPacket.size()); QMetaObject::invokeMethod(DependencyManager::get().data(), "processAvatarMixerDatagram", diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index 06fe366d69..2c9a441db1 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -69,12 +69,13 @@ public: Q_INVOKABLE bool checkAndSignalForAccessToken(); void setAccessTokenForCurrentAuthURL(const QString& accessToken); - void requestAccessToken(const QString& login, const QString& password); void requestProfile(); DataServerAccountInfo& getAccountInfo() { return _accountInfo; } public slots: + void requestAccessToken(const QString& login, const QString& password); + void requestAccessTokenFinished(); void requestProfileFinished(); void requestAccessTokenError(QNetworkReply::NetworkError error);