forked from openlp/openlp
fix renderer to make shadows small for footers
Add Keyboard events to servicemanager
This commit is contained in:
parent
9da5a3223f
commit
e788db767a
@ -40,6 +40,7 @@ class Renderer(object):
|
||||
self._debug = 0
|
||||
self._right_margin = 64 # the amount of right indent
|
||||
self._shadow_offset = 5
|
||||
self._shadow_offset_footer = 3
|
||||
self._outline_offset = 2
|
||||
self.theme_name = None
|
||||
self._theme = None
|
||||
@ -482,15 +483,17 @@ class Renderer(object):
|
||||
# dont allow alignment messing with footers
|
||||
if footer:
|
||||
align = 0
|
||||
shadow_offset = self._shadow_offset_footer
|
||||
else:
|
||||
align = int(self._theme .display_horizontalAlign)
|
||||
shadow_offset = self._shadow_offset
|
||||
for linenum in range(len(lines)):
|
||||
line = lines[linenum]
|
||||
#find out how wide line is
|
||||
w , h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False)
|
||||
if self._theme.display_shadow:
|
||||
w += self._shadow_offset
|
||||
h += self._shadow_offset
|
||||
w += shadow_offset
|
||||
h += shadow_offset
|
||||
if self._theme.display_outline:
|
||||
# pixels either side
|
||||
w += 2 * self._outline_offset
|
||||
@ -515,7 +518,7 @@ class Renderer(object):
|
||||
if live:
|
||||
# now draw the text, and any outlines/shadows
|
||||
if self._theme.display_shadow:
|
||||
self._get_extent_and_render(line, footer, tlcorner=(x+self._shadow_offset,y+self._shadow_offset),
|
||||
self._get_extent_and_render(line, footer, tlcorner=(x + shadow_offset, y + shadow_offset),
|
||||
draw=True, color = self._theme.display_shadow_color)
|
||||
if self._theme.display_outline:
|
||||
self._get_extent_and_render(line, footer, (x+self._outline_offset,y), draw=True,
|
||||
|
@ -54,10 +54,10 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
||||
self.parent.onServiceDown()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Up:
|
||||
self.parent.onServiceUp()
|
||||
self.parent.onMoveSelectionUp()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Down:
|
||||
self.parent.onServiceDown()
|
||||
self.parent.onMoveSelectionDown()
|
||||
event.accept()
|
||||
event.ignore()
|
||||
else:
|
||||
@ -65,14 +65,14 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
||||
|
||||
class Iter(QtGui.QTreeWidgetItemIterator):
|
||||
def __init__(self, *args):
|
||||
QTreeWidgetItemIterator.__init__(self, *args)
|
||||
QtGui.QTreeWidgetItemIterator.__init__(self, *args)
|
||||
def next(self):
|
||||
self.__iadd__(1)
|
||||
value = self.value()
|
||||
if value:
|
||||
return self.value()
|
||||
else:
|
||||
raise StopIteration
|
||||
self.__iadd__(1)
|
||||
value = self.value()
|
||||
if value:
|
||||
return self.value()
|
||||
else:
|
||||
return None
|
||||
|
||||
class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
@ -163,6 +163,52 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.servicePath = self.config.get_data_path()
|
||||
self.service_theme = self.config.get_config(u'theme service theme', u'')
|
||||
|
||||
def onMoveSelectionUp(self):
|
||||
"""
|
||||
Moves the selection up the window
|
||||
Called by the up arrow
|
||||
"""
|
||||
it = Iter(self.ServiceManagerList)
|
||||
item = it.value()
|
||||
tempItem = None
|
||||
setLastItem = False
|
||||
while item is not None:
|
||||
if item.isSelected() and tempItem is None:
|
||||
setLastItem = True
|
||||
item.setSelected(False)
|
||||
if item.isSelected():
|
||||
#We are on the first record
|
||||
if tempItem is not None:
|
||||
tempItem.setSelected(True)
|
||||
item.setSelected(False)
|
||||
else:
|
||||
tempItem = item
|
||||
lastItem = item
|
||||
item = it.next()
|
||||
#Top Item was selected so set the last one
|
||||
if setLastItem:
|
||||
lastItem.setSelected(True)
|
||||
|
||||
def onMoveSelectionDown(self):
|
||||
"""
|
||||
Moves the selection down the window
|
||||
Called by the down arrow
|
||||
"""
|
||||
it = Iter(self.ServiceManagerList)
|
||||
item = it.value()
|
||||
firstItem = item
|
||||
setSelected = False
|
||||
while item is not None:
|
||||
if setSelected:
|
||||
setSelected = False
|
||||
item.setSelected(True)
|
||||
elif item.isSelected():
|
||||
item.setSelected(False)
|
||||
setSelected = True
|
||||
item = it.next()
|
||||
if setSelected:
|
||||
firstItem.setSelected(True)
|
||||
|
||||
def collapsed(self, item):
|
||||
"""
|
||||
Record if an item is collapsed
|
||||
@ -254,10 +300,6 @@ class ServiceManager(QtGui.QWidget):
|
||||
Used when moving items as the move takes place in supporting array,
|
||||
and when regenerating all the items due to theme changes
|
||||
"""
|
||||
aa = Iter(self.ServiceManagerList)
|
||||
print aa
|
||||
for a in aa:
|
||||
print a
|
||||
#Correct order of idems in array
|
||||
count = 1
|
||||
for item in self.serviceItems:
|
||||
|
Loading…
Reference in New Issue
Block a user