|
1 #!/usr/bin/env python3 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 eric Tray. |
|
9 |
|
10 This is the main Python script that performs the necessary initialization |
|
11 of the system-tray application. This acts as a quickstarter by providing a |
|
12 context menu to start the eric IDE and the eric tools. |
|
13 """ |
|
14 |
|
15 import sys |
|
16 import os |
|
17 |
|
18 SettingsDir = None |
|
19 |
|
20 sys.path.insert(1, os.path.dirname(__file__)) |
|
21 |
|
22 for arg in sys.argv[:]: |
|
23 if arg.startswith("--config="): |
|
24 import Globals |
|
25 configDir = arg.replace("--config=", "") |
|
26 Globals.setConfigDir(configDir) |
|
27 sys.argv.remove(arg) |
|
28 elif arg.startswith("--settings="): |
|
29 from PyQt6.QtCore import QSettings |
|
30 SettingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
|
31 if not os.path.isdir(SettingsDir): |
|
32 os.makedirs(SettingsDir) |
|
33 QSettings.setPath( |
|
34 QSettings.Format.IniFormat, QSettings.Scope.UserScope, SettingsDir) |
|
35 sys.argv.remove(arg) |
|
36 |
|
37 from Globals import AppInfo |
|
38 |
|
39 from Toolbox import Startup |
|
40 |
|
41 |
|
42 def createMainWidget(argv): |
|
43 """ |
|
44 Function to create the main widget. |
|
45 |
|
46 @param argv list of commandline parameters (list of strings) |
|
47 @return reference to the main widget (QWidget) |
|
48 """ |
|
49 from Tools.TrayStarter import TrayStarter |
|
50 return TrayStarter(SettingsDir) |
|
51 |
|
52 |
|
53 def main(): |
|
54 """ |
|
55 Main entry point into the application. |
|
56 """ |
|
57 from PyQt6.QtGui import QGuiApplication |
|
58 QGuiApplication.setDesktopFileName("eric7_tray.desktop") |
|
59 |
|
60 options = [ |
|
61 ("--config=configDir", |
|
62 "use the given directory as the one containing the config files"), |
|
63 ("--settings=settingsDir", |
|
64 "use the given directory to store the settings files"), |
|
65 ] |
|
66 appinfo = AppInfo.makeAppInfo(sys.argv, |
|
67 "eric Tray", |
|
68 "", |
|
69 "Traystarter for eric", |
|
70 options) |
|
71 res = Startup.simpleAppStartup(sys.argv, |
|
72 appinfo, |
|
73 createMainWidget, |
|
74 quitOnLastWindowClosed=False, |
|
75 raiseIt=False) |
|
76 sys.exit(res) |
|
77 |
|
78 if __name__ == '__main__': |
|
79 main() |