Wed, 01 Jan 2020 11:57:23 +0100
Updated copyright for 2020.
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7360
9190402e4505
Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
3 | # Copyright (c) 2017 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the Diff colours configuration page. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt5.QtCore import pyqtSlot |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt5.QtGui import QPalette |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | from PyQt5.QtWidgets import QColorDialog |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from .ConfigurationPageBase import ConfigurationPageBase |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | from .Ui_DiffColoursPage import Ui_DiffColoursPage |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | import Preferences |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | class DiffColoursPage(ConfigurationPageBase, Ui_DiffColoursPage): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Class implementing the Diff colours configuration page. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | def __init__(self): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Constructor |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | super(DiffColoursPage, self).__init__() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | self.setupUi(self) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.setObjectName("DiffColoursPage") |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.__coloursDict = {} |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont") |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | self.__allSamples = ( |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | self.textSample, self.addedSample, self.removedSample, |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.replacedSample, self.contextSample, self.headerSample, |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.whitespaceSample) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | for sample in self.__allSamples: |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | sample.setFont(monospacedFont) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | # set initial values |
6116
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
44 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
45 | "TextColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
46 | self.textButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
47 | self.__updateSampleTextColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
48 | lambda: self.__selectTextColour(self.textButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
49 | self.textSample) |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
50 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
51 | "AddedColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
52 | self.addedButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
53 | self.__updateSampleBackgroundColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
54 | lambda: self.__selectBackgroundColour(self.addedButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
55 | self.addedSample) |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
56 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
57 | "RemovedColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
58 | self.removedButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
59 | self.__updateSampleBackgroundColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
60 | lambda: self.__selectBackgroundColour(self.removedButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
61 | self.removedSample) |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
62 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
63 | "ReplacedColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
64 | self.replacedButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
65 | self.__updateSampleBackgroundColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
66 | lambda: self.__selectBackgroundColour(self.replacedButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
67 | self.replacedSample) |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
68 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
69 | "ContextColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
70 | self.contextButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
71 | self.__updateSampleBackgroundColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
72 | lambda: self.__selectBackgroundColour(self.contextButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
73 | self.contextSample) |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
74 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
75 | "HeaderColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
76 | self.headerButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
77 | self.__updateSampleBackgroundColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
78 | lambda: self.__selectBackgroundColour(self.headerButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
79 | self.headerSample) |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
80 | self.__initColour( |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
81 | "BadWhitespaceColor", |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
82 | self.whitespaceButton, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
83 | self.__updateSampleBackgroundColour, |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
84 | lambda: self.__selectBackgroundColour(self.whitespaceButton), |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
85 | self.whitespaceSample) |
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | def save(self): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | Public slot to save the Diff colours configuration. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | for key in self.__coloursDict: |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | Preferences.setDiffColour(key, self.__coloursDict[key][0]) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | def __initColour(self, colourKey, button, initSlot, selectSlot, |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | sampleWidget): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | Private method to initialize a colour selection button. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | @param colourKey key of the diff colour |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | @type str |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | @param button reference to the button |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | @type QPushButton |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | @param initSlot slot to be called to initialize the sample |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | @type func |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | @param selectSlot slot to be called to select the colour |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | @type func |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | @param sampleWidget reference to the sample widget |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | @type QLineEdit |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | colour = Preferences.getDiffColour(colourKey) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | button.setProperty("colorKey", colourKey) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | button.clicked.connect(selectSlot) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | self.__coloursDict[colourKey] = [colour, sampleWidget] |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | if initSlot: |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | initSlot(colourKey) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | @pyqtSlot() |
6116
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
118 | def __selectTextColour(self, button): |
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | Private slot to select the text colour. |
6116
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
121 | |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
122 | @param button reference to the button been pressed |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
123 | @type QPushButton |
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | colorKey = button.property("colorKey") |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | if colour.isValid(): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | self.__coloursDict[colorKey][0] = colour |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | self.__updateSampleTextColour(colorKey) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | @pyqtSlot() |
6116
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
133 | def __selectBackgroundColour(self, button): |
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | Private slot to select a background colour. |
6116
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
136 | |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
137 | @param button reference to the button been pressed |
f3d3c996c193
Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
138 | @type QPushButton |
5765
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | colorKey = button.property("colorKey") |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self, |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | "", QColorDialog.ShowAlphaChannel) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | if colour.isValid(): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.__coloursDict[colorKey][0] = colour |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | self.__updateSampleBackgroundColour(colorKey) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | @pyqtSlot() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | def __updateSampleTextColour(self, colourKey): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | Private slot to update the text colour of all samples. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | @param colourKey key of the diff colour |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | @type str |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | colour = self.__coloursDict[colourKey][0] |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | for sample in self.__allSamples: |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | pl = sample.palette() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | pl.setColor(QPalette.Text, colour) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | sample.setPalette(pl) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | sample.repaint() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | def __updateSampleBackgroundColour(self, colourKey): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | Private slot to update the background colour of a sample. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | @param colourKey key of the diff colour |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | @type str |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | sample = self.__coloursDict[colourKey][1] |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | if sample: |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | colour = self.__coloursDict[colourKey][0] |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | pl = sample.palette() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | pl.setColor(QPalette.Base, colour) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | sample.setPalette(pl) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | sample.repaint() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | def create(dlg): |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | Module function to create the configuration page. |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | @param dlg reference to the configuration dialog |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | @return reference to the instantiated page (ConfigurationPageBase) |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | """ |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | page = DiffColoursPage() |
39d8b26ff557
Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | return page |