Skip to content
Snippets Groups Projects
Commit 677c2877 authored by Antoine Smolders's avatar Antoine Smolders
Browse files

Event items tooltips and captions improvements

- All-day and multidays tooltips are more explicit by displaying starting and
  ending dates and time
- Captions of events display starting time (except for all-day events)
- Tooltips are displayed also when the mouse is above captions
parent 2113d633
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,9 @@
@property
def multidays(self):
return (not self.end or (self.end - self.start).days > 0)
if not self.end:
return False
return (self.end - self.start).days > 0
def __eq__(self, other_event):
if not isinstance(other_event, Event):
......
......@@ -112,6 +112,7 @@
self.text.set_property('y', self.y)
self.text.set_property('text', caption)
self.text.set_property('fill_color', the_event_text_color)
self.text.set_property('tooltip', tooltip)
# Clip the text.
x2, y2 = self.x + self.width, self.y + self.height,
......@@ -121,6 +122,8 @@
def update_all_day_event(self):
self.width = max(self.width, 0)
if self.event.multidays and not self.event.all_day:
starttime = self.event.start.strftime(self.time_format)
startdate = self.event.start.strftime('%x')
starttime = self.event.start.strftime(self.time_format)
if self.event.end:
enddate = self.event.end.strftime('%x')
endtime = self.event.end.strftime(self.time_format)
......@@ -126,3 +129,13 @@
endtime = self.event.end.strftime(self.time_format)
tooltip = '%s - %s %s' % (starttime, endtime, self.event.caption)
if self.event.all_day:
caption = self.event.caption
if not self.event.end:
tooltip = '%s\n%s' % (startdate, caption)
else:
tooltip = '%s - %s\n%s' % (startdate, enddate, caption)
elif self.event.multidays:
caption = '%s %s' % (starttime, self.event.caption)
tooltip = '%s %s - %s %s\n%s' % (startdate, starttime, enddate,
endtime, self.event.caption)
else:
......@@ -128,6 +141,7 @@
else:
tooltip = self.event.caption
caption = '' if self.no_caption else tooltip
caption = '%s %s' % (starttime, self.event.caption)
tooltip = '%s - %s\n%s' % (starttime, endtime, self.event.caption)
caption = '' if self.no_caption else caption
the_event_bg_color = self.event.bg_color
self.text.set_property('text', caption)
logical_height = self.text.get_natural_extents()[1][3]
......@@ -161,6 +175,7 @@
self.text.set_property('x', self.x + 2)
self.text.set_property('y', self.y)
self.text.set_property('fill_color', the_event_text_color)
self.text.set_property('tooltip', tooltip)
# Clip the text.
x2, y2 = self.x + self.width, self.y + self.height,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment