5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to save a screenshot of a web page. |
7 Module implementing a dialog to save a screenshot of a web page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import pyqtSlot, Qt, QFile, QFileInfo, QSize, QIODevice |
10 import pathlib |
|
11 |
|
12 from PyQt6.QtCore import pyqtSlot, Qt, QFile, QSize, QIODevice |
11 from PyQt6.QtGui import QImage, QPainter, QPixmap |
13 from PyQt6.QtGui import QImage, QPainter, QPixmap |
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton |
14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton |
13 |
15 |
14 from EricWidgets import EricFileDialog, EricMessageBox |
16 from EricWidgets import EricFileDialog, EricMessageBox |
15 |
17 |
73 self.tr("Portable Network Graphics File (*.png)"), |
75 self.tr("Portable Network Graphics File (*.png)"), |
74 EricFileDialog.DontConfirmOverwrite) |
76 EricFileDialog.DontConfirmOverwrite) |
75 if not fileName: |
77 if not fileName: |
76 return False |
78 return False |
77 |
79 |
78 if QFileInfo(fileName).exists(): |
80 if pathlib.Path(fileName).exists(): |
79 res = EricMessageBox.yesNo( |
81 res = EricMessageBox.yesNo( |
80 self, |
82 self, |
81 self.tr("Save Page Screen"), |
83 self.tr("Save Page Screen"), |
82 self.tr("<p>The file <b>{0}</b> already exists." |
84 self.tr("<p>The file <b>{0}</b> already exists." |
83 " Overwrite it?</p>").format(fileName), |
85 " Overwrite it?</p>").format(fileName), |