Added support for rss-feed and event-list
This commit is contained in:
parent
bd69088e0b
commit
b1a796079b
1 changed files with 53 additions and 6 deletions
|
@ -2,16 +2,28 @@ from PanelDesign import PanelDesign
|
|||
from datetime import datetime, timedelta, date
|
||||
from DayHeaderDesign import DayHeaderDesign
|
||||
from HourListDesign import HourListDesign
|
||||
from settings import general_settings
|
||||
from RssPostListDesign import RssPostListDesign
|
||||
from PIL import ImageDraw
|
||||
from Assets import colors
|
||||
from EventListDesign import EventListDesign
|
||||
|
||||
header_size = (1, 0.2)
|
||||
hourlist_size = (1, 1 - header_size[1])
|
||||
showhours_count = 12
|
||||
default_shownhours_count = 12
|
||||
|
||||
infoarea_replaced_hours = 4
|
||||
infoarea_borderline_width = 3
|
||||
infoarea_padding = 5
|
||||
|
||||
class DayViewPanel (PanelDesign):
|
||||
"""Overview that focuses on the current day and
|
||||
shows a timeline split into hours."""
|
||||
def __init__ (self, size):
|
||||
super(DayViewPanel, self).__init__(size)
|
||||
self.shownhours_count = default_shownhours_count
|
||||
if general_settings["info-area"] not in ["", "empty"]:
|
||||
self.shownhours_count -= infoarea_replaced_hours
|
||||
self.__first_render__()
|
||||
|
||||
def __first_render__ (self):
|
||||
|
@ -26,8 +38,40 @@ class DayViewPanel (PanelDesign):
|
|||
self.__header__.add_events(allday_ev)
|
||||
self.__hourlist__.add_events(timed_ev)
|
||||
|
||||
if general_settings["info-area"] == "events":
|
||||
self.__draw_event_list__(calendar)
|
||||
self.__draw_infoarea_line__()
|
||||
|
||||
def add_rssfeed (self, rss):
|
||||
pass
|
||||
if general_settings["info-area"] == "rss":
|
||||
self.__draw_rss_feed__(rss)
|
||||
self.__draw_infoarea_line__()
|
||||
|
||||
def __draw_infoarea_line__(self):
|
||||
height = infoarea_replaced_hours * self.__hourlist__.row_size[1]
|
||||
ypos = self.size[1] - height
|
||||
|
||||
line_start = (0, ypos)
|
||||
line_end = (self.size[0], ypos)
|
||||
ImageDraw.Draw(self.__image__).line([ line_start, line_end ], fill=colors["fg"], width=infoarea_borderline_width)
|
||||
|
||||
def __draw_rss_feed__(self, rss):
|
||||
height = infoarea_replaced_hours * self.__hourlist__.row_size[1] - infoarea_padding
|
||||
size = (self.size[0], height)
|
||||
pos = (0, self.size[1] - size[1])
|
||||
|
||||
rss = RssPostListDesign(size, rss)
|
||||
rss.pos = pos
|
||||
self.draw_design(rss)
|
||||
|
||||
def __draw_event_list__(self, calendar):
|
||||
height = infoarea_replaced_hours * self.__hourlist__.row_size[1] - infoarea_padding
|
||||
size = (self.size[0], height)
|
||||
pos = (0, self.size[1] - size[1])
|
||||
|
||||
events = EventListDesign(size, calendar.get_upcoming_events())
|
||||
events.pos = pos
|
||||
self.draw_design(events)
|
||||
|
||||
def add_taks (self, tasks):
|
||||
pass
|
||||
|
@ -42,16 +86,19 @@ class DayViewPanel (PanelDesign):
|
|||
|
||||
def __init_hourlist__ (self):
|
||||
start, end = self.__get_current_hour_range__()
|
||||
self.__hourlist__ = HourListDesign(self.__abs_co__(hourlist_size), start, end)
|
||||
size = self.__abs_co__(hourlist_size)
|
||||
size = (size[0], size[1] * self.shownhours_count / default_shownhours_count)
|
||||
|
||||
self.__hourlist__ = HourListDesign(size, start, end)
|
||||
self.__hourlist__.pos = (0, self.__header__.size[1])
|
||||
|
||||
def __get_current_hour_range__(self):
|
||||
start_hour = datetime.now().hour
|
||||
|
||||
if start_hour + showhours_count > 23:
|
||||
start_hour = 23 - showhours_count
|
||||
if start_hour + self.shownhours_count > 23:
|
||||
start_hour = 23 - self.shownhours_count
|
||||
|
||||
return start_hour, start_hour + showhours_count
|
||||
return start_hour, start_hour + self.shownhours_count
|
||||
|
||||
def __abs_co__ (self, coordinates):
|
||||
return (int(coordinates[0] * self.size[0]),int(coordinates[1] * self.size[1]))
|
||||
|
|
Loading…
Reference in a new issue