66 Public method to deactivate this plugin. |
66 Public method to deactivate this plugin. |
67 """ |
67 """ |
68 menu = self.__ui.getMenu("wizards") |
68 menu = self.__ui.getMenu("wizards") |
69 if menu: |
69 if menu: |
70 menu.removeAction(self.qFileDialogAction) |
70 menu.removeAction(self.qFileDialogAction) |
71 menu.removeAction(self.e5FileDialogAction) |
71 menu.removeAction(self.ericFileDialogAction) |
72 self.__ui.removeE5Actions( |
72 self.__ui.removeEricActions( |
73 [self.qFileDialogAction, self.e5FileDialogAction], |
73 [self.qFileDialogAction, self.ericFileDialogAction], |
74 'wizards') |
74 'wizards') |
75 |
75 |
76 def __initActions(self): |
76 def __initActions(self): |
77 """ |
77 """ |
78 Private method to initialize the actions. |
78 Private method to initialize the actions. |
79 """ |
79 """ |
80 self.qFileDialogAction = E5Action( |
80 self.qFileDialogAction = EricAction( |
81 self.tr('QFileDialog Wizard'), |
81 self.tr('QFileDialog Wizard'), |
82 self.tr('Q&FileDialog Wizard...'), 0, 0, self, |
82 self.tr('Q&FileDialog Wizard...'), 0, 0, self, |
83 'wizards_qfiledialog') |
83 'wizards_qfiledialog') |
84 self.qFileDialogAction.setStatusTip(self.tr('QFileDialog Wizard')) |
84 self.qFileDialogAction.setStatusTip(self.tr('QFileDialog Wizard')) |
85 self.qFileDialogAction.setWhatsThis(self.tr( |
85 self.qFileDialogAction.setWhatsThis(self.tr( |
88 """ needed to create a QFileDialog. The generated code is""" |
88 """ needed to create a QFileDialog. The generated code is""" |
89 """ inserted at the current cursor position.</p>""" |
89 """ inserted at the current cursor position.</p>""" |
90 )) |
90 )) |
91 self.qFileDialogAction.triggered.connect(self.__handleQFileDialog) |
91 self.qFileDialogAction.triggered.connect(self.__handleQFileDialog) |
92 |
92 |
93 self.e5FileDialogAction = E5Action( |
93 self.ericFileDialogAction = EricAction( |
94 self.tr('E5FileDialog Wizard'), |
94 self.tr('EricFileDialog Wizard'), |
95 self.tr('E&5FileDialog Wizard...'), 0, 0, self, |
95 self.tr('E&5FileDialog Wizard...'), 0, 0, self, |
96 'wizards_e5filedialog') |
96 'wizards_e5filedialog') |
97 self.e5FileDialogAction.setStatusTip(self.tr('E5FileDialog Wizard')) |
97 self.ericFileDialogAction.setStatusTip(self.tr('EricFileDialog Wizard')) |
98 self.e5FileDialogAction.setWhatsThis(self.tr( |
98 self.ericFileDialogAction.setWhatsThis(self.tr( |
99 """<b>E5FileDialog Wizard</b>""" |
99 """<b>EricFileDialog Wizard</b>""" |
100 """<p>This wizard opens a dialog for entering all the parameters""" |
100 """<p>This wizard opens a dialog for entering all the parameters""" |
101 """ needed to create an E5FileDialog. The generated code is""" |
101 """ needed to create an EricFileDialog. The generated code is""" |
102 """ inserted at the current cursor position.</p>""" |
102 """ inserted at the current cursor position.</p>""" |
103 )) |
103 )) |
104 self.e5FileDialogAction.triggered.connect(self.__handleE5FileDialog) |
104 self.ericFileDialogAction.triggered.connect(self.__handleEricFileDialog) |
105 |
105 |
106 self.__ui.addE5Actions( |
106 self.__ui.addEricActions( |
107 [self.qFileDialogAction, self.e5FileDialogAction], |
107 [self.qFileDialogAction, self.ericFileDialogAction], |
108 'wizards') |
108 'wizards') |
109 |
109 |
110 def __initMenu(self): |
110 def __initMenu(self): |
111 """ |
111 """ |
112 Private method to add the actions to the right menu. |
112 Private method to add the actions to the right menu. |
113 """ |
113 """ |
114 menu = self.__ui.getMenu("wizards") |
114 menu = self.__ui.getMenu("wizards") |
115 if menu: |
115 if menu: |
116 menu.addAction(self.e5FileDialogAction) |
116 menu.addAction(self.ericFileDialogAction) |
117 menu.addAction(self.qFileDialogAction) |
117 menu.addAction(self.qFileDialogAction) |
118 |
118 |
119 def __callForm(self, editor, variant): |
119 def __callForm(self, editor, variant): |
120 """ |
120 """ |
121 Private method to display a dialog and get the code. |
121 Private method to display a dialog and get the code. |
122 |
122 |
123 @param editor reference to the current editor |
123 @param editor reference to the current editor |
124 @type Editor |
124 @type Editor |
125 @param variant variant of code to be generated |
125 @param variant variant of code to be generated |
126 (-1 = E5FileDialog, 0 = unknown, 5 = PyQt5) |
126 (-1 = EricFileDialog, 0 = unknown, 5 = PyQt5) |
127 @type int |
127 @type int |
128 @return the generated code (string) |
128 @return the generated code (string) |
129 """ |
129 """ |
130 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import ( |
130 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import ( |
131 FileDialogWizardDialog |
131 FileDialogWizardDialog |
145 def __handle(self, variant): |
145 def __handle(self, variant): |
146 """ |
146 """ |
147 Private method to handle the wizards action. |
147 Private method to handle the wizards action. |
148 |
148 |
149 @param variant dialog variant to be generated |
149 @param variant dialog variant to be generated |
150 (E5FileDialog or QFileDialog) |
150 (EricFileDialog or QFileDialog) |
151 @type str |
151 @type str |
152 @exception ValueError raised to indicate an illegal file dialog variant |
152 @exception ValueError raised to indicate an illegal file dialog variant |
153 """ |
153 """ |
154 editor = e5App().getObject("ViewManager").activeWindow() |
154 editor = ericApp().getObject("ViewManager").activeWindow() |
155 |
155 |
156 if editor is None: |
156 if editor is None: |
157 E5MessageBox.critical( |
157 EricMessageBox.critical( |
158 self.__ui, |
158 self.__ui, |
159 self.tr('No current editor'), |
159 self.tr('No current editor'), |
160 self.tr('Please open or create a file first.')) |
160 self.tr('Please open or create a file first.')) |
161 else: |
161 else: |
162 if variant not in ("QFileDialog", "E5FileDialog"): |
162 if variant not in ("QFileDialog", "EricFileDialog"): |
163 raise ValueError("Illegal dialog variant given") |
163 raise ValueError("Illegal dialog variant given") |
164 |
164 |
165 if variant == "QFileDialog": |
165 if variant == "QFileDialog": |
166 match = self.__pyqtRe.search(editor.text()) |
166 match = self.__pyqtRe.search(editor.text()) |
167 if match is None: |
167 if match is None: |