mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:29:47 +02:00
toggle login/logout for correct state
This commit is contained in:
parent
dc84c336ea
commit
a86073384b
3 changed files with 33 additions and 4 deletions
|
@ -53,6 +53,10 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||||
_mainWindow(NULL),
|
_mainWindow(NULL),
|
||||||
_inVRMode(false)
|
_inVRMode(false)
|
||||||
{
|
{
|
||||||
|
setApplicationName("gvr-interface");
|
||||||
|
setOrganizationName("highfidelity");
|
||||||
|
setOrganizationDomain("io");
|
||||||
|
|
||||||
if (!launchURLString.isEmpty()) {
|
if (!launchURLString.isEmpty()) {
|
||||||
// did we get launched with a lookup URL? If so it is time to give that to the AddressManager
|
// did we get launched with a lookup URL? If so it is time to give that to the AddressManager
|
||||||
qDebug() << "We were opened via a hifi URL -" << launchURLString;
|
qDebug() << "We were opened via a hifi URL -" << launchURLString;
|
||||||
|
|
|
@ -48,7 +48,8 @@ GVRMainWindow::GVRMainWindow(QWidget* parent) :
|
||||||
_wasBackKeyDown(false),
|
_wasBackKeyDown(false),
|
||||||
#endif
|
#endif
|
||||||
_mainLayout(NULL),
|
_mainLayout(NULL),
|
||||||
_menuBar(NULL)
|
_menuBar(NULL),
|
||||||
|
_loginAction(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
|
@ -114,9 +115,16 @@ 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);
|
_loginAction = new QAction("Login", fileMenu);
|
||||||
connect(login, &QAction::triggered, this, &GVRMainWindow::showLoginDialog);
|
fileMenu->addAction(_loginAction);
|
||||||
fileMenu->addAction(login);
|
|
||||||
|
// change the login action depending on our logged in/out state
|
||||||
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
connect(&accountManager, &AccountManager::loginComplete, this, &GVRMainWindow::refreshLoginAction);
|
||||||
|
connect(&accountManager, &AccountManager::logoutComplete, this, &GVRMainWindow::refreshLoginAction);
|
||||||
|
|
||||||
|
// refresh the state now
|
||||||
|
refreshLoginAction();
|
||||||
|
|
||||||
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);
|
||||||
|
@ -152,3 +160,17 @@ void GVRMainWindow::showLoginFailure() {
|
||||||
QMessageBox::warning(this, "Login Failed",
|
QMessageBox::warning(this, "Login Failed",
|
||||||
"Could not log in with that username and password. Please try again!");
|
"Could not log in with that username and password. Please try again!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GVRMainWindow::refreshLoginAction() {
|
||||||
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
disconnect(_loginAction, &QAction::triggered, &accountManager, 0);
|
||||||
|
|
||||||
|
if (accountManager.isLoggedIn()) {
|
||||||
|
_loginAction->setText("Logout");
|
||||||
|
connect(_loginAction, &QAction::triggered, &accountManager, &AccountManager::logout);
|
||||||
|
} else {
|
||||||
|
_loginAction->setText("Login");
|
||||||
|
connect(_loginAction, &QAction::triggered, this, &GVRMainWindow::showLoginDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void keyReleaseEvent(QKeyEvent* event);
|
void keyReleaseEvent(QKeyEvent* event);
|
||||||
|
private slots:
|
||||||
|
void refreshLoginAction();
|
||||||
private:
|
private:
|
||||||
void setupMenuBar();
|
void setupMenuBar();
|
||||||
|
|
||||||
|
@ -50,6 +52,7 @@ private:
|
||||||
|
|
||||||
QVBoxLayout* _mainLayout;
|
QVBoxLayout* _mainLayout;
|
||||||
QMenuBar* _menuBar;
|
QMenuBar* _menuBar;
|
||||||
|
QAction* _loginAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GVRMainWindow_h
|
#endif // hifi_GVRMainWindow_h
|
||||||
|
|
Loading…
Reference in a new issue