src/eric7/eric7_sqlbrowser.py

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

eric ide

mercurial