mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix clock in header/footer not using system time format. Fixes #1907907 [Feature request: 24h clock format in reader](https://bugs.launchpad.net/calibre/+bug/1907907)
This commit is contained in:
parent
59aa3c8541
commit
8160a8d9c8
@ -9,7 +9,7 @@ import sys
|
|||||||
from itertools import count
|
from itertools import count
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QT_VERSION, QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QPalette,
|
QT_VERSION, QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QPalette,
|
||||||
QHBoxLayout, QMimeData, QSize, Qt, QTimer, QUrl, QWidget, pyqtSignal, QIODevice
|
QHBoxLayout, QMimeData, QSize, Qt, QTimer, QUrl, QWidget, pyqtSignal, QIODevice, QLocale
|
||||||
)
|
)
|
||||||
from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler
|
from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler
|
||||||
from PyQt5.QtWebEngineWidgets import (
|
from PyQt5.QtWebEngineWidgets import (
|
||||||
@ -602,6 +602,7 @@ class WebView(RestartingWebEngineView):
|
|||||||
'show_home_page_on_ready': self.show_home_page_on_ready,
|
'show_home_page_on_ready': self.show_home_page_on_ready,
|
||||||
'system_colors': system_colors(),
|
'system_colors': system_colors(),
|
||||||
'QT_VERSION': QT_VERSION,
|
'QT_VERSION': QT_VERSION,
|
||||||
|
'short_time_fmt': QLocale.system().timeFormat(QLocale.FormatType.ShortFormat),
|
||||||
}
|
}
|
||||||
self.bridge.create_view(
|
self.bridge.create_view(
|
||||||
vprefs['session_data'], vprefs['local_storage'], field_metadata.all_metadata(), ui_data)
|
vprefs['session_data'], vprefs['local_storage'], field_metadata.all_metadata(), ui_data)
|
||||||
|
@ -140,6 +140,11 @@ else:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def set_time_formatter(func):
|
||||||
|
nonlocal time_formatter
|
||||||
|
time_formatter = {'format': func}
|
||||||
|
|
||||||
|
|
||||||
def format_time_left(seconds):
|
def format_time_left(seconds):
|
||||||
hours, minutes = divmod(int(seconds / 60), 60)
|
hours, minutes = divmod(int(seconds / 60), 60)
|
||||||
if hours <= 0:
|
if hours <= 0:
|
||||||
|
@ -5,6 +5,7 @@ from __python__ import bound_methods, hash_literals
|
|||||||
import traceback
|
import traceback
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _, install
|
from gettext import gettext as _, install
|
||||||
|
from date import format_date
|
||||||
|
|
||||||
import initialize # noqa: unused-import
|
import initialize # noqa: unused-import
|
||||||
from ajax import ajax, workaround_qt_bug
|
from ajax import ajax, workaround_qt_bug
|
||||||
@ -20,6 +21,7 @@ from read_book.globals import runtime, set_system_colors, ui_operations, default
|
|||||||
from read_book.iframe import main as iframe_main
|
from read_book.iframe import main as iframe_main
|
||||||
from read_book.shortcuts import add_standalone_viewer_shortcuts
|
from read_book.shortcuts import add_standalone_viewer_shortcuts
|
||||||
from read_book.view import View
|
from read_book.view import View
|
||||||
|
from read_book.prefs.head_foot import set_time_formatter
|
||||||
from session import local_storage, session_defaults
|
from session import local_storage, session_defaults
|
||||||
from utils import debounce, encode_query_with_path, parse_url_params
|
from utils import debounce, encode_query_with_path, parse_url_params
|
||||||
from viewer.constants import FAKE_HOST, FAKE_PROTOCOL, READER_BACKGROUND_URL
|
from viewer.constants import FAKE_HOST, FAKE_PROTOCOL, READER_BACKGROUND_URL
|
||||||
@ -177,6 +179,9 @@ def create_view(prefs, local_storage, field_metadata, ui_data):
|
|||||||
document.documentElement.style.fontFamily = f'"{ui_data.ui_font_family}", sans-serif'
|
document.documentElement.style.fontFamily = f'"{ui_data.ui_font_family}", sans-serif'
|
||||||
document.documentElement.style.fontSize = ui_data.ui_font_sz
|
document.documentElement.style.fontSize = ui_data.ui_font_sz
|
||||||
runtime.QT_VERSION = ui_data.QT_VERSION
|
runtime.QT_VERSION = ui_data.QT_VERSION
|
||||||
|
set_time_formatter(def (d):
|
||||||
|
return format_date(d, ui_data.short_time_fmt)
|
||||||
|
)
|
||||||
if view is None:
|
if view is None:
|
||||||
create_session_data(prefs, local_storage)
|
create_session_data(prefs, local_storage)
|
||||||
view = View(document.getElementById('view'))
|
view = View(document.getElementById('view'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user