src/eric7/Preferences/ConfigurationPages/DiffColoursPage.py

Tue, 18 Oct 2022 16:06:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 18 Oct 2022 16:06:21 +0200
branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
permissions
-rw-r--r--

Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.

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
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8847
diff changeset
3 # Copyright (c) 2017 - 2022 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.QtWidgets import QColorDialog
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .ConfigurationPageBase import ConfigurationPageBase
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Ui_DiffColoursPage import Ui_DiffColoursPage
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
16 from eric7 import Preferences
5765
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
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class DiffColoursPage(ConfigurationPageBase, Ui_DiffColoursPage):
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 implementing the Diff colours configuration page.
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
23
5765
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")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.__coloursDict = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33
5765
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 = (
8847
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
36 self.textSample,
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
37 self.addedSample,
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
38 self.removedSample,
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
39 self.replacedSample,
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
40 self.contextSample,
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
41 self.headerSample,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42 self.whitespaceSample,
8847
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
43 )
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 for sample in self.__allSamples:
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 sample.setFont(monospacedFont)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
46
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 # set initial values
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
48 self.__initColour(
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
49 "TextColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
50 self.textButton,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
51 self.__updateSampleTextColour,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
52 lambda: self.__selectTextColour(self.textButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53 self.textSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
54 )
6116
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 "AddedColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 self.addedButton,
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.addedButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60 self.addedSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61 )
6116
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 "RemovedColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
64 self.removedButton,
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.removedButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 self.removedSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68 )
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
69 self.__initColour(
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
70 "ReplacedColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
71 self.replacedButton,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
72 self.__updateSampleBackgroundColour,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
73 lambda: self.__selectBackgroundColour(self.replacedButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74 self.replacedSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75 )
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
76 self.__initColour(
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
77 "ContextColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
78 self.contextButton,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
79 self.__updateSampleBackgroundColour,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
80 lambda: self.__selectBackgroundColour(self.contextButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
81 self.contextSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
82 )
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
83 self.__initColour(
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
84 "HeaderColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
85 self.headerButton,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
86 self.__updateSampleBackgroundColour,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
87 lambda: self.__selectBackgroundColour(self.headerButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88 self.headerSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
89 )
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
90 self.__initColour(
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
91 "BadWhitespaceColor",
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
92 self.whitespaceButton,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
93 self.__updateSampleBackgroundColour,
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
94 lambda: self.__selectBackgroundColour(self.whitespaceButton),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
95 self.whitespaceSample,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
96 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
97
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 def save(self):
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 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
101 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 for key in self.__coloursDict:
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 Preferences.setDiffColour(key, self.__coloursDict[key][0])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
105 def __initColour(self, colourKey, button, initSlot, selectSlot, sampleWidget):
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 Private method to initialize a colour selection button.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
108
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @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
110 @type str
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @param button reference to the button
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 @type QPushButton
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 @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
114 @type func
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @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
116 @type func
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @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
118 @type QLineEdit
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 colour = Preferences.getDiffColour(colourKey)
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 button.setProperty("colorKey", colourKey)
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 button.clicked.connect(selectSlot)
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__coloursDict[colourKey] = [colour, sampleWidget]
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if initSlot:
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 initSlot(colourKey)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
126
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 @pyqtSlot()
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
128 def __selectTextColour(self, button):
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Private slot to select the text colour.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
132 @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
133 @type QPushButton
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 colorKey = button.property("colorKey")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
136
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 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
138 if colour.isValid():
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.__coloursDict[colorKey][0] = colour
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.__updateSampleTextColour(colorKey)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 @pyqtSlot()
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
143 def __selectBackgroundColour(self, button):
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 Private slot to select a background colour.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
146
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
147 @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
148 @type QPushButton
5765
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 colorKey = button.property("colorKey")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
151
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
152 colour = QColorDialog.getColor(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
153 self.__coloursDict[colorKey][0],
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
154 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
155 "",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
156 QColorDialog.ColorDialogOption.ShowAlphaChannel,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
157 )
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 if colour.isValid():
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__coloursDict[colorKey][0] = colour
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.__updateSampleBackgroundColour(colorKey)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @pyqtSlot()
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def __updateSampleTextColour(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 text colour of all samples.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
166
5765
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 colour = self.__coloursDict[colourKey][0]
8847
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
171 for key in self.__coloursDict:
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
172 if key == "TextColor":
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
173 self.__coloursDict[key][1].setStyleSheet(
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
174 "QLineEdit {{ color: {0}; }}".format(colour.name())
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
175 )
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
176 else:
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
177 self.__coloursDict[key][1].setStyleSheet(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
178 "QLineEdit {{ color: {0}; background-color: {1}; }}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
179 colour.name(), self.__coloursDict[key][0].name()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
180 )
8847
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
181 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
182
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 def __updateSampleBackgroundColour(self, colourKey):
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 Private slot to update the background colour of a sample.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @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
188 @type str
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 sample = self.__coloursDict[colourKey][1]
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 if sample:
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 colour = self.__coloursDict[colourKey][0]
8847
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
193 sample.setStyleSheet(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
194 "QLineEdit {{ color: {0}; background-color: {1}; }}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195 self.__coloursDict["TextColor"][0].name(), colour.name()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196 )
8847
8c5812ca27e1 Changed some widgets to work with style sheets instead of manipulating the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
197 )
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 def create(dlg):
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 Module function to create the configuration page.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
203
5765
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 @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
205 @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
206 """
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 page = DiffColoursPage()
39d8b26ff557 Made the colors of the diff dialogs configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 return page

eric ide

mercurial