Thu, 13 May 2010 17:43:30 +0200
Added a menu to the highlighting styles config page to change individual aspects of a font only.
--- a/APIs/Python3/eric5.api Thu May 13 14:36:46 2010 +0200 +++ b/APIs/Python3/eric5.api Thu May 13 17:43:30 2010 +0200 @@ -3699,16 +3699,18 @@ eric5.Preferences.ConfigurationPages.EditorHighlightersPage.EditorHighlightersPage.save?4() eric5.Preferences.ConfigurationPages.EditorHighlightersPage.EditorHighlightersPage?1(lexers) eric5.Preferences.ConfigurationPages.EditorHighlightersPage.create?4(dlg) +eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.FAMILYANDSIZE?7 +eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.FAMILYONLY?7 +eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.FONT?7 +eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.SIZEONLY?7 eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_allBackgroundColoursButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_allDefaultButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_allEolFillButton_clicked?4() -eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_allFontsButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_backgroundButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_defaultButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_eolfillCheckBox_toggled?4(b) eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_exportAllButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_exportCurrentButton_clicked?4() -eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_fontButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_foregroundButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_importAllButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_importCurrentButton_clicked?4() @@ -3716,6 +3718,8 @@ eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.on_styleElementList_currentRowChanged?4(index) eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.save?4() eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.saveState?4() +eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.setFont?4(style, familyOnly, sizeOnly) +eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.setSampleFont?4(familyOnly, sizeOnly) eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage.setState?4(state) eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.EditorHighlightingStylesPage?1(lexers) eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.create?4(dlg)
--- a/Documentation/Help/source.qhp Thu May 13 14:36:46 2010 +0200 +++ b/Documentation/Help/source.qhp Thu May 13 17:43:30 2010 +0200 @@ -7372,19 +7372,20 @@ <keyword name="EditorHighlightingStylesPage" id="EditorHighlightingStylesPage" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage" /> <keyword name="create" id="create" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#create" /> <keyword name="EditorHighlightingStylesPage (Constructor)" id="EditorHighlightingStylesPage (Constructor)" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__init__" /> + <keyword name="EditorHighlightingStylesPage.__allFontsButtonMenuTriggered" id="EditorHighlightingStylesPage.__allFontsButtonMenuTriggered" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__allFontsButtonMenuTriggered" /> + <keyword name="EditorHighlightingStylesPage.__changeFont" id="EditorHighlightingStylesPage.__changeFont" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__changeFont" /> <keyword name="EditorHighlightingStylesPage.__exportStyles" id="EditorHighlightingStylesPage.__exportStyles" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__exportStyles" /> + <keyword name="EditorHighlightingStylesPage.__fontButtonMenuTriggered" id="EditorHighlightingStylesPage.__fontButtonMenuTriggered" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__fontButtonMenuTriggered" /> <keyword name="EditorHighlightingStylesPage.__importStyles" id="EditorHighlightingStylesPage.__importStyles" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__importStyles" /> <keyword name="EditorHighlightingStylesPage.__setToDefault" id="EditorHighlightingStylesPage.__setToDefault" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.__setToDefault" /> <keyword name="EditorHighlightingStylesPage.on_allBackgroundColoursButton_clicked" id="EditorHighlightingStylesPage.on_allBackgroundColoursButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_allBackgroundColoursButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_allDefaultButton_clicked" id="EditorHighlightingStylesPage.on_allDefaultButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_allDefaultButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_allEolFillButton_clicked" id="EditorHighlightingStylesPage.on_allEolFillButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_allEolFillButton_clicked" /> - <keyword name="EditorHighlightingStylesPage.on_allFontsButton_clicked" id="EditorHighlightingStylesPage.on_allFontsButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_allFontsButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_backgroundButton_clicked" id="EditorHighlightingStylesPage.on_backgroundButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_backgroundButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_defaultButton_clicked" id="EditorHighlightingStylesPage.on_defaultButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_defaultButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_eolfillCheckBox_toggled" id="EditorHighlightingStylesPage.on_eolfillCheckBox_toggled" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_eolfillCheckBox_toggled" /> <keyword name="EditorHighlightingStylesPage.on_exportAllButton_clicked" id="EditorHighlightingStylesPage.on_exportAllButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_exportAllButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_exportCurrentButton_clicked" id="EditorHighlightingStylesPage.on_exportCurrentButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_exportCurrentButton_clicked" /> - <keyword name="EditorHighlightingStylesPage.on_fontButton_clicked" id="EditorHighlightingStylesPage.on_fontButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_fontButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_foregroundButton_clicked" id="EditorHighlightingStylesPage.on_foregroundButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_foregroundButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_importAllButton_clicked" id="EditorHighlightingStylesPage.on_importAllButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_importAllButton_clicked" /> <keyword name="EditorHighlightingStylesPage.on_importCurrentButton_clicked" id="EditorHighlightingStylesPage.on_importCurrentButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_importCurrentButton_clicked" /> @@ -7392,6 +7393,8 @@ <keyword name="EditorHighlightingStylesPage.on_styleElementList_currentRowChanged" id="EditorHighlightingStylesPage.on_styleElementList_currentRowChanged" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.on_styleElementList_currentRowChanged" /> <keyword name="EditorHighlightingStylesPage.save" id="EditorHighlightingStylesPage.save" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.save" /> <keyword name="EditorHighlightingStylesPage.saveState" id="EditorHighlightingStylesPage.saveState" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.saveState" /> + <keyword name="EditorHighlightingStylesPage.setFont" id="EditorHighlightingStylesPage.setFont" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.setFont" /> + <keyword name="EditorHighlightingStylesPage.setSampleFont" id="EditorHighlightingStylesPage.setSampleFont" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.setSampleFont" /> <keyword name="EditorHighlightingStylesPage.setState" id="EditorHighlightingStylesPage.setState" ref="eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html#EditorHighlightingStylesPage.setState" /> <keyword name="EditorTypingPage (Module)" id="EditorTypingPage (Module)" ref="eric5.Preferences.ConfigurationPages.EditorTypingPage.html" /> <keyword name="EditorTypingPage" id="EditorTypingPage" ref="eric5.Preferences.ConfigurationPages.EditorTypingPage.html#EditorTypingPage" />
--- a/Documentation/Source/eric5.Plugins.VcsPlugins.vcsMercurial.HgLogBrowserDialog.html Thu May 13 14:36:46 2010 +0200 +++ b/Documentation/Source/eric5.Plugins.VcsPlugins.vcsMercurial.HgLogBrowserDialog.html Thu May 13 17:43:30 2010 +0200 @@ -121,7 +121,7 @@ <td>Private slot implementing a close event handler.</td> </tr><tr> <td><a href="#HgLogBrowserDialog.col2x">col2x</a></td> -<td></td> +<td>Local function to calculate a x-position for a column.</td> </tr><tr> <td><a href="#HgLogBrowserDialog.keyPressEvent">keyPressEvent</a></td> <td>Protected slot to handle a key press event.</td> @@ -459,7 +459,17 @@ </dl><a NAME="HgLogBrowserDialog.col2x" ID="HgLogBrowserDialog.col2x"></a> <h4>HgLogBrowserDialog.col2x</h4> <b>col2x</b>(<i>radius</i>) -<a NAME="HgLogBrowserDialog.keyPressEvent" ID="HgLogBrowserDialog.keyPressEvent"></a> +<p> + Local function to calculate a x-position for a column. +</p><dl> +<dt><i>col</i></dt> +<dd> +column number (integer) +</dd><dt><i>radius</i></dt> +<dd> +radius of the indicator circle (integer) +</dd> +</dl><a NAME="HgLogBrowserDialog.keyPressEvent" ID="HgLogBrowserDialog.keyPressEvent"></a> <h4>HgLogBrowserDialog.keyPressEvent</h4> <b>keyPressEvent</b>(<i>evt</i>) <p>
--- a/Documentation/Source/eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html Thu May 13 14:36:46 2010 +0200 +++ b/Documentation/Source/eric5.Preferences.ConfigurationPages.EditorHighlightingStylesPage.html Thu May 13 17:43:30 2010 +0200 @@ -52,7 +52,7 @@ ConfigurationPageBase, Ui_EditorHighlightingStylesPage <h3>Class Attributes</h3> <table> -<tr><td>None</td></tr> +<tr><td>FAMILYANDSIZE</td></tr><tr><td>FAMILYONLY</td></tr><tr><td>FONT</td></tr><tr><td>SIZEONLY</td></tr> </table> <h3>Methods</h3> <table> @@ -60,9 +60,18 @@ <td><a href="#EditorHighlightingStylesPage.__init__">EditorHighlightingStylesPage</a></td> <td>Constructor</td> </tr><tr> +<td><a href="#EditorHighlightingStylesPage.__allFontsButtonMenuTriggered">__allFontsButtonMenuTriggered</a></td> +<td>Private slot used to change the font of all styles of a selected lexer.</td> +</tr><tr> +<td><a href="#EditorHighlightingStylesPage.__changeFont">__changeFont</a></td> +<td>Private slot to change the highlighter font.</td> +</tr><tr> <td><a href="#EditorHighlightingStylesPage.__exportStyles">__exportStyles</a></td> <td>Private method to export the styles of the given lexers.</td> </tr><tr> +<td><a href="#EditorHighlightingStylesPage.__fontButtonMenuTriggered">__fontButtonMenuTriggered</a></td> +<td>Private slot used to select the font of the selected style and lexer.</td> +</tr><tr> <td><a href="#EditorHighlightingStylesPage.__importStyles">__importStyles</a></td> <td>Private method to import the styles of the given lexers.</td> </tr><tr> @@ -78,9 +87,6 @@ <td><a href="#EditorHighlightingStylesPage.on_allEolFillButton_clicked">on_allEolFillButton_clicked</a></td> <td>Private method used to set the eolfill for all styles of a selected lexer.</td> </tr><tr> -<td><a href="#EditorHighlightingStylesPage.on_allFontsButton_clicked">on_allFontsButton_clicked</a></td> -<td>Private method used to change the font of all styles of a selected lexer.</td> -</tr><tr> <td><a href="#EditorHighlightingStylesPage.on_backgroundButton_clicked">on_backgroundButton_clicked</a></td> <td>Private method used to select the background colour of the selected style and lexer.</td> </tr><tr> @@ -96,9 +102,6 @@ <td><a href="#EditorHighlightingStylesPage.on_exportCurrentButton_clicked">on_exportCurrentButton_clicked</a></td> <td>Private slot to export the styles of the current lexer.</td> </tr><tr> -<td><a href="#EditorHighlightingStylesPage.on_fontButton_clicked">on_fontButton_clicked</a></td> -<td>Private method used to select the font of the selected style and lexer.</td> -</tr><tr> <td><a href="#EditorHighlightingStylesPage.on_foregroundButton_clicked">on_foregroundButton_clicked</a></td> <td>Private method used to select the foreground colour of the selected style and lexer.</td> </tr><tr> @@ -120,6 +123,12 @@ <td><a href="#EditorHighlightingStylesPage.saveState">saveState</a></td> <td>Public method to save the current state of the widget.</td> </tr><tr> +<td><a href="#EditorHighlightingStylesPage.setFont">setFont</a></td> +<td>Local function to set the font.</td> +</tr><tr> +<td><a href="#EditorHighlightingStylesPage.setSampleFont">setSampleFont</a></td> +<td>Local function to set the font of the sample text.</td> +</tr><tr> <td><a href="#EditorHighlightingStylesPage.setState">setState</a></td> <td>Public method to set the state of the widget.</td> </tr> @@ -134,6 +143,32 @@ <dd> reference to the lexers dictionary </dd> +</dl><a NAME="EditorHighlightingStylesPage.__allFontsButtonMenuTriggered" ID="EditorHighlightingStylesPage.__allFontsButtonMenuTriggered"></a> +<h4>EditorHighlightingStylesPage.__allFontsButtonMenuTriggered</h4> +<b>__allFontsButtonMenuTriggered</b>(<i>act</i>) +<p> + Private slot used to change the font of all styles of a selected lexer. +</p><dl> +<dt><i>act</i></dt> +<dd> +reference to the triggering action (QAction) +</dd> +</dl><a NAME="EditorHighlightingStylesPage.__changeFont" ID="EditorHighlightingStylesPage.__changeFont"></a> +<h4>EditorHighlightingStylesPage.__changeFont</h4> +<b>__changeFont</b>(<i>doAll, familyOnly, sizeOnly</i>) +<p> + Private slot to change the highlighter font. +</p><dl> +<dt><i>doAll</i></dt> +<dd> +flag indicating to change the font for all styles (boolean) +</dd><dt><i>familyOnly</i></dt> +<dd> +flag indicating to set the font family only (boolean) +</dd><dt><i>sizeOnly</i></dt> +<dd> +flag indicating to set the font size only (boolean +</dd> </dl><a NAME="EditorHighlightingStylesPage.__exportStyles" ID="EditorHighlightingStylesPage.__exportStyles"></a> <h4>EditorHighlightingStylesPage.__exportStyles</h4> <b>__exportStyles</b>(<i>lexers</i>) @@ -144,6 +179,16 @@ <dd> list of lexer objects for which to export the styles </dd> +</dl><a NAME="EditorHighlightingStylesPage.__fontButtonMenuTriggered" ID="EditorHighlightingStylesPage.__fontButtonMenuTriggered"></a> +<h4>EditorHighlightingStylesPage.__fontButtonMenuTriggered</h4> +<b>__fontButtonMenuTriggered</b>(<i>act</i>) +<p> + Private slot used to select the font of the selected style and lexer. +</p><dl> +<dt><i>act</i></dt> +<dd> +reference to the triggering action (QAction) +</dd> </dl><a NAME="EditorHighlightingStylesPage.__importStyles" ID="EditorHighlightingStylesPage.__importStyles"></a> <h4>EditorHighlightingStylesPage.__importStyles</h4> <b>__importStyles</b>(<i>lexers</i>) @@ -180,11 +225,6 @@ <b>on_allEolFillButton_clicked</b>(<i></i>) <p> Private method used to set the eolfill for all styles of a selected lexer. -</p><a NAME="EditorHighlightingStylesPage.on_allFontsButton_clicked" ID="EditorHighlightingStylesPage.on_allFontsButton_clicked"></a> -<h4>EditorHighlightingStylesPage.on_allFontsButton_clicked</h4> -<b>on_allFontsButton_clicked</b>(<i></i>) -<p> - Private method used to change the font of all styles of a selected lexer. </p><a NAME="EditorHighlightingStylesPage.on_backgroundButton_clicked" ID="EditorHighlightingStylesPage.on_backgroundButton_clicked"></a> <h4>EditorHighlightingStylesPage.on_backgroundButton_clicked</h4> <b>on_backgroundButton_clicked</b>(<i></i>) @@ -216,11 +256,6 @@ <b>on_exportCurrentButton_clicked</b>(<i></i>) <p> Private slot to export the styles of the current lexer. -</p><a NAME="EditorHighlightingStylesPage.on_fontButton_clicked" ID="EditorHighlightingStylesPage.on_fontButton_clicked"></a> -<h4>EditorHighlightingStylesPage.on_fontButton_clicked</h4> -<b>on_fontButton_clicked</b>(<i></i>) -<p> - Private method used to select the font of the selected style and lexer. </p><a NAME="EditorHighlightingStylesPage.on_foregroundButton_clicked" ID="EditorHighlightingStylesPage.on_foregroundButton_clicked"></a> <h4>EditorHighlightingStylesPage.on_foregroundButton_clicked</h4> <b>on_foregroundButton_clicked</b>(<i></i>) @@ -273,6 +308,41 @@ array containing the index of the selected lexer language (integer) and the index of the selected lexer entry (integer) </dd> +</dl><a NAME="EditorHighlightingStylesPage.setFont" ID="EditorHighlightingStylesPage.setFont"></a> +<h4>EditorHighlightingStylesPage.setFont</h4> +<b>setFont</b>(<i>style, familyOnly, sizeOnly</i>) +<p> + Local function to set the font. +</p><dl> +<dt><i>font</i></dt> +<dd> +font to be set (QFont) +</dd><dt><i>style</i></dt> +<dd> +style to set the font for (integer) +</dd><dt><i>familyOnly</i></dt> +<dd> +flag indicating to set the font family only (boolean) +</dd><dt><i>sizeOnly</i></dt> +<dd> +flag indicating to set the font size only (boolean +</dd> +</dl><a NAME="EditorHighlightingStylesPage.setSampleFont" ID="EditorHighlightingStylesPage.setSampleFont"></a> +<h4>EditorHighlightingStylesPage.setSampleFont</h4> +<b>setSampleFont</b>(<i>familyOnly, sizeOnly</i>) +<p> + Local function to set the font of the sample text. +</p><dl> +<dt><i>font</i></dt> +<dd> +font to be set (QFont) +</dd><dt><i>familyOnly</i></dt> +<dd> +flag indicating to set the font family only (boolean) +</dd><dt><i>sizeOnly</i></dt> +<dd> +flag indicating to set the font size only (boolean +</dd> </dl><a NAME="EditorHighlightingStylesPage.setState" ID="EditorHighlightingStylesPage.setState"></a> <h4>EditorHighlightingStylesPage.setState</h4> <b>setState</b>(<i>state</i>)
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Thu May 13 14:36:46 2010 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Thu May 13 17:43:30 2010 +0200 @@ -238,6 +238,12 @@ @return icon for the node (QIcon) """ def col2x(col, radius): + """ + Local function to calculate a x-position for a column. + + @param col column number (integer) + @param radius radius of the indicator circle (integer) + """ return int(1.2 * radius) * col + radius // 2 + 3 radius = self.__dotRadius
--- a/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Thu May 13 14:36:46 2010 +0200 +++ b/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Thu May 13 17:43:30 2010 +0200 @@ -11,7 +11,7 @@ from PyQt4.QtCore import pyqtSlot, QFileInfo from PyQt4.QtGui import QPalette, QFileDialog, QColorDialog, QFontDialog, \ - QInputDialog, QMessageBox + QInputDialog, QMessageBox, QFont, QMenu from .ConfigurationPageBase import ConfigurationPageBase from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage @@ -29,6 +29,11 @@ """ Class implementing the Editor Highlighting Styles configuration page. """ + FAMILYONLY = 0 + SIZEONLY = 1 + FAMILYANDSIZE = 2 + FONT = 99 + def __init__(self, lexers): """ Constructor @@ -39,6 +44,32 @@ self.setupUi(self) self.setObjectName("EditorHighlightingStylesPage") + self.__fontButtonMenu = QMenu() + act = self.__fontButtonMenu.addAction(self.trUtf8("Font")) + act.setData(self.FONT) + self.__fontButtonMenu.addSeparator() + act = self.__fontButtonMenu.addAction(self.trUtf8("Family and Size only")) + act.setData(self.FAMILYANDSIZE) + act = self.__fontButtonMenu.addAction(self.trUtf8("Family only")) + act.setData(self.FAMILYONLY) + act = self.__fontButtonMenu.addAction(self.trUtf8("Size only")) + act.setData(self.SIZEONLY) + self.__fontButtonMenu.triggered.connect(self.__fontButtonMenuTriggered) + self.fontButton.setMenu(self.__fontButtonMenu) + + self.__allFontsButtonMenu = QMenu() + act = self.__allFontsButtonMenu.addAction(self.trUtf8("Font")) + act.setData(self.FONT) + self.__allFontsButtonMenu.addSeparator() + act = self.__allFontsButtonMenu.addAction(self.trUtf8("Family and Size only")) + act.setData(self.FAMILYANDSIZE) + act = self.__allFontsButtonMenu.addAction(self.trUtf8("Family only")) + act.setData(self.FAMILYONLY) + act = self.__allFontsButtonMenu.addAction(self.trUtf8("Size only")) + act.setData(self.SIZEONLY) + self.__allFontsButtonMenu.triggered.connect(self.__allFontsButtonMenuTriggered) + self.allFontsButton.setMenu(self.__allFontsButtonMenu) + self.lexer = None self.lexers = lexers @@ -157,31 +188,89 @@ for style in list(self.lexer.ind2style.values()): self.lexer.setPaper(colour, style) - @pyqtSlot() - def on_fontButton_clicked(self): + def __changeFont(self, doAll, familyOnly, sizeOnly): + """ + Private slot to change the highlighter font. + + @param doAll flag indicating to change the font for all styles (boolean) + @param familyOnly flag indicating to set the font family only (boolean) + @param sizeOnly flag indicating to set the font size only (boolean """ - Private method used to select the font of the selected style and lexer. - """ + def setFont(font, style, familyOnly, sizeOnly): + """ + Local function to set the font. + + @param font font to be set (QFont) + @param style style to set the font for (integer) + @param familyOnly flag indicating to set the font family only (boolean) + @param sizeOnly flag indicating to set the font size only (boolean + """ + if familyOnly or sizeOnly: + newFont = QFont(self.lexer.font(style)) + if familyOnly: + newFont.setFamily(font.family()) + if sizeOnly: + newFont.setPointSize(font.pointSize()) + self.lexer.setFont(newFont, style) + else: + self.lexer.setFont(font, style) + + def setSampleFont(font, familyOnly, sizeOnly): + """ + Local function to set the font of the sample text. + + @param font font to be set (QFont) + @param familyOnly flag indicating to set the font family only (boolean) + @param sizeOnly flag indicating to set the font size only (boolean + """ + if familyOnly or sizeOnly: + newFont = QFont(self.lexer.font(self.style)) + if familyOnly: + newFont.setFamily(font.family()) + if sizeOnly: + newFont.setPointSize(font.pointSize()) + self.sampleText.setFont(newFont) + else: + self.sampleText.setFont(font) + font, ok = QFontDialog.getFont(self.lexer.font(self.style)) if ok: - self.sampleText.setFont(font) - if len(self.styleElementList.selectedItems()) > 1: + setSampleFont(font, familyOnly, sizeOnly) + if doAll: + for style in list(self.lexer.ind2style.values()): + setFont(font, style, familyOnly, sizeOnly) + elif len(self.styleElementList.selectedItems()) > 1: for selItem in self.styleElementList.selectedItems(): style = self.lexer.ind2style[self.styleElementList.row(selItem)] - self.lexer.setFont(font, style) + setFont(font, style, familyOnly, sizeOnly) else: - self.lexer.setFont(font, self.style) + setFont(font, self.style, familyOnly, sizeOnly) - @pyqtSlot() - def on_allFontsButton_clicked(self): + def __fontButtonMenuTriggered(self, act): + """ + Private slot used to select the font of the selected style and lexer. + + @param act reference to the triggering action (QAction) """ - Private method used to change the font of all styles of a selected lexer. + if act is None: + return + + familyOnly = act.data() in [self.FAMILYANDSIZE, self.FAMILYONLY] + sizeOnly = act.data() in [self.FAMILYANDSIZE, self.SIZEONLY] + self.__changeFont(False, familyOnly, sizeOnly) + + def __allFontsButtonMenuTriggered(self, act): """ - font, ok = QFontDialog.getFont(self.lexer.font(self.style)) - if ok: - self.sampleText.setFont(font) - for style in list(self.lexer.ind2style.values()): - self.lexer.setFont(font, style) + Private slot used to change the font of all styles of a selected lexer. + + @param act reference to the triggering action (QAction) + """ + if act is None: + return + + familyOnly = act.data() in [self.FAMILYANDSIZE, self.FAMILYONLY] + sizeOnly = act.data() in [self.FAMILYANDSIZE, self.SIZEONLY] + self.__changeFont(True, familyOnly, sizeOnly) def on_eolfillCheckBox_toggled(self, b): """
--- a/changelog Thu May 13 14:36:46 2010 +0200 +++ b/changelog Thu May 13 17:43:30 2010 +0200 @@ -5,7 +5,9 @@ - added code to save the editor zoom factor in the session file - added code to configure the zoom factor a file is opened with - added code to update the file browser window (mostly) automatically -- added code to update the Others tab of the project browser (mostly) automatically +- added code to update the Others tab of the project browser (mostly) automatically +- added a menu to the highlighting styles config page to change individual + aspects of a font only Version 5.0-snapshot-20100508: - bug fixes