--- a/eric7/UI/FindLocationWidget.py Fri Apr 29 15:40:17 2022 +0200 +++ b/eric7/UI/FindLocationWidget.py Fri Apr 29 17:49:47 2022 +0200 @@ -13,7 +13,8 @@ from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl from PyQt6.QtGui import QDesktopServices, QImageReader from PyQt6.QtWidgets import ( - QWidget, QHeaderView, QApplication, QTreeWidgetItem + QWidget, QHeaderView, QApplication, QTreeWidgetItem, QDialog, + QDialogButtonBox, QVBoxLayout ) from EricWidgets.EricPathPicker import EricPathPickerModes @@ -68,23 +69,28 @@ self.fileList.headerItem().setText(self.fileList.columnCount(), "") self.stopButton.setEnabled(False) + self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading")) + self.stopButton.setAutoDefault(False) self.stopButton.clicked.connect(self.__stopSearch) - self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading")) + self.findButton.setIcon(UI.PixmapCache.getIcon("find")) + self.findButton.setAutoDefault(False) self.findButton.clicked.connect(self.__searchFile) - self.findButton.setIcon(UI.PixmapCache.getIcon("find")) self.clearButton.setEnabled(False) + self.clearButton.setIcon(UI.PixmapCache.getIcon("clear")) + self.clearButton.setAutoDefault(False) self.clearButton.clicked.connect(self.__clearResults) - self.clearButton.setIcon(UI.PixmapCache.getIcon("clear")) self.openButton.setEnabled(False) self.openButton.setIcon(UI.PixmapCache.getIcon("open")) + self.openButton.setAutoDefault(False) self.openButton.clicked.connect(self.__openFile) self.__project = project self.__project.projectOpened.connect(self.__projectOpened) self.__project.projectClosed.connect(self.__projectClosed) + self.extsepLabel.setText(os.extsep) self.__shouldStop = False @@ -290,7 +296,83 @@ @pyqtSlot() def activate(self): """ - Public slot to enable/disable the project checkbox. + Public slot to activate this widget. """ self.fileNameEdit.selectAll() self.fileNameEdit.setFocus() + + +class FindLocationDialog(QDialog): + """ + Class implementing a dialog to search for files. + + The occurrences found are displayed in a QTreeWidget showing the + filename and the pathname. The file will be opened upon a double click + onto the respective entry of the list or by pressing the open button. + + @signal sourceFile(str) emitted to open a file in the editor + @signal designerFile(str) emitted to open a Qt-Designer file + @signal linguistFile(str) emitted to open a Qt-Linguist (*.ts) file + @signal trpreview([str]) emitted to preview Qt-Linguist (*.qm) files + @signal pixmapFile(str) emitted to open a pixmap file + @signal svgFile(str) emitted to open a SVG file + @signal umlFile(str) emitted to open an eric UML file + """ + sourceFile = pyqtSignal(str) + designerFile = pyqtSignal(str) + linguistFile = pyqtSignal(str) + trpreview = pyqtSignal(list) + pixmapFile = pyqtSignal(str) + svgFile = pyqtSignal(str) + umlFile = pyqtSignal(str) + + def __init__(self, project, parent=None): + """ + Constructor + + @param project reference to the project object + @type Project + @param parent parent widget of this dialog (defaults to None) + @type QWidget (optional) + """ + super().__init__(parent) + self.setWindowFlags(Qt.WindowType.Window) + + self.__layout = QVBoxLayout() + + self.__findWidget = FindLocationWidget(project, self) + self.__layout.addWidget(self.__findWidget) + + self.__buttonBox = QDialogButtonBox( + QDialogButtonBox.StandardButton.Close, + Qt.Orientation.Horizontal, + self + ) + self.__buttonBox.button( + QDialogButtonBox.StandardButton.Close).setAutoDefault(False) + self.__layout.addWidget(self.__buttonBox) + + self.setLayout(self.__layout) + self.resize(600, 800) + + # connect the widgets + self.__findWidget.sourceFile.connect(self.sourceFile) + self.__findWidget.designerFile.connect(self.designerFile) + self.__findWidget.linguistFile.connect(self.linguistFile) + self.__findWidget.trpreview.connect(self.trpreview) + self.__findWidget.pixmapFile.connect(self.pixmapFile) + self.__findWidget.svgFile.connect(self.svgFile) + self.__findWidget.umlFile.connect(self.umlFile) + + self.__buttonBox.accepted.connect(self.accept) + self.__buttonBox.rejected.connect(self.reject) + + def activate(self): + """ + Public method to activate the dialog. + """ + self.__findWidget.activate() + + self.raise_() + self.activateWindow() + self.show()