mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +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,
|
||||
this,
|
||||
SLOT(loginForCurrentDomain())));
|
||||
|
||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::Logout, 0, &AccountManager::getInstance(), SLOT(logout()));
|
||||
|
||||
addDisabledActionAndSeparator(fileMenu, "Scripts");
|
||||
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 Log = "Log";
|
||||
const QString Login = "Login";
|
||||
const QString Logout = "Logout";
|
||||
const QString LookAtVectors = "Look-at Vectors";
|
||||
const QString MetavoxelEditor = "Metavoxel Editor...";
|
||||
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) {
|
||||
if (_rootURL != rootURL) {
|
||||
_rootURL = rootURL;
|
||||
|
@ -255,7 +270,8 @@ void AccountManager::requestFinished() {
|
|||
// store this access token into the local settings
|
||||
QSettings localSettings;
|
||||
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 {
|
||||
// TODO: error handling
|
||||
|
|
|
@ -34,7 +34,6 @@ public:
|
|||
class AccountManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
static AccountManager& getInstance();
|
||||
|
||||
void authenticatedRequest(const QString& path,
|
||||
|
@ -55,6 +54,7 @@ public:
|
|||
public slots:
|
||||
void requestFinished();
|
||||
void requestError(QNetworkReply::NetworkError error);
|
||||
void logout();
|
||||
signals:
|
||||
void authenticationRequired();
|
||||
void receivedAccessToken(const QUrl& rootURL);
|
||||
|
|
Loading…
Reference in a new issue