Merge new toolbar

This commit is contained in:
Ken Roberts 2014-10-10 10:07:31 -07:00
commit a58cf9754b
9 changed files with 186 additions and 72 deletions

View File

@ -82,3 +82,16 @@ class OpenLPToolbar(QtGui.QToolBar):
self.actions[handle].setVisible(visible) self.actions[handle].setVisible(visible)
else: else:
log.warning('No handle "%s" in actions list.', str(handle)) log.warning('No handle "%s" in actions list.', str(handle))
def set_widget_enabled(self, widgets, enabled=True):
"""
Set the enabled state for a widget or a list of widgets.
:param widgets: A list of string with widget object names.
:param enabled: The new state as bool.
"""
for handle in widgets:
if handle in self.actions:
self.actions[handle].setEnabled(enabled)
else:
log.warning('No handle "%s" in actions list.', str(handle))

View File

@ -80,56 +80,108 @@ class Ui_ProjectorManager(object):
self.layout.setMargin(0) self.layout.setMargin(0)
self.layout.setObjectName('layout') self.layout.setObjectName('layout')
# Add toolbar # Add toolbar
self.toolbar = OpenLPToolbar(widget) self.top_toolbar = OpenLPToolbar(widget)
self.toolbar.add_toolbar_action('newProjector', self.top_toolbar.add_toolbar_action('newProjector',
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.toolbar.addSeparator() self.top_toolbar.addSeparator()
self.toolbar.add_toolbar_action('connect_all_projectors', self.top_toolbar.add_toolbar_action('connect_selected_projectors',
text=translate('OpenLP.ProjectorManager', 'Connect to all projectors'), text=translate('OpenLP.ProjectorManager',
'Connect to selected projectors'),
icon=':/projector/projector_connect.png', icon=':/projector/projector_connect.png',
tootip=translate('OpenLP.ProjectorManager', 'Connect to all projectors'), tootip=translate('OpenLP.ProjectorManager',
triggers=self.on_connect_all_projectors) 'Connect to selected projectors'),
self.toolbar.add_toolbar_action('disconnect_all_projectors', triggers=self.on_connect_projector)
text=translate('OpenLP.ProjectorManager', 'Disconnect from all projectors'), self.top_toolbar.add_toolbar_action('disconnect_selected_projectors',
text=translate('OpenLP.ProjectorManager',
'Disconnect from selected projectors'),
icon=':/projector/projector_disconnect.png', icon=':/projector/projector_disconnect.png',
tooltip=translate('OpenLP.ProjectorManager', 'Disconnect from all projectors'), tooltip=translate('OpenLP.ProjectorManager',
triggers=self.on_disconnect_all_projectors) 'Disconnect from selected projectors'),
self.toolbar.addSeparator() triggers=self.on_disconnect_projector)
self.toolbar.add_toolbar_action('poweron_all_projectors', self.top_toolbar.addSeparator()
text=translate('OpenLP.ProjectorManager', 'Power On All Projectors'), self.top_toolbar.add_toolbar_action('poweron_selected_projectors',
text=translate('OpenLP.ProjectorManager',
'Power on selected projectors'),
icon=':/projector/projector_power_on.png', icon=':/projector/projector_power_on.png',
tooltip=translate('OpenLP.ProjectorManager', 'Power on all projectors'), tooltip=translate('OpenLP.ProjectorManager',
triggers=self.on_poweron_all_projectors) 'Power on selected projectors'),
self.toolbar.add_toolbar_action('poweroff_all_projectors', triggers=self.on_poweron_projector)
text=translate('OpenLP.ProjectorManager', 'Standby All Projector'), self.top_toolbar.add_toolbar_action('poweroff_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', 'Put all projectors in standby'), tooltip=translate('OpenLP.ProjectorManager',
triggers=self.on_poweroff_all_projectors) 'Put selected projectors in standby'),
self.toolbar.addSeparator() triggers=self.on_poweroff_projector)
self.toolbar.add_toolbar_action('blank_projector', self.top_toolbar.addSeparator()
text=translate('OpenLP.ProjectorManager', 'Blank All Projector Screens'), self.top_toolbar.add_toolbar_action('blank_selected_projectors',
text=translate('OpenLP.ProjectorManager',
'Blank selected projector screens'),
icon=':/projector/projector_blank.png', icon=':/projector/projector_blank.png',
tooltip=translate('OpenLP.ProjectorManager', 'Blank all projector screens'), tooltip=translate('OpenLP.ProjectorManager',
triggers=self.on_blank_all_projectors) 'Blank selected projector screens'),
self.toolbar.add_toolbar_action('show_all_projector', triggers=self.on_blank_projector)
text=translate('OpenLP.ProjectorManager', 'Show All Projector Screens'), self.top_toolbar.add_toolbar_action('show_selected_projectors',
text=translate('OpenLP.ProjectorManager',
'Show selected projector screens'),
icon=':/projector/projector_show.png', icon=':/projector/projector_show.png',
tooltip=translate('OpenLP.ProjectorManager', 'Show all projector screens'), tooltip=translate('OpenLP.ProjectorManager',
triggers=self.on_show_all_projectors) 'Show selected projector screens'),
self.layout.addWidget(self.toolbar) triggers=self.on_show_projector)
self.top_toolbar.addSeparator()
self.layout.addWidget(self.top_toolbar)
# Add the projector list box # Add the projector list box
self.projector_widget = QtGui.QWidgetAction(self.toolbar) self.projector_widget = QtGui.QWidgetAction(self.top_toolbar)
self.projector_widget.setObjectName('projector_widget') self.projector_widget.setObjectName('projector_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.setAlternatingRowColors(True) self.projector_list_widget.setAlternatingRowColors(True)
self.projector_list_widget.setIconSize(QtCore.QSize(90, 50)) self.projector_list_widget.setIconSize(QtCore.QSize(90, 50))
self.projector_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.projector_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.projector_list_widget.setObjectName('projector_list_widget') self.projector_list_widget.setObjectName('projector_list_widget')
self.layout.addWidget(self.projector_list_widget) self.layout.addWidget(self.projector_list_widget)
self.bottom_toolbar = OpenLPToolbar(widget)
self.bottom_toolbar.add_toolbar_action('connect_all_projectors',
text=translate('OpenLP.ProjectorManager', 'Connect to all projectors'),
icon=':/projector/projector_connect-tiled.png',
tootip=translate('OpenLP.ProjectorManager', 'Connect to all projectors'),
triggers=self.on_connect_all_projectors)
self.bottom_toolbar.add_toolbar_action('disconnect_all_projectors',
text=translate('OpenLP.ProjectorManager',
'Disconnect from all projectors'),
icon=':/projector/projector_disconnect-tiled.png',
tooltip=translate('OpenLP.ProjectorManager',
'Disconnect from all projectors'),
triggers=self.on_disconnect_all_projectors)
self.bottom_toolbar.addSeparator()
self.bottom_toolbar.add_toolbar_action('poweron_all_projectors',
text=translate('OpenLP.ProjectorManager', 'Power On All Projectors'),
icon=':/projector/projector_power_on-tiled.png',
tooltip=translate('OpenLP.ProjectorManager', 'Power on all projectors'),
triggers=self.on_poweron_all_projectors)
self.bottom_toolbar.add_toolbar_action('poweroff_all_projectors',
text=translate('OpenLP.ProjectorManager', 'Standby All Projector'),
icon=':/projector/projector_power_off_tiled.png',
tooltip=translate('OpenLP.ProjectorManager',
'Put all projectors in standby'),
triggers=self.on_poweroff_all_projectors)
self.bottom_toolbar.addSeparator()
self.bottom_toolbar.add_toolbar_action('blank_all_projectors',
text=translate('OpenLP.ProjectorManager', 'Blank All Projector Screens'),
icon=':/projector/projector_blank_tiled.png',
tooltip=translate('OpenLP.ProjectorManager',
'Blank all projector screens'),
triggers=self.on_blank_all_projectors)
self.bottom_toolbar.add_toolbar_action('show_all_projector',
text=translate('OpenLP.ProjectorManager', 'Show All Projector Screens'),
icon=':/projector/projector_show_tiled.png',
tooltip=translate('OpenLP.ProjectorManager',
'Show all projector screens'),
triggers=self.on_show_all_projectors)
self.layout.addWidget(self.bottom_toolbar, alignment=QtCore.Qt.AlignBottom)
self.projector_list_widget.customContextMenuRequested.connect(self.context_menu) self.projector_list_widget.customContextMenuRequested.connect(self.context_menu)
# Build the context menu # Build the context menu
self.menu = QtGui.QMenu() self.menu = QtGui.QMenu()
@ -222,8 +274,13 @@ 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',
'poweron_selected_projectors', 'poweroff_selected_projectors',
'blank_selected_projectors', 'show_selected_projectors'],
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)
def context_menu(self, point): def context_menu(self, point):
""" """
@ -369,12 +426,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
try: try:
ip = opt.link.ip ip = opt.link.ip
projector = opt projector = opt
projector.link.set_shutter_closed()
except AttributeError: except AttributeError:
list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow()) for list_item in self.projector_list_widget.selectedItems():
if list_item is None: if list_item is None:
return return
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
return projector.link.set_shutter_closed() try:
projector.link.set_shutter_closed()
except:
continue
def on_connect_projector(self, opt=None): def on_connect_projector(self, opt=None):
""" """
@ -386,12 +447,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
try: try:
ip = opt.link.ip ip = opt.link.ip
projector = opt projector = opt
projector.link.connect_to_host()
except AttributeError: except AttributeError:
list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow()) for list_item in self.projector_list_widget.selectedItems():
if list_item is None: if list_item is None:
return return
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
return projector.link.connect_to_host() try:
projector.link.connect_to_host()
except:
continue
def on_connect_all_projectors(self, opt=None): def on_connect_all_projectors(self, opt=None):
""" """
@ -459,12 +524,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
try: try:
ip = opt.link.ip ip = opt.link.ip
projector = opt projector = opt
projector.link.disconnect_from_host()
except AttributeError: except AttributeError:
list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow()) for list_item in self.projector_list_widget.selectedItems():
if list_item is None: if list_item is None:
return return
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
return projector.link.disconnect_from_host() try:
projector.link.disconnect_from_host()
except:
continue
def on_disconnect_all_projectors(self, opt=None): def on_disconnect_all_projectors(self, opt=None):
""" """
@ -512,13 +581,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
try: try:
ip = opt.link.ip ip = opt.link.ip
projector = opt projector = opt
projector.link.set_power_off()
except AttributeError: except AttributeError:
# Must have been called by a mouse-click on item for list_item in self.projector_list_widget.selectedItems():
list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow())
if list_item is None: if list_item is None:
return return
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
return projector.link.set_power_off() try:
projector.link.set_power_off()
except:
continue
def on_poweron_all_projectors(self, opt=None): def on_poweron_all_projectors(self, opt=None):
""" """
@ -540,12 +612,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
try: try:
ip = opt.link.ip ip = opt.link.ip
projector = opt projector = opt
projector.link.set_power_on()
except AttributeError: except AttributeError:
lwi = self.projector_list_widget.item(self.projector_list_widget.currentRow()) for list_item in self.projector_list_widget.selectedItems():
if lwi is None: if list_item is None:
return return
projector = lwi.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
return projector.link.set_power_on() try:
projector.link.set_power_on()
except:
continue
def on_show_all_projectors(self, opt=None): def on_show_all_projectors(self, opt=None):
""" """
@ -567,12 +643,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
try: try:
ip = opt.link.ip ip = opt.link.ip
projector = opt projector = opt
projector.link.set_shutter_open()
except AttributeError: except AttributeError:
lwi = self.projector_list_widget.item(self.projector_list_widget.currentRow()) for list_item in self.projector_list_widget.selectedItems():
if lwi is None: if list_item is None:
return return
projector = lwi.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
return projector.link.set_shutter_open() try:
projector.link.set_shutter_open()
except:
continue
def on_status_projector(self, opt=None): def on_status_projector(self, opt=None):
""" """
@ -808,6 +888,22 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
log.debug('(%s) Updating icon' % item.link.name) log.debug('(%s) Updating icon' % item.link.name)
item.widget.setIcon(item.icon) item.widget.setIcon(item.icon)
@pyqtSlot()
def update_icons(self):
"""
Update the icons when the selected projectors change
"""
if not self.projector_list_widget.selectedItems():
self.top_toolbar.set_widget_enabled(['connect_selected_projectors', 'disconnect_selected_projectors',
'poweron_selected_projectors', 'poweroff_selected_projectors',
'blank_selected_projectors', 'show_selected_projectors'],
enabled=False)
else:
self.top_toolbar.set_widget_enabled(['connect_selected_projectors', 'disconnect_selected_projectors',
'poweron_selected_projectors', 'poweroff_selected_projectors',
'blank_selected_projectors', 'show_selected_projectors'],
enabled=True)
class ProjectorItem(QObject): class ProjectorItem(QObject):
""" """

View File

@ -172,10 +172,12 @@
</qresource> </qresource>
<qresource prefix="projector"> <qresource prefix="projector">
<file>projector_blank.png</file> <file>projector_blank.png</file>
<file>projector_blank_tiled.png</file>
<file>projector_connect.png</file> <file>projector_connect.png</file>
<file>projector_connectors.png</file> <file>projector_connectors.png</file>
<file>projector_cooldown.png</file> <file>projector_cooldown.png</file>
<file>projector_disconnect.png</file> <file>projector_disconnect.png</file>
<file>projector_disconnect_tiled.png</file>
<file>projector_edit.png</file> <file>projector_edit.png</file>
<file>projector_error.png</file> <file>projector_error.png</file>
<file>projector_item_connect.png</file> <file>projector_item_connect.png</file>
@ -186,8 +188,11 @@
<file>projector_off.png</file> <file>projector_off.png</file>
<file>projector_on.png</file> <file>projector_on.png</file>
<file>projector_power_off.png</file> <file>projector_power_off.png</file>
<file>projector_power_off_tiled.png</file>
<file>projector_power_on.png</file> <file>projector_power_on.png</file>
<file>projector_power_on_tiled.png</file>
<file>projector_show.png</file> <file>projector_show.png</file>
<file>projector_show_tiled.png</file>
<file>projector_status.png</file> <file>projector_status.png</file>
<file>projector_warmup.png</file> <file>projector_warmup.png</file>
<file>projector_view.png</file> <file>projector_view.png</file>

View File

Before

Width:  |  Height:  |  Size: 652 B

After

Width:  |  Height:  |  Size: 652 B

View File

Before

Width:  |  Height:  |  Size: 920 B

After

Width:  |  Height:  |  Size: 920 B

View File

Before

Width:  |  Height:  |  Size: 914 B

After

Width:  |  Height:  |  Size: 914 B

View File

Before

Width:  |  Height:  |  Size: 894 B

After

Width:  |  Height:  |  Size: 894 B

View File

Before

Width:  |  Height:  |  Size: 935 B

After

Width:  |  Height:  |  Size: 935 B

View File

Before

Width:  |  Height:  |  Size: 893 B

After

Width:  |  Height:  |  Size: 893 B