Mon, 31 Oct 2022 13:52:10 +0100
Fixed an issue importing the eric7config module.
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the Interface configuration page (variant for web browser). |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
10 | import glob |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
11 | import os |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
12 | |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
13 | from PyQt6.QtCore import QTranslator |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
14 | from PyQt6.QtWidgets import QStyleFactory |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
16 | from eric7.EricWidgets.EricPathPicker import EricPathPickerModes |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
17 | from eric7.EricWidgets.EricApplication import ericApp |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | from .ConfigurationPageBase import ConfigurationPageBase |
8876
2001accf55b3
Renamed the generic interface configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8875
diff
changeset
|
20 | from .Ui_InterfaceLightPage import Ui_InterfaceLightPage |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
22 | from eric7 import Preferences, Utilities |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
23 | |
9448
ea215f7afab3
Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
24 | from eric7.Globals import getConfig |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
8876
2001accf55b3
Renamed the generic interface configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8875
diff
changeset
|
27 | class InterfaceLightPage(ConfigurationPageBase, Ui_InterfaceLightPage): |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
8876
2001accf55b3
Renamed the generic interface configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8875
diff
changeset
|
29 | Class implementing the Interface configuration page (variant for generic |
2001accf55b3
Renamed the generic interface configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8875
diff
changeset
|
30 | use). |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
32 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | def __init__(self): |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Constructor |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
37 | super().__init__() |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.setupUi(self) |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.setObjectName("InterfacePage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
41 | self.styleSheetPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | self.styleSheetPicker.setFilters( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | "Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | "All files (*)" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | ) |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
48 | self.styleSheetPicker.setDefaultDirectory(getConfig("ericStylesDir")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
50 | styleIconsPath = ericApp().getStyleIconsPath() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | self.styleIconsPathPicker.setMode(EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
52 | self.styleIconsPathPicker.setDefaultDirectory(styleIconsPath) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | # set initial values |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | self.__populateStyleCombo() |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
56 | self.__populateLanguageCombo() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | self.styleSheetPicker.setText(Preferences.getUI("StyleSheet")) |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
59 | self.styleIconsPathPicker.setText(Preferences.getUI("StyleIconsPath")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | def save(self): |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Public slot to save the Interface configuration. |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | # save the style settings |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | styleIndex = self.styleComboBox.currentIndex() |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | style = self.styleComboBox.itemData(styleIndex) |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | Preferences.setUI("Style", style) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | Preferences.setUI("StyleSheet", self.styleSheetPicker.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
70 | Preferences.setUI("StyleIconsPath", self.styleIconsPathPicker.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
72 | # save the language settings |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
73 | uiLanguageIndex = self.languageComboBox.currentIndex() |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
74 | uiLanguage = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | self.languageComboBox.itemData(uiLanguageIndex) if uiLanguageIndex else None |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
76 | ) |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
77 | Preferences.setUILanguage(uiLanguage) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
78 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | def __populateStyleCombo(self): |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | Private method to populate the style combo box. |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | curStyle = Preferences.getUI("Style") |
8761
f05818ae6431
Corrected some code style issues detected by the enhanced comprehensions check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
84 | styles = sorted(QStyleFactory.keys()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
85 | self.styleComboBox.addItem(self.tr("System"), "System") |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | for style in styles: |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | self.styleComboBox.addItem(style, style) |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | currentIndex = self.styleComboBox.findData(curStyle) |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | if currentIndex == -1: |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | currentIndex = 0 |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | self.styleComboBox.setCurrentIndex(currentIndex) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
92 | |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
93 | def __populateLanguageCombo(self): |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
94 | """ |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
95 | Private method to initialize the language combo box. |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
96 | """ |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
97 | self.languageComboBox.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
99 | fnlist = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
100 | glob.glob("eric7_*.qm") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
101 | + glob.glob(os.path.join(getConfig("ericTranslationsDir"), "eric7_*.qm")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
102 | + glob.glob(os.path.join(Utilities.getConfigDir(), "eric7_*.qm")) |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
103 | ) |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
104 | locales = {} |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
105 | for fn in fnlist: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
106 | locale = os.path.basename(fn)[6:-3] |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
107 | if locale not in locales: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
108 | translator = QTranslator() |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
109 | translator.load(fn) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
110 | locales[locale] = translator.translate( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
111 | "InterfacePage", "English", "Translate this with your language" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
112 | ) + " ({0})".format(locale) |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
113 | localeList = sorted(locales.keys()) |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
114 | try: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
115 | uiLanguage = Preferences.getUILanguage() |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
116 | if uiLanguage == "None" or uiLanguage is None: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
117 | currentIndex = 0 |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
118 | elif uiLanguage == "System": |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
119 | currentIndex = 1 |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
120 | else: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
121 | currentIndex = localeList.index(uiLanguage) + 2 |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
122 | except ValueError: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
123 | currentIndex = 0 |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
124 | self.languageComboBox.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
125 | |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
126 | self.languageComboBox.addItem("English (default)", "None") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
127 | self.languageComboBox.addItem(self.tr("System"), "System") |
8875
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
128 | for locale in localeList: |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
129 | self.languageComboBox.addItem(locales[locale], locale) |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
130 | self.languageComboBox.setCurrentIndex(currentIndex) |
67c3ea933787
Modified HexEditor color usage such, that it is based on the configured/set palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8761
diff
changeset
|
131 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | def create(dlg): |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | """ |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | Module function to create the configuration page. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | @param dlg reference to the configuration dialog |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | @return reference to the instantiated page (ConfigurationPageBase) |
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | """ |
8876
2001accf55b3
Renamed the generic interface configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8875
diff
changeset
|
140 | page = InterfaceLightPage() |
7433
386487a96672
WebBrowserInterfacePage: added the missing interface configuration page for the web browser (part 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | return page |