5 |
5 |
6 """ |
6 """ |
7 Module implementing a configuration dialog for the bookmarked files menu. |
7 Module implementing a configuration dialog for the bookmarked files menu. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import QFileInfo, Qt, pyqtSlot |
10 import pathlib |
|
11 |
|
12 from PyQt6.QtCore import Qt, pyqtSlot |
11 from PyQt6.QtGui import QColor |
13 from PyQt6.QtGui import QColor |
12 from PyQt6.QtWidgets import QListWidgetItem, QDialog |
14 from PyQt6.QtWidgets import QListWidgetItem, QDialog |
13 |
15 |
14 from EricWidgets.EricPathPicker import EricPathPickerModes |
16 from EricWidgets.EricPathPicker import EricPathPickerModes |
15 |
17 |
33 self.filePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
35 self.filePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
34 |
36 |
35 self.bookmarks = bookmarks[:] |
37 self.bookmarks = bookmarks[:] |
36 for bookmark in self.bookmarks: |
38 for bookmark in self.bookmarks: |
37 itm = QListWidgetItem(bookmark, self.filesList) |
39 itm = QListWidgetItem(bookmark, self.filesList) |
38 if not QFileInfo(bookmark).exists(): |
40 if not pathlib.Path(bookmark).exists(): |
39 itm.setBackground(QColor(Qt.GlobalColor.red)) |
41 itm.setBackground(QColor(Qt.GlobalColor.red)) |
40 |
42 |
41 if len(self.bookmarks): |
43 if len(self.bookmarks): |
42 self.filesList.setCurrentRow(0) |
44 self.filesList.setCurrentRow(0) |
43 |
45 |
80 Private slot to add a new entry. |
82 Private slot to add a new entry. |
81 """ |
83 """ |
82 bookmark = self.filePicker.text() |
84 bookmark = self.filePicker.text() |
83 if bookmark: |
85 if bookmark: |
84 itm = QListWidgetItem(bookmark, self.filesList) |
86 itm = QListWidgetItem(bookmark, self.filesList) |
85 if not QFileInfo(bookmark).exists(): |
87 if not pathlib.Path(bookmark).exists(): |
86 itm.setBackground(QColor(Qt.GlobalColor.red)) |
88 itm.setBackground(QColor(Qt.GlobalColor.red)) |
87 self.filePicker.clear() |
89 self.filePicker.clear() |
88 self.bookmarks.append(bookmark) |
90 self.bookmarks.append(bookmark) |
89 row = self.filesList.currentRow() |
91 row = self.filesList.currentRow() |
90 self.on_filesList_currentRowChanged(row) |
92 self.on_filesList_currentRowChanged(row) |
97 row = self.filesList.currentRow() |
99 row = self.filesList.currentRow() |
98 bookmark = self.filePicker.text() |
100 bookmark = self.filePicker.text() |
99 self.bookmarks[row] = bookmark |
101 self.bookmarks[row] = bookmark |
100 itm = self.filesList.item(row) |
102 itm = self.filesList.item(row) |
101 itm.setText(bookmark) |
103 itm.setText(bookmark) |
102 if not QFileInfo(bookmark).exists(): |
104 if not pathlib.Path(bookmark).exists(): |
103 itm.setBackground(QColor(Qt.GlobalColor.red)) |
105 itm.setBackground(QColor(Qt.GlobalColor.red)) |
104 else: |
106 else: |
105 itm.setBackground(QColor()) |
107 itm.setBackground(QColor()) |
106 |
108 |
107 @pyqtSlot() |
109 @pyqtSlot() |