68 menu = self.__ui.getMenu("wizards") |
69 menu = self.__ui.getMenu("wizards") |
69 if menu: |
70 if menu: |
70 menu.removeAction(self.qFileDialogAction) |
71 menu.removeAction(self.qFileDialogAction) |
71 menu.removeAction(self.ericFileDialogAction) |
72 menu.removeAction(self.ericFileDialogAction) |
72 self.__ui.removeEricActions( |
73 self.__ui.removeEricActions( |
73 [self.qFileDialogAction, self.ericFileDialogAction], |
74 [self.qFileDialogAction, self.ericFileDialogAction], "wizards" |
74 'wizards') |
75 ) |
75 |
76 |
76 def __initActions(self): |
77 def __initActions(self): |
77 """ |
78 """ |
78 Private method to initialize the actions. |
79 Private method to initialize the actions. |
79 """ |
80 """ |
80 self.qFileDialogAction = EricAction( |
81 self.qFileDialogAction = EricAction( |
81 self.tr('QFileDialog Wizard'), |
82 self.tr("QFileDialog Wizard"), |
82 self.tr('Q&FileDialog Wizard...'), 0, 0, self, |
83 self.tr("Q&FileDialog Wizard..."), |
83 'wizards_qfiledialog') |
84 0, |
84 self.qFileDialogAction.setStatusTip(self.tr('QFileDialog Wizard')) |
85 0, |
85 self.qFileDialogAction.setWhatsThis(self.tr( |
86 self, |
86 """<b>QFileDialog Wizard</b>""" |
87 "wizards_qfiledialog", |
87 """<p>This wizard opens a dialog for entering all the parameters""" |
88 ) |
88 """ needed to create a QFileDialog. The generated code is""" |
89 self.qFileDialogAction.setStatusTip(self.tr("QFileDialog Wizard")) |
89 """ inserted at the current cursor position.</p>""" |
90 self.qFileDialogAction.setWhatsThis( |
90 )) |
91 self.tr( |
|
92 """<b>QFileDialog Wizard</b>""" |
|
93 """<p>This wizard opens a dialog for entering all the parameters""" |
|
94 """ needed to create a QFileDialog. The generated code is""" |
|
95 """ inserted at the current cursor position.</p>""" |
|
96 ) |
|
97 ) |
91 self.qFileDialogAction.triggered.connect(self.__handleQFileDialog) |
98 self.qFileDialogAction.triggered.connect(self.__handleQFileDialog) |
92 |
99 |
93 self.ericFileDialogAction = EricAction( |
100 self.ericFileDialogAction = EricAction( |
94 self.tr('EricFileDialog Wizard'), |
101 self.tr("EricFileDialog Wizard"), |
95 self.tr('EricFileDialog Wizard...'), 0, 0, self, |
102 self.tr("EricFileDialog Wizard..."), |
96 'wizards_e5filedialog') |
103 0, |
97 self.ericFileDialogAction.setStatusTip(self.tr( |
104 0, |
98 'EricFileDialog Wizard')) |
105 self, |
99 self.ericFileDialogAction.setWhatsThis(self.tr( |
106 "wizards_e5filedialog", |
100 """<b>EricFileDialog Wizard</b>""" |
107 ) |
101 """<p>This wizard opens a dialog for entering all the parameters""" |
108 self.ericFileDialogAction.setStatusTip(self.tr("EricFileDialog Wizard")) |
102 """ needed to create an EricFileDialog. The generated code is""" |
109 self.ericFileDialogAction.setWhatsThis( |
103 """ inserted at the current cursor position.</p>""" |
110 self.tr( |
104 )) |
111 """<b>EricFileDialog Wizard</b>""" |
105 self.ericFileDialogAction.triggered.connect( |
112 """<p>This wizard opens a dialog for entering all the parameters""" |
106 self.__handleEricFileDialog) |
113 """ needed to create an EricFileDialog. The generated code is""" |
107 |
114 """ inserted at the current cursor position.</p>""" |
|
115 ) |
|
116 ) |
|
117 self.ericFileDialogAction.triggered.connect(self.__handleEricFileDialog) |
|
118 |
108 self.__ui.addEricActions( |
119 self.__ui.addEricActions( |
109 [self.qFileDialogAction, self.ericFileDialogAction], |
120 [self.qFileDialogAction, self.ericFileDialogAction], "wizards" |
110 'wizards') |
121 ) |
111 |
122 |
112 def __initMenu(self): |
123 def __initMenu(self): |
113 """ |
124 """ |
114 Private method to add the actions to the right menu. |
125 Private method to add the actions to the right menu. |
115 """ |
126 """ |
116 menu = self.__ui.getMenu("wizards") |
127 menu = self.__ui.getMenu("wizards") |
117 if menu: |
128 if menu: |
118 menu.addAction(self.ericFileDialogAction) |
129 menu.addAction(self.ericFileDialogAction) |
119 menu.addAction(self.qFileDialogAction) |
130 menu.addAction(self.qFileDialogAction) |
120 |
131 |
121 def __callForm(self, editor, variant): |
132 def __callForm(self, editor, variant): |
122 """ |
133 """ |
123 Private method to display a dialog and get the code. |
134 Private method to display a dialog and get the code. |
124 |
135 |
125 @param editor reference to the current editor |
136 @param editor reference to the current editor |
126 @type Editor |
137 @type Editor |
127 @param variant variant of code to be generated |
138 @param variant variant of code to be generated |
128 (-1 = EricFileDialog, 0 = unknown, 5 = PyQt5, 6 = PyQt6) |
139 (-1 = EricFileDialog, 0 = unknown, 5 = PyQt5, 6 = PyQt6) |
129 @type int |
140 @type int |
130 @return the generated code (string) |
141 @return the generated code (string) |
131 """ |
142 """ |
132 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import ( |
143 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import ( |
133 FileDialogWizardDialog |
144 FileDialogWizardDialog, |
134 ) |
145 ) |
|
146 |
135 dlg = FileDialogWizardDialog(variant, None) |
147 dlg = FileDialogWizardDialog(variant, None) |
136 if dlg.exec() == QDialog.DialogCode.Accepted: |
148 if dlg.exec() == QDialog.DialogCode.Accepted: |
137 line, index = editor.getCursorPosition() |
149 line, index = editor.getCursorPosition() |
138 indLevel = editor.indentation(line) // editor.indentationWidth() |
150 indLevel = editor.indentation(line) // editor.indentationWidth() |
139 if editor.indentationsUseTabs(): |
151 if editor.indentationsUseTabs(): |
140 indString = '\t' |
152 indString = "\t" |
141 else: |
153 else: |
142 indString = editor.indentationWidth() * ' ' |
154 indString = editor.indentationWidth() * " " |
143 return (dlg.getCode(indLevel, indString), 1) |
155 return (dlg.getCode(indLevel, indString), 1) |
144 else: |
156 else: |
145 return (None, 0) |
157 return (None, 0) |
146 |
158 |
147 def __handle(self, variant): |
159 def __handle(self, variant): |
148 """ |
160 """ |
149 Private method to handle the wizards action. |
161 Private method to handle the wizards action. |
150 |
162 |
151 @param variant dialog variant to be generated |
163 @param variant dialog variant to be generated |
152 (EricFileDialog or QFileDialog) |
164 (EricFileDialog or QFileDialog) |
153 @type str |
165 @type str |
154 @exception ValueError raised to indicate an illegal file dialog variant |
166 @exception ValueError raised to indicate an illegal file dialog variant |
155 """ |
167 """ |
156 editor = ericApp().getObject("ViewManager").activeWindow() |
168 editor = ericApp().getObject("ViewManager").activeWindow() |
157 |
169 |
158 if editor is None: |
170 if editor is None: |
159 EricMessageBox.critical( |
171 EricMessageBox.critical( |
160 self.__ui, |
172 self.__ui, |
161 self.tr('No current editor'), |
173 self.tr("No current editor"), |
162 self.tr('Please open or create a file first.')) |
174 self.tr("Please open or create a file first."), |
|
175 ) |
163 else: |
176 else: |
164 if variant not in ("QFileDialog", "EricFileDialog"): |
177 if variant not in ("QFileDialog", "EricFileDialog"): |
165 raise ValueError("Illegal dialog variant given") |
178 raise ValueError("Illegal dialog variant given") |
166 |
179 |
167 if variant == "QFileDialog": |
180 if variant == "QFileDialog": |
168 match = self.__pyqtRe.search(editor.text()) |
181 match = self.__pyqtRe.search(editor.text()) |
169 if match is None: |
182 if match is None: |
170 # unknown |
183 # unknown |
171 dialogVariant = 0 |
184 dialogVariant = 0 |