eric6/Snapshot/SnapshotWaylandGrabber.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7960
e8fc383322f7
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a grabber object for non-Wayland desktops.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import uuid
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtCore import pyqtSignal, QObject, QTimer
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt5.QtGui import QPixmap, QCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt5.QtWidgets import QApplication
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from PyQt5.QtDBus import QDBusInterface, QDBusMessage
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 DBusAvailable = True
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 except ImportError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 DBusAvailable = False
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 from E5Gui import E5MessageBox
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 from .SnapshotModes import SnapshotModes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import Globals
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 class SnapshotWaylandGrabber(QObject):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Class implementing a grabber object for non-Wayland desktops.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @signal grabbed(QPixmap) emitted after the grab operation is finished
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 grabbed = pyqtSignal(QPixmap)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 def __init__(self, parent=None):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Constructor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param parent reference to the parent object
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @type QObject
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 super(SnapshotWaylandGrabber, self).__init__(parent)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 from .SnapshotTimer import SnapshotTimer
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__grabTimer = SnapshotTimer()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__grabTimer.timeout.connect(self.__performGrab)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def supportedModes(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Public method to get the supported screenshot modes.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @return tuple of supported screenshot modes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @rtype tuple of SnapshotModes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 if DBusAvailable and Globals.isKdeDesktop():
7957
7bdfa13bc3f5 Snapshot Widget: fixed the modified snapshot function for multiple screens.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7945
diff changeset
59 return (
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 SnapshotModes.Fullscreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 SnapshotModes.SelectedScreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 SnapshotModes.SelectedWindow,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 elif DBusAvailable and Globals.isGnomeDesktop():
7957
7bdfa13bc3f5 Snapshot Widget: fixed the modified snapshot function for multiple screens.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7945
diff changeset
65 return (
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 SnapshotModes.Fullscreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 SnapshotModes.SelectedScreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 SnapshotModes.SelectedWindow,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 SnapshotModes.Rectangle,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 else:
7957
7bdfa13bc3f5 Snapshot Widget: fixed the modified snapshot function for multiple screens.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7945
diff changeset
72 return ()
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def grab(self, mode, delay=0, captureCursor=False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 captureDecorations=False):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 Public method to perform a grab operation potentially after a delay.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @param mode screenshot mode
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @type ScreenshotModes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param delay delay in seconds
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @type int
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param captureCursor flag indicating to include the mouse cursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @type bool
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @param captureDecorations flag indicating to include the window
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 decorations (only used for mode SnapshotModes.SelectedWindow)
6917
7075ede48c2f Snapshot: fixed some issues and implemented support for the two include options (decorations, mouse cursor) on Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6916
diff changeset
87 @type bool
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 if not DBusAvailable:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 # just to play it safe
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.grabbed.emit(QPixmap())
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 return
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__mode = mode
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__captureCursor = captureCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__captureDecorations = captureDecorations
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 if delay:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__grabTimer.start(delay)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 QTimer.singleShot(200, self.__performGrab)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 def __performGrab(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 Private method to perform the grab operations.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @exception RuntimeError raised to indicate an unsupported grab mode
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 if self.__mode == SnapshotModes.Fullscreen:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.__grabFullscreen()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 elif self.__mode == SnapshotModes.SelectedScreen:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__grabSelectedScreen()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 elif self.__mode == SnapshotModes.SelectedWindow:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.__grabSelectedWindow()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 elif self.__mode == SnapshotModes.Rectangle:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.__grabRectangle()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 raise RuntimeError("unsupported grab mode given")
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 def __grabFullscreen(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 Private method to grab the complete desktop.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 if Globals.isKdeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 "org.kde.KWin",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 "/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 "org.kde.kwin.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 "screenshotFullscreen",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.__captureCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 if self.__checkReply(reply, 1):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 filename = reply.arguments()[0]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 elif Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 "Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.__captureCursor,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 if self.__checkReply(reply, 2):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def __grabSelectedScreen(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Private method to grab a selected screen.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 if Globals.isKdeDesktop():
7945
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
176 screen = QApplication.screenAt(QCursor.pos())
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
177 try:
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
178 screenId = QApplication.screens().index(screen)
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
179 except ValueError:
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
180 # default to screen 0
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
181 screenId = 0
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 # Step 2: grab the screen
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 "org.kde.KWin",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 "/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 "org.kde.kwin.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 "screenshotScreen",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 screenId,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self.__captureCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 if self.__checkReply(reply, 1):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 filename = reply.arguments()[0]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 elif Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 # Step 1: grab entire desktop
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 "ScreenshotWindow",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 self.__captureDecorations,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.__captureCursor,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 if self.__checkReply(reply, 2):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 # Step 2: extract the area of the screen containing
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 # the cursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 if not snapshot.isNull():
7945
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
231 screen = QApplication.screenAt(QCursor.pos())
76daafe10009 Removed code dealing with Qt versions less than the required one and removed use of QDesktopWidget or QApplication.desktop().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
232 geom = screen.geometry()
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 snapshot = snapshot.copy(geom)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 def __grabSelectedWindow(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 Private method to grab a selected window.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 if Globals.isKdeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 mask = 0
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 if self.__captureDecorations:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 mask |= 1
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 if self.__captureCursor:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 mask |= 2
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 "org.kde.KWin",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 "/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 "org.kde.kwin.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 "interactive",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 mask
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 if self.__checkReply(reply, 1):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 filename = reply.arguments()[0]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 elif Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 "ScreenshotWindow",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 self.__captureDecorations,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 self.__captureCursor,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 if self.__checkReply(reply, 2):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 def __grabRectangle(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 Private method to grab a rectangular desktop area.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 if Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 # Step 1: let the user select the area
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 reply = interface.call("SelectArea")
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 if self.__checkReply(reply, 4):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 x, y, width, height = reply.arguments()[:4]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 # Step 2: grab the selected area
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 "ScreenshotArea",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 x, y, width, height,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 if self.__checkReply(reply, 2):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 def __checkReply(self, reply, argumentsCount):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 Private method to check, if a reply is valid.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 @param reply reference to the reply message
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 @type QDBusMessage
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 @param argumentsCount number of expected arguments
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 @type int
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 @return flag indicating validity
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 @rtype bool
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 if reply.type() == QDBusMessage.ReplyMessage:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 if len(reply.arguments()) == argumentsCount:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 return True
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 self.tr("<p>Received an unexpected number of reply arguments."
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 " Expected {0} but got {1}</p>").format(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 argumentsCount,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 len(reply.arguments()),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 ))
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 elif reply.type() == QDBusMessage.ErrorMessage:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 self.tr("<p>Received error <b>{0}</b> from DBus while"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 " performing screenshot.</p><p>{1}</p>").format(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 reply.errorName(),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 reply.errorMessage(),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 ))
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 elif reply.type() == QDBusMessage.InvalidMessage:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 self.tr("Received an invalid reply."))
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.tr("Received an unexpected reply."))
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 return False
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 def __temporaryFilename(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 Private method to generate a temporary filename.
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 @return path name for a unique, temporary file
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 @rtype str
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 """
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7957
diff changeset
385 return "/tmp/eric-snap-{0}.png".format(uuid.uuid4().hex) # secok

eric ide

mercurial