mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Close modals when using back/forward buttons in browser
This commit is contained in:
parent
96f9365ca1
commit
e61c047395
@ -1,11 +1,12 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
from __python__ import hash_literals, bound_methods
|
||||
from __python__ import bound_methods, hash_literals
|
||||
|
||||
from book_list.constants import read_book_container_id, book_list_container_id
|
||||
from book_list.constants import book_list_container_id, read_book_container_id
|
||||
from book_list.globals import get_current_query
|
||||
from book_list.library_data import current_library_id
|
||||
from utils import parse_url_params, encode_query_with_path
|
||||
from modals import close_all_modals
|
||||
from utils import encode_query_with_path, parse_url_params
|
||||
|
||||
mode_handlers = {}
|
||||
default_mode_handler = None
|
||||
@ -38,6 +39,7 @@ def apply_mode(mode):
|
||||
|
||||
|
||||
def apply_url(ignore_handler):
|
||||
close_all_modals() # needed to close any error dialogs, etc when clicking back or forward in the browser or using push_state() to go to a new page
|
||||
data = parse_url_params()
|
||||
data.mode = data.mode or 'book_list'
|
||||
get_current_query(data)
|
||||
|
@ -125,6 +125,11 @@ class ModalContainer:
|
||||
return
|
||||
self.clear_current_modal()
|
||||
|
||||
def close_all_modals(self):
|
||||
while self.current_modal is not None:
|
||||
self.close_current_modal()
|
||||
|
||||
|
||||
def create_simple_dialog(title, msg, details, icon, prefix):
|
||||
details = details or ''
|
||||
def create_func(parent):
|
||||
@ -223,6 +228,11 @@ def create_modal_container():
|
||||
def show_modal(create_func, on_close=None, show_close=True):
|
||||
return modal_container.show_modal(create_func, on_close, show_close)
|
||||
|
||||
|
||||
def close_all_modals():
|
||||
return modal_container.close_all_modals()
|
||||
|
||||
|
||||
def error_dialog(title, msg, details=None):
|
||||
create_simple_dialog(title, msg, details, 'bug', _('Error:'))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user