summaryrefslogtreecommitdiffstats
path: root/gui/dialogs/AccountListDialog.cpp
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-27 16:14:18 -0600
committerAndrew <forkk@forkk.net>2013-11-27 16:14:18 -0600
commita4c5f0135ef8e3671f54cf56b1aa8766ee4b4a20 (patch)
treee6b379e6a49e4dabb48ed216f0468a8daa276dac /gui/dialogs/AccountListDialog.cpp
parentd794a4d0bfac0341c15bd5273e8dc81fe82531ef (diff)
downloadMultiMC-a4c5f0135ef8e3671f54cf56b1aa8766ee4b4a20.tar
MultiMC-a4c5f0135ef8e3671f54cf56b1aa8766ee4b4a20.tar.gz
MultiMC-a4c5f0135ef8e3671f54cf56b1aa8766ee4b4a20.tar.lz
MultiMC-a4c5f0135ef8e3671f54cf56b1aa8766ee4b4a20.tar.xz
MultiMC-a4c5f0135ef8e3671f54cf56b1aa8766ee4b4a20.zip
Allow setting no default account
This allows the user to select an account to use every time they launch an instance.
Diffstat (limited to 'gui/dialogs/AccountListDialog.cpp')
-rw-r--r--gui/dialogs/AccountListDialog.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index ea6861c6..5feed13d 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -25,6 +25,7 @@
#include <gui/dialogs/LoginDialog.h>
#include <gui/dialogs/ProgressDialog.h>
+#include <gui/dialogs/AccountSelectDialog.h>
#include <MultiMC.h>
@@ -37,6 +38,14 @@ AccountListDialog::AccountListDialog(QWidget *parent) :
m_accounts = MMC->accounts();
// TODO: Make the "Active?" column show checkboxes or radio buttons.
ui->listView->setModel(m_accounts.get());
+
+ QItemSelectionModel* selectionModel = ui->listView->selectionModel();
+ connect(selectionModel, &QItemSelectionModel::selectionChanged,
+ [this] (const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); });
+ connect(m_accounts.get(), &MojangAccountList::listChanged,
+ [this] () { updateButtonStates(); });
+
+ updateButtonStates();
}
AccountListDialog::~AccountListDialog()
@@ -67,7 +76,7 @@ void AccountListDialog::on_editAccountBtn_clicked()
// TODO
}
-void AccountListDialog::on_setActiveBtn_clicked()
+void AccountListDialog::on_setDefaultBtn_clicked()
{
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
if (selection.size() > 0)
@@ -80,11 +89,28 @@ void AccountListDialog::on_setActiveBtn_clicked()
}
}
+void AccountListDialog::on_noDefaultBtn_clicked()
+{
+ m_accounts->setActiveAccount("");
+}
+
void AccountListDialog::on_closeBtnBox_rejected()
{
close();
}
+void AccountListDialog::updateButtonStates()
+{
+ // If there is no selection, disable buttons that require something selected.
+ QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
+
+ ui->rmAccountBtn->setEnabled(selection.size() > 0);
+ ui->editAccountBtn->setEnabled(selection.size() > 0);
+ ui->setDefaultBtn->setEnabled(selection.size() > 0);
+
+ ui->noDefaultBtn->setDown(m_accounts->activeAccount().get() == nullptr);
+}
+
void AccountListDialog::doLogin(const QString& errMsg)
{
// TODO: We can use the login dialog for this for now, but we'll have to make something better for it eventually.