1616
1717class PugdebugSettings ():
1818
19+ defaults = {
20+ 'debugger' : {
21+ 'host' : '127.0.0.1' ,
22+ 'port_number' : 9000 ,
23+ 'idekey' : 'pugdebug' ,
24+ 'break_at_first_line' : Qt .Checked ,
25+ 'max_depth' : '3' ,
26+ 'max_children' : '128' ,
27+ 'max_data' : '512'
28+ },
29+ 'path' : {
30+ 'project_root' : os .path .expanduser ('~' ),
31+ 'path_mapping' : ''
32+ }
33+ }
34+
1935 def __init__ (self ):
2036 """Model object to handle application settings
2137
@@ -30,58 +46,19 @@ def __init__(self):
3046 QCoreApplication .setApplicationName ("pugdebug" )
3147 self .application_settings = QSettings ()
3248
33- self .setup_debugger_settings ()
34- self .setup_path_settings ()
35-
36- def setup_debugger_settings (self ):
37- """Set up initial debugger settings
38-
39- Sets up the initial host to 127.0.0.1.
40- Sets up the initial port number to 9000.
41- Sets up the initial IDE key to pugdebug.
42- """
43- self .application_settings .beginGroup ("debugger" )
44-
45- if not self .application_settings .contains ('host' ):
46- self .application_settings .setValue ('host' , '127.0.0.1' )
47-
48- if not self .application_settings .contains ('port_number' ):
49- self .application_settings .setValue ('port_number' , 9000 )
50-
51- if not self .application_settings .contains ('idekey' ):
52- self .application_settings .setValue ('idekey' , 'pugdebug' )
53-
54- if not self .application_settings .contains ('break_at_first_line' ):
55- self .application_settings .setValue ('break_at_first_line' , Qt .Checked )
56-
57- if not self .application_settings .contains ('max_depth' ):
58- self .application_settings .setValue ('max_depth' , '3' )
59-
60- if not self .application_settings .contains ('max_children' ):
61- self .application_settings .setValue ('max_children' , '128' )
62-
63- if not self .application_settings .contains ('max_data' ):
64- self .application_settings .setValue ('max_data' , '512' )
65-
66- self .application_settings .endGroup ()
67-
68- def setup_path_settings (self ):
69- """Set up initial path settings
70-
71- Sets up the initial project root to the user's home directory.
72- Sets up the initial path mapping to an empty string.
73- """
49+ self .setup_default_settings ()
7450
75- self .application_settings .beginGroup ("path" )
51+ def setup_default_settings (self ):
52+ """Set up initial debugger settings"""
7653
77- if not self .application_settings .contains ('project_root' ):
78- home_path = os .path .expanduser ('~' )
79- self .application_settings .setValue ('project_root' , home_path )
54+ for group , settings in self .defaults .items ():
55+ self .application_settings .beginGroup (group )
8056
81- if not self .application_settings .contains ('path_mapping' ):
82- self .application_settings .setValue ('path_mapping' , '' )
57+ for key , value in settings .items ():
58+ if not self .application_settings .contains (key ):
59+ self .application_settings .setValue (key , value )
8360
84- self .application_settings .endGroup ()
61+ self .application_settings .endGroup ()
8562
8663 def get (self , key ):
8764 return self .application_settings .value (key )
0 commit comments