mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
UI for misc settings
This commit is contained in:
parent
c14adff36e
commit
95dc6a06ad
@ -12,6 +12,7 @@ from read_book.prefs.colors import commit_colors, create_colors_panel
|
||||
from read_book.prefs.fonts import commit_fonts, create_fonts_panel
|
||||
from read_book.prefs.head_foot import commit_head_foot, create_head_foot_panel
|
||||
from read_book.prefs.layout import commit_layout, create_layout_panel
|
||||
from read_book.prefs.misc import commit_misc, create_misc_panel
|
||||
from read_book.prefs.user_stylesheet import (
|
||||
commit_user_stylesheet, create_user_stylesheet_panel
|
||||
)
|
||||
@ -73,6 +74,8 @@ class Prefs:
|
||||
if runtime.is_standalone_viewer:
|
||||
items.push(create_item(
|
||||
_('Fonts'), def():self.show_panel('fonts');, _('Font choices')))
|
||||
items.push(create_item(
|
||||
_('Miscellaneous'), def():self.show_panel('misc');, _('Window size, last read position, etc.')))
|
||||
build_list(c, items)
|
||||
|
||||
def display_fonts(self, container):
|
||||
@ -82,6 +85,13 @@ class Prefs:
|
||||
def close_fonts(self):
|
||||
commit_fonts(self.onchange, self.container)
|
||||
|
||||
def display_misc(self, container):
|
||||
document.getElementById(self.title_id).textContent = _('Miscellaneous')
|
||||
create_misc_panel(container)
|
||||
|
||||
def close_misc(self):
|
||||
commit_misc(self.onchange, self.container)
|
||||
|
||||
def display_colors(self, container):
|
||||
document.getElementById(self.title_id).textContent = _('Colors')
|
||||
create_colors_panel(container)
|
||||
|
65
src/pyj/read_book/prefs/misc.pyj
Normal file
65
src/pyj/read_book/prefs/misc.pyj
Normal file
@ -0,0 +1,65 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
from __python__ import bound_methods, hash_literals
|
||||
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _
|
||||
|
||||
from book_list.globals import get_session_data
|
||||
from dom import unique_id
|
||||
from widgets import create_button
|
||||
|
||||
CONTAINER = unique_id('standalone-misc-settings')
|
||||
DEFAULTS = {
|
||||
'remember_window_geometry': False,
|
||||
'remember_last_read': True,
|
||||
'save_annotations_in_ebook': True,
|
||||
}
|
||||
|
||||
|
||||
def restore_defaults():
|
||||
container = get_container()
|
||||
for q in Object.keys(DEFAULTS):
|
||||
container.querySelector(f'[name={q}]').checked = DEFAULTS[q]
|
||||
|
||||
|
||||
def get_container():
|
||||
return document.getElementById(CONTAINER)
|
||||
|
||||
|
||||
def create_misc_panel(container):
|
||||
container.appendChild(E.div(id=CONTAINER, style='margin: 1rem'))
|
||||
container = container.lastChild
|
||||
sd = get_session_data()
|
||||
settings = sd.get('standalone_misc_settings')
|
||||
settings
|
||||
|
||||
def cb(name, text):
|
||||
ans = E.input(type='checkbox', name=name)
|
||||
if jstype(settings[name]) is 'boolean':
|
||||
ans.checked = v'!!settings[name]'
|
||||
else:
|
||||
ans.checked = DEFAULTS[name]
|
||||
return E.div(style='margin-top:1ex', E.label(ans, '\xa0' + text))
|
||||
|
||||
container.append(cb('remember_window_geometry', _('Remember last used window size and position')))
|
||||
container.append(cb('remember_last_read', _('Remember current page when quitting')))
|
||||
container.append(cb('save_annotations_in_ebook', _('Keep a copy of annotations/bookmarks inside the e-book file, for easy sharing')))
|
||||
|
||||
container.appendChild(E.div(
|
||||
style='margin-top: 1rem', create_button(_('Restore defaults'), action=restore_defaults)
|
||||
))
|
||||
|
||||
|
||||
develop = create_misc_panel
|
||||
|
||||
|
||||
def commit_misc(onchange):
|
||||
sd = get_session_data()
|
||||
container = get_container()
|
||||
vals = {}
|
||||
for q in Object.keys(DEFAULTS):
|
||||
val = container.querySelector(f'[name={q}]').checked
|
||||
if val is not DEFAULTS[q]:
|
||||
vals[q] = val
|
||||
sd.set('standalone_misc_settings', vals)
|
@ -41,6 +41,7 @@ defaults = {
|
||||
'footer': {'right': 'progress'},
|
||||
'word_actions': v'[]',
|
||||
'standalone_font_settings': {},
|
||||
'standalone_misc_settings': {},
|
||||
}
|
||||
|
||||
is_local_setting = {
|
||||
@ -57,6 +58,7 @@ is_local_setting = {
|
||||
'base_font_size': True,
|
||||
'controls_help_shown_count': True,
|
||||
'standalone_font_settings': True,
|
||||
'standalone_misc_settings': True,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user