Clean up button box

This commit is contained in:
Kovid Goyal 2020-08-04 13:08:31 +05:30
parent 16d241b9d2
commit fa13ee5943
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 15 deletions

View File

@ -137,6 +137,13 @@ class EditNotesAndColors: # {{{
remove_button = create_button(_('Remove style'), 'trash', self.remove_custom_color, _('Remove this custom highlight style')) remove_button = create_button(_('Remove style'), 'trash', self.remove_custom_color, _('Remove this custom highlight style'))
remove_button.classList.add('remove-custom-color') remove_button.classList.add('remove-custom-color')
apply_button = create_button(
_('Apply') if self.annot_id else _('Create'),
'check', finish,
(_('Finish editing highlight') if self.annot_id else _('Create highlight')) + ' [Ctrl+Enter]',
True
)
apply_button.style.marginLeft = apply_button.style.marginTop = 'auto'
c = E.div( c = E.div(
style=f'background: {get_color("window-background")}; margin: auto; text-align: center; padding: 1ex;', style=f'background: {get_color("window-background")}; margin: auto; text-align: center; padding: 1ex;',
@ -154,18 +161,11 @@ class EditNotesAndColors: # {{{
style=f'display: flex; flex-wrap: wrap; width: 100%; justify-content: center', style=f'display: flex; flex-wrap: wrap; width: 100%; justify-content: center',
), ),
E.div( E.div(
style='width: 100%; display: flex; justify-content: space-between', style='width: 100%; display: flex; flex-wrap: wrap',
E.div( create_button(_('Cancel'), 'close', abort, _('Abort') + ' [Esc]'),
create_button(_('Cancel'), 'close', abort, _('Abort') + ' [Esc]'), E.span('\xa0'),
E.span('\xa0'), remove_button, apply_button
remove_button ),
),
create_button(
_('Apply') if self.annot_id else _('Create'),
'check', finish,
(_('Finish editing highlight') if self.annot_id else _('Create highlight')) + ' [Ctrl+Enter]', True),
)
) )
self.container_id = c.id self.container_id = c.id
container.appendChild(c) container.appendChild(c)
@ -186,8 +186,7 @@ class EditNotesAndColors: # {{{
def set_visibility_of_remove_button(self): def set_visibility_of_remove_button(self):
c = self.container c = self.container
item = c.querySelector('.current-swatch.custom-style') item = c.querySelector('.current-swatch.custom-style')
visibility = 'unset' if item else 'hidden' c.querySelector('.remove-custom-color').style.display = 'block' if item else 'none'
c.querySelector('.remove-custom-color').style.visibility = visibility
def add_color(self, hs, at_start): def add_color(self, hs, at_start):
if self.seen_colors[hs.key]: if self.seen_colors[hs.key]:

View File

@ -743,7 +743,7 @@ class SelectionBar:
_('Failed to apply highlighting, try adjusting extent of highlight') _('Failed to apply highlighting, try adjusting extent of highlight')
) )
self.annotations_manager.add_highlight(msg, self.current_highlight_style.style, notes) self.annotations_manager.add_highlight(msg, self.current_highlight_style.style, notes)
if msg.type is 'edit-highlight': elif msg.type is 'edit-highlight':
if self.state is WAITING: if self.state is WAITING:
self.create_highlight() self.create_highlight()
else: else: