|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2015 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Jedi Mouse Click Handler configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QDialog |
|
12 |
|
13 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
|
14 ConfigurationPageBase |
|
15 ) |
|
16 |
|
17 from .Ui_EditorMouseClickHandlerJediPage import ( |
|
18 Ui_EditorMouseClickHandlerJediPage |
|
19 ) |
|
20 |
|
21 from Utilities import MouseUtilities |
|
22 |
|
23 import Preferences |
|
24 from Preferences.MouseClickDialog import MouseClickDialog |
|
25 |
|
26 |
|
27 class EditorMouseClickHandlerJediPage(ConfigurationPageBase, |
|
28 Ui_EditorMouseClickHandlerJediPage): |
|
29 """ |
|
30 Class implementing the Jedi Mouse Click Handler configuration page. |
|
31 """ |
|
32 def __init__(self): |
|
33 """ |
|
34 Constructor |
|
35 """ |
|
36 super().__init__() |
|
37 self.setupUi(self) |
|
38 self.setObjectName("MouseClickHandlerJediPage") |
|
39 |
|
40 # set initial values |
|
41 self.__modifiers = { |
|
42 "goto": ( |
|
43 Preferences.getJedi("MouseClickGotoModifiers"), |
|
44 Preferences.getJedi("MouseClickGotoButton") |
|
45 ) |
|
46 } |
|
47 |
|
48 self.jediClickHandlerCheckBox.setChecked( |
|
49 Preferences.getJedi("MouseClickEnabled")) |
|
50 self.gotoClickEdit.setText(MouseUtilities.MouseButtonModifier2String( |
|
51 *self.__modifiers["goto"])) |
|
52 |
|
53 def save(self): |
|
54 """ |
|
55 Public slot to save the Jedi Mouse Click Handler configuration. |
|
56 """ |
|
57 Preferences.setJedi( |
|
58 "MouseClickEnabled", self.jediClickHandlerCheckBox.isChecked()) |
|
59 Preferences.setJedi( |
|
60 "MouseClickGotoModifiers", self.__modifiers["goto"][0]) |
|
61 Preferences.setJedi( |
|
62 "MouseClickGotoButton", self.__modifiers["goto"][1]) |
|
63 |
|
64 @pyqtSlot() |
|
65 def on_changeGotoButton_clicked(self): |
|
66 """ |
|
67 Private slot to change the 'goto' mouse click sequence. |
|
68 """ |
|
69 dlg = MouseClickDialog(*self.__modifiers["goto"]) |
|
70 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
71 self.__modifiers["goto"] = dlg.getClick() |
|
72 self.gotoClickEdit.setText( |
|
73 MouseUtilities.MouseButtonModifier2String( |
|
74 *self.__modifiers["goto"])) |
|
75 |
|
76 |
|
77 def create(dlg): |
|
78 """ |
|
79 Module function to create the configuration page. |
|
80 |
|
81 @param dlg reference to the configuration dialog |
|
82 @return reference to the instantiated page (ConfigurationPageBase) |
|
83 """ |
|
84 page = EditorMouseClickHandlerJediPage() |
|
85 return page |