mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
Qt: Enable switching of languages without restarting app
This commit is contained in:
parent
47f85dc453
commit
35bb20e586
|
@ -970,8 +970,8 @@ void MainWindow::setupAdditionalUi()
|
|||
connect(action, &QAction::triggered, [this, action]() {
|
||||
const QString new_language = action->data().toString();
|
||||
m_host_interface->SetStringSettingValue("Main", "Language", new_language.toUtf8().constData());
|
||||
QMessageBox::information(this, tr("DuckStation"),
|
||||
tr("Language changed. Please restart the application to apply."));
|
||||
m_host_interface->reinstallTranslator();
|
||||
recreate();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,20 @@ void QtHostInterface::installTranslator()
|
|||
}
|
||||
|
||||
Log_InfoPrintf("Loaded translation file for language '%s'", language.c_str());
|
||||
qApp->installTranslator(translator.release());
|
||||
qApp->installTranslator(translator.get());
|
||||
m_translators.push_back(translator.release());
|
||||
}
|
||||
|
||||
void QtHostInterface::reinstallTranslator()
|
||||
{
|
||||
for (QTranslator* translator : m_translators)
|
||||
{
|
||||
qApp->removeTranslator(translator);
|
||||
translator->deleteLater();
|
||||
}
|
||||
m_translators.clear();
|
||||
|
||||
installTranslator();
|
||||
}
|
||||
|
||||
void QtHostInterface::ReportError(const char* message)
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
void setMainWindow(MainWindow* window);
|
||||
HostDisplay* createHostDisplay();
|
||||
void connectDisplaySignals(QtDisplayWidget* widget);
|
||||
void reinstallTranslator();
|
||||
|
||||
void populateLoadStateMenu(const char* game_code, QMenu* menu);
|
||||
void populateSaveStateMenu(const char* game_code, QMenu* menu);
|
||||
|
@ -285,6 +286,7 @@ private:
|
|||
|
||||
QTimer* m_background_controller_polling_timer = nullptr;
|
||||
std::unique_ptr<QTimer> m_settings_save_timer;
|
||||
std::vector<QTranslator*> m_translators;
|
||||
|
||||
bool m_is_rendering_to_main = false;
|
||||
bool m_is_fullscreen = false;
|
||||
|
|
Loading…
Reference in a new issue