From 4f2b21ddfae8393f096d2ac607026af06cdeb9a4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 2 Feb 2013 19:49:56 +0000 Subject: [PATCH] Fix review comments --- openlp/core/ui/__init__.py | 3 +- openlp/core/ui/advancedtab.py | 74 +++---- openlp/core/ui/servicemanager.py | 244 +++++++++++++++++++++- openlp/core/ui/servicemanagerdialog.py | 268 ------------------------- 4 files changed, 279 insertions(+), 310 deletions(-) delete mode 100644 openlp/core/ui/servicemanagerdialog.py diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 593404206..5122c1bd7 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -98,10 +98,9 @@ from settingsform import SettingsForm from formattingtagform import FormattingTagForm from shortcutlistform import ShortcutListForm from mediadockmanager import MediaDockManager -from servicemanagerdialog import ServiceManagerDialog from servicemanager import ServiceManager from thememanager import ThemeManager __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', - 'SlideController', 'ServiceManagerDialog', 'ServiceManager', 'ThemeManager', 'MediaDockManager', + 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm' ] diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d27f7cd0c..a219b8091 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -107,11 +107,11 @@ class AdvancedTab(SettingsTab): self.service_name_day.setObjectName(u'service_name_day') self.service_name_time = QtGui.QTimeEdit(self.service_name_group_box) self.service_name_time.setObjectName(u'service_name_time') - self.service_name_timeHBox = QtGui.QHBoxLayout() - self.service_name_timeHBox.setObjectName(u'service_name_timeHBox') - self.service_name_timeHBox.addWidget(self.service_name_day) - self.service_name_timeHBox.addWidget(self.service_name_time) - self.service_name_layout.addRow(self.service_name_time_label, self.service_name_timeHBox) + self.service_name_time_layout = QtGui.QHBoxLayout() + self.service_name_time_layout.setObjectName(u'service_name_time_layout') + self.service_name_time_layout.addWidget(self.service_name_day) + self.service_name_time_layout.addWidget(self.service_name_time) + self.service_name_layout.addRow(self.service_name_time_label, self.service_name_time_layout) self.service_name_label = QtGui.QLabel(self.service_name_group_box) self.service_name_label.setObjectName(u'service_name_label') self.service_name_edit = QtGui.QLineEdit(self.service_name_group_box) @@ -120,11 +120,11 @@ class AdvancedTab(SettingsTab): self.service_name_revert_button = QtGui.QToolButton(self.service_name_group_box) self.service_name_revert_button.setObjectName(u'service_name_revert_button') self.service_name_revert_button.setIcon(build_icon(u':/general/general_revert.png')) - self.service_name_h_box = QtGui.QHBoxLayout() - self.service_name_h_box.setObjectName(u'service_name_h_box') - self.service_name_h_box.addWidget(self.service_name_edit) - self.service_name_h_box.addWidget(self.service_name_revert_button) - self.service_name_layout.addRow(self.service_name_label, self.service_name_h_box) + self.service_name_button_layout = QtGui.QHBoxLayout() + self.service_name_button_layout.setObjectName(u'service_name_layout_2') + self.service_name_button_layout.addWidget(self.service_name_edit) + self.service_name_button_layout.addWidget(self.service_name_revert_button) + self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout) self.service_name_example_label = QtGui.QLabel(self.service_name_group_box) self.service_name_example_label.setObjectName(u'service_name_example_label') self.service_name_example = QtGui.QLabel(self.service_name_group_box) @@ -157,21 +157,21 @@ class AdvancedTab(SettingsTab): self.data_directory_cancel_button = QtGui.QToolButton(self.data_directory_group_box) self.data_directory_cancel_button.setObjectName(u'data_directory_cancel_button') self.data_directory_cancel_button.setIcon(build_icon(u':/general/general_delete.png')) - self.new_data_directory_label_H_box = QtGui.QHBoxLayout() - self.new_data_directory_label_H_box.setObjectName(u'new_data_directory_label_H_box') - self.new_data_directory_label_H_box.addWidget(self.new_data_directory_edit) - self.new_data_directory_label_H_box.addWidget(self.data_directory_browse_button) - self.new_data_directory_label_H_box.addWidget(self.data_directory_default_button) - self.data_directory_copy_check_H_box = QtGui.QHBoxLayout() - self.data_directory_copy_check_H_box.setObjectName(u'data_directory_copy_check_H_box') + self.new_data_directory_label_layout = QtGui.QHBoxLayout() + self.new_data_directory_label_layout.setObjectName(u'new_data_directory_label_layout') + self.new_data_directory_label_layout.addWidget(self.new_data_directory_edit) + self.new_data_directory_label_layout.addWidget(self.data_directory_browse_button) + self.new_data_directory_label_layout.addWidget(self.data_directory_default_button) + self.data_directory_copy_check_layout = QtGui.QHBoxLayout() + self.data_directory_copy_check_layout.setObjectName(u'data_directory_copy_check_layout') self.data_directory_copy_check_box = QtGui.QCheckBox(self.data_directory_group_box) self.data_directory_copy_check_box.setObjectName(u'data_directory_copy_check_box') - self.data_directory_copy_check_H_box.addWidget(self.data_directory_copy_check_box) - self.data_directory_copy_check_H_box.addStretch() - self.data_directory_copy_check_H_box.addWidget(self.data_directory_cancel_button) + self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box) + self.data_directory_copy_check_layout.addStretch() + self.data_directory_copy_check_layout.addWidget(self.data_directory_cancel_button) self.data_directory_layout.addRow(self.data_directory_current_label, self.data_directory_label) - self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_H_box) - self.data_directory_layout.addRow(self.data_directory_copy_check_H_box) + self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_layout) + self.data_directory_layout.addRow(self.data_directory_copy_check_layout) self.data_directory_layout.addRow(self.new_data_directory_has_files_label) self.leftLayout.addWidget(self.data_directory_group_box) self.leftLayout.addStretch() @@ -195,39 +195,39 @@ class AdvancedTab(SettingsTab): self.default_revert_button = QtGui.QToolButton(self.default_image_group_box) self.default_revert_button.setObjectName(u'default_revert_button') self.default_revert_button.setIcon(build_icon(u':/general/general_revert.png')) - self.defaultFileLayout = QtGui.QHBoxLayout() - self.defaultFileLayout.setObjectName(u'defaultFileLayout') - self.defaultFileLayout.addWidget(self.default_file_edit) - self.defaultFileLayout.addWidget(self.default_browse_button) - self.defaultFileLayout.addWidget(self.default_revert_button) - self.default_image_layout.addRow(self.default_file_label, self.defaultFileLayout) + self.default_file_layout = QtGui.QHBoxLayout() + self.default_file_layout.setObjectName(u'default_file_layout') + self.default_file_layout.addWidget(self.default_file_edit) + self.default_file_layout.addWidget(self.default_browse_button) + self.default_file_layout.addWidget(self.default_revert_button) + self.default_image_layout.addRow(self.default_file_label, self.default_file_layout) self.rightLayout.addWidget(self.default_image_group_box) # Hide mouse self.hide_mouse_group_box = QtGui.QGroupBox(self.rightColumn) self.hide_mouse_group_box.setObjectName(u'hide_mouse_group_box') - self.hideMouseLayout = QtGui.QVBoxLayout(self.hide_mouse_group_box) - self.hideMouseLayout.setObjectName(u'hideMouseLayout') + self.hide_mouse_layout = QtGui.QVBoxLayout(self.hide_mouse_group_box) + self.hide_mouse_layout.setObjectName(u'hide_mouse_layout') self.hide_mouse_check_box = QtGui.QCheckBox(self.hide_mouse_group_box) self.hide_mouse_check_box.setObjectName(u'hide_mouse_check_box') - self.hideMouseLayout.addWidget(self.hide_mouse_check_box) + self.hide_mouse_layout.addWidget(self.hide_mouse_check_box) self.rightLayout.addWidget(self.hide_mouse_group_box) # Service Item Slide Limits self.slide_group_box = QtGui.QGroupBox(self.rightColumn) self.slide_group_box.setObjectName(u'slide_group_box') - self.slideLayout = QtGui.QVBoxLayout(self.slide_group_box) - self.slideLayout.setObjectName(u'slideLayout') + self.slide_layout = QtGui.QVBoxLayout(self.slide_group_box) + self.slide_layout.setObjectName(u'slide_layout') self.slide_label = QtGui.QLabel(self.slide_group_box) self.slide_label.setWordWrap(True) - self.slideLayout.addWidget(self.slide_label) + self.slide_layout.addWidget(self.slide_label) self.end_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) self.end_slide_radio_button.setObjectName(u'end_slide_radio_button') - self.slideLayout.addWidget(self.end_slide_radio_button) + self.slide_layout.addWidget(self.end_slide_radio_button) self.wrap_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) self.wrap_slide_radio_button.setObjectName(u'wrap_slide_radio_button') - self.slideLayout.addWidget(self.wrap_slide_radio_button) + self.slide_layout.addWidget(self.wrap_slide_radio_button) self.next_item_radio_button = QtGui.QRadioButton(self.slide_group_box) self.next_item_radio_button.setObjectName(u'next_item_radio_button') - self.slideLayout.addWidget(self.next_item_radio_button) + self.slide_layout.addWidget(self.next_item_radio_button) self.rightLayout.addWidget(self.slide_group_box) # Display Workarounds self.display_workaround_group_box = QtGui.QGroupBox(self.leftColumn) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 77082f2d3..ff3d0721e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -39,13 +39,251 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ +from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ translate, str_to_bool, check_directory_exists, Settings, PluginStatus, Registry, UiStrings from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box -from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm, ServiceManagerDialog +from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm -from openlp.core.utils import delete_file, split_filename, format_time +from openlp.core.utils import AppLocation, delete_file, split_filename, format_time +from openlp.core.utils.actions import ActionList, CategoryOrder + +class ServiceManagerList(QtGui.QTreeWidget): + """ + Set up key bindings and mouse behaviour for the service list + """ + def __init__(self, serviceManager, parent=None): + QtGui.QTreeWidget.__init__(self, parent) + self.serviceManager = serviceManager + + def keyPressEvent(self, event): + """ + Capture Key press and respond accordingly. + """ + if isinstance(event, QtGui.QKeyEvent): + # here accept the event and do something + if event.key() == QtCore.Qt.Key_Up: + self.serviceManager.on_move_selection_up() + event.accept() + elif event.key() == QtCore.Qt.Key_Down: + self.serviceManager.on_move_selection_down() + event.accept() + elif event.key() == QtCore.Qt.Key_Delete: + self.serviceManager.onDeleteFromService() + event.accept() + event.ignore() + else: + event.ignore() + + def mouseMoveEvent(self, event): + """ + Drag and drop event does not care what data is selected + as the recipient will use events to request the data move + just tell it what plugin to call + """ + if event.buttons() != QtCore.Qt.LeftButton: + event.ignore() + return + if not self.itemAt(self.mapFromGlobal(QtGui.QCursor.pos())): + event.ignore() + return + drag = QtGui.QDrag(self) + mime_data = QtCore.QMimeData() + drag.setMimeData(mime_data) + mime_data.setText(u'ServiceManager') + drag.start(QtCore.Qt.CopyAction) + +class ServiceManagerDialog(object): + """ + UI part of the Service Manager + """ + def setup_ui(self, widget): + """ + Define the UI + """ + # Create the top toolbar + self.toolbar = OpenLPToolbar(self) + self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', + tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) + self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', + tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), + triggers=self.on_load_service_clicked) + self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', + tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) + self.toolbar.addSeparator() + self.theme_label = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) + self.theme_label.setMargin(3) + self.theme_label.setObjectName(u'theme_label') + self.toolbar.addToolbarWidget(self.theme_label) + self.theme_combo_box = QtGui.QComboBox(self.toolbar) + self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) + self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) + self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.theme_combo_box.setObjectName(u'theme_combo_box') + self.toolbar.addToolbarWidget(self.theme_combo_box) + self.toolbar.setObjectName(u'toolbar') + self.layout.addWidget(self.toolbar) + # Create the service manager list + self.service_manager_list = ServiceManagerList(self) + self.service_manager_list.setEditTriggers( + QtGui.QAbstractItemView.CurrentChanged | + QtGui.QAbstractItemView.DoubleClicked | + QtGui.QAbstractItemView.EditKeyPressed) + self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + self.service_manager_list.setAlternatingRowColors(True) + self.service_manager_list.setHeaderHidden(True) + self.service_manager_list.setExpandsOnDoubleClick(False) + self.service_manager_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + self.context_menu) + self.service_manager_list.setObjectName(u'service_manager_list') + # enable drop + self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event + self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event + self.service_manager_list.__class__.dropEvent = self.drop_event + self.layout.addWidget(self.service_manager_list) + # Add the bottom toolbar + self.order_toolbar = OpenLPToolbar(self) + action_list = ActionList.get_instance() + action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) + self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop', + text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), + shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) + self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp', + text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), + shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) + self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown', + text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), + shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) + self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom', + text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'), + shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) + self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down', + text=translate('OpenLP.ServiceManager', 'Move &down'), + tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, + shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down) + action_list.add_action(self.service_manager_list.down) + self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', + text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', + 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], + triggers=self.on_move_selection_up) + action_list.add_action(self.service_manager_list.up) + self.order_toolbar.addSeparator() + self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', + text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', + tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), + shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService) + self.order_toolbar.addSeparator() + self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', + text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', + tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), + shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) + self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', + text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', + tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), + shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) + self.order_toolbar.addSeparator() + self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', + text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', + tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, + triggers=self.make_live) + self.layout.addWidget(self.order_toolbar) + # Connect up our signals and slots + QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), + self.on_theme_combo_box_selected) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.on_make_live) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), + self.collapsed) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), + self.expanded) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), + self.preview_live) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), + self.previous_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), + self.regenerate_service_Items) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), + self.service_item_update) + # Last little bits of setting up + self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') + self.servicePath = AppLocation.get_section_data_path(u'servicemanager') + # build the drag and drop context menu + self.dndMenu = QtGui.QMenu() + self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) + self.newAction.setIcon(build_icon(u':/general/general_edit.png')) + self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) + self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) + # build the context menu + self.menu = QtGui.QMenu() + self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), + icon=u':/general/general_edit.png', triggers=self.remote_edit) + self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), + icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) + self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), + icon=u':/services/service_notes.png', triggers=self.on_service_item_note_form) + self.time_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'), + icon=u':/media/media_time.png', triggers=self.on_start_time_form) + self.auto_start_action = create_widget_action(self.menu, text=u'', + icon=u':/media/auto-start_active.png', triggers=self.on_auto_start) + # Add already existing delete action to the menu. + self.menu.addAction(self.service_manager_list.delete) + self.create_custom_action = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), + icon=u':/general/general_edit.png', triggers=self.create_custom) + self.menu.addSeparator() + # Add AutoPlay menu actions + self.auto_play_slides_group = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) + self.menu.addMenu(self.auto_play_slides_group) + self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'), + checked=False, triggers=self.toggle_auto_play_slides_loop) + self.auto_play_slides_once = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'), + checked=False, triggers=self.toggle_auto_play_slides_once) + self.auto_play_slides_group.addSeparator() + self.timed_slide_interval = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', '&Delay between slides'), + checked=False, triggers=self.on_timed_slide_interval) + self.menu.addSeparator() + self.preview_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), + icon=u':/general/general_preview.png', triggers=self.make_preview) + # Add already existing make live action to the menu. + self.menu.addAction(self.service_manager_list.make_live) + self.menu.addSeparator() + self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) + self.menu.addMenu(self.theme_menu) + self.service_manager_list.addActions( + [self.service_manager_list.moveDown, + self.service_manager_list.moveUp, + self.service_manager_list.make_live, + self.service_manager_list.moveTop, + self.service_manager_list.moveBottom, + self.service_manager_list.up, + self.service_manager_list.down, + self.service_manager_list.expand, + self.service_manager_list.collapse + ]) + + def drag_enter_event(self, event): + """ + Accept Drag events + + ``event`` + Handle of the event pint passed + """ + event.accept() + class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ diff --git a/openlp/core/ui/servicemanagerdialog.py b/openlp/core/ui/servicemanagerdialog.py deleted file mode 100644 index e676d6060..000000000 --- a/openlp/core/ui/servicemanagerdialog.py +++ /dev/null @@ -1,268 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from openlp.core.lib import OpenLPToolbar, translate, UiStrings, Receiver, build_icon, Settings -from openlp.core.lib.ui import create_widget_action -from openlp.core.utils.actions import ActionList, CategoryOrder -from openlp.core.utils import AppLocation - -from PyQt4 import QtCore, QtGui - -class ServiceManagerList(QtGui.QTreeWidget): - """ - Set up key bindings and mouse behaviour for the service list - """ - def __init__(self, serviceManager, parent=None): - QtGui.QTreeWidget.__init__(self, parent) - self.serviceManager = serviceManager - - def keyPressEvent(self, event): - """ - Capture Key press and respond accordingly. - """ - if isinstance(event, QtGui.QKeyEvent): - # here accept the event and do something - if event.key() == QtCore.Qt.Key_Up: - self.serviceManager.on_move_selection_up() - event.accept() - elif event.key() == QtCore.Qt.Key_Down: - self.serviceManager.on_move_selection_down() - event.accept() - elif event.key() == QtCore.Qt.Key_Delete: - self.serviceManager.onDeleteFromService() - event.accept() - event.ignore() - else: - event.ignore() - - def mouseMoveEvent(self, event): - """ - Drag and drop event does not care what data is selected - as the recipient will use events to request the data move - just tell it what plugin to call - """ - if event.buttons() != QtCore.Qt.LeftButton: - event.ignore() - return - if not self.itemAt(self.mapFromGlobal(QtGui.QCursor.pos())): - event.ignore() - return - drag = QtGui.QDrag(self) - mime_data = QtCore.QMimeData() - drag.setMimeData(mime_data) - mime_data.setText(u'ServiceManager') - drag.start(QtCore.Qt.CopyAction) - -class ServiceManagerDialog(object): - """ - UI part of the Service Manager - """ - def setup_ui(self,widget): - # Create the top toolbar - self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', - tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) - self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', - tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), - triggers=self.on_load_service_clicked) - self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', - tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) - self.toolbar.addSeparator() - self.theme_label = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) - self.theme_label.setMargin(3) - self.theme_label.setObjectName(u'theme_label') - self.toolbar.addToolbarWidget(self.theme_label) - self.theme_combo_box = QtGui.QComboBox(self.toolbar) - self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) - self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.theme_combo_box.setObjectName(u'theme_combo_box') - self.toolbar.addToolbarWidget(self.theme_combo_box) - self.toolbar.setObjectName(u'toolbar') - self.layout.addWidget(self.toolbar) - # Create the service manager list - self.service_manager_list = ServiceManagerList(self) - self.service_manager_list.setEditTriggers( - QtGui.QAbstractItemView.CurrentChanged | - QtGui.QAbstractItemView.DoubleClicked | - QtGui.QAbstractItemView.EditKeyPressed) - self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - self.service_manager_list.setAlternatingRowColors(True) - self.service_manager_list.setHeaderHidden(True) - self.service_manager_list.setExpandsOnDoubleClick(False) - self.service_manager_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), - self.context_menu) - self.service_manager_list.setObjectName(u'service_manager_list') - # enable drop - self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event - self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event - self.service_manager_list.__class__.dropEvent = self.drop_event - self.layout.addWidget(self.service_manager_list) - # Add the bottom toolbar - self.order_toolbar = OpenLPToolbar(self) - action_list = ActionList.get_instance() - action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) - self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop', - text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), - shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) - self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp', - text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), - shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) - self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown', - text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), - shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) - self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom', - text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'), - shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) - self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down', - text=translate('OpenLP.ServiceManager', 'Move &down'), - tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, - shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down) - action_list.add_action(self.service_manager_list.down) - self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', - text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], - triggers=self.on_move_selection_up) - action_list.add_action(self.service_manager_list.up) - self.order_toolbar.addSeparator() - self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', - text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', - tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), - shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService) - self.order_toolbar.addSeparator() - self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', - text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', - tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), - shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) - self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', - text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', - tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), - shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) - self.order_toolbar.addSeparator() - self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', - text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', - tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), - shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, - triggers=self.make_live) - self.layout.addWidget(self.order_toolbar) - # Connect up our signals and slots - QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), - self.on_theme_combo_box_selected) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.on_make_live) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), - self.collapsed) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), - self.expanded) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), - self.preview_live) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), - self.previous_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), - self.regenerate_service_Items) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), - self.service_item_update) - # Last little bits of setting up - self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') - self.servicePath = AppLocation.get_section_data_path(u'servicemanager') - # build the drag and drop context menu - self.dndMenu = QtGui.QMenu() - self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) - self.newAction.setIcon(build_icon(u':/general/general_edit.png')) - self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) - self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) - # build the context menu - self.menu = QtGui.QMenu() - self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), - icon=u':/general/general_edit.png', triggers=self.remote_edit) - self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), - icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) - self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), - icon=u':/services/service_notes.png', triggers=self.on_service_item_note_form) - self.time_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'), - icon=u':/media/media_time.png', triggers=self.on_start_time_form) - self.auto_start_action = create_widget_action(self.menu, text=u'', - icon=u':/media/auto-start_active.png', triggers=self.on_auto_start) - # Add already existing delete action to the menu. - self.menu.addAction(self.service_manager_list.delete) - self.create_custom_action = create_widget_action(self.menu, - text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), - icon=u':/general/general_edit.png', triggers=self.create_custom) - self.menu.addSeparator() - # Add AutoPlay menu actions - self.auto_play_slides_group = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) - self.menu.addMenu(self.auto_play_slides_group) - self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'), - checked=False, triggers=self.toggle_auto_play_slides_loop) - self.auto_play_slides_once = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'), - checked=False, triggers=self.toggle_auto_play_slides_once) - self.auto_play_slides_group.addSeparator() - self.timed_slide_interval = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', '&Delay between slides'), - checked=False, triggers=self.on_timed_slide_interval) - self.menu.addSeparator() - self.preview_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), - icon=u':/general/general_preview.png', triggers=self.make_preview) - # Add already existing make live action to the menu. - self.menu.addAction(self.service_manager_list.make_live) - self.menu.addSeparator() - self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) - self.menu.addMenu(self.theme_menu) - self.service_manager_list.addActions( - [self.service_manager_list.moveDown, - self.service_manager_list.moveUp, - self.service_manager_list.make_live, - self.service_manager_list.moveTop, - self.service_manager_list.moveBottom, - self.service_manager_list.up, - self.service_manager_list.down, - self.service_manager_list.expand, - self.service_manager_list.collapse - ]) - - def drag_enter_event(self, event): - """ - Accept Drag events - - ``event`` - Handle of the event pint passed - """ - event.accept()