forked from openlp/openlp
simplify visibility interface
This commit is contained in:
parent
8e33175477
commit
c99c2694db
@ -360,7 +360,7 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
|
||||
self.audio_time_label.setObjectName('audio_time_label')
|
||||
self.toolbar.add_toolbar_widget(self.audio_time_label)
|
||||
self.toolbar.set_widget_visible(AUDIO_LIST, False)
|
||||
self.toolbar.set_widget_visible(['song_menu'], False)
|
||||
self.toolbar.set_widget_visible('song_menu', False)
|
||||
# Screen preview area
|
||||
self.preview_frame = QtWidgets.QFrame(self.splitter)
|
||||
self.preview_frame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio))
|
||||
@ -431,8 +431,8 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
|
||||
self.__add_actions_to_widget(self.controller)
|
||||
else:
|
||||
self.preview_widget.doubleClicked.connect(self.on_preview_double_click)
|
||||
self.toolbar.set_widget_visible(['editSong'], False)
|
||||
self.toolbar.set_widget_visible(['clear'], False)
|
||||
self.toolbar.set_widget_visible('editSong', False)
|
||||
self.toolbar.set_widget_visible('clear', False)
|
||||
self.controller.addActions([self.next_item, self.previous_item])
|
||||
Registry().register_function('slidecontroller_{text}_stop_loop'.format(text=self.type_prefix),
|
||||
self.on_stop_loop)
|
||||
@ -731,7 +731,7 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
|
||||
self.mediabar.hide()
|
||||
self.song_menu.hide()
|
||||
self.toolbar.set_widget_visible(LOOP_LIST, False)
|
||||
self.toolbar.set_widget_visible(['song_menu'], False)
|
||||
self.toolbar.set_widget_visible('song_menu', False)
|
||||
# Reset the button
|
||||
self.play_slides_once.setChecked(False)
|
||||
self.play_slides_once.setIcon(build_icon(':/media/media_time.png'))
|
||||
@ -742,7 +742,7 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
|
||||
if item.is_text():
|
||||
if (Settings().value(self.main_window.songs_settings_section + '/display songbar') and
|
||||
not self.song_menu.menu().isEmpty()):
|
||||
self.toolbar.set_widget_visible(['song_menu'], True)
|
||||
self.toolbar.set_widget_visible('song_menu', True)
|
||||
if item.is_capable(ItemCapabilities.CanLoop) and len(item.get_frames()) > 1:
|
||||
self.toolbar.set_widget_visible(LOOP_LIST)
|
||||
if item.is_media():
|
||||
@ -767,10 +767,10 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
|
||||
# See bug #791050
|
||||
self.toolbar.hide()
|
||||
self.mediabar.hide()
|
||||
self.toolbar.set_widget_visible(['editSong'], False)
|
||||
self.toolbar.set_widget_visible(['clear'], True)
|
||||
self.toolbar.set_widget_visible('editSong', False)
|
||||
self.toolbar.set_widget_visible('clear', True)
|
||||
if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin:
|
||||
self.toolbar.set_widget_visible(['editSong'])
|
||||
self.toolbar.set_widget_visible('editSong')
|
||||
elif item.is_media():
|
||||
self.mediabar.show()
|
||||
self.previous_item.setVisible(not item.is_media())
|
||||
@ -1392,8 +1392,8 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
|
||||
Clear the preview bar.
|
||||
"""
|
||||
self.preview_widget.clear_list()
|
||||
self.toolbar.set_widget_visible(["editSong"], False)
|
||||
self.toolbar.set_widget_visible(["clear"], False)
|
||||
self.toolbar.set_widget_visible("editSong", False)
|
||||
self.toolbar.set_widget_visible("clear", False)
|
||||
|
||||
def on_preview_add_to_service(self):
|
||||
"""
|
||||
|
@ -67,14 +67,20 @@ class OpenLPToolbar(QtWidgets.QToolBar):
|
||||
"""
|
||||
Set the visibility for a widget or a list of widgets.
|
||||
|
||||
:param widgets: A list of string with widget object names.
|
||||
:param widgets: A list of strings or individual string with widget object names.
|
||||
:param visible: The new state as bool.
|
||||
"""
|
||||
for handle in widgets:
|
||||
if handle in self.actions:
|
||||
self.actions[handle].setVisible(visible)
|
||||
if isinstance(widgets, list):
|
||||
for handle in widgets:
|
||||
if handle in self.actions:
|
||||
self.actions[handle].setVisible(visible)
|
||||
else:
|
||||
log.warning('No handle "%s" in actions list.', str(handle))
|
||||
else:
|
||||
if widgets in self.actions:
|
||||
self.actions[widgets].setVisible(visible)
|
||||
else:
|
||||
log.warning('No handle "%s" in actions list.', str(handle))
|
||||
log.warning('No handle "%s" in actions list.', str(widgets))
|
||||
|
||||
def set_widget_enabled(self, widgets, enabled=True):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user