Add a tweak to set the first day of the week in the Calendar widget in the DateTimeEdit class.

This commit is contained in:
Charles Haley 2024-03-11 13:41:18 +00:00
parent cbc2bcfe9a
commit 2a2b1a4af8
2 changed files with 11 additions and 0 deletions

View File

@ -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 # 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. # takes a glob pattern allowing a single entry to match multiple URL types.
openers_by_scheme = {} 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'

View File

@ -707,6 +707,12 @@ class DateTimeEdit(QDateTimeEdit):
self.setMinimumDateTime(UNDEFINED_QDATETIME) self.setMinimumDateTime(UNDEFINED_QDATETIME)
self.setCalendarPopup(True) self.setCalendarPopup(True)
self.cw = CalendarWidget(self) 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.cw.setVerticalHeaderFormat(QCalendarWidget.VerticalHeaderFormat.NoVerticalHeader)
self.setCalendarWidget(self.cw) self.setCalendarWidget(self.cw)
self.setSpecialValueText(_('Undefined')) self.setSpecialValueText(_('Undefined'))