Tue, 02 Apr 2019 19:52:36 +0200
Snapshot: implemented preliminary support for Wayland (needs some more testing).
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
6645
ad476851d7e0
Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
3 | # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the snapshot widget. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
3145
a9de05d4a22f
# __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3142
diff
changeset
|
10 | from __future__ import unicode_literals |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2409
diff
changeset
|
11 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
12 | # |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
13 | # SnapWidget and its associated modules are PyQt5 ports of Ksnapshot. |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
14 | # |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
15 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
16 | import os |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
17 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
18 | from PyQt5.QtCore import pyqtSlot, QFile, QFileInfo, QTimer, QPoint, \ |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
19 | QMimeData, Qt, QRegExp, QLocale, PYQT_VERSION_STR |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
20 | from PyQt5.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
21 | from PyQt5.QtWidgets import QWidget, QApplication, QShortcut |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | from E5Gui import E5FileDialog, E5MessageBox |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | from .Ui_SnapWidget import Ui_SnapWidget |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | import UI.PixmapCache |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | import Preferences |
1776
6198675d24ea
Changed the snapshot tool a little bit for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1772
diff
changeset
|
29 | import Globals |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
31 | from .SnapshotModes import SnapshotModes |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
32 | |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | class SnapWidget(QWidget, Ui_SnapWidget): |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | Class implementing the snapshot widget. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | def __init__(self, parent=None): |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | Constructor |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | @param parent reference to the parent widget (QWidget) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | """ |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2409
diff
changeset
|
44 | super(SnapWidget, self).__init__(parent) |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.setupUi(self) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.saveButton.setIcon(UI.PixmapCache.getIcon("fileSaveAs.png")) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.takeButton.setIcon(UI.PixmapCache.getIcon("cameraPhoto.png")) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | self.copyButton.setIcon(UI.PixmapCache.getIcon("editCopy.png")) |
3129
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
50 | self.copyPreviewButton.setIcon(UI.PixmapCache.getIcon("editCopy.png")) |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | self.setWindowIcon(UI.PixmapCache.getIcon("ericSnap.png")) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
53 | # TODO: correct this once tested |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
54 | # if Globals.isWaylandSession(): |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
55 | if True: |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
56 | from .SnapshotWaylandGrabber import SnapshotWaylandGrabber |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
57 | self.__grabber = SnapshotWaylandGrabber(self) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
58 | else: |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
59 | from .SnapshotDefaultGrabber import SnapshotDefaultGrabber |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
60 | self.__grabber = SnapshotDefaultGrabber(self) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
61 | self.decorationsCheckBox.hide() |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
62 | self.mouseCursorCheckBox.hide() |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
63 | self.__grabber.grabbed.connect(self.__captured) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
64 | supportedModes = self.__grabber.supportedModes() |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
65 | |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
66 | if SnapshotModes.Fullscreen in supportedModes: |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
67 | self.modeCombo.addItem(self.tr("Fullscreen"), |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
68 | SnapshotModes.Fullscreen) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
69 | if SnapshotModes.SelectedScreen in supportedModes: |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
70 | if Globals.qVersionTuple() >= (5, 10, 0): |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
71 | if len(QApplication.screens()) > 1: |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
72 | self.modeCombo.addItem(self.tr("Select Screen"), |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
73 | SnapshotModes.SelectedScreen) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
74 | else: |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
75 | if QApplication.desktop().screenCount() > 1: |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
76 | self.modeCombo.addItem(self.tr("Select Screen"), |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
77 | SnapshotModes.SelectedScreen) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
78 | if SnapshotModes.SelectedWindow in supportedModes: |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
79 | self.modeCombo.addItem(self.tr("Select Window"), |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
80 | SnapshotModes.SelectedWindow) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
81 | if SnapshotModes.Rectangle in supportedModes: |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
82 | self.modeCombo.addItem(self.tr("Rectangular Selection"), |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
83 | SnapshotModes.Rectangle) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
84 | if SnapshotModes.Ellipse in supportedModes: |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
85 | self.modeCombo.addItem(self.tr("Elliptical Selection"), |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
86 | SnapshotModes.Ellipse) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
87 | if SnapshotModes.Freehand in supportedModes: |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
88 | self.modeCombo.addItem(self.tr("Freehand Selection"), |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
89 | SnapshotModes.Freehand) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
90 | mode = int(Preferences.Prefs.settings.value("Snapshot/Mode", 0)) |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
91 | index = self.modeCombo.findData(SnapshotModes(mode)) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
92 | if index == -1: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
93 | index = 0 |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | self.modeCombo.setCurrentIndex(index) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
96 | delay = int(Preferences.Prefs.settings.value("Snapshot/Delay", 0)) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
97 | self.delaySpin.setValue(delay) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
98 | |
3778
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
99 | if PYQT_VERSION_STR >= "5.0.0": |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
100 | from PyQt5.QtCore import QStandardPaths |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
101 | picturesLocation = QStandardPaths.writableLocation( |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
102 | QStandardPaths.PicturesLocation) |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
103 | else: |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
104 | from PyQt5.QtGui import QDesktopServices |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
105 | picturesLocation = QDesktopServices.storageLocation( |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
106 | QDesktopServices.PicturesLocation) |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
107 | self.__filename = Preferences.Prefs.settings.value( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
108 | "Snapshot/Filename", |
3778
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
109 | os.path.join(picturesLocation, |
0c5bc18da740
Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3670
diff
changeset
|
110 | self.tr("snapshot") + "1.png")) |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
112 | self.__snapshot = QPixmap() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
113 | self.__savedPosition = QPoint() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
114 | self.__modified = False |
4689
957339210f40
Fixed the locale handling in the snapshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
115 | self.__locale = QLocale() |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
116 | |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | self.__initFileFilters() |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
118 | self.__initShortcuts() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
119 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
120 | self.preview.startDrag.connect(self.__dragSnapshot) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
121 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
122 | self.__updateTimer = QTimer() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
123 | self.__updateTimer.setSingleShot(True) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
124 | self.__updateTimer.timeout.connect(self.__updatePreview) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
125 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
126 | self.__updateCaption() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
127 | self.takeButton.setFocus() |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | def __initFileFilters(self): |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | Private method to define the supported image file filters. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | filters = { |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
134 | 'bmp': self.tr("Windows Bitmap File (*.bmp)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
135 | 'gif': self.tr("Graphic Interchange Format File (*.gif)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
136 | 'ico': self.tr("Windows Icon File (*.ico)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
137 | 'jpg': self.tr("JPEG File (*.jpg)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
138 | 'mng': self.tr("Multiple-Image Network Graphics File (*.mng)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
139 | 'pbm': self.tr("Portable Bitmap File (*.pbm)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
140 | 'pcx': self.tr("Paintbrush Bitmap File (*.pcx)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
141 | 'pgm': self.tr("Portable Graymap File (*.pgm)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
142 | 'png': self.tr("Portable Network Graphics File (*.png)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
143 | 'ppm': self.tr("Portable Pixmap File (*.ppm)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
144 | 'sgi': self.tr("Silicon Graphics Image File (*.sgi)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
145 | 'svg': self.tr("Scalable Vector Graphics File (*.svg)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
146 | 'tga': self.tr("Targa Graphic File (*.tga)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
147 | 'tif': self.tr("TIFF File (*.tif)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
148 | 'xbm': self.tr("X11 Bitmap File (*.xbm)"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
149 | 'xpm': self.tr("X11 Pixmap File (*.xpm)"), |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | } |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | outputFormats = [] |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | writeFormats = QImageWriter.supportedImageFormats() |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | for writeFormat in writeFormats: |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | try: |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | outputFormats.append(filters[bytes(writeFormat).decode()]) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | except KeyError: |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | pass |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | outputFormats.sort() |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | self.__outputFilter = ';;'.join(outputFormats) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | self.__defaultFilter = filters['png'] |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
164 | def __initShortcuts(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
165 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
166 | Private method to initialize the keyboard shortcuts. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
167 | """ |
2993
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
168 | self.__quitShortcut = QShortcut( |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
169 | QKeySequence(QKeySequence.Quit), self, self.close) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
170 | |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
171 | self.__copyShortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
172 | QKeySequence(QKeySequence.Copy), self, |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
173 | self.copyButton.animateClick) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
174 | |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
175 | self.__quickSaveShortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
176 | QKeySequence(Qt.Key_Q), self, self.__quickSave) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
177 | |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
178 | self.__save1Shortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
179 | QKeySequence(QKeySequence.Save), self, |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
180 | self.saveButton.animateClick) |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
181 | self.__save2Shortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
182 | QKeySequence(Qt.Key_S), self, self.saveButton.animateClick) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
183 | |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
184 | self.__grab1Shortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
185 | QKeySequence(QKeySequence.New), self, self.takeButton.animateClick) |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
186 | self.__grab2Shortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
187 | QKeySequence(Qt.Key_N), self, self.takeButton.animateClick) |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
188 | self.__grab3Shortcut = QShortcut( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
189 | QKeySequence(Qt.Key_Space), self, self.takeButton.animateClick) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
190 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
191 | def __quickSave(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
192 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
193 | Private slot to save the snapshot bypassing the file selection dialog. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
194 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
195 | if not self.__snapshot.isNull(): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
196 | while os.path.exists(self.__filename): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
197 | self.__autoIncFilename() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
198 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
199 | if self.__saveImage(self.__filename): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
200 | self.__modified = False |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
201 | self.__autoIncFilename() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
202 | self.__updateCaption() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
203 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
204 | @pyqtSlot() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
205 | def on_saveButton_clicked(self): |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | Private slot to save the snapshot. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | """ |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
209 | if not self.__snapshot.isNull(): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
210 | while os.path.exists(self.__filename): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
211 | self.__autoIncFilename() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
212 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
213 | fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
214 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
215 | self.tr("Save Snapshot"), |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
216 | self.__filename, |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
217 | self.__outputFilter, |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
218 | self.__defaultFilter, |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
219 | E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
220 | if not fileName: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
221 | return |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
222 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
223 | ext = QFileInfo(fileName).suffix() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
224 | if not ext: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
225 | ex = selectedFilter.split("(*")[1].split(")")[0] |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
226 | if ex: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
227 | fileName += ex |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
228 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
229 | if self.__saveImage(fileName): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
230 | self.__modified = False |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
231 | self.__filename = fileName |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
232 | self.__autoIncFilename() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
233 | self.__updateCaption() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
234 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
235 | def __saveImage(self, fileName): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
236 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
237 | Private method to save the snapshot. |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
239 | @param fileName name of the file to save to (string) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
240 | @return flag indicating success (boolean) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
241 | """ |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | if QFileInfo(fileName).exists(): |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2993
diff
changeset
|
243 | res = E5MessageBox.yesNo( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2993
diff
changeset
|
244 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
245 | self.tr("Save Snapshot"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
246 | self.tr("<p>The file <b>{0}</b> already exists." |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
247 | " Overwrite it?</p>").format(fileName), |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | icon=E5MessageBox.Warning) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | if not res: |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
250 | return False |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | file = QFile(fileName) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | if not file.open(QFile.WriteOnly): |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2993
diff
changeset
|
254 | E5MessageBox.warning( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
255 | self, self.tr("Save Snapshot"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
256 | self.tr("Cannot write file '{0}:\n{1}.") |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
257 | .format(fileName, file.errorString())) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
258 | return False |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
260 | ok = self.__snapshot.save(file) |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | file.close() |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
263 | if not ok: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2993
diff
changeset
|
264 | E5MessageBox.warning( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
265 | self, self.tr("Save Snapshot"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
266 | self.tr("Cannot write file '{0}:\n{1}.") |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
267 | .format(fileName, file.errorString())) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
268 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
269 | return ok |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
271 | def __autoIncFilename(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
272 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
273 | Private method to auto-increment the file name. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
274 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
275 | # Extract the file name |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
276 | name = os.path.basename(self.__filename) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
277 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
278 | # If the name contains a number, then increment it. |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
279 | numSearch = QRegExp("(^|[^\\d])(\\d+)") |
2993
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
280 | # We want to match as far left as possible, and when the number is |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
281 | # at the start of the name. |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
282 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
283 | # Does it have a number? |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
284 | start = numSearch.lastIndexIn(name) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
285 | if start != -1: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
286 | # It has a number, increment it. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
287 | start = numSearch.pos(2) # Only the second group is of interest. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
288 | numAsStr = numSearch.capturedTexts()[2] |
2993
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
289 | number = "{0:0{width}d}".format( |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
290 | int(numAsStr) + 1, width=len(numAsStr)) |
1965
96f5a76e1845
Fixed some PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1779
diff
changeset
|
291 | name = name[:start] + number + name[start + len(numAsStr):] |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
292 | else: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
293 | # no number |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
294 | start = name.rfind('.') |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
295 | if start != -1: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
296 | # has a '.' somewhere, e.g. it has an extension |
1965
96f5a76e1845
Fixed some PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1779
diff
changeset
|
297 | name = name[:start] + '1' + name[start:] |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
298 | else: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
299 | # no extension, just tack it on to the end |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
300 | name += '1' |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
301 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
302 | self.__filename = os.path.join(os.path.dirname(self.__filename), name) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
303 | self.__updateCaption() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
304 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
305 | @pyqtSlot() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
306 | def on_takeButton_clicked(self): |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | Private slot to take a snapshot. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | """ |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
310 | self.__savedPosition = self.pos() |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | self.hide() |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
313 | # TODO: add support for decorations and mouse cursor |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
314 | self.__grabber.grab( |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
315 | self.modeCombo.itemData(self.modeCombo.currentIndex()), |
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
316 | self.delaySpin.value()) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
317 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
318 | def __redisplay(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
319 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
320 | Private method to redisplay the window. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
321 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
322 | self.__updatePreview() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
323 | QApplication.restoreOverrideCursor() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
324 | if not self.__savedPosition.isNull(): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
325 | self.move(self.__savedPosition) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
326 | self.show() |
1776
6198675d24ea
Changed the snapshot tool a little bit for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1772
diff
changeset
|
327 | self.raise_() |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
328 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
329 | self.saveButton.setEnabled(not self.__snapshot.isNull()) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
330 | self.copyButton.setEnabled(not self.__snapshot.isNull()) |
3129
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
331 | self.copyPreviewButton.setEnabled(not self.__snapshot.isNull()) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
332 | |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | @pyqtSlot() |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | def on_copyButton_clicked(self): |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | Private slot to copy the snapshot to the clipboard. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | """ |
3129
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
338 | if not self.__snapshot.isNull(): |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
339 | QApplication.clipboard().setPixmap(QPixmap(self.__snapshot)) |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
340 | |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
341 | @pyqtSlot() |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
342 | def on_copyPreviewButton_clicked(self): |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
343 | """ |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
344 | Private slot to copy the snapshot preview to the clipboard. |
138331f6b0a0
Corrected and extended the screenshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3039
diff
changeset
|
345 | """ |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | QApplication.clipboard().setPixmap(self.preview.pixmap()) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | def __captured(self, pixmap): |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | """ |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | Private slot to show a preview of the snapshot. |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | @param pixmap pixmap of the snapshot (QPixmap) |
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | """ |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
354 | self.__snapshot = QPixmap(pixmap) |
1770
c17e67e69ef5
Added a tool to take screenshots (fullscreen or rectangular selection).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
356 | self.__redisplay() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
357 | self.__modified = True |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
358 | self.__updateCaption() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
359 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
360 | def __updatePreview(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
361 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
362 | Private slot to update the preview picture. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
363 | """ |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
364 | self.preview.setToolTip(self.tr( |
4689
957339210f40
Fixed the locale handling in the snapshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
365 | "Preview of the snapshot image ({0} x {1})").format( |
957339210f40
Fixed the locale handling in the snapshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
366 | self.__locale.toString(self.__snapshot.width()), |
957339210f40
Fixed the locale handling in the snapshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
367 | self.__locale.toString(self.__snapshot.height())) |
957339210f40
Fixed the locale handling in the snapshot tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
368 | ) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
369 | self.preview.setPreview(self.__snapshot) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
370 | self.preview.adjustSize() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
371 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
372 | def resizeEvent(self, evt): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
373 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
374 | Protected method handling a resizing of the window. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
375 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
376 | @param evt resize event (QResizeEvent) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
377 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
378 | self.__updateTimer.start(200) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
379 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
380 | def __dragSnapshot(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
381 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
382 | Private slot handling the dragging of the preview picture. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
383 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
384 | drag = QDrag(self) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
385 | mimeData = QMimeData() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
386 | mimeData.setImageData(self.__snapshot) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
387 | drag.setMimeData(mimeData) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
388 | drag.setPixmap(self.preview.pixmap()) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
389 | drag.exec_(Qt.CopyAction) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
390 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
391 | def closeEvent(self, evt): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
392 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
393 | Protected method handling the close event. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
394 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
395 | @param evt close event (QCloseEvent) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
396 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
397 | if self.__modified: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2993
diff
changeset
|
398 | res = E5MessageBox.question( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2993
diff
changeset
|
399 | self, |
3670
f0cb7579c0b4
Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3664
diff
changeset
|
400 | self.tr("eric6 Snapshot"), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
401 | self.tr( |
2993
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
402 | """The application contains an unsaved snapshot."""), |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
403 | E5MessageBox.StandardButtons( |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
404 | E5MessageBox.Abort | |
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
405 | E5MessageBox.Discard | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
406 | E5MessageBox.Save)) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
407 | if res == E5MessageBox.Abort: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
408 | evt.ignore() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
409 | return |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
410 | elif res == E5MessageBox.Save: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
411 | self.on_saveButton_clicked() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
412 | |
2993
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
413 | Preferences.Prefs.settings.setValue( |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
414 | "Snapshot/Delay", self.delaySpin.value()) |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
415 | Preferences.Prefs.settings.setValue( |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
416 | "Snapshot/Mode", |
6914
5ae038f273c4
Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6911
diff
changeset
|
417 | self.modeCombo.itemData(self.modeCombo.currentIndex()).value) |
2993
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
418 | Preferences.Prefs.settings.setValue( |
4933ac9daa80
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
419 | "Snapshot/Filename", self.__filename) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
420 | Preferences.Prefs.settings.sync() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
421 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
422 | def __updateCaption(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
423 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
424 | Private method to update the window caption. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
425 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
426 | self.setWindowTitle("{0}[*] - {1}".format( |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
427 | os.path.basename(self.__filename), |
3670
f0cb7579c0b4
Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3664
diff
changeset
|
428 | self.tr("eric6 Snapshot"))) |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
429 | self.setWindowModified(self.__modified) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1770
diff
changeset
|
430 | self.pathNameEdit.setText(os.path.dirname(self.__filename)) |
6916
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
431 | |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
432 | @pyqtSlot(int) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
433 | def on_modeCombo_currentIndexChanged(self, index): |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
434 | """ |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
435 | Private slot handling the selection of a screenshot mode. |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
436 | |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
437 | @param index index of the selection |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
438 | @type int |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
439 | """ |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
440 | isWindowMode = False |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
441 | if index >= 0: |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
442 | mode = self.modeCombo.itemData(index) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
443 | isWindowMode = (mode == SnapshotModes.SelectedWindow) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
444 | |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
445 | self.decorationsCheckBox.setEnabled(isWindowMode) |
76810bef8425
Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6914
diff
changeset
|
446 | self.decorationsCheckBox.setChecked(isWindowMode) |