|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2015 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Rope Mouse Click Handler configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtWidgets import QDialog |
|
12 |
|
13 from Preferences.ConfigurationPages.ConfigurationPageBase import \ |
|
14 ConfigurationPageBase |
|
15 from .Ui_MouseClickHandlerRopePage import Ui_MouseClickHandlerRopePage |
|
16 |
|
17 from Utilities import MouseUtilities |
|
18 from Preferences.MouseClickDialog import MouseClickDialog |
|
19 |
|
20 |
|
21 class MouseClickHandlerRopePage(ConfigurationPageBase, |
|
22 Ui_MouseClickHandlerRopePage): |
|
23 """ |
|
24 Class implementing the Rope Mouse Click Handler configuration page. |
|
25 """ |
|
26 def __init__(self, plugin): |
|
27 """ |
|
28 Constructor |
|
29 |
|
30 @param plugin reference to the plugin object |
|
31 @type RefactoringRopePlugin |
|
32 """ |
|
33 ConfigurationPageBase.__init__(self) |
|
34 self.setupUi(self) |
|
35 self.setObjectName("AutoCompletionRopePage") |
|
36 |
|
37 self.__plugin = plugin |
|
38 |
|
39 # set initial values |
|
40 self.__modifiers = { |
|
41 "goto": ( |
|
42 self.__plugin.getPreferences("MouseClickGotoModifiers"), |
|
43 self.__plugin.getPreferences("MouseClickGotoButton") |
|
44 ) |
|
45 } |
|
46 |
|
47 self.ropeClickHandlerCheckBox.setChecked( |
|
48 self.__plugin.getPreferences("MouseClickEnabled")) |
|
49 self.gotoClickEdit.setText(MouseUtilities.MouseButtonModifier2String( |
|
50 *self.__modifiers["goto"])) |
|
51 |
|
52 def save(self): |
|
53 """ |
|
54 Public slot to save the Rope Mouse Click Handler configuration. |
|
55 """ |
|
56 self.__plugin.setPreferences("MouseClickEnabled", |
|
57 self.ropeClickHandlerCheckBox.isChecked()) |
|
58 self.__plugin.setPreferences("MouseClickGotoModifiers", |
|
59 int(self.__modifiers["goto"][0])) |
|
60 self.__plugin.setPreferences("MouseClickGotoButton", |
|
61 int(self.__modifiers["goto"][1])) |
|
62 |
|
63 @pyqtSlot() |
|
64 def on_changeGotoButton_clicked(self): |
|
65 """ |
|
66 Private slot to change the 'goto' mouse click sequence. |
|
67 """ |
|
68 dlg = MouseClickDialog(*self.__modifiers["goto"]) |
|
69 if dlg.exec_() == QDialog.Accepted: |
|
70 self.__modifiers["goto"] = dlg.getClick() |
|
71 self.gotoClickEdit.setText( |
|
72 MouseUtilities.MouseButtonModifier2String( |
|
73 *self.__modifiers["goto"])) |