mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +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),
|
||||
_inVRMode(false)
|
||||
{
|
||||
setApplicationName("gvr-interface");
|
||||
setOrganizationName("highfidelity");
|
||||
setOrganizationDomain("io");
|
||||
|
||||
if (!launchURLString.isEmpty()) {
|
||||
// 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;
|
||||
|
|
|
@ -48,7 +48,8 @@ GVRMainWindow::GVRMainWindow(QWidget* parent) :
|
|||
_wasBackKeyDown(false),
|
||||
#endif
|
||||
_mainLayout(NULL),
|
||||
_menuBar(NULL)
|
||||
_menuBar(NULL),
|
||||
_loginAction(NULL)
|
||||
{
|
||||
|
||||
#ifndef ANDROID
|
||||
|
@ -114,9 +115,16 @@ 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);
|
||||
_loginAction = new QAction("Login", fileMenu);
|
||||
fileMenu->addAction(_loginAction);
|
||||
|
||||
// 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);
|
||||
connect(aboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
|
||||
|
@ -152,3 +160,17 @@ void GVRMainWindow::showLoginFailure() {
|
|||
QMessageBox::warning(this, "Login Failed",
|
||||
"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:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
private slots:
|
||||
void refreshLoginAction();
|
||||
private:
|
||||
void setupMenuBar();
|
||||
|
||||
|
@ -50,6 +52,7 @@ private:
|
|||
|
||||
QVBoxLayout* _mainLayout;
|
||||
QMenuBar* _menuBar;
|
||||
QAction* _loginAction;
|
||||
};
|
||||
|
||||
#endif // hifi_GVRMainWindow_h
|
||||
|
|
Loading…
Reference in a new issue