forked from openlp/openlp
This commit is contained in:
commit
0f73fbd310
@ -244,7 +244,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
# Add the List widget
|
# Add the List widget
|
||||||
self.listView = ListWidgetWithDnD(self, self.plugin.name)
|
self.listView = ListWidgetWithDnD(self, self.plugin.name)
|
||||||
self.listView.uniformItemSizes = True
|
self.listView.setUniformItemSizes(True)
|
||||||
self.listView.setSpacing(1)
|
self.listView.setSpacing(1)
|
||||||
self.listView.setSelectionMode(
|
self.listView.setSelectionMode(
|
||||||
QtGui.QAbstractItemView.ExtendedSelection)
|
QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
@ -254,54 +254,54 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
# Add to pageLayout
|
# Add to pageLayout
|
||||||
self.pageLayout.addWidget(self.listView)
|
self.pageLayout.addWidget(self.listView)
|
||||||
# define and add the context menu
|
# define and add the context menu
|
||||||
self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||||
if self.hasEditIcon:
|
if self.hasEditIcon:
|
||||||
self.listView.addAction(
|
context_menu_action(
|
||||||
context_menu_action(
|
self.listView, u':/general/general_edit.png',
|
||||||
self.listView, u':/general/general_edit.png',
|
self.plugin.getString(StringContent.Edit)[u'title'],
|
||||||
self.plugin.getString(StringContent.Edit)[u'title'],
|
self.onEditClick, context=QtCore.Qt.WidgetShortcut)
|
||||||
self.onEditClick, context=QtCore.Qt.WidgetShortcut))
|
context_menu_separator(self.listView)
|
||||||
self.listView.addAction(context_menu_separator(self.listView))
|
|
||||||
if self.hasDeleteIcon:
|
if self.hasDeleteIcon:
|
||||||
self.listView.addAction(
|
|
||||||
context_menu_action(
|
|
||||||
self.listView, u':/general/general_delete.png',
|
|
||||||
self.plugin.getString(StringContent.Delete)[u'title'],
|
|
||||||
self.onDeleteClick, [QtCore.Qt.Key_Delete],
|
|
||||||
context=QtCore.Qt.WidgetShortcut))
|
|
||||||
self.listView.addAction(context_menu_separator(self.listView))
|
|
||||||
self.listView.addAction(
|
|
||||||
context_menu_action(
|
context_menu_action(
|
||||||
self.listView, u':/general/general_preview.png',
|
self.listView, u':/general/general_delete.png',
|
||||||
self.plugin.getString(StringContent.Preview)[u'title'],
|
self.plugin.getString(StringContent.Delete)[u'title'],
|
||||||
self.onPreviewClick, [QtCore.Qt.Key_Enter,
|
self.onDeleteClick, [QtCore.Qt.Key_Delete],
|
||||||
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut))
|
context=QtCore.Qt.WidgetShortcut)
|
||||||
self.listView.addAction(
|
context_menu_separator(self.listView)
|
||||||
context_menu_action(
|
context_menu_action(
|
||||||
self.listView, u':/general/general_live.png',
|
self.listView, u':/general/general_preview.png',
|
||||||
self.plugin.getString(StringContent.Live)[u'title'],
|
self.plugin.getString(StringContent.Preview)[u'title'],
|
||||||
self.onLiveClick, [QtCore.Qt.ShiftModifier + \
|
self.onPreviewClick, [QtCore.Qt.Key_Enter,
|
||||||
QtCore.Qt.Key_Enter, QtCore.Qt.ShiftModifier + \
|
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut)
|
||||||
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut))
|
context_menu_action(
|
||||||
self.listView.addAction(
|
self.listView, u':/general/general_live.png',
|
||||||
|
self.plugin.getString(StringContent.Live)[u'title'],
|
||||||
|
self.onLiveClick, [QtCore.Qt.ShiftModifier + \
|
||||||
|
QtCore.Qt.Key_Enter, QtCore.Qt.ShiftModifier + \
|
||||||
|
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut)
|
||||||
|
context_menu_action(
|
||||||
|
self.listView, u':/general/general_add.png',
|
||||||
|
self.plugin.getString(StringContent.Service)[u'title'],
|
||||||
|
self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
|
||||||
|
context=QtCore.Qt.WidgetShortcut)
|
||||||
|
if self.addToServiceItem:
|
||||||
context_menu_action(
|
context_menu_action(
|
||||||
self.listView, u':/general/general_add.png',
|
self.listView, u':/general/general_add.png',
|
||||||
self.plugin.getString(StringContent.Service)[u'title'],
|
translate('OpenLP.MediaManagerItem',
|
||||||
self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
|
'&Add to selected Service Item'),
|
||||||
context=QtCore.Qt.WidgetShortcut))
|
self.onAddEditClick, context=QtCore.Qt.WidgetShortcut)
|
||||||
if self.addToServiceItem:
|
# Create the context menu and add all actions from the listView.
|
||||||
self.listView.addAction(
|
self.menu = QtGui.QMenu()
|
||||||
context_menu_action(
|
self.menu.addActions(self.listView.actions())
|
||||||
self.listView, u':/general/general_add.png',
|
|
||||||
translate('OpenLP.MediaManagerItem',
|
|
||||||
'&Add to selected Service Item'),
|
|
||||||
self.onAddEditClick, context=QtCore.Qt.WidgetShortcut))
|
|
||||||
QtCore.QObject.connect(self.listView,
|
QtCore.QObject.connect(self.listView,
|
||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||||
self.onClickPressed)
|
self.onClickPressed)
|
||||||
QtCore.QObject.connect(self.listView,
|
QtCore.QObject.connect(self.listView,
|
||||||
QtCore.SIGNAL(u'itemSelectionChanged()'),
|
QtCore.SIGNAL(u'itemSelectionChanged()'),
|
||||||
self.onSelectionChange)
|
self.onSelectionChange)
|
||||||
|
QtCore.QObject.connect(self.listView,
|
||||||
|
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
|
||||||
|
self.contextMenu)
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
"""
|
"""
|
||||||
@ -354,6 +354,14 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.settingsSection, self.getFileList())
|
self.settingsSection, self.getFileList())
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
|
|
||||||
|
def contextMenu(self, point):
|
||||||
|
item = self.listView.itemAt(point)
|
||||||
|
if item is None:
|
||||||
|
return
|
||||||
|
if not item.flags() & QtCore.Qt.ItemIsSelectable:
|
||||||
|
return
|
||||||
|
self.menu.exec_(self.listView.mapToGlobal(point))
|
||||||
|
|
||||||
def getFileList(self):
|
def getFileList(self):
|
||||||
"""
|
"""
|
||||||
Return the current list of files
|
Return the current list of files
|
||||||
|
@ -364,6 +364,7 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
|
|||||||
action.setShortcutContext(context)
|
action.setShortcutContext(context)
|
||||||
action_list = ActionList.get_instance()
|
action_list = ActionList.get_instance()
|
||||||
action_list.add_action(action)
|
action_list.add_action(action)
|
||||||
|
base.addAction(action)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def context_menu(base, icon, text):
|
def context_menu(base, icon, text):
|
||||||
@ -392,6 +393,7 @@ def context_menu_separator(base):
|
|||||||
"""
|
"""
|
||||||
action = QtGui.QAction(u'', base)
|
action = QtGui.QAction(u'', base)
|
||||||
action.setSeparator(True)
|
action.setSeparator(True)
|
||||||
|
base.addAction(action)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def add_widget_completer(cache, widget):
|
def add_widget_completer(cache, widget):
|
||||||
|
Loading…
Reference in New Issue
Block a user