11 import sys |
11 import sys |
12 |
12 |
13 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl |
13 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl |
14 from PyQt6.QtGui import QDesktopServices, QImageReader |
14 from PyQt6.QtGui import QDesktopServices, QImageReader |
15 from PyQt6.QtWidgets import ( |
15 from PyQt6.QtWidgets import ( |
16 QWidget, QHeaderView, QApplication, QTreeWidgetItem |
16 QWidget, QHeaderView, QApplication, QTreeWidgetItem, QDialog, |
|
17 QDialogButtonBox, QVBoxLayout |
17 ) |
18 ) |
18 |
19 |
19 from EricWidgets.EricPathPicker import EricPathPickerModes |
20 from EricWidgets.EricPathPicker import EricPathPickerModes |
20 |
21 |
21 from .Ui_FindLocationWidget import Ui_FindLocationWidget |
22 from .Ui_FindLocationWidget import Ui_FindLocationWidget |
66 self.searchDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
67 self.searchDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
67 |
68 |
68 self.fileList.headerItem().setText(self.fileList.columnCount(), "") |
69 self.fileList.headerItem().setText(self.fileList.columnCount(), "") |
69 |
70 |
70 self.stopButton.setEnabled(False) |
71 self.stopButton.setEnabled(False) |
|
72 self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading")) |
|
73 self.stopButton.setAutoDefault(False) |
71 self.stopButton.clicked.connect(self.__stopSearch) |
74 self.stopButton.clicked.connect(self.__stopSearch) |
72 self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading")) |
75 |
73 |
76 self.findButton.setIcon(UI.PixmapCache.getIcon("find")) |
|
77 self.findButton.setAutoDefault(False) |
74 self.findButton.clicked.connect(self.__searchFile) |
78 self.findButton.clicked.connect(self.__searchFile) |
75 self.findButton.setIcon(UI.PixmapCache.getIcon("find")) |
|
76 |
79 |
77 self.clearButton.setEnabled(False) |
80 self.clearButton.setEnabled(False) |
|
81 self.clearButton.setIcon(UI.PixmapCache.getIcon("clear")) |
|
82 self.clearButton.setAutoDefault(False) |
78 self.clearButton.clicked.connect(self.__clearResults) |
83 self.clearButton.clicked.connect(self.__clearResults) |
79 self.clearButton.setIcon(UI.PixmapCache.getIcon("clear")) |
|
80 |
84 |
81 self.openButton.setEnabled(False) |
85 self.openButton.setEnabled(False) |
82 self.openButton.setIcon(UI.PixmapCache.getIcon("open")) |
86 self.openButton.setIcon(UI.PixmapCache.getIcon("open")) |
|
87 self.openButton.setAutoDefault(False) |
83 self.openButton.clicked.connect(self.__openFile) |
88 self.openButton.clicked.connect(self.__openFile) |
84 |
89 |
85 self.__project = project |
90 self.__project = project |
86 self.__project.projectOpened.connect(self.__projectOpened) |
91 self.__project.projectOpened.connect(self.__projectOpened) |
87 self.__project.projectClosed.connect(self.__projectClosed) |
92 self.__project.projectClosed.connect(self.__projectClosed) |
|
93 |
88 self.extsepLabel.setText(os.extsep) |
94 self.extsepLabel.setText(os.extsep) |
89 |
95 |
90 self.__shouldStop = False |
96 self.__shouldStop = False |
91 |
97 |
92 self.fileNameEdit.returnPressed.connect(self.__searchFile) |
98 self.fileNameEdit.returnPressed.connect(self.__searchFile) |
288 self.projectCheckBox.setChecked(False) |
294 self.projectCheckBox.setChecked(False) |
289 |
295 |
290 @pyqtSlot() |
296 @pyqtSlot() |
291 def activate(self): |
297 def activate(self): |
292 """ |
298 """ |
293 Public slot to enable/disable the project checkbox. |
299 Public slot to activate this widget. |
294 """ |
300 """ |
295 self.fileNameEdit.selectAll() |
301 self.fileNameEdit.selectAll() |
296 self.fileNameEdit.setFocus() |
302 self.fileNameEdit.setFocus() |
|
303 |
|
304 |
|
305 class FindLocationDialog(QDialog): |
|
306 """ |
|
307 Class implementing a dialog to search for files. |
|
308 |
|
309 The occurrences found are displayed in a QTreeWidget showing the |
|
310 filename and the pathname. The file will be opened upon a double click |
|
311 onto the respective entry of the list or by pressing the open button. |
|
312 |
|
313 @signal sourceFile(str) emitted to open a file in the editor |
|
314 @signal designerFile(str) emitted to open a Qt-Designer file |
|
315 @signal linguistFile(str) emitted to open a Qt-Linguist (*.ts) file |
|
316 @signal trpreview([str]) emitted to preview Qt-Linguist (*.qm) files |
|
317 @signal pixmapFile(str) emitted to open a pixmap file |
|
318 @signal svgFile(str) emitted to open a SVG file |
|
319 @signal umlFile(str) emitted to open an eric UML file |
|
320 """ |
|
321 sourceFile = pyqtSignal(str) |
|
322 designerFile = pyqtSignal(str) |
|
323 linguistFile = pyqtSignal(str) |
|
324 trpreview = pyqtSignal(list) |
|
325 pixmapFile = pyqtSignal(str) |
|
326 svgFile = pyqtSignal(str) |
|
327 umlFile = pyqtSignal(str) |
|
328 |
|
329 def __init__(self, project, parent=None): |
|
330 """ |
|
331 Constructor |
|
332 |
|
333 @param project reference to the project object |
|
334 @type Project |
|
335 @param parent parent widget of this dialog (defaults to None) |
|
336 @type QWidget (optional) |
|
337 """ |
|
338 super().__init__(parent) |
|
339 self.setWindowFlags(Qt.WindowType.Window) |
|
340 |
|
341 self.__layout = QVBoxLayout() |
|
342 |
|
343 self.__findWidget = FindLocationWidget(project, self) |
|
344 self.__layout.addWidget(self.__findWidget) |
|
345 |
|
346 self.__buttonBox = QDialogButtonBox( |
|
347 QDialogButtonBox.StandardButton.Close, |
|
348 Qt.Orientation.Horizontal, |
|
349 self |
|
350 ) |
|
351 self.__buttonBox.button( |
|
352 QDialogButtonBox.StandardButton.Close).setAutoDefault(False) |
|
353 self.__layout.addWidget(self.__buttonBox) |
|
354 |
|
355 self.setLayout(self.__layout) |
|
356 self.resize(600, 800) |
|
357 |
|
358 # connect the widgets |
|
359 self.__findWidget.sourceFile.connect(self.sourceFile) |
|
360 self.__findWidget.designerFile.connect(self.designerFile) |
|
361 self.__findWidget.linguistFile.connect(self.linguistFile) |
|
362 self.__findWidget.trpreview.connect(self.trpreview) |
|
363 self.__findWidget.pixmapFile.connect(self.pixmapFile) |
|
364 self.__findWidget.svgFile.connect(self.svgFile) |
|
365 self.__findWidget.umlFile.connect(self.umlFile) |
|
366 |
|
367 self.__buttonBox.accepted.connect(self.accept) |
|
368 self.__buttonBox.rejected.connect(self.reject) |
|
369 |
|
370 def activate(self): |
|
371 """ |
|
372 Public method to activate the dialog. |
|
373 """ |
|
374 self.__findWidget.activate() |
|
375 |
|
376 self.raise_() |
|
377 self.activateWindow() |
|
378 self.show() |