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.QtGui import QWidget, QIcon, QPixmap, QColor, QColorDialog, QFontDialog |
10 from PyQt4.QtGui import QWidget, QIcon, QPixmap, QColor, QColorDialog, QFontDialog |
|
11 |
11 |
12 |
12 class ConfigurationPageBase(QWidget): |
13 class ConfigurationPageBase(QWidget): |
13 """ |
14 """ |
14 Class implementing the base class for all configuration pages. |
15 Class implementing the base class for all configuration pages. |
15 """ |
16 """ |
48 @param prefMethod preferences method to get the colour |
49 @param prefMethod preferences method to get the colour |
49 @return reference to the created colour (QColor) |
50 @return reference to the created colour (QColor) |
50 """ |
51 """ |
51 colour = QColor(prefMethod(colourstr)) |
52 colour = QColor(prefMethod(colourstr)) |
52 size = button.size() |
53 size = button.size() |
53 pm = QPixmap(size.width()/2, size.height()/2) |
54 pm = QPixmap(size.width() / 2, size.height() / 2) |
54 pm.fill(colour) |
55 pm.fill(colour) |
55 button.setIconSize(pm.size()) |
56 button.setIconSize(pm.size()) |
56 button.setIcon(QIcon(pm)) |
57 button.setIcon(QIcon(pm)) |
57 return colour |
58 return colour |
58 |
59 |
59 def selectColour(self, button, colourVar, showAlpha = False): |
60 def selectColour(self, button, colourVar, showAlpha=False): |
60 """ |
61 """ |
61 Public method used by the colour selection buttons. |
62 Public method used by the colour selection buttons. |
62 |
63 |
63 @param button reference to a button to show the colour on (QPushButton) |
64 @param button reference to a button to show the colour on (QPushButton) |
64 @param colourVar reference to the variable containing the colour (QColor) |
65 @param colourVar reference to the variable containing the colour (QColor) |
65 @param showAlpha flag indicating to show a selection for the alpha |
66 @param showAlpha flag indicating to show a selection for the alpha |
66 channel (boolean) |
67 channel (boolean) |
67 @return selected colour (QColor) |
68 @return selected colour (QColor) |
68 """ |
69 """ |
69 if showAlpha: |
70 if showAlpha: |
70 colour = QColorDialog.getColor(colourVar, None, "", |
71 colour = QColorDialog.getColor(colourVar, None, "", |
71 QColorDialog.ShowAlphaChannel) |
72 QColorDialog.ShowAlphaChannel) |
72 else: |
73 else: |
73 colour = QColorDialog.getColor(colourVar) |
74 colour = QColorDialog.getColor(colourVar) |
74 if colour.isValid(): |
75 if colour.isValid(): |
75 size = button.iconSize() |
76 size = button.iconSize() |
78 button.setIcon(QIcon(pm)) |
79 button.setIcon(QIcon(pm)) |
79 else: |
80 else: |
80 colour = colourVar |
81 colour = colourVar |
81 return colour |
82 return colour |
82 |
83 |
83 def selectFont(self, fontSample, fontVar, showFontInfo = False): |
84 def selectFont(self, fontSample, fontVar, showFontInfo=False): |
84 """ |
85 """ |
85 Public method used by the font selection buttons. |
86 Public method used by the font selection buttons. |
86 |
87 |
87 @param fontSample reference to the font sample widget (QLineEdit) |
88 @param fontSample reference to the font sample widget (QLineEdit) |
88 @param fontVar reference to the variable containing the font (QFont) |
89 @param fontVar reference to the variable containing the font (QFont) |