Fix ServiceManager drag and drop`

Fix rendering size issues
Fix screen sizes following display changes

bzr-revno: 741
This commit is contained in:
Tim Bentley 2010-03-14 14:36:48 +00:00
commit d0f3322aa5
7 changed files with 41 additions and 15 deletions

View File

@ -43,7 +43,6 @@ class Renderer(object):
"""
self._rect = None
self._debug = False
self._right_margin = 64 # the amount of right indent
self._display_shadow_size_footer = 0
self._display_outline_size_footer = 0
self.theme_name = None
@ -149,7 +148,7 @@ class Renderer(object):
def pre_render_text(self, text):
metrics = QtGui.QFontMetrics(self.mainFont)
#work out line width
line_width = self._rect.width() - self._right_margin
line_width = self._rect.width()
#number of lines on a page - adjust for rounding up.
line_height = metrics.height()
if self._theme.display_shadow:
@ -224,6 +223,7 @@ class Renderer(object):
``rect_footer``
The footer text block.
"""
log.debug(u'set_text_rectangle %s , %s' %(rect_main, rect_footer) )
self._rect = rect_main
self._rect_footer = rect_footer
@ -447,8 +447,7 @@ class Renderer(object):
rightextent = x + w
# shift right from last line's rh edge
if self._theme.display_wrapStyle == 1 and linenum != 0:
rightextent = self._first_line_right_extent + \
self._right_margin
rightextent = self._first_line_right_extent
if rightextent > maxx:
rightextent = maxx
x = rightextent - w

View File

@ -146,13 +146,13 @@ class RenderManager(object):
footer_rect = None
if not theme.font_main_override:
main_rect = QtCore.QRect(10, 0,
self.width - 1, self.footer_start)
self.width - 20, self.footer_start)
else:
main_rect = QtCore.QRect(theme.font_main_x, theme.font_main_y,
theme.font_main_width - 1, theme.font_main_height - 1)
if not theme.font_footer_override:
footer_rect = QtCore.QRect(10, self.footer_start,
self.width - 1, self.height - self.footer_start)
self.width - 20, self.height - self.footer_start)
else:
footer_rect = QtCore.QRect(theme.font_footer_x,
theme.font_footer_y, theme.font_footer_width - 1,

View File

@ -53,7 +53,7 @@ blankthemexml=\
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<location override="False" x="10" y="10" width="1024" height="730"/>
<location override="False" x="10" y="10" width="1004" height="730"/>
</font>
<font type="footer">
<name>Arial</name>
@ -62,7 +62,7 @@ blankthemexml=\
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<location override="False" x="10" y="730" width="1024" height="38"/>
<location override="False" x="10" y="730" width="1004" height="38"/>
</font>
<display>
<shadow color="#000000" size="5">True</shadow>

View File

@ -621,6 +621,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.screens.set_current_display(updated_display)
self.RenderManager.update_display(updated_display)
self.mainDisplay.setup(updated_display)
#Trigger after changes have been made
Receiver.send_message(u'config_updated')
self.activateWindow()
def closeEvent(self, event):

View File

@ -100,6 +100,7 @@ class ServiceManager(QtGui.QWidget):
self.parent = parent
self.serviceItems = []
self.serviceName = u''
self.droppos = 0
#is a new service and has not been saved
self.isNew = True
#Indicates if remoteTriggering is active. If it is the next addServiceItem call
@ -190,6 +191,8 @@ class ServiceManager(QtGui.QWidget):
QtCore.SIGNAL(u'presentation types'), self.onPresentationTypes)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems)
# Last little bits of setting up
self.config = PluginConfig(u'ServiceManager')
self.servicePath = self.config.get_data_path()
@ -617,7 +620,7 @@ class ServiceManager(QtGui.QWidget):
for item in tempServiceItems:
self.addServiceItem(item[u'service_item'], False, item[u'expanded'])
#Set to False as items may have changed rendering
#does not impact the saved song so True may aslo be valid
#does not impact the saved song so True may also be valid
self.parent.serviceChanged(False, self.serviceName)
def addServiceItem(self, item, rebuild=False, expand=True):
@ -637,19 +640,21 @@ class ServiceManager(QtGui.QWidget):
self.repaintServiceList(sitem + 1, 0)
self.parent.LiveController.replaceServiceManagerItem(item)
else:
if sitem == -1:
#nothing selected or dnd
if self.droppos == 0:
self.serviceItems.append({u'service_item': item,
u'order': len(self.serviceItems) + 1,
u'expanded':expand})
self.repaintServiceList(len(self.serviceItems) + 1, 0)
else:
self.serviceItems.insert(sitem + 1, {u'service_item': item,
u'order': len(self.serviceItems)+1,
self.serviceItems.insert(self.droppos, {u'service_item': item,
u'order': self.droppos,
u'expanded':expand})
self.repaintServiceList(sitem + 1, 0)
self.repaintServiceList(self.droppos, 0)
#if rebuilding list make sure live is fixed.
if rebuild:
self.parent.LiveController.replaceServiceManagerItem(item)
self.droppos = 0
self.parent.serviceChanged(False, self.serviceName)
def makePreview(self):
@ -730,9 +735,9 @@ class ServiceManager(QtGui.QWidget):
link = event.mimeData()
if link.hasText():
plugin = event.mimeData().text()
item = self.ServiceManagerList.itemAt(event.pos())
if plugin == u'ServiceManager':
startpos, startCount = self.findServiceItem()
item = self.ServiceManagerList.itemAt(event.pos())
if item is None:
endpos = len(self.serviceItems)
else:
@ -751,6 +756,14 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.insert(newpos, serviceItem)
self.repaintServiceList(endpos, startCount)
else:
if item == None:
self.droppos = len(self.serviceItems)
else:
parentitem = item.parent()
if parentitem is None:
self.droppos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
else:
self.droppos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
Receiver.send_message(u'%s_add_service_item' % plugin)
def updateThemeList(self, theme_list):

View File

@ -65,7 +65,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
def accept(self):
for tab_index in range(0, self.SettingsTabWidget.count()):
self.SettingsTabWidget.widget(tab_index).save()
Receiver.send_message(u'config_updated')
return QtGui.QDialog.accept(self)
def postSetUp(self):

View File

@ -299,6 +299,8 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'%s_change' % prefix), self.onSlideChange)
QtCore.QObject.connect(self.Splitter,
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.refreshServiceItem)
def widthChanged(self):
"""
@ -377,6 +379,17 @@ class SlideController(QtGui.QWidget):
self.Mediabar.setVisible(True)
self.volumeSlider.setAudioOutput(self.audio)
def refreshServiceItem(self):
"""
Method to update the service item if the screen has changed
"""
log.debug(u'refreshServiceItem')
if self.serviceItem:
if self.serviceItem.is_text() or self.serviceItem.is_image():
item = self.serviceItem
item.render()
self.addServiceManagerItem(item, self.selectedRow)
def addServiceItem(self, item):
"""
Method to install the service item into the controller