mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Added possibility to set up custom date in new game wizard.
This commit is contained in:
42
qt_ui/widgets/QLiberationCalendar.py
Normal file
42
qt_ui/widgets/QLiberationCalendar.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from PySide2 import QtCore, QtGui, QtWidgets
|
||||
from PySide2.QtWidgets import QCalendarWidget
|
||||
|
||||
from qt_ui.uiconstants import COLORS
|
||||
|
||||
|
||||
class QLiberationCalendar(QCalendarWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(QLiberationCalendar, self).__init__(parent)
|
||||
self.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
|
||||
self.setGridVisible(False)
|
||||
|
||||
# Overrride default QCalendar behaviour that is rendering week end days in red
|
||||
for d in (
|
||||
QtCore.Qt.Monday,
|
||||
QtCore.Qt.Tuesday,
|
||||
QtCore.Qt.Wednesday,
|
||||
QtCore.Qt.Thursday,
|
||||
QtCore.Qt.Friday,
|
||||
QtCore.Qt.Saturday,
|
||||
QtCore.Qt.Sunday,
|
||||
):
|
||||
fmt = self.weekdayTextFormat(d)
|
||||
fmt.setForeground(QtCore.Qt.darkGray)
|
||||
self.setWeekdayTextFormat(d, fmt)
|
||||
|
||||
def paintCell(self, painter, rect, date):
|
||||
if date == self.selectedDate():
|
||||
painter.save()
|
||||
painter.fillRect(rect, QtGui.QColor("#D3D3D3"))
|
||||
painter.setPen(QtCore.Qt.NoPen)
|
||||
painter.setBrush(QtGui.QColor(COLORS["sea_blue"]))
|
||||
r = QtCore.QRect(
|
||||
QtCore.QPoint(), min(rect.width(), rect.height()) * QtCore.QSize(1, 1)
|
||||
)
|
||||
r.moveCenter(rect.center())
|
||||
painter.drawEllipse(r)
|
||||
painter.setPen(QtGui.QPen(QtGui.QColor("white")))
|
||||
painter.drawText(rect, QtCore.Qt.AlignCenter, str(date.day()))
|
||||
painter.restore()
|
||||
else:
|
||||
super(QLiberationCalendar, self).paintCell(painter, rect, date)
|
||||
Reference in New Issue
Block a user