74 |
74 |
75 # step 1: collect all the shortcuts |
75 # step 1: collect all the shortcuts |
76 if helpViewer is None: |
76 if helpViewer is None: |
77 self.__addActionsToDict( |
77 self.__addActionsToDict( |
78 "Project", |
78 "Project", |
79 e5App().getObject("Project").getActions(), |
79 ericApp().getObject("Project").getActions(), |
80 actionsDict |
80 actionsDict |
81 ) |
81 ) |
82 self.__addActionsToDict( |
82 self.__addActionsToDict( |
83 "General", |
83 "General", |
84 e5App().getObject("UserInterface").getActions('ui'), |
84 ericApp().getObject("UserInterface").getActions('ui'), |
85 actionsDict |
85 actionsDict |
86 ) |
86 ) |
87 self.__addActionsToDict( |
87 self.__addActionsToDict( |
88 "Wizards", |
88 "Wizards", |
89 e5App().getObject("UserInterface").getActions('wizards'), |
89 ericApp().getObject("UserInterface").getActions('wizards'), |
90 actionsDict |
90 actionsDict |
91 ) |
91 ) |
92 self.__addActionsToDict( |
92 self.__addActionsToDict( |
93 "Debug", |
93 "Debug", |
94 e5App().getObject("DebugUI").getActions(), |
94 ericApp().getObject("DebugUI").getActions(), |
95 actionsDict |
95 actionsDict |
96 ) |
96 ) |
97 self.__addActionsToDict( |
97 self.__addActionsToDict( |
98 "Edit", |
98 "Edit", |
99 e5App().getObject("ViewManager").getActions('edit'), |
99 ericApp().getObject("ViewManager").getActions('edit'), |
100 actionsDict |
100 actionsDict |
101 ) |
101 ) |
102 self.__addActionsToDict( |
102 self.__addActionsToDict( |
103 "File", |
103 "File", |
104 e5App().getObject("ViewManager").getActions('file'), |
104 ericApp().getObject("ViewManager").getActions('file'), |
105 actionsDict |
105 actionsDict |
106 ) |
106 ) |
107 self.__addActionsToDict( |
107 self.__addActionsToDict( |
108 "Search", |
108 "Search", |
109 e5App().getObject("ViewManager").getActions('search'), |
109 ericApp().getObject("ViewManager").getActions('search'), |
110 actionsDict |
110 actionsDict |
111 ) |
111 ) |
112 self.__addActionsToDict( |
112 self.__addActionsToDict( |
113 "View", |
113 "View", |
114 e5App().getObject("ViewManager").getActions('view'), |
114 ericApp().getObject("ViewManager").getActions('view'), |
115 actionsDict |
115 actionsDict |
116 ) |
116 ) |
117 self.__addActionsToDict( |
117 self.__addActionsToDict( |
118 "Macro", |
118 "Macro", |
119 e5App().getObject("ViewManager").getActions('macro'), |
119 ericApp().getObject("ViewManager").getActions('macro'), |
120 actionsDict |
120 actionsDict |
121 ) |
121 ) |
122 self.__addActionsToDict( |
122 self.__addActionsToDict( |
123 "Bookmarks", |
123 "Bookmarks", |
124 e5App().getObject("ViewManager").getActions('bookmark'), |
124 ericApp().getObject("ViewManager").getActions('bookmark'), |
125 actionsDict |
125 actionsDict |
126 ) |
126 ) |
127 self.__addActionsToDict( |
127 self.__addActionsToDict( |
128 "Spelling", |
128 "Spelling", |
129 e5App().getObject("ViewManager").getActions('spelling'), |
129 ericApp().getObject("ViewManager").getActions('spelling'), |
130 actionsDict |
130 actionsDict |
131 ) |
131 ) |
132 self.__addActionsToDict( |
132 self.__addActionsToDict( |
133 "Window", |
133 "Window", |
134 e5App().getObject("ViewManager").getActions('window'), |
134 ericApp().getObject("ViewManager").getActions('window'), |
135 actionsDict |
135 actionsDict |
136 ) |
136 ) |
137 |
137 |
138 for category, ref in e5App().getPluginObjects(): |
138 for category, ref in ericApp().getPluginObjects(): |
139 if hasattr(ref, "getActions"): |
139 if hasattr(ref, "getActions"): |
140 self.__addActionsToDict( |
140 self.__addActionsToDict( |
141 category, ref.getActions(), actionsDict |
141 category, ref.getActions(), actionsDict |
142 ) |
142 ) |
143 |
143 |
162 try: |
162 try: |
163 jsonString = json.dumps(shortcutsDict, indent=2) |
163 jsonString = json.dumps(shortcutsDict, indent=2) |
164 with open(filename, "w") as f: |
164 with open(filename, "w") as f: |
165 f.write(jsonString) |
165 f.write(jsonString) |
166 except (TypeError, OSError) as err: |
166 except (TypeError, OSError) as err: |
167 with E5OverridenCursor(): |
167 with EricOverridenCursor(): |
168 E5MessageBox.critical( |
168 EricMessageBox.critical( |
169 None, |
169 None, |
170 self.tr("Export Keyboard Shortcuts"), |
170 self.tr("Export Keyboard Shortcuts"), |
171 self.tr( |
171 self.tr( |
172 "<p>The keyboard shortcuts file <b>{0}</b> could not" |
172 "<p>The keyboard shortcuts file <b>{0}</b> could not" |
173 " be written.</p><p>Reason: {1}</p>" |
173 " be written.</p><p>Reason: {1}</p>" |
192 try: |
192 try: |
193 with open(filename, "r") as f: |
193 with open(filename, "r") as f: |
194 jsonString = f.read() |
194 jsonString = f.read() |
195 shortcutsDict = json.loads(jsonString) |
195 shortcutsDict = json.loads(jsonString) |
196 except (OSError, json.JSONDecodeError) as err: |
196 except (OSError, json.JSONDecodeError) as err: |
197 E5MessageBox.critical( |
197 EricMessageBox.critical( |
198 None, |
198 None, |
199 self.tr("Import Keyboard Shortcuts"), |
199 self.tr("Import Keyboard Shortcuts"), |
200 self.tr( |
200 self.tr( |
201 "<p>The keyboard shortcuts file <b>{0}</b> could not be" |
201 "<p>The keyboard shortcuts file <b>{0}</b> could not be" |
202 " read.</p><p>Reason: {1}</p>" |
202 " read.</p><p>Reason: {1}</p>" |