Retranslate account actions after switching language

This commit is contained in:
Kenneth Chew 2022-05-08 23:19:23 -04:00
parent f7f39854f8
commit ea9d61c21c
No known key found for this signature in database
GPG Key ID: F17D3E14A07739DA

View File

@ -238,6 +238,9 @@ public:
TranslatedAction actionREDDIT; TranslatedAction actionREDDIT;
TranslatedAction actionAbout; TranslatedAction actionAbout;
TranslatedAction actionNoAccountsAdded;
TranslatedAction actionNoDefaultAccount;
QVector<TranslatedToolButton *> all_toolbuttons; QVector<TranslatedToolButton *> all_toolbuttons;
QWidget *centralWidget = nullptr; QWidget *centralWidget = nullptr;
@ -1252,10 +1255,14 @@ void MainWindow::repopulateAccountsMenu()
if (accounts->count() <= 0) if (accounts->count() <= 0)
{ {
QAction *action = new QAction(tr("No accounts added!"), this); ui->all_actions.removeAll(&ui->actionNoAccountsAdded);
action->setEnabled(false); ui->actionNoAccountsAdded = TranslatedAction(this);
accountMenu->addAction(action); ui->actionNoAccountsAdded->setObjectName(QStringLiteral("actionNoAccountsAdded"));
ui->profileMenu->addAction(action); ui->actionNoAccountsAdded.setTextId(QT_TRANSLATE_NOOP("MainWindow", "No accounts added!"));
ui->actionNoAccountsAdded->setEnabled(false);
accountMenu->addAction(ui->actionNoAccountsAdded);
ui->profileMenu->addAction(ui->actionNoAccountsAdded);
ui->all_actions.append(&ui->actionNoAccountsAdded);
} }
else else
{ {
@ -1295,18 +1302,23 @@ void MainWindow::repopulateAccountsMenu()
accountMenu->addSeparator(); accountMenu->addSeparator();
ui->profileMenu->addSeparator(); ui->profileMenu->addSeparator();
QAction *action = new QAction(tr("No Default Account"), this); ui->all_actions.removeAll(&ui->actionNoDefaultAccount);
action->setCheckable(true); ui->actionNoDefaultAccount = TranslatedAction(this);
action->setIcon(APPLICATION->getThemedIcon("noaccount")); ui->actionNoDefaultAccount->setObjectName(QStringLiteral("actionNoDefaultAccount"));
action->setData(-1); ui->actionNoDefaultAccount.setTextId(QT_TRANSLATE_NOOP("MainWindow", "No Default Account"));
action->setShortcut(QKeySequence(tr("Ctrl+0"))); ui->actionNoDefaultAccount->setCheckable(true);
ui->actionNoDefaultAccount->setIcon(APPLICATION->getThemedIcon("noaccount"));
ui->actionNoDefaultAccount->setData(-1);
ui->actionNoDefaultAccount->setShortcut(QKeySequence(tr("Ctrl+0")));
if (!defaultAccount) { if (!defaultAccount) {
action->setChecked(true); ui->actionNoDefaultAccount->setChecked(true);
} }
accountMenu->addAction(action); accountMenu->addAction(ui->actionNoDefaultAccount);
ui->profileMenu->addAction(action); ui->profileMenu->addAction(ui->actionNoDefaultAccount);
connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount())); connect(ui->actionNoDefaultAccount, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));
ui->all_actions.append(&ui->actionNoDefaultAccount);
ui->actionNoDefaultAccount.retranslate();
accountMenu->addSeparator(); accountMenu->addSeparator();
ui->profileMenu->addSeparator(); ui->profileMenu->addSeparator();