forked from openlp/openlp
Replace Context menu with smart context menu
This commit is contained in:
parent
cc42dc34d8
commit
e33e4cb7ff
@ -236,7 +236,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.addToAction = self.dndMenu.addAction(
|
self.addToAction = self.dndMenu.addAction(
|
||||||
translate('OpenLP.ServiceManager', '&Add to Selected Item'))
|
translate('OpenLP.ServiceManager', '&Add to Selected Item'))
|
||||||
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
|
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||||
#build the context menu
|
# build the context menu
|
||||||
self.menu = QtGui.QMenu()
|
self.menu = QtGui.QMenu()
|
||||||
self.editAction = self.menu.addAction(
|
self.editAction = self.menu.addAction(
|
||||||
translate('OpenLP.ServiceManager', '&Edit Item'))
|
translate('OpenLP.ServiceManager', '&Edit Item'))
|
||||||
|
@ -88,41 +88,32 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.themeListWidget.setAlternatingRowColors(True)
|
self.themeListWidget.setAlternatingRowColors(True)
|
||||||
self.themeListWidget.setIconSize(QtCore.QSize(88, 50))
|
self.themeListWidget.setIconSize(QtCore.QSize(88, 50))
|
||||||
self.layout.addWidget(self.themeListWidget)
|
self.layout.addWidget(self.themeListWidget)
|
||||||
self.themeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.themeListWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||||
self.themeListWidget.addAction(
|
QtCore.QObject.connect(self.themeListWidget,
|
||||||
context_menu_action(self.themeListWidget,
|
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
|
||||||
u':/themes/theme_edit.png',
|
self.contextMenu)
|
||||||
translate('OpenLP.ThemeManager', '&Edit Theme'),
|
# build the context menu
|
||||||
self.onEditTheme))
|
self.menu = QtGui.QMenu()
|
||||||
self.themeListWidget.addAction(
|
self.editAction = self.menu.addAction(
|
||||||
context_menu_action(self.themeListWidget,
|
translate('OpenLP.ThemeManager', '&Edit Theme'))
|
||||||
u':/themes/theme_edit.png',
|
self.editAction.setIcon(build_icon(u':/themes/theme_edit.png'))
|
||||||
translate('OpenLP.ThemeManager', '&Rename Theme'),
|
self.copyAction = self.menu.addAction(
|
||||||
self.onRenameTheme))
|
translate('OpenLP.ThemeManager', '&Copy Theme'))
|
||||||
self.themeListWidget.addAction(
|
self.copyAction.setIcon(build_icon(u':/themes/theme_edit.png'))
|
||||||
context_menu_action(self.themeListWidget,
|
self.renameAction = self.menu.addAction(
|
||||||
u':/themes/theme_edit.png',
|
translate('OpenLP.ThemeManager', '&Rename Theme'))
|
||||||
translate('OpenLP.ThemeManager', '&Copy Theme'),
|
self.renameAction.setIcon(build_icon(u':/themes/theme_edit.png'))
|
||||||
self.onCopyTheme))
|
self.deleteAction = self.menu.addAction(
|
||||||
self.themeListWidget.addAction(
|
translate('OpenLP.ThemeManager', '&Delete Theme'))
|
||||||
context_menu_separator(self.themeListWidget))
|
self.deleteAction.setIcon(build_icon(u':/general/general_delete.png'))
|
||||||
self.themeListWidget.addAction(
|
self.sep1 = self.menu.addAction(u'')
|
||||||
context_menu_action(self.themeListWidget,
|
self.sep1.setSeparator(True)
|
||||||
u':/general/general_delete.png',
|
self.globalAction = self.menu.addAction(
|
||||||
translate('OpenLP.ThemeManager', '&Delete Theme'),
|
translate('OpenLP.ThemeManager', 'Set As &Global Default'))
|
||||||
self.onDeleteTheme))
|
self.globalAction.setIcon(build_icon(u':/general/general_export.png'))
|
||||||
self.themeListWidget.addAction(
|
self.exportAction = self.menu.addAction(
|
||||||
context_menu_action(self.themeListWidget,
|
translate('OpenLP.ThemeManager', '&Export Theme'))
|
||||||
u':/general/general_export.png',
|
self.exportAction.setIcon(build_icon(u':/general/general_export.png'))
|
||||||
translate('OpenLP.ThemeManager', 'Set As &Global Default'),
|
|
||||||
self.changeGlobalFromScreen))
|
|
||||||
self.themeListWidget.addAction(
|
|
||||||
context_menu_action(self.themeListWidget,
|
|
||||||
u':/general/general_export.png',
|
|
||||||
translate('OpenLP.ThemeManager', 'E&xport Theme'),
|
|
||||||
self.onExportTheme))
|
|
||||||
self.themeListWidget.addAction(
|
|
||||||
context_menu_separator(self.themeListWidget))
|
|
||||||
#Signals
|
#Signals
|
||||||
QtCore.QObject.connect(self.themeListWidget,
|
QtCore.QObject.connect(self.themeListWidget,
|
||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||||
@ -143,6 +134,31 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.settingsSection + u'/global theme',
|
self.settingsSection + u'/global theme',
|
||||||
QtCore.QVariant(u'')).toString())
|
QtCore.QVariant(u'')).toString())
|
||||||
|
|
||||||
|
def contextMenu(self, point):
|
||||||
|
item = self.themeListWidget.itemAt(point)
|
||||||
|
if item is None:
|
||||||
|
return
|
||||||
|
realThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
|
themeName = unicode(item.text())
|
||||||
|
self.deleteAction.setVisible(False)
|
||||||
|
self.renameAction.setVisible(False)
|
||||||
|
if realThemeName == themeName:
|
||||||
|
self.deleteAction.setVisible(True)
|
||||||
|
self.renameAction.setVisible(True)
|
||||||
|
action = self.menu.exec_(self.themeListWidget.mapToGlobal(point))
|
||||||
|
if action == self.editAction:
|
||||||
|
self.onEditTheme()
|
||||||
|
if action == self.copyAction:
|
||||||
|
self.onCopyTheme()
|
||||||
|
if action == self.renameAction:
|
||||||
|
self.onRenameTheme()
|
||||||
|
if action == self.deleteAction:
|
||||||
|
self.onDeleteTheme()
|
||||||
|
if action == self.globalAction:
|
||||||
|
self. self.changeGlobalFromScreen()
|
||||||
|
if action == self.exportAction:
|
||||||
|
self. self.onExportTheme()
|
||||||
|
|
||||||
def changeGlobalFromTab(self, themeName):
|
def changeGlobalFromTab(self, themeName):
|
||||||
"""
|
"""
|
||||||
Change the global theme when it is changed through the Themes settings
|
Change the global theme when it is changed through the Themes settings
|
||||||
|
Loading…
Reference in New Issue
Block a user