fix main toolbar accounts toolbutton name
previously it was not using the selected account name when opening the launcher and i also added an action group to the menu items so it uses radio buttons instead of checkboxes :p Signed-off-by: leo78913 <leo3758@riseup.net>
This commit is contained in:
parent
7537ea1ef5
commit
d59a06344a
@ -199,7 +199,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
helpMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
auto accountMenuButton = dynamic_cast<QToolButton*>(ui->mainToolBar->widgetForAction(ui->actionAccountsButton));
|
||||
ui->actionAccountsButton->setMenu(ui->accountsMenu);
|
||||
accountMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||
}
|
||||
|
||||
@ -414,15 +413,6 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event)
|
||||
|
||||
void MainWindow::retranslateUi()
|
||||
{
|
||||
auto accounts = APPLICATION->accounts();
|
||||
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
||||
if(defaultAccount) {
|
||||
auto profileLabel = profileInUseFilter(defaultAccount->profileName(), defaultAccount->isInUse());
|
||||
ui->actionAccountsButton->setText(profileLabel);
|
||||
}
|
||||
else {
|
||||
ui->actionAccountsButton->setText(tr("Accounts"));
|
||||
}
|
||||
|
||||
if (m_selectedInstance) {
|
||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||
@ -432,6 +422,12 @@ void MainWindow::retranslateUi()
|
||||
|
||||
ui->retranslateUi(this);
|
||||
|
||||
MinecraftAccountPtr defaultAccount = APPLICATION->accounts()->defaultAccount();
|
||||
if(defaultAccount) {
|
||||
auto profileLabel = profileInUseFilter(defaultAccount->profileName(), defaultAccount->isInUse());
|
||||
ui->actionAccountsButton->setText(profileLabel);
|
||||
}
|
||||
|
||||
changeIconButton->setToolTip(ui->actionChangeInstIcon->toolTip());
|
||||
renameButton->setToolTip(ui->actionRenameInstance->toolTip());
|
||||
|
||||
@ -673,6 +669,15 @@ void MainWindow::repopulateAccountsMenu()
|
||||
{
|
||||
ui->accountsMenu->clear();
|
||||
|
||||
// NOTE: this is done so the accounts button text is not set to the accounts menu title
|
||||
QMenu *accountsButtonMenu = ui->actionAccountsButton->menu();
|
||||
if (accountsButtonMenu) {
|
||||
accountsButtonMenu->clear();
|
||||
} else {
|
||||
accountsButtonMenu = new QMenu(this);
|
||||
ui->actionAccountsButton->setMenu(accountsButtonMenu);
|
||||
}
|
||||
|
||||
auto accounts = APPLICATION->accounts();
|
||||
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
||||
|
||||
@ -687,6 +692,8 @@ void MainWindow::repopulateAccountsMenu()
|
||||
}
|
||||
}
|
||||
|
||||
QActionGroup* accountsGroup = new QActionGroup(this);
|
||||
|
||||
if (accounts->count() <= 0)
|
||||
{
|
||||
ui->actionNoAccountsAdded->setEnabled(false);
|
||||
@ -702,6 +709,7 @@ void MainWindow::repopulateAccountsMenu()
|
||||
QAction *action = new QAction(profileLabel, this);
|
||||
action->setData(i);
|
||||
action->setCheckable(true);
|
||||
action->setActionGroup(accountsGroup);
|
||||
if (defaultAccount == account)
|
||||
{
|
||||
action->setChecked(true);
|
||||
@ -730,6 +738,7 @@ void MainWindow::repopulateAccountsMenu()
|
||||
|
||||
ui->actionNoDefaultAccount->setData(-1);
|
||||
ui->actionNoDefaultAccount->setChecked(!defaultAccount);
|
||||
ui->actionNoDefaultAccount->setActionGroup(accountsGroup);
|
||||
|
||||
ui->accountsMenu->addAction(ui->actionNoDefaultAccount);
|
||||
|
||||
@ -737,6 +746,8 @@ void MainWindow::repopulateAccountsMenu()
|
||||
|
||||
ui->accountsMenu->addSeparator();
|
||||
ui->accountsMenu->addAction(ui->actionManageAccounts);
|
||||
|
||||
accountsButtonMenu->addActions(ui->accountsMenu->actions());
|
||||
}
|
||||
|
||||
void MainWindow::updatesAllowedChanged(bool allowed)
|
||||
|
Loading…
Reference in New Issue
Block a user