Fixed issue where screens were being loaded twice; Fixed an issue where an underlying C++ object was being deleted before the Python object was finished with it

This commit is contained in:
Raoul Snyman 2018-10-01 23:00:25 -07:00
parent aa3b0c4bcc
commit e45be1a50f
3 changed files with 29 additions and 17 deletions

View File

@ -49,7 +49,7 @@ class Screen(object):
:param bool is_primary: Whether or not this screen is the primary screen
:param bool is_display: Whether or not this screen should be used to display lyrics
"""
self.number = number
self.number = int(number)
self.geometry = geometry
self.custom_geometry = None
self.is_primary = is_primary
@ -66,6 +66,12 @@ class Screen(object):
name = '{name} ({primary})'.format(name=name, primary=translate('OpenLP.ScreenList', 'primary'))
return name
def __repr__(self):
"""
Return a string representation of the object
"""
return '<{screen}>'.format(screen=self)
@property
def display_geometry(self):
"""
@ -124,12 +130,16 @@ class Screen(object):
:param dict screen_dict: The dictionary which we want to apply to the screen
"""
self.number = screen_dict['number']
self.number = int(screen_dict['number'])
self.is_display = screen_dict['is_display']
self.is_primary = screen_dict['is_primary']
self.geometry = QtCore.QRect(**screen_dict['geometry'])
self.geometry = QtCore.QRect(screen_dict['geometry']['x'], screen_dict['geometry']['y'],
screen_dict['geometry']['width'], screen_dict['geometry']['height'])
if 'display_geometry' in screen_dict:
self.display_geometry = QtCore.QRect(**screen_dict['display_geometry'])
self.display_geometry = QtCore.QRect(screen_dict['display_geometry']['x'],
screen_dict['display_geometry']['y'],
screen_dict['display_geometry']['width'],
screen_dict['display_geometry']['height'])
class ScreenList(object):
@ -222,6 +232,8 @@ class ScreenList(object):
Settings.extend_default_settings(screen_settings)
screen_settings = Settings().value('core/screens')
for number, screen_dict in screen_settings.items():
# Sometimes this loads as a string instead of an int
number = int(number)
if self.has_screen(number):
self[number].update(screen_dict)
else:

View File

@ -81,6 +81,7 @@ class ScreensTab(SettingsTab):
super(ScreensTab, self).__init__(parent, 'Screens', screens_translated)
self.settings_section = 'core'
self.current_screen = None
self.identify_labels = []
def setup_ui(self):
"""
@ -262,11 +263,18 @@ class ScreensTab(SettingsTab):
# On save update the screens as well
self.settings_form.register_post_process('config_screen_changed')
@QtCore.pyqtSlot()
def _on_identify_timer_shot(self):
for label in self.identify_labels:
label.hide()
label.setParent(None)
label.deleteLater()
self.identify_labels = []
def on_identify_button_clicked(self):
"""
Display a widget on every screen for 5 seconds
"""
labels = []
for screen in self.screens:
label = QtWidgets.QLabel(None)
label.setAlignment(QtCore.Qt.AlignCenter)
@ -278,17 +286,9 @@ class ScreensTab(SettingsTab):
label.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.WindowDoesNotAcceptFocus)
label.show()
labels.append(label)
self.identify_labels.append(label)
@QtCore.pyqtSlot()
def _close_label():
label.hide()
if label in labels:
labels.remove(label)
label.setParent(None)
label.deleteLater()
QtCore.QTimer.singleShot(3000, _close_label)
QtCore.QTimer.singleShot(3000, self._on_identify_timer_shot)
def on_screen_button_clicked(self):
"""

View File

@ -5,12 +5,12 @@
[pep8]
exclude=resources.py,vlc.py
max-line-length = 120
ignore = E402
ignore = E402,E722,W503,W504
[flake8]
exclude=resources.py,vlc.py
max-line-length = 120
ignore = E402
ignore = E402,E722,W503,W504
[pycodestyle]
exclude = resources.py,vlc.py