9 |
9 |
10 import os |
10 import os |
11 import contextlib |
11 import contextlib |
12 |
12 |
13 from PyQt6.QtCore import ( |
13 from PyQt6.QtCore import ( |
14 pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, QFile, QEvent |
14 pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, QFile, QEvent, QIODevice |
15 ) |
15 ) |
16 from PyQt6.QtGui import ( |
16 from PyQt6.QtGui import ( |
17 QPalette, QImage, QImageReader, QImageWriter, QKeySequence |
17 QPalette, QImage, QImageReader, QImageWriter, QKeySequence |
18 ) |
18 ) |
19 from PyQt6.QtWidgets import QScrollArea, QLabel, QDockWidget, QWhatsThis |
19 from PyQt6.QtWidgets import QScrollArea, QLabel, QDockWidget, QWhatsThis |
1155 self, self.tr("eric Icon Editor"), |
1155 self, self.tr("eric Icon Editor"), |
1156 self.tr("The file '{0}' does not exist.") |
1156 self.tr("The file '{0}' does not exist.") |
1157 .format(fileName)) |
1157 .format(fileName)) |
1158 return |
1158 return |
1159 |
1159 |
1160 if not file.open(QFile.ReadOnly): |
1160 if not file.open(QIODevice.OpenModeFlag.ReadOnly): |
1161 EricMessageBox.warning( |
1161 EricMessageBox.warning( |
1162 self, self.tr("eric Icon Editor"), |
1162 self, self.tr("eric Icon Editor"), |
1163 self.tr("Cannot read file '{0}:\n{1}.") |
1163 self.tr("Cannot read file '{0}:\n{1}.") |
1164 .format(fileName, file.errorString())) |
1164 .format(fileName, file.errorString())) |
1165 return |
1165 return |
1175 |
1175 |
1176 @param fileName name of the file to save to (string) |
1176 @param fileName name of the file to save to (string) |
1177 @return flag indicating success (boolean) |
1177 @return flag indicating success (boolean) |
1178 """ |
1178 """ |
1179 file = QFile(fileName) |
1179 file = QFile(fileName) |
1180 if not file.open(QFile.WriteOnly): |
1180 if not file.open(QIODevice.OpenModeFlag.WriteOnly): |
1181 EricMessageBox.warning( |
1181 EricMessageBox.warning( |
1182 self, self.tr("eric Icon Editor"), |
1182 self, self.tr("eric Icon Editor"), |
1183 self.tr("Cannot write file '{0}:\n{1}.") |
1183 self.tr("Cannot write file '{0}:\n{1}.") |
1184 .format(fileName, file.errorString())) |
1184 .format(fileName, file.errorString())) |
1185 |
1185 |