22 from PyQt6.QtWidgets import QLabel, QMenu, QScrollArea, QSizePolicy, QToolBar |
21 from PyQt6.QtWidgets import QLabel, QMenu, QScrollArea, QSizePolicy, QToolBar |
23 |
22 |
24 from eric7 import Preferences |
23 from eric7 import Preferences |
25 from eric7.EricGui import EricPixmapCache |
24 from eric7.EricGui import EricPixmapCache |
26 from eric7.EricWidgets import EricMessageBox |
25 from eric7.EricWidgets import EricMessageBox |
|
26 from eric7.EricWidgets.EricApplication import ericApp |
27 from eric7.EricWidgets.EricMainWindow import EricMainWindow |
27 from eric7.EricWidgets.EricMainWindow import EricMainWindow |
28 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
28 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
|
29 from eric7.SystemUtilities import FileSystemUtilities |
29 |
30 |
30 |
31 |
31 class PixmapDiagram(EricMainWindow): |
32 class PixmapDiagram(EricMainWindow): |
32 """ |
33 """ |
33 Class implementing a dialog showing a pixmap. |
34 Class implementing a dialog showing a pixmap. |
184 @param filename name of the file to be shown |
185 @param filename name of the file to be shown |
185 @type str |
186 @type str |
186 @return flag indicating success |
187 @return flag indicating success |
187 @rtype bool |
188 @rtype bool |
188 """ |
189 """ |
189 image = QImage(filename) |
190 pixmap = QPixmap() |
190 if image.isNull(): |
191 if FileSystemUtilities.isRemoteFileName(filename): |
|
192 try: |
|
193 data = ( |
|
194 ericApp() |
|
195 .getObject("EricServer") |
|
196 .getServiceInterface("FileSystem") |
|
197 .readFile(filename) |
|
198 ) |
|
199 pixmap.loadFromData(data) |
|
200 except OSError as err: |
|
201 EricMessageBox.warning( |
|
202 self, |
|
203 self.tr("Pixmap-Viewer"), |
|
204 self.tr( |
|
205 """<p>The file <b>{0}</b> cannot be loaded.</p>""" |
|
206 """<p>Reason: {1}</p>""" |
|
207 ).format(filename, str(err)), |
|
208 ) |
|
209 return False |
|
210 else: |
|
211 pixmap.load(filename) |
|
212 |
|
213 if pixmap.isNull(): |
191 EricMessageBox.warning( |
214 EricMessageBox.warning( |
192 self, |
215 self, |
193 self.tr("Pixmap-Viewer"), |
216 self.tr("Pixmap-Viewer"), |
194 self.tr( |
217 self.tr( |
195 """<p>The file <b>{0}</b> cannot be displayed.""" |
218 """<p>The file <b>{0}</b> cannot be displayed.""" |
196 """ The format is not supported.</p>""" |
219 """ The format is not supported.</p>""" |
197 ).format(filename), |
220 ).format(filename), |
198 ) |
221 ) |
199 return False |
222 return False |
200 |
223 |
201 self.pixmapLabel.setPixmap(QPixmap.fromImage(image)) |
224 self.pixmapLabel.setPixmap(pixmap) |
202 self.pixmapLabel.adjustSize() |
225 self.pixmapLabel.adjustSize() |
203 return True |
226 return True |
204 |
227 |
205 def getDiagramName(self): |
228 def getDiagramName(self): |
206 """ |
229 """ |