summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/MainWindow.cpp30
-rw-r--r--gui/dialogs/AccountListDialog.cpp2
-rw-r--r--logic/lists/MojangAccountList.cpp6
3 files changed, 29 insertions, 9 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index a9f29d86..f8904267 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -255,9 +255,10 @@ void MainWindow::repopulateAccountsMenu()
accountMenu->clear();
std::shared_ptr<MojangAccountList> accounts = MMC->accounts();
+ MojangAccountPtr active_account = accounts->activeAccount();
- QString active_username;
- if(accounts->activeAccount() != nullptr)
+ QString active_username = "";
+ if(active_account != nullptr)
{
active_username = accounts->activeAccount()->username();
}
@@ -301,6 +302,18 @@ void MainWindow::repopulateAccountsMenu()
}
}
+ QAction *action = new QAction(tr("No default"), this);
+ action->setCheckable(true);
+ action->setData("");
+ if(active_username.isEmpty())
+ {
+ action->setChecked(true);
+ }
+
+ accountMenu->addAction(action);
+ connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));
+
+ accountMenu->addSeparator();
accountMenu->addAction(manageAccountsAction);
}
@@ -310,18 +323,19 @@ void MainWindow::repopulateAccountsMenu()
void MainWindow::changeActiveAccount()
{
QAction* sAction = (QAction*) sender();
-
// Profile's associated Mojang username
// Will need to change when profiles are properly implemented
if(sAction->data().type() != QVariant::Type::String) return;
- QString id = sAction->data().toString();
-
- if(id != nullptr && !id.isEmpty())
+ QVariant data = sAction->data();
+ QString id = "";
+ if(!data.isNull())
{
- MMC->accounts()->setActiveAccount(id);
+ id = data.toString();
}
+ MMC->accounts()->setActiveAccount(id);
+
activeAccountChanged();
}
@@ -331,7 +345,7 @@ void MainWindow::activeAccountChanged()
MojangAccountPtr account = MMC->accounts()->activeAccount();
- if(account != nullptr)
+ if(account != nullptr && account->username() != "")
{
const AccountProfile *profile = account->currentProfile();
if(profile != nullptr)
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index 97dc0564..29f3838d 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -92,6 +92,8 @@ void AccountListDialog::on_setDefaultBtn_clicked()
void AccountListDialog::on_noDefaultBtn_clicked()
{
m_accounts->setActiveAccount("");
+
+ emit activeAccountChanged();
}
void AccountListDialog::on_closeBtnBox_rejected()
diff --git a/logic/lists/MojangAccountList.cpp b/logic/lists/MojangAccountList.cpp
index a30ef4ab..c6dce836 100644
--- a/logic/lists/MojangAccountList.cpp
+++ b/logic/lists/MojangAccountList.cpp
@@ -100,8 +100,10 @@ void MojangAccountList::setActiveAccount(const QString& username)
else
{
for (MojangAccountPtr account : m_accounts)
+ {
if (account->username() == username)
m_activeAccount = username;
+ }
}
endResetModel();
onListChanged();
@@ -113,7 +115,9 @@ void MojangAccountList::onListChanged()
if (m_autosave)
// TODO: Alert the user if this fails.
saveList();
- emit listChanged();
+
+ // TODO: stop this getting called from setActiveAccount
+ //emit listChanged();
}