eric7/QScintilla/MiniEditor.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8885
b0bbe8bda1f2
equal deleted inserted replaced
9151:8c5296fe3056 9152:8a68afaf1ba2
6 """ 6 """
7 Module implementing an editor for simple editing tasks. 7 Module implementing an editor for simple editing tasks.
8 """ 8 """
9 9
10 import os 10 import os
11 import pathlib
11 import re 12 import re
12 import contextlib 13 import contextlib
13 14
14 import editorconfig 15 import editorconfig
15 16
16 from PyQt6.QtCore import ( 17 from PyQt6.QtCore import (
17 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QPoint, QTimer, QFileInfo, QSize, 18 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QPoint, QTimer, QSize,
18 QCoreApplication 19 QCoreApplication
19 ) 20 )
20 from PyQt6.QtGui import ( 21 from PyQt6.QtGui import (
21 QKeySequence, QPalette, QFont, QPixmap, QActionGroup, QAction 22 QKeySequence, QPalette, QFont, QPixmap, QActionGroup, QAction
22 ) 23 )
495 @type int 496 @type int
496 """ 497 """
497 if not self.__curFile: 498 if not self.__curFile:
498 writ = ' ' 499 writ = ' '
499 else: 500 else:
500 if QFileInfo(self.__curFile).isWritable(): 501 if os.access(self.__curFile, os.W_OK):
501 writ = ' rw' 502 writ = ' rw'
502 else: 503 else:
503 writ = ' ro' 504 writ = ' ro'
504 505
505 self.sbWritable.setText(writ) 506 self.sbWritable.setText(writ)
2872 Private method to return the filename part of the given path. 2873 Private method to return the filename part of the given path.
2873 2874
2874 @param fullFileName full pathname of the given file (string) 2875 @param fullFileName full pathname of the given file (string)
2875 @return filename part (string) 2876 @return filename part (string)
2876 """ 2877 """
2877 return QFileInfo(fullFileName).fileName() 2878 return pathlib.Path(fullFileName).name
2878 2879
2879 def __modificationChanged(self, m): 2880 def __modificationChanged(self, m):
2880 """ 2881 """
2881 Private slot to handle the modificationChanged signal. 2882 Private slot to handle the modificationChanged signal.
2882 2883
3138 True) 3139 True)
3139 if printDialog.exec() == QDialog.DialogCode.Accepted: 3140 if printDialog.exec() == QDialog.DialogCode.Accepted:
3140 sb.showMessage(self.tr('Printing...')) 3141 sb.showMessage(self.tr('Printing...'))
3141 QApplication.processEvents() 3142 QApplication.processEvents()
3142 if self.__curFile: 3143 if self.__curFile:
3143 printer.setDocName(QFileInfo(self.__curFile).fileName()) 3144 printer.setDocName(pathlib.Path(self.__curFile).name)
3144 else: 3145 else:
3145 printer.setDocName(self.tr("Untitled")) 3146 printer.setDocName(self.tr("Untitled"))
3146 if ( 3147 if (
3147 printDialog.printRange() == 3148 printDialog.printRange() ==
3148 QAbstractPrintDialog.PrintRange.Selection 3149 QAbstractPrintDialog.PrintRange.Selection
3173 from PyQt6.QtPrintSupport import QPrintPreviewDialog 3174 from PyQt6.QtPrintSupport import QPrintPreviewDialog
3174 from .Printer import Printer 3175 from .Printer import Printer
3175 3176
3176 printer = Printer(mode=QPrinter.PrinterMode.HighResolution) 3177 printer = Printer(mode=QPrinter.PrinterMode.HighResolution)
3177 if self.__curFile: 3178 if self.__curFile:
3178 printer.setDocName(QFileInfo(self.__curFile).fileName()) 3179 printer.setDocName(pathlib.Path(self.__curFile).name)
3179 else: 3180 else:
3180 printer.setDocName(self.tr("Untitled")) 3181 printer.setDocName(self.tr("Untitled"))
3181 preview = QPrintPreviewDialog(printer, self) 3182 preview = QPrintPreviewDialog(printer, self)
3182 preview.paintRequested.connect(self.__printPreview) 3183 preview.paintRequested.connect(self.__printPreview)
3183 preview.exec() 3184 preview.exec()

eric ide

mercurial