Minor changes
This commit is contained in:
parent
76ddf4fe10
commit
f02e224d75
3 changed files with 21 additions and 13 deletions
|
@ -136,6 +136,10 @@ class CalDrawerScene(QGraphicsScene):
|
||||||
brush.setColor(QtGui.QColor(self.daysLabelBG))
|
brush.setColor(QtGui.QColor(self.daysLabelBG))
|
||||||
brush.setStyle(Qt.BrushStyle.SolidPattern)
|
brush.setStyle(Qt.BrushStyle.SolidPattern)
|
||||||
painter.setBrush(brush)
|
painter.setBrush(brush)
|
||||||
|
# Brush for today
|
||||||
|
brushToday=QtGui.QBrush()
|
||||||
|
brushToday.setColor(QtGui.QColor("#23a1fc"))
|
||||||
|
brushToday.setStyle(Qt.BrushStyle.SolidPattern)
|
||||||
# Init various things
|
# Init various things
|
||||||
days=self.calState.getMonthDays()
|
days=self.calState.getMonthDays()
|
||||||
font=painter.font()
|
font=painter.font()
|
||||||
|
@ -148,13 +152,19 @@ class CalDrawerScene(QGraphicsScene):
|
||||||
for i in range(0,len(self.daysRect)):
|
for i in range(0,len(self.daysRect)):
|
||||||
r=self.daysRect[i]
|
r=self.daysRect[i]
|
||||||
d=days[i]
|
d=days[i]
|
||||||
dayLabel="["+str(d[2])+"]" if d == today else str(d[2])
|
dayLabel=str(d[2])
|
||||||
labelW=metric.boundingRect(dayLabel).width()
|
labelW=metric.boundingRect(dayLabel).width()
|
||||||
offsetX=int(r.width()/2-labelW/2)
|
offsetX=int(r.width()/2-labelW/2)
|
||||||
painter.setPen(Qt.PenStyle.NoPen)
|
painter.setPen(Qt.PenStyle.NoPen)
|
||||||
painter.drawRect(r.x(),r.y(),r.width(),labelH) # Remember r is within grid stroke
|
painter.drawRect(r.x(),r.y(),r.width(),labelH) # Remember r is within grid stroke
|
||||||
painter.setPen(pen)
|
painter.setPen(pen)
|
||||||
# painter.drawText(r.x()+offsetX,r.y()+offsetY,dayLabel)
|
# painter.drawText(r.x()+offsetX,r.y()+offsetY,dayLabel)
|
||||||
|
if d == today:
|
||||||
|
painter.setBrush(brushToday)
|
||||||
|
painter.setPen(Qt.PenStyle.NoPen)
|
||||||
|
painter.drawRect(r.x()+int(r.width()/4),r.y(),int(r.width()/2),labelH)
|
||||||
|
painter.setBrush(brush)
|
||||||
|
painter.setPen(pen)
|
||||||
painter.drawText(r,Qt.AlignmentFlag.AlignHCenter,dayLabel)
|
painter.drawText(r,Qt.AlignmentFlag.AlignHCenter,dayLabel)
|
||||||
self.eventsRect.append(QRect(r.x(),r.y()+labelH+margin,r.width(),r.height()-(labelH+margin)))
|
self.eventsRect.append(QRect(r.x(),r.y()+labelH+margin,r.width(),r.height()-(labelH+margin)))
|
||||||
|
|
||||||
|
@ -241,7 +251,6 @@ class CalDrawer():
|
||||||
# self.gv.setSizePolicy(spLeft);
|
# self.gv.setSizePolicy(spLeft);
|
||||||
layout.addWidget(self.gv)
|
layout.addWidget(self.gv)
|
||||||
|
|
||||||
def getSelectionEvents(self):
|
def getSelection(self):
|
||||||
(yy,mm,dd,ww)=self.gs.selection
|
return self.gs.selection
|
||||||
return self.env.listEventsOn(yy,mm,dd)
|
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@ class EvtDrawerScene(QGraphicsScene):
|
||||||
self.env=env
|
self.env=env
|
||||||
self.eventsRect=list()
|
self.eventsRect=list()
|
||||||
self.eventsList=list()
|
self.eventsList=list()
|
||||||
|
self.setDay(self.env.calState.today())
|
||||||
|
|
||||||
def drawForeground(self, painter, rect):
|
def drawForeground(self, painter, rect):
|
||||||
self.eventsList=self.env.listEventsOn(2024,10,1)
|
|
||||||
self.eventsRect.clear()
|
self.eventsRect.clear()
|
||||||
origXF, origYF, widthF, heightF = rect.getRect()
|
origXF, origYF, widthF, heightF = rect.getRect()
|
||||||
origXI, origYI, widthI, heightI = (int(origXF),int(origYF),int(widthF),int(heightF))
|
origXI, origYI, widthI, heightI = (int(origXF),int(origYF),int(widthF),int(heightF))
|
||||||
|
@ -62,9 +62,10 @@ class EvtDrawerScene(QGraphicsScene):
|
||||||
r=self.eventsRect[i]
|
r=self.eventsRect[i]
|
||||||
painter.drawText(r.x(),r.y()+labelH,"Hello event")
|
painter.drawText(r.x(),r.y()+labelH,"Hello event")
|
||||||
|
|
||||||
def setEvents(self, events):
|
def setDay(self, day):
|
||||||
print(events)
|
self.eventsList=self.env.listEventsOn(day[0],day[1],day[2])
|
||||||
pass
|
self.update()
|
||||||
|
|
||||||
|
|
||||||
class EvtDrawer():
|
class EvtDrawer():
|
||||||
|
|
||||||
|
@ -86,5 +87,5 @@ class EvtDrawer():
|
||||||
# self.gv.setSizePolicy(spLeft);
|
# self.gv.setSizePolicy(spLeft);
|
||||||
layout.addWidget(self.gv)
|
layout.addWidget(self.gv)
|
||||||
|
|
||||||
def setEvents(self,events):
|
def setDay(self,day):
|
||||||
self.gs.setEvents(events)
|
self.gs.setDay(day)
|
||||||
|
|
|
@ -20,16 +20,14 @@ class MainWindow(QMainWindow):
|
||||||
self.calDrawer=CalDrawer(self, self.calContainer.layout(), env)
|
self.calDrawer=CalDrawer(self, self.calContainer.layout(), env)
|
||||||
self.evtDrawer=EvtDrawer(self.calContainer.layout(), env)
|
self.evtDrawer=EvtDrawer(self.calContainer.layout(), env)
|
||||||
self.show()
|
self.show()
|
||||||
print(self.calDrawer.getSelectionEvents())
|
|
||||||
|
|
||||||
def setVersion(self,version):
|
def setVersion(self,version):
|
||||||
self.statusbar.showMessage("TropiCal v"+version,0)
|
self.statusbar.showMessage("TropiCal v"+version,0)
|
||||||
|
|
||||||
def event(self, event):
|
def event(self, event):
|
||||||
if event.type() == DaySelectedEvent:
|
if event.type() == DaySelectedEvent:
|
||||||
self.evtDrawer.setEvents(self.calDrawer.getSelectionEvents())
|
self.evtDrawer.setDay(self.calDrawer.getSelection())
|
||||||
return QWidget.event(self,event) #super().event(event)
|
return QWidget.event(self,event) #super().event(event)
|
||||||
|
|
||||||
|
|
||||||
def StartApplication(env):
|
def StartApplication(env):
|
||||||
path = os.path.dirname(os.path.abspath(__file__))+"/designer"
|
path = os.path.dirname(os.path.abspath(__file__))+"/designer"
|
||||||
|
|
Loading…
Add table
Reference in a new issue