6 """ |
6 """ |
7 Module implementing the base class for all configuration pages. |
7 Module implementing the base class for all configuration pages. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSlot |
10 from PyQt4.QtCore import pyqtSlot |
11 from PyQt4.QtGui import QWidget, QIcon, QPixmap, QColor, QColorDialog, QFontDialog |
11 from PyQt4.QtGui import QWidget, QIcon, QPixmap, QColor, QColorDialog, \ |
|
12 QFontDialog |
12 |
13 |
13 |
14 |
14 class ConfigurationPageBase(QWidget): |
15 class ConfigurationPageBase(QWidget): |
15 """ |
16 """ |
16 Class implementing the base class for all configuration pages. |
17 Class implementing the base class for all configuration pages. |
41 |
42 |
42 @param state state data generated by saveState |
43 @param state state data generated by saveState |
43 """ |
44 """ |
44 return |
45 return |
45 |
46 |
46 def initColour(self, colourKey, button, prefMethod, byName=False, hasAlpha=False): |
47 def initColour(self, colourKey, button, prefMethod, byName=False, |
|
48 hasAlpha=False): |
47 """ |
49 """ |
48 Public method to initialize a colour selection button. |
50 Public method to initialize a colour selection button. |
49 |
51 |
50 @param colourKey key of the colour resource (string) |
52 @param colourKey key of the colour resource (string) |
51 @param button reference to a button to show the colour on (QPushButton) |
53 @param button reference to a button to show the colour on (QPushButton) |
52 @param prefMethod preferences method to get the colour |
54 @param prefMethod preferences method to get the colour |
53 @keyparam byName flag indicating to retrieve/save by colour name (boolean) |
55 @keyparam byName flag indicating to retrieve/save by colour name |
|
56 (boolean) |
54 @keyparam hasAlpha flag indicating to allow alpha channel (boolean) |
57 @keyparam hasAlpha flag indicating to allow alpha channel (boolean) |
55 """ |
58 """ |
56 colour = QColor(prefMethod(colourKey)) |
59 colour = QColor(prefMethod(colourKey)) |
57 size = button.size() |
60 size = button.size() |
58 pm = QPixmap(size.width() / 2, size.height() / 2) |
61 pm = QPixmap(size.width() / 2, size.height() / 2) |
72 button = self.sender() |
75 button = self.sender() |
73 colorKey = button.property("colorKey") |
76 colorKey = button.property("colorKey") |
74 hasAlpha = button.property("hasAlpha") |
77 hasAlpha = button.property("hasAlpha") |
75 |
78 |
76 if hasAlpha: |
79 if hasAlpha: |
77 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], None, "", |
80 colour = QColorDialog.getColor( |
|
81 self.__coloursDict[colorKey][0], None, "", |
78 QColorDialog.ShowAlphaChannel) |
82 QColorDialog.ShowAlphaChannel) |
79 else: |
83 else: |
80 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0]) |
84 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0]) |
81 if colour.isValid(): |
85 if colour.isValid(): |
82 size = button.iconSize() |
86 size = button.iconSize() |