|
24 | 24 | import uuid
|
25 | 25 |
|
26 | 26 | # Third party imports
|
27 |
| -from qtpy.compat import from_qvariant, getopenfilenames, to_qvariant |
28 |
| -from qtpy.QtCore import QByteArray, Qt, Signal, Slot, QDir |
| 27 | +from qtpy.compat import from_qvariant, to_qvariant |
| 28 | +from qtpy.QtCore import QByteArray, Qt, Signal, Slot |
29 | 29 | from qtpy.QtGui import QTextCursor
|
30 | 30 | from qtpy.QtPrintSupport import QAbstractPrintDialog, QPrintDialog, QPrinter
|
31 | 31 | from qtpy.QtWidgets import (QAction, QActionGroup, QApplication, QDialog,
|
32 |
| - QFileDialog, QInputDialog, QSplitter, |
33 |
| - QVBoxLayout, QWidget) |
| 32 | + QInputDialog, QSplitter, QVBoxLayout, QWidget) |
34 | 33 |
|
35 | 34 | # Local imports
|
36 | 35 | from spyder.api.config.decorators import on_conf_change
|
37 | 36 | from spyder.api.plugins import Plugins
|
38 | 37 | from spyder.api.widgets.main_widget import PluginMainWidget
|
39 |
| -from spyder.config.base import _, get_conf_path, running_under_pytest |
40 |
| -from spyder.config.utils import (get_edit_filetypes, get_edit_filters, |
41 |
| - get_filter) |
| 38 | +from spyder.config.base import _, get_conf_path |
42 | 39 | from spyder.plugins.editor.api.panel import Panel
|
43 | 40 | from spyder.py3compat import qbytearray_to_str, to_text_string
|
44 | 41 | from spyder.utils import encoding, programs, sourcecode
|
@@ -391,7 +388,7 @@ def setup(self):
|
391 | 388 | text=_("&Open..."),
|
392 | 389 | icon=self.create_icon('fileopen'),
|
393 | 390 | tip=_("Open file"),
|
394 |
| - triggered=self.load, |
| 391 | + triggered=self._plugin.main.load_files, |
395 | 392 | context=Qt.WidgetShortcut,
|
396 | 393 | register_shortcut=True
|
397 | 394 | )
|
@@ -1612,7 +1609,7 @@ def register_editorstack(self, editorstack):
|
1612 | 1609 | editorstack.text_changed_at.connect(self.text_changed_at)
|
1613 | 1610 | editorstack.current_file_changed.connect(self.current_file_changed)
|
1614 | 1611 | editorstack.plugin_load.connect(self.load)
|
1615 |
| - editorstack.plugin_load[()].connect(self.load) |
| 1612 | + editorstack.plugin_load[()].connect(self._plugin.main.load_files) |
1616 | 1613 | editorstack.edit_goto.connect(self.load)
|
1617 | 1614 | editorstack.sig_save_as.connect(self.save_as)
|
1618 | 1615 | editorstack.sig_prev_edit_pos.connect(self.go_to_last_edit_location)
|
@@ -2177,77 +2174,12 @@ def load(self, filenames=None, goto=None, word='',
|
2177 | 2174 | except (AttributeError, RuntimeError):
|
2178 | 2175 | pass
|
2179 | 2176 |
|
2180 |
| - editor0 = self.get_current_editor() |
2181 |
| - if editor0 is not None: |
2182 |
| - filename0 = self.get_current_filename() |
2183 |
| - else: |
2184 |
| - filename0 = None |
2185 |
| - |
2186 | 2177 | if not filenames:
|
2187 | 2178 | # Recent files action
|
2188 | 2179 | action = self.sender()
|
2189 | 2180 | if isinstance(action, QAction):
|
2190 | 2181 | filenames = from_qvariant(action.data(), to_text_string)
|
2191 | 2182 |
|
2192 |
| - if not filenames: |
2193 |
| - basedir = getcwd_or_home() |
2194 |
| - if self.edit_filetypes is None: |
2195 |
| - self.edit_filetypes = get_edit_filetypes() |
2196 |
| - if self.edit_filters is None: |
2197 |
| - self.edit_filters = get_edit_filters() |
2198 |
| - |
2199 |
| - c_fname = self.get_current_filename() |
2200 |
| - if c_fname is not None and c_fname != self.TEMPFILE_PATH: |
2201 |
| - basedir = osp.dirname(c_fname) |
2202 |
| - |
2203 |
| - self.sig_redirect_stdio_requested.emit(False) |
2204 |
| - parent_widget = self.get_current_editorstack() |
2205 |
| - if filename0 is not None: |
2206 |
| - selectedfilter = get_filter(self.edit_filetypes, |
2207 |
| - osp.splitext(filename0)[1]) |
2208 |
| - else: |
2209 |
| - selectedfilter = '' |
2210 |
| - |
2211 |
| - if not running_under_pytest(): |
2212 |
| - # See: spyder-ide/spyder#3291 |
2213 |
| - if sys.platform == 'darwin': |
2214 |
| - dialog = QFileDialog( |
2215 |
| - parent=parent_widget, |
2216 |
| - caption=_("Open file"), |
2217 |
| - directory=basedir, |
2218 |
| - ) |
2219 |
| - dialog.setNameFilters(self.edit_filters.split(';;')) |
2220 |
| - dialog.setOption(QFileDialog.HideNameFilterDetails, True) |
2221 |
| - dialog.setFilter(QDir.AllDirs | QDir.Files | QDir.Drives |
2222 |
| - | QDir.Hidden) |
2223 |
| - dialog.setFileMode(QFileDialog.ExistingFiles) |
2224 |
| - |
2225 |
| - if dialog.exec_(): |
2226 |
| - filenames = dialog.selectedFiles() |
2227 |
| - else: |
2228 |
| - filenames, _sf = getopenfilenames( |
2229 |
| - parent_widget, |
2230 |
| - _("Open file"), |
2231 |
| - basedir, |
2232 |
| - self.edit_filters, |
2233 |
| - selectedfilter=selectedfilter, |
2234 |
| - options=QFileDialog.HideNameFilterDetails, |
2235 |
| - ) |
2236 |
| - else: |
2237 |
| - # Use a Qt (i.e. scriptable) dialog for pytest |
2238 |
| - dialog = QFileDialog(parent_widget, _("Open file"), |
2239 |
| - options=QFileDialog.DontUseNativeDialog) |
2240 |
| - if dialog.exec_(): |
2241 |
| - filenames = dialog.selectedFiles() |
2242 |
| - |
2243 |
| - self.sig_redirect_stdio_requested.emit(True) |
2244 |
| - |
2245 |
| - if filenames: |
2246 |
| - filenames = [osp.normpath(fname) for fname in filenames] |
2247 |
| - else: |
2248 |
| - self.__ignore_cursor_history = cursor_history_state |
2249 |
| - return |
2250 |
| - |
2251 | 2183 | focus_widget = QApplication.focusWidget()
|
2252 | 2184 | if self.editorwindows and not self.dockwidget.isVisible():
|
2253 | 2185 | # We override the editorwindow variable to force a focus on
|
|
0 commit comments