styles->html

This commit is contained in:
Kovid Goyal 2021-11-10 22:21:06 +05:30
parent 077a6089ef
commit 10905d4329
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -304,7 +304,7 @@ class Rules(RulesBase): # {{{
RuleItemClass = RuleItem RuleItemClass = RuleItem
RuleEditDialogClass = RuleEditDialog RuleEditDialogClass = RuleEditDialog
ACTION_KEY = 'actions' ACTION_KEY = 'actions'
MSG = _('You can specify rules to transform styles here. Click the "Add rule" button' MSG = _('You can specify rules to transform HTML here. Click the "Add rule" button'
' below to get started.') ' below to get started.')
# }}} # }}}
@ -356,15 +356,15 @@ class Tester(Dialog): # {{{
class RulesDialog(RulesDialogBase): # {{{ class RulesDialog(RulesDialogBase): # {{{
DIALOG_TITLE = _('Edit style transform rules') DIALOG_TITLE = _('Edit HTML transform rules')
PREFS_NAME = 'edit-style-transform-rules' PREFS_NAME = 'edit-html-transform-rules'
RulesClass = Rules RulesClass = Rules
TesterClass = Tester TesterClass = Tester
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
# This has to be loaded on instantiation as it can be shared by # This has to be loaded on instantiation as it can be shared by
# multiple processes # multiple processes
self.PREFS_OBJECT = JSONConfig('style-transform-rules') self.PREFS_OBJECT = JSONConfig('html-transform-rules')
RulesDialogBase.__init__(self, *args, **kw) RulesDialogBase.__init__(self, *args, **kw)
# }}} # }}}
@ -376,7 +376,7 @@ class RulesWidget(QWidget, SaveLoadMixin): # {{{
def __init__(self, parent=None): def __init__(self, parent=None):
self.loaded_ruleset = None self.loaded_ruleset = None
QWidget.__init__(self, parent) QWidget.__init__(self, parent)
self.PREFS_OBJECT = JSONConfig('style-transform-rules') self.PREFS_OBJECT = JSONConfig('html-transform-rules')
l = QVBoxLayout(self) l = QVBoxLayout(self)
self.rules_widget = w = Rules(self) self.rules_widget = w = Rules(self)
w.changed.connect(self.changed.emit) w.changed.connect(self.changed.emit)
@ -412,14 +412,14 @@ class RulesWidget(QWidget, SaveLoadMixin): # {{{
if not rules: if not rules:
return error_dialog(self, _('No rules'), _( return error_dialog(self, _('No rules'), _(
'There are no rules to export'), show=True) 'There are no rules to export'), show=True)
path = choose_save_file(self, 'export-style-transform-rules', _('Choose file for exported rules'), initial_filename='rules.txt') path = choose_save_file(self, 'export-html-transform-rules', _('Choose file for exported rules'), initial_filename='html-rules.json')
if path: if path:
raw = export_rules(rules) raw = export_rules(rules)
with open(path, 'wb') as f: with open(path, 'wb') as f:
f.write(raw) f.write(raw)
def import_rules(self): def import_rules(self):
paths = choose_files(self, 'export-style-transform-rules', _('Choose file to import rules from'), select_only_single_file=True) paths = choose_files(self, 'export-html-transform-rules', _('Choose file to import rules from'), select_only_single_file=True)
if paths: if paths:
with open(paths[0], 'rb') as f: with open(paths[0], 'rb') as f:
rules = import_rules(f.read()) rules = import_rules(f.read())