From f02e224d757c1098cff503a14322a004e8cccfe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gu=C3=A9gan?= Date: Wed, 18 Sep 2024 20:38:41 +0200 Subject: [PATCH] Minor changes --- tropical/qt/caldrawer.py | 17 +++++++++++++---- tropical/qt/eventdrawer.py | 13 +++++++------ tropical/qt/mainwindow.py | 4 +--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tropical/qt/caldrawer.py b/tropical/qt/caldrawer.py index b7a7502..1f8245b 100644 --- a/tropical/qt/caldrawer.py +++ b/tropical/qt/caldrawer.py @@ -136,6 +136,10 @@ class CalDrawerScene(QGraphicsScene): brush.setColor(QtGui.QColor(self.daysLabelBG)) brush.setStyle(Qt.BrushStyle.SolidPattern) painter.setBrush(brush) + # Brush for today + brushToday=QtGui.QBrush() + brushToday.setColor(QtGui.QColor("#23a1fc")) + brushToday.setStyle(Qt.BrushStyle.SolidPattern) # Init various things days=self.calState.getMonthDays() font=painter.font() @@ -148,13 +152,19 @@ class CalDrawerScene(QGraphicsScene): for i in range(0,len(self.daysRect)): r=self.daysRect[i] d=days[i] - dayLabel="["+str(d[2])+"]" if d == today else str(d[2]) + dayLabel=str(d[2]) labelW=metric.boundingRect(dayLabel).width() offsetX=int(r.width()/2-labelW/2) painter.setPen(Qt.PenStyle.NoPen) painter.drawRect(r.x(),r.y(),r.width(),labelH) # Remember r is within grid stroke painter.setPen(pen) # 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) 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); layout.addWidget(self.gv) - def getSelectionEvents(self): - (yy,mm,dd,ww)=self.gs.selection - return self.env.listEventsOn(yy,mm,dd) + def getSelection(self): + return self.gs.selection diff --git a/tropical/qt/eventdrawer.py b/tropical/qt/eventdrawer.py index c1b450f..6b9af44 100644 --- a/tropical/qt/eventdrawer.py +++ b/tropical/qt/eventdrawer.py @@ -24,9 +24,9 @@ class EvtDrawerScene(QGraphicsScene): self.env=env self.eventsRect=list() self.eventsList=list() + self.setDay(self.env.calState.today()) def drawForeground(self, painter, rect): - self.eventsList=self.env.listEventsOn(2024,10,1) self.eventsRect.clear() origXF, origYF, widthF, heightF = rect.getRect() origXI, origYI, widthI, heightI = (int(origXF),int(origYF),int(widthF),int(heightF)) @@ -62,9 +62,10 @@ class EvtDrawerScene(QGraphicsScene): r=self.eventsRect[i] painter.drawText(r.x(),r.y()+labelH,"Hello event") - def setEvents(self, events): - print(events) - pass + def setDay(self, day): + self.eventsList=self.env.listEventsOn(day[0],day[1],day[2]) + self.update() + class EvtDrawer(): @@ -86,5 +87,5 @@ class EvtDrawer(): # self.gv.setSizePolicy(spLeft); layout.addWidget(self.gv) - def setEvents(self,events): - self.gs.setEvents(events) + def setDay(self,day): + self.gs.setDay(day) diff --git a/tropical/qt/mainwindow.py b/tropical/qt/mainwindow.py index f9f9ac0..2805683 100644 --- a/tropical/qt/mainwindow.py +++ b/tropical/qt/mainwindow.py @@ -20,16 +20,14 @@ class MainWindow(QMainWindow): self.calDrawer=CalDrawer(self, self.calContainer.layout(), env) self.evtDrawer=EvtDrawer(self.calContainer.layout(), env) self.show() - print(self.calDrawer.getSelectionEvents()) def setVersion(self,version): self.statusbar.showMessage("TropiCal v"+version,0) def event(self, event): if event.type() == DaySelectedEvent: - self.evtDrawer.setEvents(self.calDrawer.getSelectionEvents()) + self.evtDrawer.setDay(self.calDrawer.getSelection()) return QWidget.event(self,event) #super().event(event) - def StartApplication(env): path = os.path.dirname(os.path.abspath(__file__))+"/designer"