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