App: Retranslate all pages when the language is changed

This commit is contained in:
Jamie Mansfield 2022-02-22 18:23:53 +00:00 committed by Sefa Eyeoglu
parent a2c85a8531
commit dd5c4b6864
No known key found for this signature in database
GPG Key ID: C10411294912A422
54 changed files with 158 additions and 11 deletions

View File

@ -47,6 +47,8 @@ public:
{
m_container = container;
};
virtual void retranslate() { }
public:
int stackIndex = -1;
int listIndex = -1;

View File

@ -85,3 +85,8 @@ bool APIPage::apply()
applySettings();
return true;
}
void APIPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -69,6 +69,7 @@ public:
return "APIs";
}
virtual bool apply() override;
void retranslate() override;
private:
void loadSettings();

View File

@ -104,6 +104,11 @@ AccountListPage::~AccountListPage()
delete ui;
}
void AccountListPage::retranslate()
{
ui->retranslateUi(this);
}
void AccountListPage::ShowContextMenu(const QPoint& pos)
{
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));

View File

@ -78,6 +78,7 @@ public:
{
return "Getting-Started#adding-an-account";
}
void retranslate() override;
public slots:
void on_actionAddMojang_triggered();

View File

@ -49,3 +49,8 @@ void CustomCommandsPage::loadSettings()
s->get("PostExitCommand").toString()
);
}
void CustomCommandsPage::retranslate()
{
// fixme: implement
}

View File

@ -47,6 +47,7 @@ public:
return "Custom-commands";
}
bool apply() override;
void retranslate() override;
private:
void applySettings();

View File

@ -231,3 +231,8 @@ bool ExternalToolsPage::apply()
applySettings();
return true;
}
void ExternalToolsPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -54,6 +54,7 @@ public:
return "Tools";
}
virtual bool apply() override;
void retranslate() override;
private:
void loadSettings();

View File

@ -151,3 +151,8 @@ void JavaPage::checkerFinished()
{
checker.reset();
}
void JavaPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -54,6 +54,7 @@ public:
return "Java-settings";
}
bool apply() override;
void retranslate() override;
private:
void applySettings();

View File

@ -40,12 +40,3 @@ void LanguagePage::retranslate()
{
mainWidget->retranslate();
}
void LanguagePage::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange)
{
retranslate();
}
QWidget::changeEvent(event);
}

View File

@ -48,12 +48,11 @@ public:
}
bool apply() override;
void changeEvent(QEvent * ) override;
void retranslate() override;
private:
void applySettings();
void loadSettings();
void retranslate();
private:
LanguageSelectionWidget *mainWidget;

View File

@ -441,3 +441,8 @@ void LauncherPage::refreshFontPreview()
workCursor.insertBlock();
}
}
void LauncherPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -57,6 +57,7 @@ public:
return "Launcher-settings";
}
bool apply() override;
void retranslate() override;
private:
void applySettings();

View File

@ -94,3 +94,8 @@ void MinecraftPage::loadSettings()
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
}
void MinecraftPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -54,6 +54,7 @@ public:
return "Minecraft-settings";
}
bool apply() override;
void retranslate() override;
private:
void updateCheckboxStuff();

View File

@ -104,3 +104,8 @@ void ProxyPage::loadSettings()
ui->proxyUserEdit->setText(s->get("ProxyUser").toString());
ui->proxyPassEdit->setText(s->get("ProxyPass").toString());
}
void ProxyPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -51,6 +51,7 @@ public:
return "Proxy-settings";
}
bool apply() override;
void retranslate() override;
private:
void updateCheckboxStuff();

View File

@ -35,3 +35,8 @@ void GameOptionsPage::closedImpl()
{
// m_model->unobserve();
}
void GameOptionsPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -56,6 +56,7 @@ public:
{
return "Game-Options-management";
}
void retranslate() override;
private: // data
Ui::GameOptionsPage *ui = nullptr;

View File

@ -339,3 +339,8 @@ void InstanceSettingsPage::checkerFinished()
{
checker.reset();
}
void InstanceSettingsPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -55,6 +55,7 @@ public:
return "Instance-settings";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
private slots:
void on_javaDetectBtn_clicked();

View File

@ -328,3 +328,8 @@ void LogPage::findActivated()
ui->searchBar->selectAll();
}
}
void LogPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -54,6 +54,7 @@ public:
return "Minecraft-Logs";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
private slots:
void on_btnPaste_clicked();

View File

@ -252,6 +252,11 @@ bool ModFolderPage::shouldDisplay() const
return true;
}
void ModFolderPage::retranslate()
{
ui->retranslateUi(this);
}
bool CoreModFolderPage::shouldDisplay() const
{
if (ModFolderPage::shouldDisplay())

View File

@ -66,6 +66,7 @@ public:
return m_helpName;
}
virtual bool shouldDisplay() const override;
void retranslate() override;
virtual void openedImpl() override;
virtual void closedImpl() override;

View File

@ -19,3 +19,8 @@ bool NotesPage::apply()
m_inst->setNotes(ui->noteEditor->toPlainText());
return true;
}
void NotesPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@ -53,6 +53,7 @@ public:
{
return "Notes";
}
void retranslate() override;
private:
Ui::NotesPage *ui;

View File

@ -55,6 +55,11 @@ OtherLogsPage::~OtherLogsPage()
delete ui;
}
void OtherLogsPage::retranslate()
{
ui->retranslateUi(this);
}
void OtherLogsPage::openedImpl()
{
m_watcher->enable();

View File

@ -52,6 +52,8 @@ public:
{
return "Minecraft-Logs";
}
void retranslate() override;
void openedImpl() override;
void closedImpl() override;

View File

@ -270,6 +270,11 @@ bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt)
return QWidget::eventFilter(obj, evt);
}
void ScreenshotsPage::retranslate()
{
ui->retranslateUi(this);
}
ScreenshotsPage::~ScreenshotsPage()
{
delete ui;

View File

@ -67,6 +67,7 @@ public:
{
return !m_uploadActive;
}
void retranslate() override;
protected:
QMenu * createPopupMenu() override;

View File

@ -600,6 +600,11 @@ ServersPage::~ServersPage()
delete ui;
}
void ServersPage::retranslate()
{
ui->retranslateUi(this);
}
void ServersPage::ShowContextMenu(const QPoint& pos)
{
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));

View File

@ -57,6 +57,7 @@ public:
{
return "Servers-management";
}
void retranslate() override;
protected:
QMenu * createPopupMenu() override;

View File

@ -99,6 +99,11 @@ bool VersionPage::shouldDisplay() const
return true;
}
void VersionPage::retranslate()
{
ui->retranslateUi(this);
}
QMenu * VersionPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();

View File

@ -47,6 +47,7 @@ public:
return "Instance-Version";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
private slots:
void on_actionChange_version_triggered();

View File

@ -122,6 +122,11 @@ bool WorldListPage::shouldDisplay() const
return true;
}
void WorldListPage::retranslate()
{
ui->retranslateUi(this);
}
bool WorldListPage::worldListFilter(QKeyEvent *keyEvent)
{
switch (keyEvent->key())

View File

@ -57,6 +57,7 @@ public:
return "Worlds";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
virtual void openedImpl() override;
virtual void closedImpl() override;

View File

@ -50,6 +50,11 @@ bool ImportPage::shouldDisplay() const
return true;
}
void ImportPage::retranslate()
{
ui->retranslateUi(this);
}
void ImportPage::openedImpl()
{
updateState();

View File

@ -52,6 +52,7 @@ public:
return "Zip-import";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
void setUrl(const QString & url);
void openedImpl() override;

View File

@ -74,6 +74,11 @@ bool VanillaPage::shouldDisplay() const
return true;
}
void VanillaPage::retranslate()
{
ui->retranslateUi(this);
}
BaseVersionPtr VanillaPage::selectedVersion() const
{
return m_selectedVersion;

View File

@ -52,6 +52,8 @@ public:
return "Vanilla-platform";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;
BaseVersionPtr selectedVersion() const;

View File

@ -65,6 +65,11 @@ bool AtlPage::shouldDisplay() const
return true;
}
void AtlPage::retranslate()
{
ui->retranslateUi(this);
}
void AtlPage::openedImpl()
{
if(!initialized)

View File

@ -57,6 +57,7 @@ public:
return "ATL-platform";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;

View File

@ -57,6 +57,11 @@ bool FlamePage::shouldDisplay() const
return true;
}
void FlamePage::retranslate()
{
ui->retranslateUi(this);
}
void FlamePage::openedImpl()
{
suggestCurrent();

View File

@ -57,6 +57,7 @@ public:
return "Flame-platform";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;

View File

@ -78,6 +78,11 @@ bool FtbPage::shouldDisplay() const
return true;
}
void FtbPage::retranslate()
{
ui->retranslateUi(this);
}
void FtbPage::openedImpl()
{
if(!initialised)

View File

@ -55,6 +55,7 @@ public:
return "FTB-platform";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;

View File

@ -122,6 +122,11 @@ void Page::openedImpl()
suggestCurrent();
}
void Page::retranslate()
{
ui->retranslateUi(this);
}
void Page::suggestCurrent()
{
if(!isOpened)

View File

@ -66,6 +66,7 @@ public:
}
bool shouldDisplay() const override;
void openedImpl() override;
void retranslate() override;
private:
void suggestCurrent();

View File

@ -61,6 +61,11 @@ bool TechnicPage::shouldDisplay() const
return true;
}
void TechnicPage::retranslate()
{
ui->retranslateUi(this);
}
void TechnicPage::openedImpl()
{
suggestCurrent();

View File

@ -57,6 +57,7 @@ public:
return "Technic-platform";
}
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;

View File

@ -166,6 +166,9 @@ void PageContainer::retranslate()
{
if (m_currentPage)
m_header->setText(m_currentPage->displayName());
for (auto page : m_model->pages())
page->retranslate();
}
void PageContainer::addButtons(QWidget *buttons)