Englisch hinzugefügt
This commit is contained in:
@@ -135,6 +135,37 @@ void MainWindow::setupMenuBar()
|
||||
m_actDarkMode->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_D);
|
||||
connect(m_actDarkMode, &QAction::toggled, this, &MainWindow::onToggleDarkMode);
|
||||
|
||||
mAnsicht->addSeparator();
|
||||
|
||||
// Sprachauswahl
|
||||
QMenu *mSprache = mAnsicht->addMenu(tr("Sprache"));
|
||||
m_langGroup = new QActionGroup(this);
|
||||
m_langGroup->setExclusive(true);
|
||||
|
||||
const QSettings langSettings(QSettings::IniFormat, QSettings::UserScope,
|
||||
"BareCode", "BareCode");
|
||||
const QString currentLocale = langSettings.value("language/locale",
|
||||
QLocale::system().name()).toString();
|
||||
|
||||
struct LangEntry { QString locale; QString label; };
|
||||
const QList<LangEntry> languages = {
|
||||
{ "de", "Deutsch" },
|
||||
{ "en", "English" },
|
||||
};
|
||||
|
||||
for (const LangEntry &lang : languages)
|
||||
{
|
||||
QAction *act = mSprache->addAction(lang.label);
|
||||
act->setCheckable(true);
|
||||
act->setData(lang.locale);
|
||||
act->setChecked(currentLocale.startsWith(lang.locale));
|
||||
m_langGroup->addAction(act);
|
||||
connect(act, &QAction::triggered, this, [this, lang]()
|
||||
{
|
||||
onLanguageChanged(lang.locale);
|
||||
});
|
||||
}
|
||||
|
||||
// ---- Hilfe ----
|
||||
QMenu *mHilfe = menuBar()->addMenu(tr("&Hilfe"));
|
||||
m_actAbout = mHilfe->addAction(tr("&Über BareCode…"), this, &MainWindow::onAbout);
|
||||
@@ -277,6 +308,17 @@ void MainWindow::onToggleDarkMode(bool checked)
|
||||
m_settings->setDarkMode(checked);
|
||||
}
|
||||
|
||||
void MainWindow::onLanguageChanged(const QString &locale)
|
||||
{
|
||||
QSettings s(QSettings::IniFormat, QSettings::UserScope, "BareCode", "BareCode");
|
||||
s.setValue("language/locale", locale);
|
||||
|
||||
QMessageBox::information(this,
|
||||
tr("Sprache geändert"),
|
||||
tr("Die Sprache wird beim nächsten Start von BareCode aktiv.")
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Slots – Hilfe
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user