mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Allow changing font size in the template editor dialog
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
		
						commit
						cac89566a3
					
				@ -127,6 +127,7 @@ defs['show_highlight_toggle_button'] = False
 | 
				
			|||||||
defs['add_comments_to_email'] = False
 | 
					defs['add_comments_to_email'] = False
 | 
				
			||||||
defs['cb_preserve_aspect_ratio'] = False
 | 
					defs['cb_preserve_aspect_ratio'] = False
 | 
				
			||||||
defs['show_rating_in_cover_browser'] = True
 | 
					defs['show_rating_in_cover_browser'] = True
 | 
				
			||||||
 | 
					defs['gpm_template_editor_font_size'] = 10
 | 
				
			||||||
del defs
 | 
					del defs
 | 
				
			||||||
# }}}
 | 
					# }}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ from PyQt4.Qt import (Qt, QDialog, QDialogButtonBox, QSyntaxHighlighter, QFont,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from calibre import sanitize_file_name_unicode
 | 
					from calibre import sanitize_file_name_unicode
 | 
				
			||||||
from calibre.constants import config_dir
 | 
					from calibre.constants import config_dir
 | 
				
			||||||
 | 
					from calibre.gui2 import gprefs
 | 
				
			||||||
from calibre.gui2.dialogs.template_dialog_ui import Ui_TemplateDialog
 | 
					from calibre.gui2.dialogs.template_dialog_ui import Ui_TemplateDialog
 | 
				
			||||||
from calibre.utils.formatter_functions import formatter_functions
 | 
					from calibre.utils.formatter_functions import formatter_functions
 | 
				
			||||||
from calibre.utils.icu import sort_key
 | 
					from calibre.utils.icu import sort_key
 | 
				
			||||||
@ -75,7 +76,6 @@ class TemplateHighlighter(QSyntaxHighlighter):
 | 
				
			|||||||
    def initializeFormats(self):
 | 
					    def initializeFormats(self):
 | 
				
			||||||
        Config = self.Config
 | 
					        Config = self.Config
 | 
				
			||||||
        Config["fontfamily"] = "monospace"
 | 
					        Config["fontfamily"] = "monospace"
 | 
				
			||||||
        #Config["fontsize"] = 10
 | 
					 | 
				
			||||||
        for name, color, bold, italic in (
 | 
					        for name, color, bold, italic in (
 | 
				
			||||||
                ("normal", "#000000", False, False),
 | 
					                ("normal", "#000000", False, False),
 | 
				
			||||||
                ("keyword", "#000080", True, False),
 | 
					                ("keyword", "#000080", True, False),
 | 
				
			||||||
@ -88,10 +88,10 @@ class TemplateHighlighter(QSyntaxHighlighter):
 | 
				
			|||||||
            Config["%sfontcolor" % name] = color
 | 
					            Config["%sfontcolor" % name] = color
 | 
				
			||||||
            Config["%sfontbold" % name] = bold
 | 
					            Config["%sfontbold" % name] = bold
 | 
				
			||||||
            Config["%sfontitalic" % name] = italic
 | 
					            Config["%sfontitalic" % name] = italic
 | 
				
			||||||
 | 
					 | 
				
			||||||
        baseFormat = QTextCharFormat()
 | 
					        baseFormat = QTextCharFormat()
 | 
				
			||||||
        baseFormat.setFontFamily(Config["fontfamily"])
 | 
					        baseFormat.setFontFamily(Config["fontfamily"])
 | 
				
			||||||
        #baseFormat.setFontPointSize(Config["fontsize"])
 | 
					        Config["fontsize"] = gprefs['gpm_template_editor_font_size']
 | 
				
			||||||
 | 
					        baseFormat.setFontPointSize(Config["fontsize"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for name in ("normal", "keyword", "builtin", "comment",
 | 
					        for name in ("normal", "keyword", "builtin", "comment",
 | 
				
			||||||
                     "string", "number", "lparen", "rparen"):
 | 
					                     "string", "number", "lparen", "rparen"):
 | 
				
			||||||
@ -325,6 +325,14 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
 | 
				
			|||||||
                '<a href="http://manual.calibre-ebook.com/template_ref.html">'
 | 
					                '<a href="http://manual.calibre-ebook.com/template_ref.html">'
 | 
				
			||||||
                '%s</a>'%tt)
 | 
					                '%s</a>'%tt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.font_size_box.setValue(gprefs['gpm_template_editor_font_size'])
 | 
				
			||||||
 | 
					        self.font_size_box.valueChanged.connect(self.font_size_changed)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def font_size_changed(self, toWhat):
 | 
				
			||||||
 | 
					        gprefs['gpm_template_editor_font_size'] = toWhat
 | 
				
			||||||
 | 
					        self.highlighter.initializeFormats()
 | 
				
			||||||
 | 
					        self.highlighter.rehighlight()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def filename_button_clicked(self):
 | 
					    def filename_button_clicked(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            path = choose_files(self, 'choose_category_icon',
 | 
					            path = choose_files(self, 'choose_category_icon',
 | 
				
			||||||
 | 
				
			|||||||
@ -166,17 +166,51 @@
 | 
				
			|||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="6" column="1">
 | 
					     <item row="6" column="0">
 | 
				
			||||||
      <widget class="QDialogButtonBox" name="buttonBox">
 | 
					      <widget class="QLabel" name="label">
 | 
				
			||||||
       <property name="orientation">
 | 
					       <property name="text">
 | 
				
			||||||
        <enum>Qt::Horizontal</enum>
 | 
					        <string>Font size:</string>
 | 
				
			||||||
       </property>
 | 
					 | 
				
			||||||
       <property name="standardButtons">
 | 
					 | 
				
			||||||
        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
					 | 
				
			||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="6" column="0">
 | 
					     <item row="6" column="1">
 | 
				
			||||||
 | 
					      <layout class="QGridLayout" name="gridLayout">
 | 
				
			||||||
 | 
					       <item row="1" column="0">
 | 
				
			||||||
 | 
					        <widget class="QSpinBox" name="font_size_box"/>
 | 
				
			||||||
 | 
					       </item>
 | 
				
			||||||
 | 
					       <item row="1" column="1">
 | 
				
			||||||
 | 
					        <spacer>
 | 
				
			||||||
 | 
					         <property name="orientation">
 | 
				
			||||||
 | 
					          <enum>Qt::Horizontal</enum>
 | 
				
			||||||
 | 
					         </property>
 | 
				
			||||||
 | 
					         <property name="sizeHint" stdset="0">
 | 
				
			||||||
 | 
					          <size>
 | 
				
			||||||
 | 
					           <width>0</width>
 | 
				
			||||||
 | 
					           <height>0</height>
 | 
				
			||||||
 | 
					          </size>
 | 
				
			||||||
 | 
					         </property>
 | 
				
			||||||
 | 
					        </spacer>
 | 
				
			||||||
 | 
					       </item>
 | 
				
			||||||
 | 
					       <item row="1" column="2">
 | 
				
			||||||
 | 
					        <widget class="QDialogButtonBox" name="buttonBox">
 | 
				
			||||||
 | 
					         <property name="orientation">
 | 
				
			||||||
 | 
					          <enum>Qt::Horizontal</enum>
 | 
				
			||||||
 | 
					         </property>
 | 
				
			||||||
 | 
					         <property name="standardButtons">
 | 
				
			||||||
 | 
					          <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
				
			||||||
 | 
					         </property>
 | 
				
			||||||
 | 
					        </widget>
 | 
				
			||||||
 | 
					       </item>
 | 
				
			||||||
 | 
					      </layout>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					     <item row="7" column="0" colspan="2">
 | 
				
			||||||
 | 
					      <widget class="QFrame">
 | 
				
			||||||
 | 
					       <property name="frameShape">
 | 
				
			||||||
 | 
					        <enum>QFrame::HLine</enum>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </widget>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					     <item row="8" column="0">
 | 
				
			||||||
      <widget class="QLabel" name="label">
 | 
					      <widget class="QLabel" name="label">
 | 
				
			||||||
       <property name="text">
 | 
					       <property name="text">
 | 
				
			||||||
        <string>Function &name:</string>
 | 
					        <string>Function &name:</string>
 | 
				
			||||||
@ -186,10 +220,10 @@
 | 
				
			|||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="7" column="1">
 | 
					     <item row="8" column="1">
 | 
				
			||||||
      <widget class="QComboBox" name="function"/>
 | 
					      <widget class="QComboBox" name="function"/>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="8" column="0">
 | 
					     <item row="9" column="0">
 | 
				
			||||||
      <widget class="QLabel" name="label_2">
 | 
					      <widget class="QLabel" name="label_2">
 | 
				
			||||||
       <property name="text">
 | 
					       <property name="text">
 | 
				
			||||||
        <string>&Documentation:</string>
 | 
					        <string>&Documentation:</string>
 | 
				
			||||||
@ -202,7 +236,7 @@
 | 
				
			|||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="9" column="0">
 | 
					     <item row="10" column="0">
 | 
				
			||||||
      <widget class="QLabel" name="label_3">
 | 
					      <widget class="QLabel" name="label_3">
 | 
				
			||||||
       <property name="text">
 | 
					       <property name="text">
 | 
				
			||||||
        <string>Python &code:</string>
 | 
					        <string>Python &code:</string>
 | 
				
			||||||
@ -215,7 +249,7 @@
 | 
				
			|||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="8" column="1">
 | 
					     <item row="9" column="1">
 | 
				
			||||||
      <widget class="QPlainTextEdit" name="documentation">
 | 
					      <widget class="QPlainTextEdit" name="documentation">
 | 
				
			||||||
       <property name="maximumSize">
 | 
					       <property name="maximumSize">
 | 
				
			||||||
        <size>
 | 
					        <size>
 | 
				
			||||||
@ -225,17 +259,17 @@
 | 
				
			|||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="9" column="1">
 | 
					     <item row="10" column="1">
 | 
				
			||||||
      <widget class="QPlainTextEdit" name="source_code"/>
 | 
					      <widget class="QPlainTextEdit" name="source_code"/>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="10" column="1">
 | 
					     <item row="11" column="1">
 | 
				
			||||||
      <widget class="QLabel" name="template_tutorial">
 | 
					      <widget class="QLabel" name="template_tutorial">
 | 
				
			||||||
       <property name="openExternalLinks">
 | 
					       <property name="openExternalLinks">
 | 
				
			||||||
        <bool>true</bool>
 | 
					        <bool>true</bool>
 | 
				
			||||||
       </property>
 | 
					       </property>
 | 
				
			||||||
      </widget>
 | 
					      </widget>
 | 
				
			||||||
     </item>
 | 
					     </item>
 | 
				
			||||||
     <item row="11" column="1">
 | 
					     <item row="12" column="1">
 | 
				
			||||||
      <widget class="QLabel" name="template_func_reference">
 | 
					      <widget class="QLabel" name="template_func_reference">
 | 
				
			||||||
       <property name="openExternalLinks">
 | 
					       <property name="openExternalLinks">
 | 
				
			||||||
        <bool>true</bool>
 | 
					        <bool>true</bool>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user