本文整理汇总了Python中calibre.gui2.preferences.coloring.EditRules.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python EditRules.initialize方法的具体用法?Python EditRules.initialize怎么用?Python EditRules.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.preferences.coloring.EditRules
的用法示例。
在下文中一共展示了EditRules.initialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import initialize [as 别名]
#.........这里部分代码省略.........
self.opt_cover_grid_disk_cache_size.setMaximum(self.gui.grid_view.thumbnail_cache.min_disk_cache * 100)
self.opt_cover_grid_width.valueChanged.connect(self.update_aspect_ratio)
self.opt_cover_grid_height.valueChanged.connect(self.update_aspect_ratio)
@property
def current_cover_size(self):
cval = self.opt_cover_grid_height.value()
wval = self.opt_cover_grid_width.value()
if cval < 0.1:
dpi = self.opt_cover_grid_height.logicalDpiY()
cval = auto_height(self.opt_cover_grid_height) / dpi / CM_TO_INCH
if wval < 0.1:
wval = 0.75 * cval
return wval, cval
def update_aspect_ratio(self, *args):
width, height = self.current_cover_size
ar = width / height
self.cover_grid_aspect_ratio.setText(_('Current aspect ratio (width/height): %.2g') % ar)
def resize_cover(self, smaller):
wval, cval = self.current_cover_size
ar = wval / cval
delta = 0.2 * (-1 if smaller else 1)
cval += delta
cval = max(0, cval)
self.opt_cover_grid_height.setValue(cval)
self.opt_cover_grid_width.setValue(cval * ar)
def cg_reset_size(self):
self.opt_cover_grid_width.setValue(0)
self.opt_cover_grid_height.setValue(0)
def initialize(self):
ConfigWidgetBase.initialize(self)
font = gprefs['font']
if font is not None:
font = list(font)
font.append(gprefs.get('font_stretch', QFont.Unstretched))
self.current_font = self.initial_font = font
self.update_font_display()
self.display_model.initialize()
db = self.gui.current_db
try:
idx = self.gui.library_view.currentIndex().row()
mi = db.get_metadata(idx, index_is_id=False)
except:
mi=None
self.edit_rules.initialize(db.field_metadata, db.prefs, mi, 'column_color_rules')
self.icon_rules.initialize(db.field_metadata, db.prefs, mi, 'column_icon_rules')
self.grid_rules.initialize(db.field_metadata, db.prefs, mi, 'cover_grid_icon_rules')
self.set_cg_color(gprefs['cover_grid_color'])
self.set_cg_texture(gprefs['cover_grid_texture'])
self.update_aspect_ratio()
def open_cg_cache(self):
open_local_file(self.gui.grid_view.thumbnail_cache.location)
def update_cg_cache_size(self, size):
self.cover_grid_current_disk_cache.setText(
_('Current space used: %s') % human_readable(size))
def tab_changed(self, index):
if self.tabWidget.currentWidget() is self.cover_grid_tab:
self.show_current_cache_usage()
示例2: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import initialize [as 别名]
#.........这里部分代码省略.........
"categories_using_hierarchy",
db.prefs,
setting=CommaSeparatedList,
choices=sorted(list(choices), key=sort_key),
)
self.current_font = self.initial_font = None
self.change_font_button.clicked.connect(self.change_font)
self.display_model = DisplayedFields(self.gui.current_db, self.field_display_order)
self.display_model.dataChanged.connect(self.changed_signal)
self.field_display_order.setModel(self.display_model)
self.df_up_button.clicked.connect(self.move_df_up)
self.df_down_button.clicked.connect(self.move_df_down)
self.edit_rules = EditRules(self.tabWidget)
self.edit_rules.changed.connect(self.changed_signal)
self.tabWidget.addTab(self.edit_rules, QIcon(I("format-fill-color.png")), _("Column coloring"))
self.icon_rules = EditRules(self.tabWidget)
self.icon_rules.changed.connect(self.changed_signal)
self.tabWidget.addTab(self.icon_rules, QIcon(I("icon_choose.png")), _("Column icons"))
self.tabWidget.setCurrentIndex(0)
keys = [QKeySequence("F11", QKeySequence.PortableText), QKeySequence("Ctrl+Shift+F", QKeySequence.PortableText)]
keys = [unicode(x.toString(QKeySequence.NativeText)) for x in keys]
self.fs_help_msg.setText(unicode(self.fs_help_msg.text()) % (_(" or ").join(keys)))
self.cover_grid_color_button.clicked.connect(self.change_cover_grid_color)
if not tweaks.get("use_new_db", False):
for i in range(self.tabWidget.count()):
if self.tabWidget.widget(i) is self.cover_grid_tab:
self.tabWidget.removeTab(i)
def initialize(self):
ConfigWidgetBase.initialize(self)
font = gprefs["font"]
if font is not None:
font = list(font)
font.append(gprefs.get("font_stretch", QFont.Unstretched))
self.current_font = self.initial_font = font
self.update_font_display()
self.display_model.initialize()
db = self.gui.current_db
try:
idx = self.gui.library_view.currentIndex().row()
mi = db.get_metadata(idx, index_is_id=False)
except:
mi = None
self.edit_rules.initialize(db.field_metadata, db.prefs, mi, "column_color_rules")
self.icon_rules.initialize(db.field_metadata, db.prefs, mi, "column_icon_rules")
self.set_cg_color(gprefs["cover_grid_color"])
def set_cg_color(self, val):
pal = QPalette()
pal.setColor(QPalette.Window, QColor(*val))
self.cover_grid_color_label.setPalette(pal)
def restore_defaults(self):
ConfigWidgetBase.restore_defaults(self)
ofont = self.current_font
self.current_font = None
if ofont is not None:
self.changed_signal.emit()
self.update_font_display()
self.display_model.restore_defaults()
self.edit_rules.clear()
示例3: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import initialize [as 别名]
#.........这里部分代码省略.........
choices |= set(['search'])
self.opt_categories_using_hierarchy.update_items_cache(choices)
r('categories_using_hierarchy', db.prefs, setting=CommaSeparatedList,
choices=sorted(list(choices), key=sort_key))
self.current_font = self.initial_font = None
self.change_font_button.clicked.connect(self.change_font)
self.display_model = DisplayedFields(self.gui.current_db,
self.field_display_order)
self.display_model.dataChanged.connect(self.changed_signal)
self.field_display_order.setModel(self.display_model)
self.df_up_button.clicked.connect(self.move_df_up)
self.df_down_button.clicked.connect(self.move_df_down)
self.edit_rules = EditRules(self.tabWidget)
self.edit_rules.changed.connect(self.changed_signal)
self.tabWidget.addTab(self.edit_rules,
QIcon(I('format-fill-color.png')), _('Column coloring'))
self.icon_rules = EditRules(self.tabWidget)
self.icon_rules.changed.connect(self.changed_signal)
self.tabWidget.addTab(self.icon_rules,
QIcon(I('icon_choose.png')), _('Column icons'))
self.tabWidget.setCurrentIndex(0)
keys = [QKeySequence('F11', QKeySequence.PortableText), QKeySequence(
'Ctrl+Shift+F', QKeySequence.PortableText)]
keys = [unicode(x.toString(QKeySequence.NativeText)) for x in keys]
self.fs_help_msg.setText(unicode(self.fs_help_msg.text())%(
_(' or ').join(keys)))
def initialize(self):
ConfigWidgetBase.initialize(self)
font = gprefs['font']
if font is not None:
font = list(font)
font.append(gprefs.get('font_stretch', QFont.Unstretched))
self.current_font = self.initial_font = font
self.update_font_display()
self.display_model.initialize()
db = self.gui.current_db
try:
idx = self.gui.library_view.currentIndex().row()
mi = db.get_metadata(idx, index_is_id=False)
except:
mi=None
self.edit_rules.initialize(db.field_metadata, db.prefs, mi, 'column_color_rules')
self.icon_rules.initialize(db.field_metadata, db.prefs, mi, 'column_icon_rules')
def restore_defaults(self):
ConfigWidgetBase.restore_defaults(self)
ofont = self.current_font
self.current_font = None
if ofont is not None:
self.changed_signal.emit()
self.update_font_display()
self.display_model.restore_defaults()
self.edit_rules.clear()
self.icon_rules.clear()
self.changed_signal.emit()
def build_font_obj(self):
font_info = self.current_font
if font_info is not None:
示例4: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import initialize [as 别名]
#.........这里部分代码省略.........
cval = self.opt_cover_grid_height.value()
wval = self.opt_cover_grid_width.value()
if cval < 0.1:
dpi = self.opt_cover_grid_height.logicalDpiY()
cval = auto_height(self.opt_cover_grid_height) / dpi / CM_TO_INCH
if wval < 0.1:
wval = 0.75 * cval
return wval, cval
def update_aspect_ratio(self, *args):
width, height = self.current_cover_size
ar = width / height
self.cover_grid_aspect_ratio.setText(_('Current aspect ratio (width/height): %.2g') % ar)
def resize_cover(self, smaller):
wval, cval = self.current_cover_size
ar = wval / cval
delta = 0.2 * (-1 if smaller else 1)
cval += delta
cval = max(0, cval)
self.opt_cover_grid_height.setValue(cval)
self.opt_cover_grid_width.setValue(cval * ar)
def cg_reset_size(self):
self.opt_cover_grid_width.setValue(0)
self.opt_cover_grid_height.setValue(0)
def edit_cb_title_template(self):
t = TemplateDialog(self, self.opt_cover_browser_title_template.text(), fm=self.gui.current_db.field_metadata)
t.setWindowTitle(_('Edit template for caption'))
if t.exec_():
self.opt_cover_browser_title_template.setText(t.rule[1])
def initialize(self):
ConfigWidgetBase.initialize(self)
self.default_author_link.value = default_author_link()
font = gprefs['font']
if font is not None:
font = list(font)
font.append(gprefs.get('font_stretch', QFont.Unstretched))
self.current_font = self.initial_font = font
self.update_font_display()
self.display_model.initialize()
self.qv_display_model.initialize()
db = self.gui.current_db
try:
idx = self.gui.library_view.currentIndex().row()
mi = db.get_metadata(idx, index_is_id=False)
except:
mi=None
self.edit_rules.initialize(db.field_metadata, db.prefs, mi, 'column_color_rules')
self.icon_rules.initialize(db.field_metadata, db.prefs, mi, 'column_icon_rules')
self.grid_rules.initialize(db.field_metadata, db.prefs, mi, 'cover_grid_icon_rules')
self.set_cg_color(gprefs['cover_grid_color'])
self.set_cg_texture(gprefs['cover_grid_texture'])
self.update_aspect_ratio()
def open_cg_cache(self):
open_local_file(self.gui.grid_view.thumbnail_cache.location)
def update_cg_cache_size(self, size):
self.cover_grid_current_disk_cache.setText(
_('Current space used: %s') % human_readable(size))
def tab_changed(self, index):
if self.tabWidget.currentWidget() is self.cover_grid_tab:
示例5: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import initialize [as 别名]
#.........这里部分代码省略.........
self.opt_cover_grid_disk_cache_size.setMaximum(self.gui.grid_view.thumbnail_cache.min_disk_cache * 100)
self.opt_cover_grid_width.valueChanged.connect(self.update_aspect_ratio)
self.opt_cover_grid_height.valueChanged.connect(self.update_aspect_ratio)
@property
def current_cover_size(self):
cval = self.opt_cover_grid_height.value()
wval = self.opt_cover_grid_width.value()
if cval < 0.1:
dpi = self.opt_cover_grid_height.logicalDpiY()
cval = auto_height(self.opt_cover_grid_height) / dpi / CM_TO_INCH
if wval < 0.1:
wval = 0.75 * cval
return wval, cval
def update_aspect_ratio(self, *args):
width, height = self.current_cover_size
ar = width / height
self.cover_grid_aspect_ratio.setText(_("Current aspect ratio (width/height): %.2g") % ar)
def resize_cover(self, smaller):
wval, cval = self.current_cover_size
ar = wval / cval
delta = 0.2 * (-1 if smaller else 1)
cval += delta
cval = max(0, cval)
self.opt_cover_grid_height.setValue(cval)
self.opt_cover_grid_width.setValue(cval * ar)
def cg_reset_size(self):
self.opt_cover_grid_width.setValue(0)
self.opt_cover_grid_height.setValue(0)
def initialize(self):
ConfigWidgetBase.initialize(self)
font = gprefs["font"]
if font is not None:
font = list(font)
font.append(gprefs.get("font_stretch", QFont.Unstretched))
self.current_font = self.initial_font = font
self.update_font_display()
self.display_model.initialize()
db = self.gui.current_db
try:
idx = self.gui.library_view.currentIndex().row()
mi = db.get_metadata(idx, index_is_id=False)
except:
mi = None
self.edit_rules.initialize(db.field_metadata, db.prefs, mi, "column_color_rules")
self.icon_rules.initialize(db.field_metadata, db.prefs, mi, "column_icon_rules")
self.set_cg_color(gprefs["cover_grid_color"])
self.set_cg_texture(gprefs["cover_grid_texture"])
self.update_aspect_ratio()
def open_cg_cache(self):
open_local_file(self.gui.grid_view.thumbnail_cache.location)
def update_cg_cache_size(self, size):
self.cover_grid_current_disk_cache.setText(_("Current space used: %s") % human_readable(size))
def tab_changed(self, index):
if self.tabWidget.currentWidget() is self.cover_grid_tab:
self.show_current_cache_usage()
def show_current_cache_usage(self):
t = Thread(target=self.calc_cache_size)