eric6/Snapshot/SnapshotWaylandGrabber.py

Sun, 02 Feb 2020 11:04:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 Feb 2020 11:04:32 +0100
changeset 7380
c99320e859ca
parent 7360
9190402e4505
child 7628
f904d0eef264
permissions
-rw-r--r--

Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
3 # Copyright (c) 2019 - 2020 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
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import uuid
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 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
15 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
16 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
17
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 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
20 DBusAvailable = True
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 except ImportError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 DBusAvailable = False
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 from E5Gui import E5MessageBox
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from .SnapshotModes import SnapshotModes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Globals
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
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 class SnapshotWaylandGrabber(QObject):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 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
34
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @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
36 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 grabbed = pyqtSignal(QPixmap)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 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
40 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Constructor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @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
44 @type QObject
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 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
47
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 from .SnapshotTimer import SnapshotTimer
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__grabTimer = SnapshotTimer()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 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
51
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 def supportedModes(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 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
55
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @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
57 @rtype tuple of SnapshotModes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 if DBusAvailable and Globals.isKdeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 modes = (
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 SnapshotModes.Fullscreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 SnapshotModes.SelectedScreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 SnapshotModes.SelectedWindow,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 elif DBusAvailable and Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 modes = (
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 SnapshotModes.Fullscreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 SnapshotModes.SelectedScreen,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 SnapshotModes.SelectedWindow,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 SnapshotModes.Rectangle,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 else:
7249
0bf517e60f54 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
73 modes = ()
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 return modes
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 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
78 captureDecorations=False):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 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
81
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @param mode screenshot mode
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @type ScreenshotModes
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @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
85 @type int
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 @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
87 @type bool
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @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
89 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
90 @type bool
6916
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if not DBusAvailable:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 # 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
94 self.grabbed.emit(QPixmap())
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 return
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__mode = mode
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__captureCursor = captureCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.__captureDecorations = captureDecorations
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if delay:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__grabTimer.start(delay)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 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
104
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 def __performGrab(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 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
108
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @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
110 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 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
112 self.__grabFullscreen()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 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
114 self.__grabSelectedScreen()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 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
116 self.__grabSelectedWindow()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 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
118 self.__grabRectangle()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 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
121
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 def __grabFullscreen(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 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
125 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if Globals.isKdeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 "org.kde.KWin",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 "/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 "org.kde.kwin.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 "screenshotFullscreen",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.__captureCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 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
139 filename = reply.arguments()[0]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 elif Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 "Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.__captureCursor,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 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
161 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 def __grabSelectedScreen(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 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
175 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 if Globals.isKdeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 # Step 1: get the screen number of screen containing the cursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 if Globals.qVersionTuple() >= (5, 10, 0):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 screen = QApplication.screenAt(QCursor.pos())
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 screenId = QApplication.screens().index(screen)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 except ValueError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 # default to screen 0
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 screenId = 0
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 desktop = QApplication.desktop()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 screenId = desktop.screenNumber(QCursor.pos())
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 # 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
192 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 "org.kde.KWin",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 "/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 "org.kde.kwin.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 "screenshotScreen",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 screenId,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 self.__captureCursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 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
203 filename = reply.arguments()[0]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 elif Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 # 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
213 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 "ScreenshotWindow",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 self.__captureDecorations,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 self.__captureCursor,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 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
227 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 # 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
237 # the cursor
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 if not snapshot.isNull():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 if Globals.qVersionTuple() >= (5, 10, 0):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 screen = QApplication.screenAt(QCursor.pos())
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 geom = screen.geometry()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 desktop = QApplication.desktop()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 screenId = desktop.screenNumber(QCursor.pos())
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 geom = desktop.screenGeometry(screenId)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 snapshot = snapshot.copy(geom)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 def __grabSelectedWindow(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 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
253 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 if Globals.isKdeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 mask = 0
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 if self.__captureDecorations:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 mask |= 1
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 if self.__captureCursor:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 mask |= 2
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 "org.kde.KWin",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 "/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 "org.kde.kwin.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 "interactive",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 mask
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 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
272 filename = reply.arguments()[0]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 elif Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 "ScreenshotWindow",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.__captureDecorations,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.__captureCursor,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 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
295 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 pass
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.grabbed.emit(snapshot)
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 def __grabRectangle(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 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
309 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 snapshot = QPixmap()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 if Globals.isGnomeDesktop():
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 # 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
314 interface = QDBusInterface(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 "org.gnome.Shell",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 "/org/gnome/Shell/Screenshot",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 "org.gnome.Shell.Screenshot"
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 reply = interface.call("SelectArea")
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 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
321 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
322
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 # 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
324 path = self.__temporaryFilename()
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 reply = interface.call(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 "ScreenshotArea",
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 x, y, width, height,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 False,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 path
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 )
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 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
332 filename = reply.arguments()[1]
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 if filename:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 snapshot = QPixmap(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 try:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 os.remove(filename)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 except OSError:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 # just ignore it
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 pass
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 self.grabbed.emit(snapshot)
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 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
344 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 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
346
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 @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
348 @type QDBusMessage
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 @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
350 @type int
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 @return flag indicating validity
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 @rtype bool
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 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
355 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
356 return True
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 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
362 " 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
363 argumentsCount,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 len(reply.arguments()),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 ))
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 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
368 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 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
372 " 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
373 reply.errorName(),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 reply.errorMessage(),
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
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 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
378 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 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
382
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 else:
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 E5MessageBox.warning(
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 None,
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 self.tr("Screenshot Error"),
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 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
388
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 return False
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 def __temporaryFilename(self):
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 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
394
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 @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
396 @rtype str
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 """
76810bef8425 Snapshot: implemented preliminary support for Wayland (needs some more testing).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 return "/tmp/eric6-snap-{0}.png".format(uuid.uuid4().hex)

eric ide

mercurial