11 import sys |
11 import sys |
12 |
12 |
13 from PyQt6.QtCore import QTranslator, QLocale, QLibraryInfo, QDir |
13 from PyQt6.QtCore import QTranslator, QLocale, QLibraryInfo, QDir |
14 from PyQt6.QtWidgets import QApplication |
14 from PyQt6.QtWidgets import QApplication |
15 |
15 |
16 from EricWidgets.EricApplication import EricApplication |
16 from eric7.EricWidgets.EricApplication import EricApplication |
17 |
17 |
18 import Globals |
18 from eric7 import Globals |
19 |
19 |
20 import UI.PixmapCache |
20 from eric7.EricGui import EricPixmapCache |
21 |
21 |
22 from eric7config import getConfig |
22 from eric7config import getConfig |
23 |
23 |
24 application = None |
24 application = None |
25 |
25 |
118 Module function to initialize the default mime source factory. |
118 Module function to initialize the default mime source factory. |
119 |
119 |
120 @param application reference to the application object |
120 @param application reference to the application object |
121 @type EricApplication |
121 @type EricApplication |
122 """ |
122 """ |
123 import Preferences |
123 from eric7 import Preferences |
124 |
124 |
125 defaultIconPaths = getDefaultIconPaths(application) |
125 defaultIconPaths = getDefaultIconPaths(application) |
126 iconPaths = Preferences.getIcons("Path") |
126 iconPaths = Preferences.getIcons("Path") |
127 for iconPath in iconPaths: |
127 for iconPath in iconPaths: |
128 if iconPath: |
128 if iconPath: |
129 UI.PixmapCache.addSearchPath(iconPath) |
129 EricPixmapCache.addSearchPath(iconPath) |
130 for defaultIconPath in defaultIconPaths: |
130 for defaultIconPath in defaultIconPaths: |
131 if defaultIconPath not in iconPaths: |
131 if defaultIconPath not in iconPaths: |
132 UI.PixmapCache.addSearchPath(defaultIconPath) |
132 EricPixmapCache.addSearchPath(defaultIconPath) |
133 |
133 |
134 |
134 |
135 def getDefaultIconPaths(application): |
135 def getDefaultIconPaths(application): |
136 """ |
136 """ |
137 Module function to determine the default icon paths. |
137 Module function to determine the default icon paths. |
139 @param application reference to the application object |
139 @param application reference to the application object |
140 @type EricApplication |
140 @type EricApplication |
141 @return list of default icon paths |
141 @return list of default icon paths |
142 @rtype list of str |
142 @rtype list of str |
143 """ |
143 """ |
144 import Preferences |
144 from eric7 import Preferences |
145 |
145 |
146 defaultIconsPath = Preferences.getIcons("DefaultIconsPath") |
146 defaultIconsPath = Preferences.getIcons("DefaultIconsPath") |
147 if defaultIconsPath == "automatic": |
147 if defaultIconsPath == "automatic": |
148 if application.usesDarkPalette(): |
148 if application.usesDarkPalette(): |
149 # dark desktop |
149 # dark desktop |
188 @param app reference to the application object (QApplication) |
188 @param app reference to the application object (QApplication) |
189 @param translationFiles tuple of additional translations to |
189 @param translationFiles tuple of additional translations to |
190 be loaded (tuple of strings) |
190 be loaded (tuple of strings) |
191 @return the requested locale (string) |
191 @return the requested locale (string) |
192 """ |
192 """ |
193 import Preferences |
193 from eric7 import Preferences |
194 |
194 |
195 global loaded_translators |
195 global loaded_translators |
196 |
196 |
197 translations = ( |
197 translations = ( |
198 "qt", |
198 "qt", |
274 app = EricApplication(argv) |
274 app = EricApplication(argv) |
275 application = app |
275 application = app |
276 app.setQuitOnLastWindowClosed(quitOnLastWindowClosed) |
276 app.setQuitOnLastWindowClosed(quitOnLastWindowClosed) |
277 |
277 |
278 # the following code depends upon a valid application object |
278 # the following code depends upon a valid application object |
279 import Preferences |
279 from eric7 import Preferences |
280 |
280 |
281 # set the application style sheet |
281 # set the application style sheet |
282 app.setStyleSheetFile(Preferences.getUI("StyleSheet")) |
282 app.setStyleSheetFile(Preferences.getUI("StyleSheet")) |
283 |
283 |
284 initializeResourceSearchPath(app) |
284 initializeResourceSearchPath(app) |
285 QApplication.setWindowIcon(UI.PixmapCache.getIcon("eric")) |
285 QApplication.setWindowIcon(EricPixmapCache.getIcon("eric")) |
286 |
286 |
287 qtTransDir = Preferences.getQtTranslationsDir() |
287 qtTransDir = Preferences.getQtTranslationsDir() |
288 if not qtTransDir: |
288 if not qtTransDir: |
289 qtTransDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath) |
289 qtTransDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath) |
290 loadTranslators(qtTransDir, app, ("qscintilla",)) |
290 loadTranslators(qtTransDir, app, ("qscintilla",)) |
300 if raiseIt: |
300 if raiseIt: |
301 w.raise_() |
301 w.raise_() |
302 |
302 |
303 if installErrorHandler: |
303 if installErrorHandler: |
304 # generate a graphical error handler |
304 # generate a graphical error handler |
305 from EricWidgets import EricErrorMessage |
305 from eric7.EricWidgets import EricErrorMessage |
306 |
306 |
307 eMsg = EricErrorMessage.qtHandler() |
307 eMsg = EricErrorMessage.qtHandler() |
308 eMsg.setMinimumSize(600, 400) |
308 eMsg.setMinimumSize(600, 400) |
309 |
309 |
310 return app.exec() |
310 return app.exec() |