Allow configuration of default colors for graph and calendar
issue9435 review300011002
This commit is contained in:
1 parent
61f4d1fac4
commit
4973fb2adc
4 files changed
+13
-3
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Allow configuration of default colors for graph and calendar
|
||||
* Use existing context for get_preferences
|
||||
* Add context to export URL
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ class ConfigManager(object):
|
||||
'client.bus_timeout': 10 * 60,
|
||||
'icon.colors': '#3465a4,#555753,#cc0000',
|
||||
'tree.colors': '#777,#dff0d8,#fcf8e3,#f2dede',
|
||||
'calendar.colors': '#fff,#3465a4',
|
||||
'graph.color': '#3465a4',
|
||||
'image.max_size': 10 ** 6,
|
||||
'bug.url': 'https://bugs.tryton.org/',
|
||||
'download.url': 'https://downloads-cdn.tryton.org/',
|
||||
|
||||
@@ -6,6 +6,9 @@ import goocalendar
|
||||
from .dates_period import DatesPeriod
|
||||
|
||||
from tryton.common import MODELACCESS
|
||||
from tryton.config import CONFIG
|
||||
|
||||
_colors = CONFIG['calendar.colors'].split(',')
|
||||
|
||||
|
||||
class Calendar_(goocalendar.Calendar):
|
||||
@@ -14,6 +17,9 @@ class Calendar_(goocalendar.Calendar):
|
||||
def __init__(self, attrs, view, fields, event_store=None):
|
||||
super(Calendar_, self).__init__(
|
||||
event_store, attrs.get('mode', 'month'))
|
||||
self.props.selected_border_color = _colors[1]
|
||||
if hasattr(self.props, 'selected_text_color'):
|
||||
self.props.selected_text_color = _colors[0]
|
||||
self.attrs = attrs
|
||||
self.view_calendar = view
|
||||
self.fields = fields
|
||||
@@ -69,10 +75,10 @@ class Calendar_(goocalendar.Calendar):
|
||||
return domain
|
||||
|
||||
def get_colors(self, record):
|
||||
text_color = None
|
||||
text_color = _colors[0]
|
||||
if self.attrs.get('color'):
|
||||
text_color = record[self.attrs['color']].get(record)
|
||||
bg_color = 'lightblue'
|
||||
bg_color = _colors[1]
|
||||
if self.attrs.get('background_color'):
|
||||
bg_color = record[self.attrs['background_color']].get(
|
||||
record)
|
||||
|
||||
@@ -14,6 +14,7 @@ from gi.repository import Gdk, Gtk
|
||||
import tryton.rpc as rpc
|
||||
from tryton.action import Action
|
||||
from tryton.common import hex2rgb, generateColorscheme, COLOR_SCHEMES
|
||||
from tryton.config import CONFIG
|
||||
from tryton.gui.window import Window
|
||||
from tryton.pyson import PYSONDecoder
|
||||
|
||||
@@ -460,7 +461,7 @@ class Graph(Gtk.DrawingArea):
|
||||
|
||||
def setColorScheme(self):
|
||||
keys = self._getDatasKeys()
|
||||
color = self.attrs.get('color', 'blue')
|
||||
color = self.attrs.get('color', CONFIG['graph.color'])
|
||||
r, g, b = hex2rgb(COLOR_SCHEMES.get(color, color))
|
||||
maxcolor = max(max(r, g), b)
|
||||
self.colorScheme = generateColorscheme(color, keys,
|
||||
|
||||
Reference in new issue
Block a user