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 HexEdit.HexEditMainWindow import HexEditMainWindow |
50 from HexEdit.HexEditMainWindow import HexEditMainWindow |
48 |
51 |
49 try: |
52 try: |
50 fileName = argv[1] |
53 fileName = argv[1] |
51 except IndexError: |
54 except IndexError: |
52 fileName = "" |
55 fileName = "" |
53 |
56 |
54 editor = HexEditMainWindow(fileName, None) |
57 editor = HexEditMainWindow(fileName, None) |
55 return editor |
58 return editor |
56 |
59 |
57 |
60 |
58 def main(): |
61 def main(): |
59 """ |
62 """ |
60 Main entry point into the application. |
63 Main entry point into the application. |
61 """ |
64 """ |
62 from PyQt6.QtGui import QGuiApplication |
65 from PyQt6.QtGui import QGuiApplication |
|
66 |
63 QGuiApplication.setDesktopFileName("eric7_hexeditor.desktop") |
67 QGuiApplication.setDesktopFileName("eric7_hexeditor.desktop") |
64 |
68 |
65 options = [ |
69 options = [ |
66 ("--config=configDir", |
70 ( |
67 "use the given directory as the one containing the config files"), |
71 "--config=configDir", |
68 ("--settings=settingsDir", |
72 "use the given directory as the one containing the config files", |
69 "use the given directory to store the settings files"), |
73 ), |
70 ("", "name of file to edit") |
74 ( |
|
75 "--settings=settingsDir", |
|
76 "use the given directory to store the settings files", |
|
77 ), |
|
78 ("", "name of file to edit"), |
71 ] |
79 ] |
72 appinfo = AppInfo.makeAppInfo(sys.argv, |
80 appinfo = AppInfo.makeAppInfo( |
73 "eric Hex Editor", |
81 sys.argv, "eric Hex Editor", "", "Little tool to edit binary files.", options |
74 "", |
82 ) |
75 "Little tool to edit binary files.", |
83 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget) |
76 options) |
|
77 res = Startup.simpleAppStartup(sys.argv, |
|
78 appinfo, |
|
79 createMainWidget) |
|
80 sys.exit(res) |
84 sys.exit(res) |
81 |
85 |
82 if __name__ == '__main__': |
86 |
|
87 if __name__ == "__main__": |
83 main() |
88 main() |