summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorSky <git@bunnies.cc>2013-11-27 23:39:36 +0000
committerSky <git@bunnies.cc>2013-11-27 23:39:36 +0000
commit191e850cf14666302c3338d69073d1f417925a45 (patch)
treeb1e7c2ddc985813b3b795a7eefd51d37a066fe59 /gui
parentd32cb1c95d5c1a50c322085cdfe4bf3f991431e7 (diff)
downloadMultiMC-191e850cf14666302c3338d69073d1f417925a45.tar
MultiMC-191e850cf14666302c3338d69073d1f417925a45.tar.gz
MultiMC-191e850cf14666302c3338d69073d1f417925a45.tar.lz
MultiMC-191e850cf14666302c3338d69073d1f417925a45.tar.xz
MultiMC-191e850cf14666302c3338d69073d1f417925a45.zip
Add support for "no default account"
Diffstat (limited to 'gui')
-rw-r--r--gui/MainWindow.cpp30
-rw-r--r--gui/dialogs/AccountListDialog.cpp2
2 files changed, 24 insertions, 8 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()