mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement the block alignment actions
This commit is contained in:
parent
5ac8d64c55
commit
35e531a737
@ -201,10 +201,10 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
|||||||
('ordered_list', 'format-list-ordered', _('Ordered list'), True),
|
('ordered_list', 'format-list-ordered', _('Ordered list'), True),
|
||||||
('unordered_list', 'format-list-unordered', _('Unordered list'), True),
|
('unordered_list', 'format-list-unordered', _('Unordered list'), True),
|
||||||
|
|
||||||
('align_left', 'format-justify-left', _('Align left'), ),
|
('align_left', 'format-justify-left', _('Align left'), True),
|
||||||
('align_center', 'format-justify-center', _('Align center'), ),
|
('align_center', 'format-justify-center', _('Align center'), True),
|
||||||
('align_right', 'format-justify-right', _('Align right'), ),
|
('align_right', 'format-justify-right', _('Align right'), True),
|
||||||
('align_justified', 'format-justify-fill', _('Align justified'), ),
|
('align_justified', 'format-justify-fill', _('Align justified'), True),
|
||||||
('undo', 'edit-undo', _('Undo'), ),
|
('undo', 'edit-undo', _('Undo'), ),
|
||||||
('redo', 'edit-redo', _('Redo'), ),
|
('redo', 'edit-redo', _('Redo'), ),
|
||||||
('remove_format', 'edit-clear', _('Remove formatting'), ),
|
('remove_format', 'edit-clear', _('Remove formatting'), ),
|
||||||
@ -287,6 +287,11 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
|||||||
self.action_italic.setChecked(tcf.fontItalic())
|
self.action_italic.setChecked(tcf.fontItalic())
|
||||||
self.action_underline.setChecked(tcf.fontUnderline())
|
self.action_underline.setChecked(tcf.fontUnderline())
|
||||||
self.action_strikethrough.setChecked(tcf.fontStrikeOut())
|
self.action_strikethrough.setChecked(tcf.fontStrikeOut())
|
||||||
|
a = c.blockFormat().alignment()
|
||||||
|
self.action_align_left.setChecked(a == Qt.AlignLeft)
|
||||||
|
self.action_align_right.setChecked(a == Qt.AlignRight)
|
||||||
|
self.action_align_center.setChecked(a == Qt.AlignHCenter)
|
||||||
|
self.action_align_justified.setChecked(a == Qt.AlignJustify)
|
||||||
|
|
||||||
def set_readonly(self, what):
|
def set_readonly(self, what):
|
||||||
self.readonly = what
|
self.readonly = what
|
||||||
@ -360,17 +365,23 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
|||||||
def do_unordered_list(self):
|
def do_unordered_list(self):
|
||||||
self.do_list(QTextListFormat.ListDisc)
|
self.do_list(QTextListFormat.ListDisc)
|
||||||
|
|
||||||
|
def do_alignment(self, which):
|
||||||
|
with self.editing_cursor() as c:
|
||||||
|
fmt = QTextBlockFormat()
|
||||||
|
fmt.setAlignment(which)
|
||||||
|
c.setBlockFormat(fmt)
|
||||||
|
|
||||||
def do_align_left(self):
|
def do_align_left(self):
|
||||||
raise NotImplementedError('TODO')
|
self.do_alignment(Qt.AlignLeft)
|
||||||
|
|
||||||
def do_align_center(self):
|
def do_align_center(self):
|
||||||
raise NotImplementedError('TODO')
|
self.do_alignment(Qt.AlignHCenter)
|
||||||
|
|
||||||
def do_align_right(self):
|
def do_align_right(self):
|
||||||
raise NotImplementedError('TODO')
|
self.do_alignment(Qt.AlignRight)
|
||||||
|
|
||||||
def do_align_justified(self):
|
def do_align_justified(self):
|
||||||
raise NotImplementedError('TODO')
|
self.do_alignment(Qt.AlignJustify)
|
||||||
|
|
||||||
def do_undo(self):
|
def do_undo(self):
|
||||||
self.undo()
|
self.undo()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user