Simplify to use bool instead of storing domain name

This commit is contained in:
David Rowe 2014-08-28 12:21:55 -07:00
parent 46c1a9d59a
commit 85e9f8064a
2 changed files with 7 additions and 9 deletions

View file

@ -114,7 +114,7 @@ Menu::Menu() :
_loginAction(NULL), _loginAction(NULL),
_preferencesDialog(NULL), _preferencesDialog(NULL),
_loginDialog(NULL), _loginDialog(NULL),
_loginDomain(), _hasLoginDialogDisplayed(false),
_snapshotsLocation(), _snapshotsLocation(),
_scriptsLocation(), _scriptsLocation(),
_walletPrivateKey() _walletPrivateKey()
@ -1055,23 +1055,21 @@ const float DIALOG_RATIO_OF_WINDOW = 0.30f;
void Menu::clearLoginDomain() { void Menu::clearLoginDomain() {
// Needed for domains that don't require login. // Needed for domains that don't require login.
_loginDomain = QString(); _hasLoginDialogDisplayed = false;
} }
void Menu::loginForCurrentDomain() { void Menu::loginForCurrentDomain() {
QString domain = NodeList::getInstance()->getDomainHandler().getHostname(); if (!_loginDialog && !_hasLoginDialogDisplayed) {
bool hasShownForDomain = domain == _loginDomain;
if (!_loginDialog && !hasShownForDomain) {
_loginDomain = domain;
_loginDialog = new LoginDialog(Application::getInstance()->getWindow()); _loginDialog = new LoginDialog(Application::getInstance()->getWindow());
_loginDialog->show(); _loginDialog->show();
_loginDialog->resizeAndPosition(false); _loginDialog->resizeAndPosition(false);
} }
_hasLoginDialogDisplayed = true;
} }
void Menu::showLoginForCurrentDomain() { void Menu::showLoginForCurrentDomain() {
_loginDomain = QString(); _hasLoginDialogDisplayed = false;
loginForCurrentDomain(); loginForCurrentDomain();
} }

View file

@ -304,7 +304,7 @@ private:
QPointer<AttachmentsDialog> _attachmentsDialog; QPointer<AttachmentsDialog> _attachmentsDialog;
QPointer<AnimationsDialog> _animationsDialog; QPointer<AnimationsDialog> _animationsDialog;
QPointer<LoginDialog> _loginDialog; QPointer<LoginDialog> _loginDialog;
QString _loginDomain; bool _hasLoginDialogDisplayed;
QAction* _chatAction; QAction* _chatAction;
QString _snapshotsLocation; QString _snapshotsLocation;
QString _scriptsLocation; QString _scriptsLocation;