eric7/Preferences/ConfigurationPages/DiffColoursPage.py

Sun, 16 May 2021 20:07:24 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 16 May 2021 20:07:24 +0200
branch
eric7
changeset 8318
962bce857696
parent 8312
800c432b34c8
child 8847
8c5812ca27e1
permissions
-rw-r--r--

Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2017 - 2021 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
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
10 from PyQt6.QtCore import pyqtSlot
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
11 from PyQt6.QtGui import QPalette
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
12 from PyQt6.QtWidgets import QColorDialog
5765
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 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
28 super().__init__()
5765
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
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
141 colour = QColorDialog.getColor(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
142 self.__coloursDict[colorKey][0], self, "",
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
143 QColorDialog.ColorDialogOption.ShowAlphaChannel)
5765
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()
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
159 pl.setColor(QPalette.ColorRole.Text, colour)
5765
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()
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
174 pl.setColor(QPalette.ColorRole.Base, colour)
5765
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

eric ide

mercurial