本文整理汇总了Python中calibre.gui2.preferences.coloring.EditRules.commit方法的典型用法代码示例。如果您正苦于以下问题:Python EditRules.commit方法的具体用法?Python EditRules.commit怎么用?Python EditRules.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.preferences.coloring.EditRules
的用法示例。
在下文中一共展示了EditRules.commit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import commit [as 别名]
#.........这里部分代码省略.........
self.set_cg_color(gprefs.defaults['cover_grid_color'])
self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
def change_cover_grid_color(self):
col = QColorDialog.getColor(self.cg_bg_widget.bcol,
self.gui, _('Choose background color for cover grid'))
if col.isValid():
col = tuple(col.getRgb())[:3]
self.set_cg_color(col)
self.changed_signal.emit()
if self.cg_bg_widget.btex:
if question_dialog(
self, _('Remove background image?'),
_('There is currently a background image set, so the color'
' you have chosen will not be visible. Remove the background image?')):
self.set_cg_texture(None)
def change_cover_grid_texture(self):
from calibre.gui2.preferences.texture_chooser import TextureChooser
d = TextureChooser(parent=self, initial=self.cg_bg_widget.btex)
if d.exec_() == d.Accepted:
self.set_cg_texture(d.texture)
self.changed_signal.emit()
def restore_cover_grid_appearance(self):
self.set_cg_color(gprefs.defaults['cover_grid_color'])
self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
self.changed_signal.emit()
def build_font_obj(self):
font_info = qt_app.original_font if self.current_font is None else self.current_font
font = QFont(*(font_info[:4]))
font.setStretch(font_info[4])
return font
def update_font_display(self):
font = self.build_font_obj()
fi = QFontInfo(font)
name = unicode(fi.family())
self.font_display.setFont(font)
self.font_display.setText(name +
' [%dpt]'%fi.pointSize())
def move_df_up(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, -1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def move_df_down(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, 1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def change_font(self, *args):
fd = QFontDialog(self.build_font_obj(), self)
if fd.exec_() == fd.Accepted:
font = fd.selectedFont()
fi = QFontInfo(font)
self.current_font = [unicode(fi.family()), fi.pointSize(),
fi.weight(), fi.italic(), font.stretch()]
self.update_font_display()
self.changed_signal.emit()
def commit(self, *args):
rr = ConfigWidgetBase.commit(self, *args)
if self.current_font != self.initial_font:
gprefs['font'] = (self.current_font[:4] if self.current_font else
None)
gprefs['font_stretch'] = (self.current_font[4] if self.current_font
is not None else QFont.Unstretched)
QApplication.setFont(self.font_display.font())
rr = True
self.display_model.commit()
self.edit_rules.commit(self.gui.current_db.prefs)
self.icon_rules.commit(self.gui.current_db.prefs)
self.grid_rules.commit(self.gui.current_db.prefs)
gprefs['cover_grid_color'] = tuple(self.cg_bg_widget.bcol.getRgb())[:3]
gprefs['cover_grid_texture'] = self.cg_bg_widget.btex
return rr
def refresh_gui(self, gui):
m = gui.library_view.model()
m.beginResetModel(), m.endResetModel()
self.update_font_display()
gui.tags_view.reread_collapse_parameters()
gui.library_view.refresh_book_details()
if hasattr(gui.cover_flow, 'setShowReflections'):
gui.cover_flow.setShowReflections(gprefs['cover_browser_reflections'])
gui.cover_flow.setPreserveAspectRatio(gprefs['cb_preserve_aspect_ratio'])
gui.library_view.refresh_row_sizing()
gui.grid_view.refresh_settings()
示例2: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import commit [as 别名]
#.........这里部分代码省略.........
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()
self.icon_rules.clear()
self.changed_signal.emit()
self.set_cg_color(gprefs.defaults["cover_grid_color"])
def change_cover_grid_color(self):
col = QColorDialog.getColor(
self.cover_grid_color_label.palette().color(QPalette.Window),
self.gui,
_("Choose background color for cover grid"),
)
if col.isValid():
col = tuple(col.getRgb())[:3]
self.set_cg_color(col)
self.changed_signal.emit()
def build_font_obj(self):
font_info = self.current_font
if font_info is not None:
font = QFont(*(font_info[:4]))
font.setStretch(font_info[4])
else:
font = qt_app.original_font
return font
def update_font_display(self):
font = self.build_font_obj()
fi = QFontInfo(font)
name = unicode(fi.family())
self.font_display.setFont(font)
self.font_display.setText(name + " [%dpt]" % fi.pointSize())
def move_df_up(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, -1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def move_df_down(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, 1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def change_font(self, *args):
fd = QFontDialog(self.build_font_obj(), self)
if fd.exec_() == fd.Accepted:
font = fd.selectedFont()
fi = QFontInfo(font)
self.current_font = [unicode(fi.family()), fi.pointSize(), fi.weight(), fi.italic(), font.stretch()]
self.update_font_display()
self.changed_signal.emit()
def commit(self, *args):
rr = ConfigWidgetBase.commit(self, *args)
if self.current_font != self.initial_font:
gprefs["font"] = self.current_font[:4] if self.current_font else None
gprefs["font_stretch"] = self.current_font[4] if self.current_font is not None else QFont.Unstretched
QApplication.setFont(self.font_display.font())
rr = True
self.display_model.commit()
self.edit_rules.commit(self.gui.current_db.prefs)
self.icon_rules.commit(self.gui.current_db.prefs)
gprefs["cover_grid_color"] = tuple(self.cover_grid_color_label.palette().color(QPalette.Window).getRgb())[:3]
return rr
def refresh_gui(self, gui):
gui.library_view.model().reset()
self.update_font_display()
gui.tags_view.reread_collapse_parameters()
gui.library_view.refresh_book_details()
if hasattr(gui.cover_flow, "setShowReflections"):
gui.cover_flow.setShowReflections(gprefs["cover_browser_reflections"])
gui.library_view.refresh_row_sizing()
gui.grid_view.refresh_settings()
示例3: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import commit [as 别名]
#.........这里部分代码省略.........
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:
font = QFont(*(font_info[:4]))
font.setStretch(font_info[4])
else:
font = qt_app.original_font
return font
def update_font_display(self):
font = self.build_font_obj()
fi = QFontInfo(font)
name = unicode(fi.family())
self.font_display.setFont(font)
self.font_display.setText(name +
' [%dpt]'%fi.pointSize())
def move_df_up(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, -1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def move_df_down(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, 1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def change_font(self, *args):
fd = QFontDialog(self.build_font_obj(), self)
if fd.exec_() == fd.Accepted:
font = fd.selectedFont()
fi = QFontInfo(font)
self.current_font = [unicode(fi.family()), fi.pointSize(),
fi.weight(), fi.italic(), font.stretch()]
self.update_font_display()
self.changed_signal.emit()
def commit(self, *args):
rr = ConfigWidgetBase.commit(self, *args)
if self.current_font != self.initial_font:
gprefs['font'] = (self.current_font[:4] if self.current_font else
None)
gprefs['font_stretch'] = (self.current_font[4] if self.current_font
is not None else QFont.Unstretched)
QApplication.setFont(self.font_display.font())
rr = True
self.display_model.commit()
self.edit_rules.commit(self.gui.current_db.prefs)
self.icon_rules.commit(self.gui.current_db.prefs)
return rr
def refresh_gui(self, gui):
gui.library_view.model().reset()
self.update_font_display()
gui.tags_view.reread_collapse_parameters()
gui.library_view.refresh_book_details()
if hasattr(gui.cover_flow, 'setShowReflections'):
gui.cover_flow.setShowReflections(gprefs['cover_browser_reflections'])
示例4: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import commit [as 别名]
class ConfigWidget(ConfigWidgetBase, Ui_Form):
size_calculated = pyqtSignal(object)
def genesis(self, gui):
self.gui = gui
if not isosx and not iswindows:
self.label_widget_style.setVisible(False)
self.opt_ui_style.setVisible(False)
db = gui.library_view.model().db
r = self.register
try:
self.icon_theme_title = json.loads(I('icon-theme.json', data=True))['name']
except Exception:
self.icon_theme_title = _('Default icons')
self.icon_theme.setText(_('Icon theme: <b>%s</b>') % self.icon_theme_title)
self.commit_icon_theme = None
self.icon_theme_button.clicked.connect(self.choose_icon_theme)
self.default_author_link = DefaultAuthorLink(self.default_author_link_container)
self.default_author_link.changed_signal.connect(self.changed_signal)
r('gui_layout', config, restart_required=True, choices=[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
r('hidpi', gprefs, restart_required=True, choices=[(_('Automatic'), 'auto'), (_('On'), 'on'), (_('Off'), 'off')])
if isosx:
self.opt_hidpi.setVisible(False), self.label_hidpi.setVisible(False)
r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
r('book_list_tooltips', gprefs)
r('dnd_merge', gprefs)
r('wrap_toolbar_text', gprefs, restart_required=True)
r('show_layout_buttons', gprefs, restart_required=True)
r('row_numbers_in_book_list', gprefs)
r('tag_browser_old_look', gprefs)
r('tag_browser_hide_empty_categories', gprefs)
r('tag_browser_show_tooltips', gprefs)
r('bd_show_cover', gprefs)
r('bd_overlay_cover_size', gprefs)
r('cover_grid_width', gprefs)
r('cover_grid_height', gprefs)
r('cover_grid_cache_size_multiple', gprefs)
r('cover_grid_disk_cache_size', gprefs)
r('cover_grid_spacing', gprefs)
r('cover_grid_show_title', gprefs)
r('tag_browser_show_counts', gprefs)
r('tag_browser_item_padding', gprefs)
r('qv_respects_vls', gprefs)
r('qv_dclick_changes_column', gprefs)
r('qv_retkey_changes_column', gprefs)
r('qv_follows_column', gprefs)
r('cover_flow_queue_length', config, restart_required=True)
r('cover_browser_reflections', gprefs)
r('cover_browser_title_template', db.prefs)
fm = db.field_metadata
r('cover_browser_subtitle_field', db.prefs, choices=[(_('No subtitle'), 'none')] + sorted(
(fm[k].get('name'), k) for k in fm.all_field_keys() if fm[k].get('name')
))
r('emblem_size', gprefs)
r('emblem_position', gprefs, choices=[
(_('Left'), 'left'), (_('Top'), 'top'), (_('Right'), 'right'), (_('Bottom'), 'bottom')])
r('book_list_extra_row_spacing', gprefs)
r('booklist_grid', gprefs)
r('book_details_narrow_comments_layout', gprefs, choices=[(_('Float'), 'float'), (_('Columns'), 'columns')])
self.opt_book_details_narrow_comments_layout.setToolTip(textwrap.fill(_(
'Choose how the text is laid out when using the "Narrow" user interface layout.'
' A value of "Float" means that the comments text will wrap around'
' the other metadata fields, while a value of "Columns" means that'
' the comments will be in a separate fixed width column.')))
self.cover_browser_title_template_button.clicked.connect(self.edit_cb_title_template)
self.id_links_button.clicked.connect(self.edit_id_link_rules)
def get_esc_lang(l):
if l == 'en':
return 'English'
return get_language(l)
lang = get_lang()
if lang is None or lang not in available_translations():
lang = 'en'
items = [(l, get_esc_lang(l)) for l in available_translations()
if l != lang]
if lang != 'en':
items.append(('en', get_esc_lang('en')))
items.sort(key=lambda x: x[1].lower())
choices = [(y, x) for x, y in items]
# Default language is the autodetected one
choices = [(get_language(lang), lang)] + choices
r('language', prefs, choices=choices, restart_required=True)
r('show_avg_rating', config)
r('disable_animations', config)
r('systray_icon', config, restart_required=True)
r('show_splash_screen', gprefs)
r('disable_tray_notification', config)
r('use_roman_numerals_for_series_number', config)
r('separate_cover_flow', config, restart_required=True)
r('cb_fullscreen', gprefs)
r('cb_preserve_aspect_ratio', gprefs)
#.........这里部分代码省略.........
示例5: ConfigWidget
# 需要导入模块: from calibre.gui2.preferences.coloring import EditRules [as 别名]
# 或者: from calibre.gui2.preferences.coloring.EditRules import commit [as 别名]
#.........这里部分代码省略.........
self.set_cg_color(gprefs.defaults["cover_grid_color"])
self.set_cg_texture(gprefs.defaults["cover_grid_texture"])
def change_cover_grid_color(self):
col = QColorDialog.getColor(self.cg_bg_widget.bcol, self.gui, _("Choose background color for cover grid"))
if col.isValid():
col = tuple(col.getRgb())[:3]
self.set_cg_color(col)
self.changed_signal.emit()
if self.cg_bg_widget.btex:
if question_dialog(
self,
_("Remove background image?"),
_(
"There is currently a background image set, so the color"
" you have chosen will not be visible. Remove the background image?"
),
):
self.set_cg_texture(None)
def change_cover_grid_texture(self):
from calibre.gui2.preferences.texture_chooser import TextureChooser
d = TextureChooser(parent=self, initial=self.cg_bg_widget.btex)
if d.exec_() == d.Accepted:
self.set_cg_texture(d.texture)
self.changed_signal.emit()
def restore_cover_grid_appearance(self):
self.set_cg_color(gprefs.defaults["cover_grid_color"])
self.set_cg_texture(gprefs.defaults["cover_grid_texture"])
self.changed_signal.emit()
def build_font_obj(self):
font_info = self.current_font
if font_info is not None:
font = QFont(*(font_info[:4]))
font.setStretch(font_info[4])
else:
font = qt_app.original_font
return font
def update_font_display(self):
font = self.build_font_obj()
fi = QFontInfo(font)
name = unicode(fi.family())
self.font_display.setFont(font)
self.font_display.setText(name + " [%dpt]" % fi.pointSize())
def move_df_up(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, -1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def move_df_down(self):
idx = self.field_display_order.currentIndex()
if idx.isValid():
idx = self.display_model.move(idx, 1)
if idx is not None:
sm = self.field_display_order.selectionModel()
sm.select(idx, sm.ClearAndSelect)
self.field_display_order.setCurrentIndex(idx)
def change_font(self, *args):
fd = QFontDialog(self.build_font_obj(), self)
if fd.exec_() == fd.Accepted:
font = fd.selectedFont()
fi = QFontInfo(font)
self.current_font = [unicode(fi.family()), fi.pointSize(), fi.weight(), fi.italic(), font.stretch()]
self.update_font_display()
self.changed_signal.emit()
def commit(self, *args):
rr = ConfigWidgetBase.commit(self, *args)
if self.current_font != self.initial_font:
gprefs["font"] = self.current_font[:4] if self.current_font else None
gprefs["font_stretch"] = self.current_font[4] if self.current_font is not None else QFont.Unstretched
QApplication.setFont(self.font_display.font())
rr = True
self.display_model.commit()
self.edit_rules.commit(self.gui.current_db.prefs)
self.icon_rules.commit(self.gui.current_db.prefs)
gprefs["cover_grid_color"] = tuple(self.cg_bg_widget.bcol.getRgb())[:3]
gprefs["cover_grid_texture"] = self.cg_bg_widget.btex
return rr
def refresh_gui(self, gui):
gui.library_view.model().reset()
self.update_font_display()
gui.tags_view.reread_collapse_parameters()
gui.library_view.refresh_book_details()
if hasattr(gui.cover_flow, "setShowReflections"):
gui.cover_flow.setShowReflections(gprefs["cover_browser_reflections"])
gui.library_view.refresh_row_sizing()
gui.grid_view.refresh_settings()