forked from openlp/openlp
Merge branch 'issue-989-no-context-menu' into 'master'
Move the common context menu code into the FolderLibraryItem class Closes #989 See merge request openlp/openlp!394
This commit is contained in:
commit
9b1fb4fe9f
@ -30,7 +30,8 @@ from openlp.core.common import sha256_file_hash
|
||||
from openlp.core.common.i18n import UiStrings, get_natural_key, translate
|
||||
from openlp.core.lib import check_item_selected
|
||||
from openlp.core.lib.mediamanageritem import MediaManagerItem
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.lib.plugin import StringContent
|
||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
||||
from openlp.core.ui.folders import AddFolderForm, ChooseFolderForm
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.core.widgets.views import TreeWidgetWithDnD
|
||||
@ -144,6 +145,62 @@ class FolderLibraryItem(MediaManagerItem):
|
||||
self.page_layout.addWidget(self.list_view)
|
||||
# define and add the context menu
|
||||
self.list_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||
if self.has_edit_icon:
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
text=self.plugin.get_string(StringContent.Edit)['title'],
|
||||
icon=UiIcons().edit,
|
||||
triggers=self.on_edit_click)
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{preview}Item'.format(name=self.plugin.name.title(), preview=StringContent.Preview.title()),
|
||||
text=self.plugin.get_string(StringContent.Preview)['title'],
|
||||
icon=UiIcons().preview,
|
||||
can_shortcuts=True,
|
||||
triggers=self.on_preview_click)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{live}Item'.format(name=self.plugin.name.title(), live=StringContent.Live.title()),
|
||||
text=self.plugin.get_string(StringContent.Live)['title'],
|
||||
icon=UiIcons().live,
|
||||
can_shortcuts=True,
|
||||
triggers=self.on_live_click)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{service}Item'.format(name=self.plugin.name.title(), service=StringContent.Service.title()),
|
||||
can_shortcuts=True,
|
||||
text=self.plugin.get_string(StringContent.Service)['title'],
|
||||
icon=UiIcons().add,
|
||||
triggers=self.on_add_click)
|
||||
if self.add_to_service_item:
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'),
|
||||
icon=UiIcons().add,
|
||||
triggers=self.on_add_edit_click)
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
if self.has_delete_icon:
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{delete}Item'.format(name=self.plugin.name.title(), delete=StringContent.Delete.title()),
|
||||
text=self.plugin.get_string(StringContent.Delete)['title'],
|
||||
icon=UiIcons().delete,
|
||||
can_shortcuts=True, triggers=self.on_delete_click)
|
||||
self.add_custom_context_actions()
|
||||
# Create the context menu and add all actions from the list_view.
|
||||
self.menu = QtWidgets.QMenu()
|
||||
self.menu.addActions(self.list_view.actions())
|
||||
self.list_view.doubleClicked.connect(self.on_double_clicked)
|
||||
self.list_view.itemSelectionChanged.connect(self.on_selection_change)
|
||||
self.list_view.customContextMenuRequested.connect(self.context_menu)
|
||||
|
||||
def add_custom_context_actions(self):
|
||||
"""
|
||||
Override this method to add custom context actions
|
||||
"""
|
||||
pass
|
||||
|
||||
def add_middle_header_bar(self):
|
||||
"""
|
||||
|
@ -32,7 +32,6 @@ from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.path import create_paths
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.lib import MediaType, ServiceItemContext
|
||||
from openlp.core.lib.plugin import StringContent
|
||||
from openlp.core.lib.serviceitem import ItemCapabilities
|
||||
from openlp.core.lib.ui import create_action, create_widget_action, critical_error_message_box
|
||||
from openlp.core.state import State
|
||||
@ -125,62 +124,6 @@ class MediaMediaItem(FolderLibraryItem):
|
||||
self.service_path = AppLocation.get_section_data_path('media') / 'thumbnails'
|
||||
self.rebuild_players()
|
||||
|
||||
def add_list_view_to_toolbar(self):
|
||||
"""
|
||||
Creates the main widget for listing items.
|
||||
"""
|
||||
super().add_list_view_to_toolbar()
|
||||
if self.has_edit_icon:
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
text=self.plugin.get_string(StringContent.Edit)['title'],
|
||||
icon=UiIcons().edit,
|
||||
triggers=self.on_edit_click)
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{preview}Item'.format(name=self.plugin.name.title(), preview=StringContent.Preview.title()),
|
||||
text=self.plugin.get_string(StringContent.Preview)['title'],
|
||||
icon=UiIcons().preview,
|
||||
can_shortcuts=True,
|
||||
triggers=self.on_preview_click)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{live}Item'.format(name=self.plugin.name.title(), live=StringContent.Live.title()),
|
||||
text=self.plugin.get_string(StringContent.Live)['title'],
|
||||
icon=UiIcons().live,
|
||||
can_shortcuts=True,
|
||||
triggers=self.on_live_click)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{service}Item'.format(name=self.plugin.name.title(), service=StringContent.Service.title()),
|
||||
can_shortcuts=True,
|
||||
text=self.plugin.get_string(StringContent.Service)['title'],
|
||||
icon=UiIcons().add,
|
||||
triggers=self.on_add_click)
|
||||
if self.add_to_service_item:
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'),
|
||||
icon=UiIcons().add,
|
||||
triggers=self.on_add_edit_click)
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
if self.has_delete_icon:
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
'listView{name}{delete}Item'.format(name=self.plugin.name.title(), delete=StringContent.Delete.title()),
|
||||
text=self.plugin.get_string(StringContent.Delete)['title'],
|
||||
icon=UiIcons().delete,
|
||||
can_shortcuts=True, triggers=self.on_delete_click)
|
||||
self.add_custom_context_actions()
|
||||
# Create the context menu and add all actions from the list_view.
|
||||
self.menu = QtWidgets.QMenu()
|
||||
self.menu.addActions(self.list_view.actions())
|
||||
self.list_view.doubleClicked.connect(self.on_double_clicked)
|
||||
self.list_view.itemSelectionChanged.connect(self.on_selection_change)
|
||||
self.list_view.customContextMenuRequested.connect(self.context_menu)
|
||||
|
||||
def add_custom_context_actions(self):
|
||||
"""
|
||||
Add custom actions to the context menu.
|
||||
|
@ -29,10 +29,10 @@ from openlp.core.common import sha256_file_hash
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.lib import ServiceItemContext, build_icon, create_thumb, validate_thumb
|
||||
from openlp.core.ui.library import FolderLibraryItem
|
||||
from openlp.core.lib.serviceitem import ItemCapabilities
|
||||
from openlp.core.lib.ui import create_horizontal_adjusting_combo_box, critical_error_message_box
|
||||
from openlp.core.lib.ui import create_horizontal_adjusting_combo_box, create_widget_action, critical_error_message_box
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.core.ui.library import FolderLibraryItem
|
||||
|
||||
from openlp.plugins.presentations.lib.db import Folder, Item
|
||||
from openlp.plugins.presentations.lib.messagelistener import MessageListener
|
||||
@ -102,6 +102,20 @@ class PresentationMediaItem(FolderLibraryItem):
|
||||
self.load_list(self.manager.get_all_objects(Item, order_by_ref=Item.file_path), is_initial_load=True)
|
||||
self.populate_display_types()
|
||||
|
||||
def add_custom_context_actions(self):
|
||||
"""
|
||||
Add custom actions to the context menu.
|
||||
"""
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
text=UiStrings().AddFolder, icon=UiIcons().folder, triggers=self.on_add_folder_click)
|
||||
create_widget_action(
|
||||
self.list_view,
|
||||
text=translate('PresentationsPlugin', 'Add new presentation'),
|
||||
icon=UiIcons().open, triggers=self.on_file_click)
|
||||
create_widget_action(self.list_view, separator=True)
|
||||
|
||||
def add_middle_header_bar(self):
|
||||
"""
|
||||
Display custom media manager items for presentations.
|
||||
|
Loading…
Reference in New Issue
Block a user