Sun, 29 Jul 2012 18:05:03 +0200
Fixed some PEP-8 related issues.
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de> |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the snapshot timer widget. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from PyQt4.QtCore import pyqtSignal, Qt, QTimer, QRect |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt4.QtGui import QWidget, QApplication, QPainter, QToolTip, QPalette |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | class SnapshotTimer(QWidget): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | Class implementing the snapshot timer widget. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | @signal timeout() emitted after the timer timed out |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | timeout = pyqtSignal() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | def __init__(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | Constructor |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | super().__init__(None) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
1965
96f5a76e1845
Fixed some PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1772
diff
changeset
|
28 | self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | |
1772
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | Qt.X11BypassWindowManagerHint) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.__timer = QTimer() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.__textRect = QRect() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.__time = 0 |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.__length = 0 |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.__toggle = True |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | # text is taken from paintEvent with maximum number plus some margin |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.resize( |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.fontMetrics().width( |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | self.trUtf8("Snapshot will be taken in %n seconds", "", 99)) + 6, |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.fontMetrics().height() + 4) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.__timer.timeout.connect(self.__bell) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | def start(self, seconds): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | Public method to start the timer. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | @param seconds timeout value (integer) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | screenGeom = QApplication.desktop().screenGeometry() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | self.move(screenGeom.width() // 2 - self.size().width() // 2, screenGeom.top()) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | self.__toggle = True |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.__time = 0 |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | self.__length = seconds |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.__timer.start(1000) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.show() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | def stop(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | Public method to stop the timer. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | self.setVisible(False) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.hide() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | self.__timer.stop() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | def __bell(self): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | Private slot handling timer timeouts. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | if self.__time == self.__length - 1: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.hide() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | else: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | if self.__time == self.__length: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | self.__timer.stop() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.timeout.emit() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.__time += 1 |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.__toggle = not self.__toggle |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | self.update() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | def paintEvent(self, evt): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | Protected method handling paint events. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | @param evt paint event (QPaintEvent) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | painter = QPainter(self) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | if self.__time < self.__length: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | pal = QToolTip.palette() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | textBackgroundColor = pal.color(QPalette.Active, QPalette.Base) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | if self.__toggle: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | textColor = pal.color(QPalette.Active, QPalette.Text) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | else: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | textColor = pal.color(QPalette.Active, QPalette.Base) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | painter.setPen(textColor) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | painter.setBrush(textBackgroundColor) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | helpText = self.trUtf8("Snapshot will be taken in %n seconds", "", |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | self.__length - self.__time) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | textRect = painter.boundingRect(self.rect().adjusted(2, 2, -2, -2), |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | Qt.AlignHCenter | Qt.TextSingleLine, helpText) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | painter.drawText(textRect, Qt.AlignHCenter | Qt.TextSingleLine, helpText) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | def enterEvent(self, evt): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | Protected method handling the mouse cursor entering the widget. |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | @param evt enter event (QEvent) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | """ |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | screenGeom = QApplication.desktop().screenGeometry() |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | if self.x() == screenGeom.left(): |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | self.move( |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | screenGeom.x() + (screenGeom.width() // 2 - self.size().width() // 2), |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | screenGeom.top()) |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | else: |
f325dfdc8f6b
Extended the snapshot tool to allow for the selection of a screen (for multi screen systems), elliptical selection and a freehand selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | self.move(screenGeom.topLeft()) |