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 EricWidgets.EricApplication import EricApplication |
38 from EricWidgets.EricApplication import EricApplication |
36 |
39 |
37 from Tools.TRSingleApplication import TRSingleApplicationClient |
40 from Tools.TRSingleApplication import TRSingleApplicationClient |
43 |
46 |
44 |
47 |
45 def createMainWidget(argv): |
48 def createMainWidget(argv): |
46 """ |
49 """ |
47 Function to create the main widget. |
50 Function to create the main widget. |
48 |
51 |
49 @param argv list of commandline parameters (list of strings) |
52 @param argv list of commandline parameters (list of strings) |
50 @return reference to the main widget (QWidget) |
53 @return reference to the main widget (QWidget) |
51 """ |
54 """ |
52 from Tools.TRPreviewer import TRPreviewer |
55 from Tools.TRPreviewer import TRPreviewer |
53 |
56 |
54 files = argv[1:] if len(argv) > 1 else [] |
57 files = argv[1:] if len(argv) > 1 else [] |
55 previewer = TRPreviewer(files, None, 'TRPreviewer') |
58 previewer = TRPreviewer(files, None, "TRPreviewer") |
56 |
59 |
57 return previewer |
60 return previewer |
58 |
61 |
59 |
62 |
60 def main(): |
63 def main(): |
61 """ |
64 """ |
62 Main entry point into the application. |
65 Main entry point into the application. |
63 """ |
66 """ |
64 global app |
67 global app |
65 |
68 |
66 from PyQt6.QtGui import QGuiApplication |
69 from PyQt6.QtGui import QGuiApplication |
|
70 |
67 QGuiApplication.setDesktopFileName("eric7_trpreviewer.desktop") |
71 QGuiApplication.setDesktopFileName("eric7_trpreviewer.desktop") |
68 |
72 |
69 options = [ |
73 options = [ |
70 ("--config=configDir", |
74 ( |
71 "use the given directory as the one containing the config files"), |
75 "--config=configDir", |
72 ("--settings=settingsDir", |
76 "use the given directory as the one containing the config files", |
73 "use the given directory to store the settings files"), |
77 ), |
|
78 ( |
|
79 "--settings=settingsDir", |
|
80 "use the given directory to store the settings files", |
|
81 ), |
74 ] |
82 ] |
75 appinfo = AppInfo.makeAppInfo(sys.argv, |
83 appinfo = AppInfo.makeAppInfo( |
76 "eric TR Previewer", |
84 sys.argv, "eric TR Previewer", "file", "TR file previewer", options |
77 "file", |
85 ) |
78 "TR file previewer", |
86 |
79 options) |
|
80 |
|
81 # set the library paths for plugins |
87 # set the library paths for plugins |
82 Startup.setLibraryPaths() |
88 Startup.setLibraryPaths() |
83 |
89 |
84 app = EricApplication(sys.argv) |
90 app = EricApplication(sys.argv) |
85 client = TRSingleApplicationClient() |
91 client = TRSingleApplicationClient() |
86 res = client.connect() |
92 res = client.connect() |
87 if res > 0: |
93 if res > 0: |
88 if len(sys.argv) > 1: |
94 if len(sys.argv) > 1: |