18 sys.path.insert(1, os.path.dirname(__file__)) |
18 sys.path.insert(1, os.path.dirname(__file__)) |
19 |
19 |
20 for arg in sys.argv[:]: |
20 for arg in sys.argv[:]: |
21 if arg.startswith("--config="): |
21 if arg.startswith("--config="): |
22 import Globals |
22 import Globals |
|
23 |
23 configDir = arg.replace("--config=", "") |
24 configDir = arg.replace("--config=", "") |
24 Globals.setConfigDir(configDir) |
25 Globals.setConfigDir(configDir) |
25 sys.argv.remove(arg) |
26 sys.argv.remove(arg) |
26 elif arg.startswith("--settings="): |
27 elif arg.startswith("--settings="): |
27 from PyQt6.QtCore import QSettings |
28 from PyQt6.QtCore import QSettings |
|
29 |
28 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
30 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
29 if not os.path.isdir(settingsDir): |
31 if not os.path.isdir(settingsDir): |
30 os.makedirs(settingsDir) |
32 os.makedirs(settingsDir) |
31 QSettings.setPath( |
33 QSettings.setPath( |
32 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir) |
34 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir |
|
35 ) |
33 sys.argv.remove(arg) |
36 sys.argv.remove(arg) |
34 |
37 |
35 from Globals import AppInfo |
38 from Globals import AppInfo |
36 |
39 |
37 from Toolbox import Startup |
40 from Toolbox import Startup |
38 |
41 |
39 |
42 |
40 def createMainWidget(argv): |
43 def createMainWidget(argv): |
41 """ |
44 """ |
42 Function to create the main widget. |
45 Function to create the main widget. |
43 |
46 |
44 @param argv list of commandline parameters (list of strings) |
47 @param argv list of commandline parameters (list of strings) |
45 @return reference to the main widget (QWidget) |
48 @return reference to the main widget (QWidget) |
46 """ |
49 """ |
47 from Tools.UIPreviewer import UIPreviewer |
50 from Tools.UIPreviewer import UIPreviewer |
48 |
51 |
49 fn = argv[1] if len(argv) > 1 else None |
52 fn = argv[1] if len(argv) > 1 else None |
50 previewer = UIPreviewer(fn, None, 'UIPreviewer') |
53 previewer = UIPreviewer(fn, None, "UIPreviewer") |
51 |
54 |
52 return previewer |
55 return previewer |
53 |
56 |
54 |
57 |
55 def main(): |
58 def main(): |
56 """ |
59 """ |
57 Main entry point into the application. |
60 Main entry point into the application. |
58 """ |
61 """ |
59 from PyQt6.QtGui import QGuiApplication |
62 from PyQt6.QtGui import QGuiApplication |
|
63 |
60 QGuiApplication.setDesktopFileName("eric7_uipreviewer.desktop") |
64 QGuiApplication.setDesktopFileName("eric7_uipreviewer.desktop") |
61 |
65 |
62 options = [ |
66 options = [ |
63 ("--config=configDir", |
67 ( |
64 "use the given directory as the one containing the config files"), |
68 "--config=configDir", |
65 ("--settings=settingsDir", |
69 "use the given directory as the one containing the config files", |
66 "use the given directory to store the settings files"), |
70 ), |
|
71 ( |
|
72 "--settings=settingsDir", |
|
73 "use the given directory to store the settings files", |
|
74 ), |
67 ] |
75 ] |
68 appinfo = AppInfo.makeAppInfo(sys.argv, |
76 appinfo = AppInfo.makeAppInfo( |
69 "eric UI Previewer", |
77 sys.argv, "eric UI Previewer", "file", "UI file previewer", options |
70 "file", |
78 ) |
71 "UI file previewer", |
79 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget) |
72 options) |
|
73 res = Startup.simpleAppStartup(sys.argv, |
|
74 appinfo, |
|
75 createMainWidget) |
|
76 sys.exit(res) |
80 sys.exit(res) |
77 |
81 |
78 if __name__ == '__main__': |
82 |
|
83 if __name__ == "__main__": |
79 main() |
84 main() |