diff --git a/src/pyj/modals.pyj b/src/pyj/modals.pyj index cbad8eb0c3..63a25a1561 100644 --- a/src/pyj/modals.pyj +++ b/src/pyj/modals.pyj @@ -11,6 +11,7 @@ from dom import add_extra_css, build_rule, clear, set_css, svgicon, unique_id from popups import MODAL_Z_INDEX from utils import safe_set_inner_html from widgets import create_button +from book_list.globals import get_session_data modal_container = None modal_count = 0 @@ -236,7 +237,11 @@ def get_text_dialog(title, callback, initial_text=None, msg=None, rows=12): ) -def question_dialog(title, msg, callback, yes_text=None, no_text=None): +def question_dialog( + title, msg, callback, yes_text=None, no_text=None, + skip_dialog_name=None, skip_dialog_msg=None, + skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True, +): yes_text = yes_text or _('Yes') no_text = no_text or _('No') called = {} @@ -245,6 +250,12 @@ def question_dialog(title, msg, callback, yes_text=None, no_text=None): if called.done: return called.done = True + if skip_dialog_name: + if not skip_box.querySelector('input').checked: + sd = get_session_data() + skipped_dialogs = Object.assign(v'{}', sd.get('skipped_dialogs', v'{}')) + skipped_dialogs[skip_dialog_name] = Date().toISOString() + sd.set('skipped_dialogs', skipped_dialogs) if close_modal: close_modal() callback(yes) @@ -259,10 +270,24 @@ def question_dialog(title, msg, callback, yes_text=None, no_text=None): event.preventDefault(), event.stopPropagation() keyaction(True, close_modal) + skip_box = E.div(style='margin-top: 2ex;') + if skip_dialog_name: + sd = get_session_data() + skipped_dialogs = sd.get('skipped_dialogs', v'{}') + if skipped_dialogs[skip_dialog_name]: + return callback(skip_dialog_skipped_value) + skip_dialog_msg = skip_dialog_msg or _('Show this confirmation again') + skip_box.appendChild(E.label(E.input(type='checkbox', name='skip_dialog'), '\xa0', skip_dialog_msg)) + if skip_dialog_skip_precheck: + skip_box.querySelector('input').checked = True + else: + skip_box.style.display = 'none' + create_custom_dialog( title, def(parent, close_modal): parent.appendChild(E.div( E.div(msg), + skip_box, E.div(class_='button-box', create_button(yes_text, 'check', keyaction.bind(None, True, close_modal), highlight=True), '\xa0', diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index 496e53dc0c..39ef494851 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -27,7 +27,7 @@ from read_book.prefs.font_size import create_font_size_panel from read_book.prefs.main import create_prefs_panel from read_book.toc import create_toc_panel from read_book.word_actions import create_word_actions_panel -from session import get_device_uuid +from session import get_device_uuid, defaults as session_defaults from utils import ( default_context_menu_should_be_allowed, full_screen_element, full_screen_supported, is_ios, safe_set_inner_html @@ -360,7 +360,12 @@ class MainOverlay: # {{{ ac(_('Inspector'), _('Show the content inspector'), def(): self.overlay.hide(), ui_operations.toggle_inspector();, 'bug'), ac(_('Reset interface'), _('Reset viewer panels, toolbars and scrollbars to defaults'), - def(): self.overlay.hide(), ui_operations.reset_interface();, 'window-restore'), + def(): + self.overlay.hide() + ui_operations.reset_interface() + sd = get_session_data() + sd.set('skipped_dialogs', session_defaults.skipped_dialogs) + , 'window-restore'), ac(_('Quit'), _('Close the viewer'), def(): self.overlay.hide(), ui_operations.quit();, 'remove'), )) diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index 2b9fd10002..5350f5eefc 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -935,10 +935,12 @@ class SelectionBar: def remove_highlight(self): annot_id = self.view.currently_showing.selection.annot_id if annot_id: - question_dialog(_('Are you sure?'), _('Are you sure you want to delete this highlight permanently?'), + question_dialog( + _('Are you sure?'), _('Are you sure you want to delete this highlight permanently?'), def (yes): if yes: self.remove_highlight_with_id(annot_id) + , skip_dialog_name='confirm_remove_highlight' ) def remove_highlight_with_id(self, annot_id): diff --git a/src/pyj/session.pyj b/src/pyj/session.pyj index 17743364d5..2000c020b9 100644 --- a/src/pyj/session.pyj +++ b/src/pyj/session.pyj @@ -68,9 +68,11 @@ defaults = { 'net_search_url': 'https://google.com/search?q={q}', 'selection_bar_actions': v"['copy', 'lookup', 'highlight', 'remove_highlight', 'search_net', 'clear']", 'selection_bar_quick_highlights': v"[]", + 'skipped_dialogs': v'{}', } is_local_setting = { + 'skipped_dialogs': True, 'background_image_fade': True, 'background_image_style': True, 'background_image': True,