7 Module implementing the view manager base class. |
7 Module implementing the view manager base class. |
8 """ |
8 """ |
9 |
9 |
10 import re |
10 import re |
11 import os |
11 import os |
|
12 import pathlib |
12 import contextlib |
13 import contextlib |
13 |
14 |
14 from PyQt6.QtCore import ( |
15 from PyQt6.QtCore import ( |
15 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QTimer, QFileInfo, QPoint, |
16 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QTimer, QPoint, QCoreApplication |
16 QCoreApplication |
|
17 ) |
17 ) |
18 from PyQt6.QtGui import QKeySequence, QPixmap |
18 from PyQt6.QtGui import QKeySequence, QPixmap |
19 from PyQt6.QtWidgets import ( |
19 from PyQt6.QtWidgets import ( |
20 QToolBar, QDialog, QApplication, QMenu, QWidget |
20 QToolBar, QDialog, QApplication, QMenu, QWidget |
21 ) |
21 ) |
188 self.recent = [] |
188 self.recent = [] |
189 Preferences.Prefs.rsettings.sync() |
189 Preferences.Prefs.rsettings.sync() |
190 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
190 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
191 if rs is not None: |
191 if rs is not None: |
192 for f in Preferences.toList(rs): |
192 for f in Preferences.toList(rs): |
193 if QFileInfo(f).exists(): |
193 if pathlib.Path(f).exists(): |
194 self.recent.append(f) |
194 self.recent.append(f) |
195 |
195 |
196 def __saveRecent(self): |
196 def __saveRecent(self): |
197 """ |
197 """ |
198 Private method to save the list of recently opened filenames. |
198 Private method to save the list of recently opened filenames. |
5189 act = self.recentMenu.addAction( |
5189 act = self.recentMenu.addAction( |
5190 formatStr.format( |
5190 formatStr.format( |
5191 idx, |
5191 idx, |
5192 Utilities.compactPath(rs, self.ui.maxMenuFilePathLen))) |
5192 Utilities.compactPath(rs, self.ui.maxMenuFilePathLen))) |
5193 act.setData(rs) |
5193 act.setData(rs) |
5194 act.setEnabled(QFileInfo(rs).exists()) |
5194 act.setEnabled(pathlib.Path(rs).exists()) |
5195 |
5195 |
5196 self.recentMenu.addSeparator() |
5196 self.recentMenu.addSeparator() |
5197 self.recentMenu.addAction( |
5197 self.recentMenu.addAction( |
5198 QCoreApplication.translate('ViewManager', '&Clear'), |
5198 QCoreApplication.translate('ViewManager', '&Clear'), |
5199 self.clearRecent) |
5199 self.clearRecent) |
5223 |
5223 |
5224 for rp in self.bookmarked: |
5224 for rp in self.bookmarked: |
5225 act = self.bookmarkedMenu.addAction( |
5225 act = self.bookmarkedMenu.addAction( |
5226 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)) |
5226 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)) |
5227 act.setData(rp) |
5227 act.setData(rp) |
5228 act.setEnabled(QFileInfo(rp).exists()) |
5228 act.setEnabled(pathlib.Path(rp).exists()) |
5229 |
5229 |
5230 if len(self.bookmarked): |
5230 if len(self.bookmarked): |
5231 self.bookmarkedMenu.addSeparator() |
5231 self.bookmarkedMenu.addSeparator() |
5232 self.bookmarkedMenu.addAction( |
5232 self.bookmarkedMenu.addAction( |
5233 QCoreApplication.translate('ViewManager', '&Add'), |
5233 QCoreApplication.translate('ViewManager', '&Add'), |