Don't set .parent's on Qt items, pass to init instead

This commit is contained in:
Jonathan Corwin 2011-05-28 19:47:14 +01:00
parent 01a89abe52
commit 82a72fdc87
11 changed files with 37 additions and 41 deletions

View File

@ -47,7 +47,6 @@ class OpenLPDockWidget(QtGui.QDockWidget):
"""
log.debug(u'Initialise the %s widget' % name)
QtGui.QDockWidget.__init__(self, parent)
self.parent = parent
if name:
self.setObjectName(name)
if icon:

View File

@ -90,8 +90,7 @@ class MediaManagerItem(QtGui.QWidget):
"""
Constructor to create the media manager item.
"""
QtGui.QWidget.__init__(self)
self.parent = parent
QtGui.QWidget.__init__(self, parent)
self.whitespace = re.compile(r'\W+', re.UNICODE)
self.plugin = plugin
visible_title = self.plugin.getString(StringContent.VisibleName)

View File

@ -215,7 +215,8 @@ class Plugin(QtCore.QObject):
you need, and return it for integration into openlp.org.
"""
if self.media_item_class:
return self.media_item_class(self.mediadock, self, self.icon)
return self.media_item_class(self.mediadock.media_dock, self,
self.icon)
return None
def addImportMenuItem(self, importMenu):

View File

@ -77,7 +77,7 @@ class Renderer(object):
self.theme_data = None
self.bg_frame = None
self.force_page = False
self.display = MainDisplay(self, self.image_manager, False)
self.display = MainDisplay(None, self.image_manager, False)
self.display.setup()
def update_display(self):
@ -86,7 +86,7 @@ class Renderer(object):
"""
log.debug(u'Update Display')
self._calculate_default(self.screens.current[u'size'])
self.display = MainDisplay(self, self.image_manager, False)
self.display = MainDisplay(None, self.image_manager, False)
self.display.setup()
self.bg_frame = None
self.theme_data = None

View File

@ -50,7 +50,8 @@ class MainDisplay(QtGui.QGraphicsView):
"""
def __init__(self, parent, image_manager, live):
QtGui.QGraphicsView.__init__(self)
self.parent = parent
if parent:
self.setParent(parent)
self.isLive = live
self.image_manager = image_manager
self.screens = ScreenList.get_instance()

View File

@ -40,7 +40,6 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
"""
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.parent = parent
self.activePlugin = None
self.programaticChange = False
self.setupUi(self)
@ -65,7 +64,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
self._clearDetails()
self.programaticChange = True
pluginListWidth = 0
for plugin in self.parent.pluginManager.plugins:
for plugin in self.parent().pluginManager.plugins:
item = QtGui.QListWidgetItem(self.pluginListWidget)
# We do this just to make 100% sure the status is an integer as
# sometimes when it's loaded from the config, it isn't cast to int.
@ -117,7 +116,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
plugin_name_singular = \
self.pluginListWidget.currentItem().text().split(u' ')[0]
self.activePlugin = None
for plugin in self.parent.pluginManager.plugins:
for plugin in self.parent().pluginManager.plugins:
if plugin.nameStrings[u'singular'] == plugin_name_singular:
self.activePlugin = plugin
break

View File

@ -46,7 +46,6 @@ class SlideList(QtGui.QTableWidget):
"""
def __init__(self, parent=None, name=None):
QtGui.QTableWidget.__init__(self, parent.controller)
self.parent = parent
class SlideController(QtGui.QWidget):
@ -60,11 +59,10 @@ class SlideController(QtGui.QWidget):
"""
QtGui.QWidget.__init__(self, parent)
self.isLive = isLive
self.parent = parent
self.screens = ScreenList.get_instance()
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.image_manager = self.parent.image_manager
self.image_manager = self.parent().image_manager
self.loopList = [
u'Start Loop',
u'Loop Separator',
@ -461,7 +459,7 @@ class SlideController(QtGui.QWidget):
self.previewListWidget.resizeRowsToContents()
else:
# Sort out image heights.
width = self.parent.controlSplitter.sizes()[self.split]
width = self.parent().controlSplitter.sizes()[self.split]
for framenumber in range(len(self.serviceItem.get_frames())):
self.previewListWidget.setRowHeight(
framenumber, width / self.ratio)
@ -502,7 +500,7 @@ class SlideController(QtGui.QWidget):
self.toolbar.actions[u'Stop Loop'].setVisible(False)
if item.is_text():
if QtCore.QSettings().value(
self.parent.songsSettingsSection + u'/display songbar',
self.parent().songsSettingsSection + u'/display songbar',
QtCore.QVariant(True)).toBool() and len(self.slideList) > 0:
self.toolbar.makeWidgetsVisible([u'Song Menu'])
if item.is_capable(ItemCapabilities.AllowsLoop) and \
@ -591,7 +589,7 @@ class SlideController(QtGui.QWidget):
Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
[serviceItem, self.isLive, self.hideMode(), slideno])
self.slideList = {}
width = self.parent.controlSplitter.sizes()[self.split]
width = self.parent().controlSplitter.sizes()[self.split]
self.previewListWidget.clear()
self.previewListWidget.setRowCount(0)
self.previewListWidget.setColumnWidth(0, width)
@ -625,8 +623,8 @@ class SlideController(QtGui.QWidget):
label.setScaledContents(True)
if self.serviceItem.is_command():
image = resize_image(frame[u'image'],
self.parent.renderer.width,
self.parent.renderer.height)
self.parent().renderer.width,
self.parent().renderer.height)
else:
# If current slide set background to image
if framenumber == slideno:
@ -635,7 +633,7 @@ class SlideController(QtGui.QWidget):
image = self.image_manager.get_image(frame[u'title'])
label.setPixmap(QtGui.QPixmap.fromImage(image))
self.previewListWidget.setCellWidget(framenumber, 0, label)
slideHeight = width * self.parent.renderer.screen_ratio
slideHeight = width * self.parent().renderer.screen_ratio
row += 1
text.append(unicode(row))
self.previewListWidget.setItem(framenumber, 0, item)
@ -736,7 +734,7 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'mainDisplaySetBackground live = %s' % self.isLive)
display_type = QtCore.QSettings().value(
self.parent.generalSettingsSection + u'/screen blank',
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'')).toString()
if not self.display.primary:
# Order done to handle initial conversion
@ -772,11 +770,11 @@ class SlideController(QtGui.QWidget):
self.desktopScreen.setChecked(False)
if checked:
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'blanked'))
else:
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
self.parent().generalSettingsSection + u'/screen blank')
self.blankPlugin()
self.updatePreview()
@ -793,11 +791,11 @@ class SlideController(QtGui.QWidget):
self.desktopScreen.setChecked(False)
if checked:
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'themed'))
else:
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
self.parent().generalSettingsSection + u'/screen blank')
self.blankPlugin()
self.updatePreview()
@ -814,11 +812,11 @@ class SlideController(QtGui.QWidget):
self.desktopScreen.setChecked(checked)
if checked:
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'hidden'))
else:
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
self.parent().generalSettingsSection + u'/screen blank')
self.hidePlugin(checked)
self.updatePreview()
@ -956,8 +954,8 @@ class SlideController(QtGui.QWidget):
else:
row = self.previewListWidget.currentRow() + 1
if row == self.previewListWidget.rowCount():
if QtCore.QSettings().value(self.parent.generalSettingsSection +
u'/enable slide loop', QtCore.QVariant(True)).toBool():
if QtCore.QSettings().value(self.parent().generalSettingsSection
+ u'/enable slide loop', QtCore.QVariant(True)).toBool():
row = 0
else:
row = self.previewListWidget.rowCount() - 1
@ -977,8 +975,8 @@ class SlideController(QtGui.QWidget):
else:
row = self.previewListWidget.currentRow() - 1
if row == -1:
if QtCore.QSettings().value(self.parent.generalSettingsSection +
u'/enable slide loop', QtCore.QVariant(True)).toBool():
if QtCore.QSettings().value(self.parent().generalSettingsSection
+ u'/enable slide loop', QtCore.QVariant(True)).toBool():
row = self.previewListWidget.rowCount() - 1
else:
row = 0
@ -1055,7 +1053,8 @@ class SlideController(QtGui.QWidget):
From the preview display request the Item to be added to service
"""
if self.serviceItem:
self.parent.serviceManagerContents.addServiceItem(self.serviceItem)
self.parent().serviceManagerContents.addServiceItem(
self.serviceItem)
def onGoLiveClick(self):
"""
@ -1083,7 +1082,7 @@ class SlideController(QtGui.QWidget):
Receiver.send_message('servicemanager_preview_live',
u'%s:%s' % (self.serviceItem._uuid, row))
else:
self.parent.liveController.addServiceManagerItem(
self.parent().liveController.addServiceManagerItem(
self.serviceItem, row)
def onMediaStart(self, item):

View File

@ -42,7 +42,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
"""
self.manager = plugin.manager
self.plugin = plugin
self.parent = plugin.formparent
self.item_id = None
QtGui.QDialog.__init__(self, plugin.formparent)
self.setupUi(self)

View File

@ -40,8 +40,7 @@ class AlertsManager(QtCore.QObject):
log.info(u'Alert Manager loaded')
def __init__(self, parent):
QtCore.QObject.__init__(self)
self.parent = parent
QtCore.QObject.__init__(self, parent)
self.screen = None
self.timer_id = 0
self.alertList = []
@ -85,8 +84,8 @@ class AlertsManager(QtCore.QObject):
if len(self.alertList) == 0:
return
text = self.alertList.pop(0)
alertTab = self.parent.settings_tab
self.parent.liveController.display.alert(text)
alertTab = self.parent().settings_tab
self.parent().liveController.display.alert(text)
# Check to see if we have a timer running.
if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
@ -101,7 +100,7 @@ class AlertsManager(QtCore.QObject):
"""
log.debug(u'timer event')
if event.timerId() == self.timer_id:
self.parent.liveController.display.alert(u'')
self.parent().liveController.display.alert(u'')
self.killTimer(self.timer_id)
self.timer_id = 0
self.generateAlert()

View File

@ -99,7 +99,7 @@ class PresentationPlugin(Plugin):
Create the Media Manager List
"""
return PresentationMediaItem(
self.mediadock, self, self.icon, self.controllers)
self.mediadock.media_dock, self, self.icon, self.controllers)
def registerControllers(self, controller):
"""

View File

@ -648,7 +648,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = unicode(self.songBookComboBox.currentText())
if item == 0 and text:
temp_song_book = text
self.parent.song_maintenance_form.exec_()
self.parent().song_maintenance_form.exec_()
self.loadAuthors()
self.loadBooks()
self.loadTopics()
@ -754,7 +754,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.topics.append(self.manager.get_object(Topic, topicId))
clean_song(self.manager, self.song)
self.manager.save_object(self.song)
self.parent.auto_select_id = self.song.id
self.parent().auto_select_id = self.song.id
def _processLyrics(self):
"""