Manager: Add a language selector in Preferences

This commit is contained in:
Alexander Babikov
2025-08-03 13:26:25 +05:00
parent c6a75fa693
commit 79f0ed89b0
8 changed files with 109 additions and 1 deletions

View File

@@ -23,6 +23,8 @@
# include "qt_updatecheckdialog.hpp"
#endif
#include "qt_about.hpp"
#include "qt_progsettings.hpp"
#include "qt_util.hpp"
#include <QLineEdit>
#include <QStringListModel>
@@ -113,6 +115,7 @@ VMManagerMainWindow(QWidget *parent)
// Inform the main view when preferences are updated
connect(this, &VMManagerMainWindow::preferencesUpdated, vmm, &VMManagerMain::onPreferencesUpdated);
connect(this, &VMManagerMainWindow::languageUpdated, vmm, &VMManagerMain::onLanguageUpdated);
}
@@ -151,6 +154,7 @@ VMManagerMainWindow::preferencesTriggered()
const auto prefs = new VMManagerPreferences();
if (prefs->exec() == QDialog::Accepted) {
emit preferencesUpdated();
updateLanguage();
}
}
@@ -164,6 +168,27 @@ VMManagerMainWindow::saveSettings() const
config->sync();
}
void
VMManagerMainWindow::updateLanguage()
{
ProgSettings::loadTranslators(QCoreApplication::instance());
ProgSettings::reloadStrings();
ui->retranslateUi(this);
setWindowTitle(tr("%1 VM Manager").arg(EMU_NAME));
emit languageUpdated();
}
void
VMManagerMainWindow::changeEvent(QEvent *event)
{
#ifdef Q_OS_WINDOWS
if (event->type() == QEvent::LanguageChange) {
QApplication::setFont(QFont(ProgSettings::getFontName(lang_id), 9));
}
#endif
QWidget::changeEvent(event);
}
void
VMManagerMainWindow::closeEvent(QCloseEvent *event)
{