Toolbar change based on selected projector items

This commit is contained in:
Ken Roberts 2014-10-14 10:12:49 -07:00
parent 5f232ce5fd
commit cc43efa809

View File

@ -58,10 +58,10 @@ STATUS_ICONS = {S_NOT_CONNECTED: ':/projector/projector_item_disconnect.png',
S_ON: ':/projector/projector_on.png', S_ON: ':/projector/projector_on.png',
S_COOLDOWN: ':/projector/projector_cooldown.png', S_COOLDOWN: ':/projector/projector_cooldown.png',
E_ERROR: ':/projector/projector_error.png', E_ERROR: ':/projector/projector_error.png',
E_NETWORK: ':/projector/projector_not_connected.png', E_NETWORK: ':/projector/projector_error.png',
E_AUTHENTICATION: ':/projector/projector_not_connected.png', E_AUTHENTICATION: ':/projector/projector_error.png',
E_UNKNOWN_SOCKET_ERROR: ':/icons/openlp-logo-64x64.png', E_UNKNOWN_SOCKET_ERROR: ':/icons/projector_error.png',
E_NOT_CONNECTED: ':/projector/projector_not_connected.png' E_NOT_CONNECTED: ':/projector/projector_error.png'
} }
@ -80,106 +80,142 @@ class Ui_ProjectorManager(object):
self.layout.setSpacing(0) self.layout.setSpacing(0)
self.layout.setMargin(0) self.layout.setMargin(0)
self.layout.setObjectName('layout') self.layout.setObjectName('layout')
# Add toolbar # Add spacer toolbar
self.top_toolbar = OpenLPToolbar(widget) self.no_toolbar = OpenLPToolbar(widget)
self.top_toolbar.add_toolbar_action('newProjector', self.no_toolbar.add_toolbar_action('new_projector',
text=translate('OpenLP.Projector', 'Add Projector'), text=translate('OpenLP.Projector', 'Add Projector'),
icon=':/projector/projector_new.png', icon=':/projector/projector_new.png',
tooltip=translate('OpenLP.ProjectorManager', 'Add a new projector'), tooltip=translate('OpenLP.ProjectorManager', 'Add a new projector'),
triggers=self.on_add_projector) triggers=self.on_add_projector)
self.top_toolbar.addSeparator() self.no_toolbar.addSeparator()
self.top_toolbar.add_toolbar_action('connect_selected_projectors', self.no_toolbar.add_toolbar_action('connect_no_projectors',
icon=':/projector/projector_spacer.png')
self.no_toolbar.add_toolbar_action('disconnect_no_projectors',
icon=':/projector/projector_spacer.png')
self.no_toolbar.addSeparator()
self.no_toolbar.add_toolbar_action('poweron_no_projectors',
icon=':/projector/projector_spacer.png')
self.no_toolbar.add_toolbar_action('poweroff_no_projectors',
icon=':/projector/projector_spacer.png')
self.no_toolbar.addSeparator()
self.no_toolbar.add_toolbar_action('blank_no_projectors',
icon=':/projector/projector_spacer.png')
self.no_toolbar.add_toolbar_action('show_no_projectors',
icon=':/projector/projector_spacer.png')
self.no_toolbar.addSeparator()
self.layout.addWidget(self.no_toolbar)
self.projector_one_widget = QtGui.QWidgetAction(self.no_toolbar)
self.projector_one_widget.setObjectName('projector_no_toolbar_widget')
# Add one selection toolbar
self.one_toolbar = OpenLPToolbar(widget)
self.one_toolbar.add_toolbar_action('new_projector',
text=translate('OpenLP.Projector', 'Add Projector'),
icon=':/projector/projector_new.png',
tooltip=translate('OpenLP.ProjectorManager', 'Add a new projector'),
triggers=self.on_add_projector)
self.one_toolbar.addSeparator()
self.one_toolbar.add_toolbar_action('connect_selected_projectors',
text=translate('OpenLP.ProjectorManager', text=translate('OpenLP.ProjectorManager',
'Connect to selected projectors'), 'Connect to selected projectors'),
icon=':/projector/projector_connect.png', icon=':/projector/projector_connect.png',
tootip=translate('OpenLP.ProjectorManager', tootip=translate('OpenLP.ProjectorManager',
'Connect to selected projectors'), 'Connect to selected projectors'),
triggers=self.on_connect_projector) triggers=self.on_connect_projector)
self.top_toolbar.add_toolbar_action('disconnect_selected_projectors', self.one_toolbar.add_toolbar_action('disconnect_selected_projectors',
text=translate('OpenLP.ProjectorManager', text=translate('OpenLP.ProjectorManager',
'Disconnect from selected projectors'), 'Disconnect from selected projectors'),
icon=':/projector/projector_disconnect.png', icon=':/projector/projector_disconnect.png',
tooltip=translate('OpenLP.ProjectorManager', tooltip=translate('OpenLP.ProjectorManager',
'Disconnect from selected projectors'), 'Disconnect from selected projectors'),
triggers=self.on_disconnect_projector) triggers=self.on_disconnect_projector)
self.top_toolbar.addSeparator() self.one_toolbar.addSeparator()
self.top_toolbar.add_toolbar_action('poweron_selected_projectors', self.one_toolbar.add_toolbar_action('poweron_selected_projectors',
text=translate('OpenLP.ProjectorManager', text=translate('OpenLP.ProjectorManager',
'Power on selected projectors'), 'Power on selected projectors'),
icon=':/projector/projector_power_on.png', icon=':/projector/projector_power_on.png',
tooltip=translate('OpenLP.ProjectorManager', tooltip=translate('OpenLP.ProjectorManager',
'Power on selected projectors'), 'Power on selected projectors'),
triggers=self.on_poweron_projector) triggers=self.on_poweron_projector)
self.top_toolbar.add_toolbar_action('poweroff_selected_projectors', self.one_toolbar.add_toolbar_action('poweroff_selected_projectors',
text=translate('OpenLP.ProjectorManager', 'Standby selected projectors'), text=translate('OpenLP.ProjectorManager', 'Standby selected projectors'),
icon=':/projector/projector_power_off.png', icon=':/projector/projector_power_off.png',
tooltip=translate('OpenLP.ProjectorManager', tooltip=translate('OpenLP.ProjectorManager',
'Put selected projectors in standby'), 'Put selected projectors in standby'),
triggers=self.on_poweroff_projector) triggers=self.on_poweroff_projector)
self.top_toolbar.addSeparator() self.one_toolbar.addSeparator()
self.top_toolbar.add_toolbar_action('blank_selected_projectors', self.one_toolbar.add_toolbar_action('blank_selected_projectors',
text=translate('OpenLP.ProjectorManager', text=translate('OpenLP.ProjectorManager',
'Blank selected projector screens'), 'Blank selected projector screens'),
icon=':/projector/projector_blank.png', icon=':/projector/projector_blank.png',
tooltip=translate('OpenLP.ProjectorManager', tooltip=translate('OpenLP.ProjectorManager',
'Blank selected projector screens'), 'Blank selected projector screens'),
triggers=self.on_blank_projector) triggers=self.on_blank_projector)
self.top_toolbar.add_toolbar_action('show_selected_projectors', self.one_toolbar.add_toolbar_action('show_selected_projectors',
ext=translate('OpenLP.ProjectorManager', ext=translate('OpenLP.ProjectorManager',
'Show selected projector screens'), 'Show selected projector screens'),
icon=':/projector/projector_show.png', icon=':/projector/projector_show.png',
tooltip=translate('OpenLP.ProjectorManager', tooltip=translate('OpenLP.ProjectorManager',
'Show selected projector screens'), 'Show selected projector screens'),
triggers=self.on_show_projector) triggers=self.on_show_projector)
self.top_toolbar.addSeparator() self.one_toolbar.addSeparator()
self.layout.addWidget(self.top_toolbar) self.layout.addWidget(self.one_toolbar)
self.projector_widget = QtGui.QWidgetAction(self.top_toolbar) self.projector_one_widget = QtGui.QWidgetAction(self.one_toolbar)
self.projector_widget.setObjectName('projector_top_toolbar_widget') self.projector_one_widget.setObjectName('projector_one_toolbar_widget')
# Create the second toolbar # Add many selection toolbar
self.bottom_toolbar = OpenLPToolbar(widget) self.many_toolbar = OpenLPToolbar(widget)
self.bottom_toolbar.add_toolbar_action('connect_all_projectors', self.many_toolbar.add_toolbar_action('new_projector',
text=translate('OpenLP.ProjectorManager', 'Nothing here'), text=translate('OpenLP.Projector', 'Add Projector'),
icon=':/projector/projector_spacer.png') icon=':/projector/projector_new.png',
self.bottom_toolbar.addSeparator() tooltip=translate('OpenLP.ProjectorManager', 'Add a new projector'),
self.bottom_toolbar.add_toolbar_action('connect_all_projectors', triggers=self.on_add_projector)
text=translate('OpenLP.ProjectorManager', 'Connect to all projectors'), self.many_toolbar.addSeparator()
icon=':/projector/projector_connect_tiled.png', self.many_toolbar.add_toolbar_action('connect_selected_projectors',
tootip=translate('OpenLP.ProjectorManager', 'Connect to all projectors'), text=translate('OpenLP.ProjectorManager',
triggers=self.on_connect_all_projectors) 'Connect to selected projectors'),
self.bottom_toolbar.add_toolbar_action('disconnect_all_projectors', icon=':/projector/projector_connect_tiled.png',
text=translate('OpenLP.ProjectorManager', tootip=translate('OpenLP.ProjectorManager',
'Disconnect from all projectors'), 'Connect to selected projectors'),
icon=':/projector/projector_disconnect_tiled.png', triggers=self.on_connect_projector)
tooltip=translate('OpenLP.ProjectorManager', self.many_toolbar.add_toolbar_action('disconnect_selected_projectors',
'Disconnect from all projectors'), text=translate('OpenLP.ProjectorManager',
triggers=self.on_disconnect_all_projectors) 'Disconnect from selected projectors'),
self.bottom_toolbar.addSeparator() icon=':/projector/projector_disconnect_tiled.png',
self.bottom_toolbar.add_toolbar_action('poweron_all_projectors', tooltip=translate('OpenLP.ProjectorManager',
text=translate('OpenLP.ProjectorManager', 'Power On All Projectors'), 'Disconnect from selected projectors'),
icon=':/projector/projector_power_on_tiled.png', triggers=self.on_disconnect_projector)
tooltip=translate('OpenLP.ProjectorManager', 'Power on all projectors'), self.many_toolbar.addSeparator()
triggers=self.on_poweron_all_projectors) self.many_toolbar.add_toolbar_action('poweron_selected_projectors',
self.bottom_toolbar.add_toolbar_action('poweroff_all_projectors', text=translate('OpenLP.ProjectorManager',
text=translate('OpenLP.ProjectorManager', 'Standby All Projector'), 'Power on selected projectors'),
icon=':/projector/projector_power_off_tiled.png', icon=':/projector/projector_power_on_tiled.png',
tooltip=translate('OpenLP.ProjectorManager', tooltip=translate('OpenLP.ProjectorManager',
'Put all projectors in standby'), 'Power on selected projectors'),
triggers=self.on_poweroff_all_projectors) triggers=self.on_poweron_projector)
self.bottom_toolbar.addSeparator() self.many_toolbar.add_toolbar_action('poweroff_selected_projectors',
self.bottom_toolbar.add_toolbar_action('blank_all_projectors', text=translate('OpenLP.ProjectorManager', 'Standby selected projectors'),
text=translate('OpenLP.ProjectorManager', 'Blank All Projector Screens'), icon=':/projector/projector_power_off_tiled.png',
icon=':/projector/projector_blank_tiled.png', tooltip=translate('OpenLP.ProjectorManager',
tooltip=translate('OpenLP.ProjectorManager', 'Put selected projectors in standby'),
'Blank all projector screens'), triggers=self.on_poweroff_projector)
triggers=self.on_blank_all_projectors) self.many_toolbar.addSeparator()
self.bottom_toolbar.add_toolbar_action('show_all_projector', self.many_toolbar.add_toolbar_action('blank_selected_projectors',
text=translate('OpenLP.ProjectorManager', 'Show All Projector Screens'), text=translate('OpenLP.ProjectorManager',
icon=':/projector/projector_show_tiled.png', 'Blank selected projector screens'),
tooltip=translate('OpenLP.ProjectorManager', icon=':/projector/projector_blank_tiled.png',
'Show all projector screens'), tooltip=translate('OpenLP.ProjectorManager',
triggers=self.on_show_all_projectors) 'Blank selected projector screens'),
self.bottom_toolbar.addSeparator() triggers=self.on_blank_projector)
self.layout.addWidget(self.bottom_toolbar, alignment=QtCore.Qt.AlignBottom) self.many_toolbar.add_toolbar_action('show_selected_projectors',
ext=translate('OpenLP.ProjectorManager',
'Show selected projector screens'),
icon=':/projector/projector_show_tiled.png',
tooltip=translate('OpenLP.ProjectorManager',
'Show selected projector screens'),
triggers=self.on_show_projector)
self.many_toolbar.addSeparator()
self.layout.addWidget(self.many_toolbar)
self.projector_one_widget = QtGui.QWidgetAction(self.many_toolbar)
self.projector_one_widget.setObjectName('projector_many_toolbar_widget')
# Create projector manager list # Create projector manager list
self.projector_list_widget = QtGui.QListWidget(widget) self.projector_list_widget = QtGui.QListWidget(widget)
self.projector_list_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.projector_list_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
@ -250,6 +286,7 @@ class Ui_ProjectorManager(object):
'&Delete Projector'), '&Delete Projector'),
icon=':/general/general_delete.png', icon=':/general/general_delete.png',
triggers=self.on_delete_projector) triggers=self.on_delete_projector)
self.update_icons()
class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorManager, RegistryProperties): class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorManager, RegistryProperties):
@ -282,10 +319,12 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
def bootstrap_post_set_up(self): def bootstrap_post_set_up(self):
self.load_projectors() self.load_projectors()
self.projector_form = ProjectorWizard(self, projectordb=self.projectordb) self.projector_form = ProjectorWizard(self, projectordb=self.projectordb)
self.top_toolbar.set_widget_enabled(['connect_selected_projectors', 'disconnect_selected_projectors', '''
self.one_toolbar.set_widget_enabled(['connect_selected_projectors', 'disconnect_selected_projectors',
'poweron_selected_projectors', 'poweroff_selected_projectors', 'poweron_selected_projectors', 'poweroff_selected_projectors',
'blank_selected_projectors', 'show_selected_projectors'], 'blank_selected_projectors', 'show_selected_projectors'],
enabled=False) enabled=False)
'''
self.projector_form.edit_page.newProjector.connect(self.add_projector_from_wizard) self.projector_form.edit_page.newProjector.connect(self.add_projector_from_wizard)
self.projector_form.edit_page.editProjector.connect(self.edit_projector_from_wizard) self.projector_form.edit_page.editProjector.connect(self.edit_projector_from_wizard)
self.projector_list_widget.itemSelectionChanged.connect(self.update_icons) self.projector_list_widget.itemSelectionChanged.connect(self.update_icons)
@ -916,16 +955,18 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
""" """
Update the icons when the selected projectors change Update the icons when the selected projectors change
""" """
if not self.projector_list_widget.selectedItems(): count = len(self.projector_list_widget.selectedItems())
self.top_toolbar.set_widget_enabled(['connect_selected_projectors', 'disconnect_selected_projectors', self.no_toolbar.setHidden(False if count == 0 else True)
'poweron_selected_projectors', 'poweroff_selected_projectors', self.one_toolbar.setHidden(False if count == 1 else True)
'blank_selected_projectors', 'show_selected_projectors'], self.many_toolbar.setHidden(False if count > 1 else True)
enabled=False) '''
else: enable = False if count == 0 else True
self.top_toolbar.set_widget_enabled(['connect_selected_projectors', 'disconnect_selected_projectors', item_list = ['connect_selected_projectors', 'disconnect_selected_projectors',
'poweron_selected_projectors', 'poweroff_selected_projectors', 'poweron_selected_projectors', 'poweroff_selected_projectors',
'blank_selected_projectors', 'show_selected_projectors'], 'blank_selected_projectors', 'show_selected_projectors']
enabled=True) for item in item_list:
self.one_toolbar.set_widget_enabled([item,], enabled=enable)
'''
@pyqtSlot(str) @pyqtSlot(str)
def authentication_error(self, name): def authentication_error(self, name):