Merge branch 'dev' into norwegian_locale

This commit is contained in:
Veronica K. B. Olsen
2021-02-17 10:06:12 +01:00
7 changed files with 80 additions and 7 deletions
+19
View File
@@ -393,6 +393,25 @@ class Config:
return
def listLanguages(self):
"""List localisation files in the i18n folder. The default GUI
language 'en_GB' is British English.
"""
langList = {
"en_GB": QLocale("en_GB").nativeLanguageName().title()
}
for qmFile in os.listdir(self.nwLangPath):
if not os.path.isfile(os.path.join(self.nwLangPath, qmFile)):
continue
if not qmFile.startswith("nw_") or not qmFile.endswith(".qm"):
continue
qmLang = qmFile[3:-3]
qmName = QLocale(qmLang).nativeLanguageName().title()
if qmLang and qmName:
langList[qmLang] = qmName
return sorted(langList.items(), key=lambda x: x[0])
def loadConfig(self):
"""Load preferences from file and replace default settings.
"""
+22 -2
View File
@@ -137,10 +137,27 @@ class GuiPreferencesGeneral(QWidget):
# Look and Feel
# =============
self.mainForm.addGroupLabel(self.tr("Look and Feel"))
minWidth = self.mainConf.pxInt(200)
## Select Locale
self.guiLang = QComboBox()
self.guiLang.setMinimumWidth(minWidth)
self.theLangs = self.mainConf.listLanguages()
for lang, langName in self.theLangs:
self.guiLang.addItem(langName, lang)
langIdx = self.guiLang.findData(self.mainConf.guiLang)
if langIdx != -1:
self.guiLang.setCurrentIndex(langIdx)
self.mainForm.addRow(
self.tr("Main GUI language"),
self.guiLang,
self.tr("Changing this requires restarting novelWriter.")
)
## Select Theme
self.guiTheme = QComboBox()
self.guiTheme.setMinimumWidth(self.mainConf.pxInt(200))
self.guiTheme.setMinimumWidth(minWidth)
self.theThemes = self.theTheme.listThemes()
for themeDir, themeName in self.theThemes:
self.guiTheme.addItem(themeName, themeDir)
@@ -156,7 +173,7 @@ class GuiPreferencesGeneral(QWidget):
## Select Icon Theme
self.guiIcons = QComboBox()
self.guiIcons.setMinimumWidth(self.mainConf.pxInt(200))
self.guiIcons.setMinimumWidth(minWidth)
self.theIcons = self.theTheme.theIcons.listThemes()
for iconDir, iconName in self.theIcons:
self.guiIcons.addItem(iconName, iconDir)
@@ -240,6 +257,7 @@ class GuiPreferencesGeneral(QWidget):
def saveValues(self):
"""Save the values set for this tab.
"""
guiLang = self.guiLang.currentData()
guiTheme = self.guiTheme.currentData()
guiIcons = self.guiIcons.currentData()
guiDark = self.guiDark.isChecked()
@@ -248,12 +266,14 @@ class GuiPreferencesGeneral(QWidget):
# Check if restart is needed
needsRestart = False
needsRestart |= self.mainConf.guiLang != guiLang
needsRestart |= self.mainConf.guiTheme != guiTheme
needsRestart |= self.mainConf.guiIcons != guiIcons
needsRestart |= self.mainConf.guiDark != guiDark
needsRestart |= self.mainConf.guiFont != guiFont
needsRestart |= self.mainConf.guiFontSize != guiFontSize
self.mainConf.guiLang = guiLang
self.mainConf.guiTheme = guiTheme
self.mainConf.guiIcons = guiIcons
self.mainConf.guiDark = guiDark