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