mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 22:40:27 +02:00
add a logout option to the menu
This commit is contained in:
parent
0686539734
commit
6165ca658a
4 changed files with 21 additions and 2 deletions
|
@ -91,6 +91,8 @@ Menu::Menu() :
|
||||||
0,
|
0,
|
||||||
this,
|
this,
|
||||||
SLOT(loginForCurrentDomain())));
|
SLOT(loginForCurrentDomain())));
|
||||||
|
|
||||||
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::Logout, 0, &AccountManager::getInstance(), SLOT(logout()));
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Scripts");
|
addDisabledActionAndSeparator(fileMenu, "Scripts");
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, appInstance, SLOT(loadDialog()));
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, appInstance, SLOT(loadDialog()));
|
||||||
|
|
|
@ -245,6 +245,7 @@ namespace MenuOption {
|
||||||
const QString LodTools = "LOD Tools";
|
const QString LodTools = "LOD Tools";
|
||||||
const QString Log = "Log";
|
const QString Log = "Log";
|
||||||
const QString Login = "Login";
|
const QString Login = "Login";
|
||||||
|
const QString Logout = "Logout";
|
||||||
const QString LookAtVectors = "Look-at Vectors";
|
const QString LookAtVectors = "Look-at Vectors";
|
||||||
const QString MetavoxelEditor = "Metavoxel Editor...";
|
const QString MetavoxelEditor = "Metavoxel Editor...";
|
||||||
const QString Metavoxels = "Metavoxels";
|
const QString Metavoxels = "Metavoxels";
|
||||||
|
|
|
@ -63,6 +63,21 @@ AccountManager::AccountManager() :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString DOUBLE_SLASH_SUBSTITUTE = "slashslash";
|
||||||
|
|
||||||
|
void AccountManager::logout() {
|
||||||
|
// a logout means we want to delete the DataServerAccountInfo we currently have for this URL, in-memory and in file
|
||||||
|
_accounts.remove(_rootURL);
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup(ACCOUNTS_GROUP);
|
||||||
|
|
||||||
|
QString keyURLString(_rootURL.toString().replace("//", DOUBLE_SLASH_SUBSTITUTE));
|
||||||
|
settings.remove(keyURLString);
|
||||||
|
|
||||||
|
qDebug() << "Removed account info for" << _rootURL << "from in-memory accounts and .ini file";
|
||||||
|
}
|
||||||
|
|
||||||
void AccountManager::setRootURL(const QUrl& rootURL) {
|
void AccountManager::setRootURL(const QUrl& rootURL) {
|
||||||
if (_rootURL != rootURL) {
|
if (_rootURL != rootURL) {
|
||||||
_rootURL = rootURL;
|
_rootURL = rootURL;
|
||||||
|
@ -255,7 +270,8 @@ void AccountManager::requestFinished() {
|
||||||
// store this access token into the local settings
|
// store this access token into the local settings
|
||||||
QSettings localSettings;
|
QSettings localSettings;
|
||||||
localSettings.beginGroup(ACCOUNTS_GROUP);
|
localSettings.beginGroup(ACCOUNTS_GROUP);
|
||||||
localSettings.setValue(rootURL.toString().replace("//", "slashslash"), QVariant::fromValue(freshAccountInfo));
|
localSettings.setValue(rootURL.toString().replace("//", DOUBLE_SLASH_SUBSTITUTE),
|
||||||
|
QVariant::fromValue(freshAccountInfo));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: error handling
|
// TODO: error handling
|
||||||
|
|
|
@ -34,7 +34,6 @@ public:
|
||||||
class AccountManager : public QObject {
|
class AccountManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static AccountManager& getInstance();
|
static AccountManager& getInstance();
|
||||||
|
|
||||||
void authenticatedRequest(const QString& path,
|
void authenticatedRequest(const QString& path,
|
||||||
|
@ -55,6 +54,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void requestFinished();
|
void requestFinished();
|
||||||
void requestError(QNetworkReply::NetworkError error);
|
void requestError(QNetworkReply::NetworkError error);
|
||||||
|
void logout();
|
||||||
signals:
|
signals:
|
||||||
void authenticationRequired();
|
void authenticationRequired();
|
||||||
void receivedAccessToken(const QUrl& rootURL);
|
void receivedAccessToken(const QUrl& rootURL);
|
||||||
|
|
Loading…
Reference in a new issue