From 2a2b1a4af8861308c39c3816ff56d7601b7a0b31 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Mon, 11 Mar 2024 13:41:18 +0000 Subject: [PATCH] Add a tweak to set the first day of the week in the Calendar widget in the DateTimeEdit class. --- resources/default_tweaks.py | 5 +++++ src/calibre/gui2/widgets2.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index beb8cbcb5b..c170f22ad2 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -575,3 +575,8 @@ allow_template_database_functions_in_composites = False # for https://whatever URLs. %u is replaced by the URL to be opened. The scheme # takes a glob pattern allowing a single entry to match multiple URL types. openers_by_scheme = {} + +#: Set the first day of the week for calendar popups +# It must be one of the values Default, Sunday, Monday, Tuesday, Wednesday, +# Thursday, Friday, or Saturday, all in English, spelled exactly as shown. +calendar_start_day_of_week = 'Default' diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py index 5e1e589fc7..6040479314 100644 --- a/src/calibre/gui2/widgets2.py +++ b/src/calibre/gui2/widgets2.py @@ -707,6 +707,12 @@ class DateTimeEdit(QDateTimeEdit): self.setMinimumDateTime(UNDEFINED_QDATETIME) self.setCalendarPopup(True) self.cw = CalendarWidget(self) + if tweaks['calendar_start_day_of_week'] != 'Default': + try: + dow = Qt.DayOfWeek[tweaks['calendar_start_day_of_week']] + self.cw.setFirstDayOfWeek(dow) + except Exception: + print(f"Bad value for tweak calendar_start_day_of_week: {tweaks['calendar_start_day_of_week']}") self.cw.setVerticalHeaderFormat(QCalendarWidget.VerticalHeaderFormat.NoVerticalHeader) self.setCalendarWidget(self.cw) self.setSpecialValueText(_('Undefined'))