eric6/Preferences/MouseClickDialog.py

Sun, 04 Oct 2020 15:25:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 04 Oct 2020 15:25:17 +0200
changeset 7749
285855999b4e
parent 7360
9190402e4505
child 7780
41420f82c0ac
permissions
-rw-r--r--

Configuration Dialog: optimized the display of the various configuration pages.

4291
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7263
diff changeset
3 # Copyright (c) 2015 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4291
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog for the configuration of a mouse click sequence.
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtCore import pyqtSlot, Qt, QEvent
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Ui_MouseClickDialog import Ui_MouseClickDialog
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from Utilities import MouseUtilities
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class MouseClickDialog(QDialog, Ui_MouseClickDialog):
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing a dialog for the configuration of a mouse click
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 sequence.
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, modifiers, button, parent=None):
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param modifiers keyboard modifiers of the handler
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type Qt.KeyboardModifiers
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param button mouse button of the handler
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type Qt.MouseButton
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent reference to the parent widget
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type QWidget
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 super(MouseClickDialog, self).__init__(parent)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setModal(True)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.clickGroup.installEventFilter(self)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.clearButton.installEventFilter(self)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.clickEdit.installEventFilter(self)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.buttonBox.button(QDialogButtonBox.Ok).installEventFilter(self)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.buttonBox.button(QDialogButtonBox.Cancel).installEventFilter(self)
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__modifiers = modifiers
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__button = button
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__showClickText()
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 msh = self.minimumSizeHint()
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.resize(max(self.width(), msh.width()), msh.height())
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @pyqtSlot()
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 def on_clearButton_clicked(self):
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 Private slot to clear the entered sequence.
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__modifiers = Qt.NoModifier
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__button = Qt.NoButton
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__showClickText()
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 def __showClickText(self):
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 Private method to show a string representing the entered mouse click
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 sequence.
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 if self.__button == Qt.NoButton:
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.clickEdit.setText("")
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 else:
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.clickEdit.setText(MouseUtilities.MouseButtonModifier2String(
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__modifiers, self.__button))
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def eventFilter(self, watched, event):
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Public method called to filter the event queue.
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @param watched reference to the watched object
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @type QObject
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @param event reference to the event that occurred
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @type QEvent
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @return flag indicating a handled event
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @rtype bool
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
85 if (
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
86 event.type() == QEvent.MouseButtonRelease and
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
87 watched == self.clickEdit
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
88 ):
4291
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__modifiers = int(event.modifiers())
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__button = int(event.button())
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__showClickText()
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 return True
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 return False
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def getClick(self):
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Public method to get the entered mouse click sequence.
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @return tuple containing the modifiers and the mouse button
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @rtype tuple of Qt.KeyboardModifiers and Qt.MouseButton
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
5f7f8c8d8bc2 Added a dialog to configure a mouse click sequence.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 return (self.__modifiers, self.__button)

eric ide

mercurial