forked from openlp/openlp
started reworking shortcuts
This commit is contained in:
parent
ba90ab2ce2
commit
19138cd9e5
@ -31,6 +31,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import build_icon, Receiver, translate
|
from openlp.core.lib import build_icon, Receiver, translate
|
||||||
|
from openlp.core.utils.actions import actionList
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -265,6 +266,7 @@ def icon_action(parent, name, icon, checked=None):
|
|||||||
else:
|
else:
|
||||||
action = base_action(parent, name)
|
action = base_action(parent, name)
|
||||||
action.setIcon(build_icon(icon))
|
action.setIcon(build_icon(icon))
|
||||||
|
#actionList.add_action(action, name)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def shortcut_action(parent, text, shortcuts, function):
|
def shortcut_action(parent, text, shortcuts, function):
|
||||||
|
@ -38,7 +38,8 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
|
|||||||
ThemeManager, SlideController, PluginForm, MediaDockManager, \
|
ThemeManager, SlideController, PluginForm, MediaDockManager, \
|
||||||
ShortcutListForm, DisplayTagForm
|
ShortcutListForm, DisplayTagForm
|
||||||
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
|
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
|
||||||
ActionList, get_application_version
|
get_application_version
|
||||||
|
from openlp.core.utils.actions import actionList
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -163,53 +164,52 @@ class Ui_MainWindow(object):
|
|||||||
# Create the menu items
|
# Create the menu items
|
||||||
self.FileNewItem = icon_action(mainWindow, u'FileNewItem',
|
self.FileNewItem = icon_action(mainWindow, u'FileNewItem',
|
||||||
u':/general/general_new.png')
|
u':/general/general_new.png')
|
||||||
mainWindow.actionList.add_action(self.FileNewItem, u'File')
|
actionList.add_action(self.FileNewItem, u'File')
|
||||||
self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem',
|
self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem',
|
||||||
u':/general/general_open.png')
|
u':/general/general_open.png')
|
||||||
mainWindow.actionList.add_action(self.FileOpenItem, u'File')
|
actionList.add_action(self.FileOpenItem, u'File')
|
||||||
self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem',
|
self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem',
|
||||||
u':/general/general_save.png')
|
u':/general/general_save.png')
|
||||||
mainWindow.actionList.add_action(self.FileSaveItem, u'File')
|
actionList.add_action(self.FileSaveItem, u'File')
|
||||||
self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem')
|
self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem')
|
||||||
mainWindow.actionList.add_action(self.FileSaveAsItem, u'File')
|
actionList.add_action(self.FileSaveAsItem, u'File')
|
||||||
self.printServiceOrderItem = base_action(
|
self.printServiceOrderItem = base_action(
|
||||||
mainWindow, u'printServiceItem')
|
mainWindow, u'printServiceItem')
|
||||||
mainWindow.actionList.add_action(
|
actionList.add_action(self.printServiceOrderItem, u'File')
|
||||||
self.printServiceOrderItem, u'Print Service Order')
|
|
||||||
self.FileExitItem = icon_action(mainWindow, u'FileExitItem',
|
self.FileExitItem = icon_action(mainWindow, u'FileExitItem',
|
||||||
u':/system/system_exit.png')
|
u':/system/system_exit.png')
|
||||||
mainWindow.actionList.add_action(self.FileExitItem, u'File')
|
actionList.add_action(self.FileExitItem, u'File')
|
||||||
self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem')
|
self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem')
|
||||||
mainWindow.actionList.add_action(self.ImportThemeItem, u'Import')
|
actionList.add_action(self.ImportThemeItem, u'Import')
|
||||||
self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem')
|
self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem')
|
||||||
mainWindow.actionList.add_action(self.ImportLanguageItem, u'Import')
|
actionList.add_action(self.ImportLanguageItem, u'Import')
|
||||||
self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem')
|
self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem')
|
||||||
mainWindow.actionList.add_action(self.ExportThemeItem, u'Export')
|
actionList.add_action(self.ExportThemeItem, u'Export')
|
||||||
self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem')
|
self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem')
|
||||||
mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export')
|
actionList.add_action(self.ExportLanguageItem, u'Export')
|
||||||
self.ViewMediaManagerItem = icon_action(mainWindow,
|
self.ViewMediaManagerItem = icon_action(mainWindow,
|
||||||
u'ViewMediaManagerItem', u':/system/system_mediamanager.png',
|
u'ViewMediaManagerItem', u':/system/system_mediamanager.png',
|
||||||
self.mediaManagerDock.isVisible())
|
self.mediaManagerDock.isVisible())
|
||||||
self.ViewThemeManagerItem = icon_action(mainWindow,
|
self.ViewThemeManagerItem = icon_action(mainWindow,
|
||||||
u'ViewThemeManagerItem', u':/system/system_thememanager.png',
|
u'ViewThemeManagerItem', u':/system/system_thememanager.png',
|
||||||
self.themeManagerDock.isVisible())
|
self.themeManagerDock.isVisible())
|
||||||
mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View')
|
actionList.add_action(self.ViewMediaManagerItem, u'View')
|
||||||
self.ViewServiceManagerItem = icon_action(mainWindow,
|
self.ViewServiceManagerItem = icon_action(mainWindow,
|
||||||
u'ViewServiceManagerItem', u':/system/system_servicemanager.png',
|
u'ViewServiceManagerItem', u':/system/system_servicemanager.png',
|
||||||
self.serviceManagerDock.isVisible())
|
self.serviceManagerDock.isVisible())
|
||||||
mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View')
|
actionList.add_action(self.ViewServiceManagerItem, u'View')
|
||||||
self.ViewPreviewPanel = checkable_action(mainWindow,
|
self.ViewPreviewPanel = checkable_action(mainWindow,
|
||||||
u'ViewPreviewPanel', previewVisible)
|
u'ViewPreviewPanel', previewVisible)
|
||||||
mainWindow.actionList.add_action(self.ViewPreviewPanel, u'View')
|
actionList.add_action(self.ViewPreviewPanel, u'View')
|
||||||
self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel',
|
self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel',
|
||||||
liveVisible)
|
liveVisible)
|
||||||
mainWindow.actionList.add_action(self.ViewLivePanel, u'View')
|
actionList.add_action(self.ViewLivePanel, u'View')
|
||||||
self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem')
|
self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem')
|
||||||
mainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode')
|
actionList.add_action(self.ModeDefaultItem, u'View Mode')
|
||||||
self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem')
|
self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem')
|
||||||
mainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode')
|
actionList.add_action(self.ModeSetupItem, u'View Mode')
|
||||||
self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True)
|
self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True)
|
||||||
mainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode')
|
actionList.add_action(self.ModeLiveItem, u'View Mode')
|
||||||
self.ModeGroup = QtGui.QActionGroup(mainWindow)
|
self.ModeGroup = QtGui.QActionGroup(mainWindow)
|
||||||
self.ModeGroup.addAction(self.ModeDefaultItem)
|
self.ModeGroup.addAction(self.ModeDefaultItem)
|
||||||
self.ModeGroup.addAction(self.ModeSetupItem)
|
self.ModeGroup.addAction(self.ModeSetupItem)
|
||||||
@ -217,18 +217,18 @@ class Ui_MainWindow(object):
|
|||||||
self.ModeDefaultItem.setChecked(True)
|
self.ModeDefaultItem.setChecked(True)
|
||||||
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
|
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
|
||||||
u':/tools/tools_add.png')
|
u':/tools/tools_add.png')
|
||||||
mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools')
|
actionList.add_action(self.ToolsAddToolItem, u'Tools')
|
||||||
self.ToolsOpenDataFolder = icon_action(mainWindow,
|
self.ToolsOpenDataFolder = icon_action(mainWindow,
|
||||||
u'ToolsOpenDataFolder', u':/general/general_open.png')
|
u'ToolsOpenDataFolder', u':/general/general_open.png')
|
||||||
mainWindow.actionList.add_action(self.ToolsOpenDataFolder, u'Tools')
|
actionList.add_action(self.ToolsOpenDataFolder, u'Tools')
|
||||||
self.settingsPluginListItem = icon_action(mainWindow,
|
self.settingsPluginListItem = icon_action(mainWindow,
|
||||||
u'settingsPluginListItem', u':/system/settings_plugin_list.png')
|
u'settingsPluginListItem', u':/system/settings_plugin_list.png')
|
||||||
mainWindow.actionList.add_action(self.settingsPluginListItem,
|
actionList.add_action(self.settingsPluginListItem,
|
||||||
u'Settings')
|
u'Settings')
|
||||||
# i18n Language Items
|
# i18n Language Items
|
||||||
self.AutoLanguageItem = checkable_action(mainWindow,
|
self.AutoLanguageItem = checkable_action(mainWindow,
|
||||||
u'AutoLanguageItem', LanguageManager.auto_language)
|
u'AutoLanguageItem', LanguageManager.auto_language)
|
||||||
mainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings')
|
actionList.add_action(self.AutoLanguageItem, u'Settings')
|
||||||
self.LanguageGroup = QtGui.QActionGroup(mainWindow)
|
self.LanguageGroup = QtGui.QActionGroup(mainWindow)
|
||||||
self.LanguageGroup.setExclusive(True)
|
self.LanguageGroup.setExclusive(True)
|
||||||
self.LanguageGroup.setObjectName(u'LanguageGroup')
|
self.LanguageGroup.setObjectName(u'LanguageGroup')
|
||||||
@ -246,19 +246,19 @@ class Ui_MainWindow(object):
|
|||||||
u'DisplayTagItem', u':/system/tag_editor.png')
|
u'DisplayTagItem', u':/system/tag_editor.png')
|
||||||
self.SettingsConfigureItem = icon_action(mainWindow,
|
self.SettingsConfigureItem = icon_action(mainWindow,
|
||||||
u'SettingsConfigureItem', u':/system/system_settings.png')
|
u'SettingsConfigureItem', u':/system/system_settings.png')
|
||||||
mainWindow.actionList.add_action(self.SettingsShortcutsItem,
|
actionList.add_action(self.SettingsShortcutsItem,
|
||||||
u'Settings')
|
u'Settings')
|
||||||
self.HelpDocumentationItem = icon_action(mainWindow,
|
self.HelpDocumentationItem = icon_action(mainWindow,
|
||||||
u'HelpDocumentationItem', u':/system/system_help_contents.png')
|
u'HelpDocumentationItem', u':/system/system_help_contents.png')
|
||||||
self.HelpDocumentationItem.setEnabled(False)
|
self.HelpDocumentationItem.setEnabled(False)
|
||||||
mainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help')
|
actionList.add_action(self.HelpDocumentationItem, u'Help')
|
||||||
self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem',
|
self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem',
|
||||||
u':/system/system_about.png')
|
u':/system/system_about.png')
|
||||||
mainWindow.actionList.add_action(self.HelpAboutItem, u'Help')
|
actionList.add_action(self.HelpAboutItem, u'Help')
|
||||||
self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem')
|
self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem')
|
||||||
mainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help')
|
actionList.add_action(self.HelpOnlineHelpItem, u'Help')
|
||||||
self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem')
|
self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem')
|
||||||
mainWindow.actionList.add_action(self.helpWebSiteItem, u'Help')
|
actionList.add_action(self.helpWebSiteItem, u'Help')
|
||||||
add_actions(self.FileImportMenu,
|
add_actions(self.FileImportMenu,
|
||||||
(self.ImportThemeItem, self.ImportLanguageItem))
|
(self.ImportThemeItem, self.ImportLanguageItem))
|
||||||
add_actions(self.FileExportMenu,
|
add_actions(self.FileExportMenu,
|
||||||
@ -301,7 +301,6 @@ class Ui_MainWindow(object):
|
|||||||
self.ToolsAddToolItem.setVisible(False)
|
self.ToolsAddToolItem.setVisible(False)
|
||||||
self.ImportLanguageItem.setVisible(False)
|
self.ImportLanguageItem.setVisible(False)
|
||||||
self.ExportLanguageItem.setVisible(False)
|
self.ExportLanguageItem.setVisible(False)
|
||||||
self.SettingsShortcutsItem.setVisible(False)
|
|
||||||
self.HelpDocumentationItem.setVisible(False)
|
self.HelpDocumentationItem.setVisible(False)
|
||||||
|
|
||||||
def retranslateUi(self, mainWindow):
|
def retranslateUi(self, mainWindow):
|
||||||
@ -467,8 +466,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
log.info(u'MainWindow loaded')
|
log.info(u'MainWindow loaded')
|
||||||
|
|
||||||
actionList = ActionList()
|
|
||||||
|
|
||||||
def __init__(self, screens, application):
|
def __init__(self, screens, application):
|
||||||
"""
|
"""
|
||||||
This constructor sets up the interface, the various managers, and the
|
This constructor sets up the interface, the various managers, and the
|
||||||
@ -476,7 +473,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
QtGui.QMainWindow.__init__(self)
|
QtGui.QMainWindow.__init__(self)
|
||||||
self.screens = screens
|
self.screens = screens
|
||||||
|
|
||||||
self.application = application
|
self.application = application
|
||||||
# Set up settings sections for the main application
|
# Set up settings sections for the main application
|
||||||
# (not for use by plugins)
|
# (not for use by plugins)
|
||||||
@ -485,7 +481,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.serviceSettingsSection = u'servicemanager'
|
self.serviceSettingsSection = u'servicemanager'
|
||||||
self.songsSettingsSection = u'songs'
|
self.songsSettingsSection = u'songs'
|
||||||
self.serviceNotSaved = False
|
self.serviceNotSaved = False
|
||||||
self.actionList = ActionList()
|
|
||||||
self.settingsmanager = SettingsManager(screens)
|
self.settingsmanager = SettingsManager(screens)
|
||||||
self.aboutForm = AboutForm(self)
|
self.aboutForm = AboutForm(self)
|
||||||
self.settingsForm = SettingsForm(self.screens, self, self)
|
self.settingsForm = SettingsForm(self.screens, self, self)
|
||||||
@ -777,7 +772,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
Show the shortcuts dialog
|
Show the shortcuts dialog
|
||||||
"""
|
"""
|
||||||
self.shortcutForm.exec_(self.actionList)
|
self.shortcutForm.exec_()
|
||||||
|
|
||||||
def onModeDefaultItemClicked(self):
|
def onModeDefaultItemClicked(self):
|
||||||
"""
|
"""
|
||||||
|
@ -40,6 +40,7 @@ from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
|
|||||||
from openlp.core.ui.printserviceform import PrintServiceForm
|
from openlp.core.ui.printserviceform import PrintServiceForm
|
||||||
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
||||||
split_filename
|
split_filename
|
||||||
|
from openlp.core.utils.actions import actionList
|
||||||
|
|
||||||
class ServiceManagerList(QtGui.QTreeWidget):
|
class ServiceManagerList(QtGui.QTreeWidget):
|
||||||
"""
|
"""
|
||||||
@ -315,7 +316,6 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.configUpdated()
|
self.configUpdated()
|
||||||
|
|
||||||
def setServiceHotkeys(self):
|
def setServiceHotkeys(self):
|
||||||
actionList = self.mainwindow.actionList
|
|
||||||
actionList.add_action(self.serviceManagerList.moveDown, u'Service')
|
actionList.add_action(self.serviceManagerList.moveDown, u'Service')
|
||||||
actionList.add_action(self.serviceManagerList.moveUp, u'Service')
|
actionList.add_action(self.serviceManagerList.moveUp, u'Service')
|
||||||
actionList.add_action(self.serviceManagerList.moveTop, u'Service')
|
actionList.add_action(self.serviceManagerList.moveTop, u'Service')
|
||||||
|
@ -30,6 +30,7 @@ import re
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.utils import translate
|
from openlp.core.utils import translate
|
||||||
|
from openlp.core.utils.actions import actionList
|
||||||
from shortcutlistdialog import Ui_ShortcutListDialog
|
from shortcutlistdialog import Ui_ShortcutListDialog
|
||||||
|
|
||||||
REMOVE_AMPERSAND = re.compile(r'&{1}')
|
REMOVE_AMPERSAND = re.compile(r'&{1}')
|
||||||
@ -40,21 +41,24 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
The shortcut list dialog
|
The shortcut list dialog
|
||||||
"""
|
"""
|
||||||
|
#TODO: do not close on ESC
|
||||||
def __init__(self, parent):
|
#TODO: ability to remove actions
|
||||||
"""
|
#TODO: Save shortcuts
|
||||||
Do some initialisation stuff
|
#TODO: doc
|
||||||
"""
|
def __init__(self, parent=None):
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.actionList = None
|
self.assingedShortcuts = []
|
||||||
self.captureShortcut = False
|
self.shortcutButton.setText(u'')
|
||||||
QtCore.QObject.connect(self.shortcutButton,
|
QtCore.QObject.connect(self.shortcutButton,
|
||||||
QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked)
|
QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.treeWidget,
|
||||||
|
QtCore.SIGNAL(u'itemPressed(QTreeWidgetItem*, int)'),
|
||||||
|
self.onItemPressed)
|
||||||
|
|
||||||
def keyReleaseEvent(self, event):
|
def keyReleaseEvent(self, event):
|
||||||
Qt = QtCore.Qt
|
Qt = QtCore.Qt
|
||||||
if not self.captureShortcut:
|
if not self.shortcutButton.isChecked():
|
||||||
return
|
return
|
||||||
key = event.key()
|
key = event.key()
|
||||||
if key == Qt.Key_Shift or key == Qt.Key_Control or \
|
if key == Qt.Key_Shift or key == Qt.Key_Control or \
|
||||||
@ -68,45 +72,80 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier:
|
if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier:
|
||||||
key_string = u'Shift+' + key_string
|
key_string = u'Shift+' + key_string
|
||||||
key_sequence = QtGui.QKeySequence(key_string)
|
key_sequence = QtGui.QKeySequence(key_string)
|
||||||
existing_key = QtGui.QKeySequence(u'Ctrl+Shift+F8')
|
if key_sequence in self.assingedShortcuts:
|
||||||
if key_sequence == existing_key:
|
QtGui.QMessageBox.warning(self,
|
||||||
QtGui.QMessageBox.warning(
|
|
||||||
self,
|
|
||||||
translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
|
translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
|
||||||
unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut '
|
unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut '
|
||||||
'"%s" is already assigned to another action, please '
|
'"%s" is already assigned to another action, please '
|
||||||
'use a different shortcut.')) % key_sequence.toString(),
|
'use a different shortcut.')) % key_sequence.toString(),
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
|
||||||
QtGui.QMessageBox.Ok
|
QtGui.QMessageBox.Ok
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.shortcutButton.setText(key_sequence.toString())
|
self.shortcutButton.setText(key_sequence.toString())
|
||||||
self.shortcutButton.setChecked(False)
|
self.shortcutButton.setChecked(False)
|
||||||
self.captureShortcut = False
|
|
||||||
|
|
||||||
def exec_(self, actionList):
|
def exec_(self):
|
||||||
self.actionList = actionList
|
# The dialog is opened the first time
|
||||||
self.refreshActions()
|
if self.treeWidget.topLevelItemCount() == 0:
|
||||||
|
QtCore.QObject.connect(actionList.signal,
|
||||||
|
QtCore.SIGNAL(u'addedAction()'), self.initialiseActionList)
|
||||||
|
self.initialiseActionList()
|
||||||
|
self.refreshActionList()
|
||||||
return QtGui.QDialog.exec_(self)
|
return QtGui.QDialog.exec_(self)
|
||||||
|
|
||||||
def refreshActions(self):
|
def refreshActionList(self):
|
||||||
self.treeWidget.clear()
|
self.assingedShortcuts = []
|
||||||
for category in self.actionList.categories:
|
iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget)
|
||||||
item = QtGui.QTreeWidgetItem([category.name])
|
while iterator.value():
|
||||||
for action in category.actions:
|
treewidgetItem = iterator.value()
|
||||||
|
action = treewidgetItem.data(0, QtCore.Qt.UserRole).toPyObject()
|
||||||
|
if action is not None:
|
||||||
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
|
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
|
||||||
if (len(action.shortcuts()) == 2):
|
if len(action.shortcuts()) == 2:
|
||||||
shortcutText = action.shortcuts()[0].toString()
|
shortcutText = action.shortcuts()[0].toString()
|
||||||
alternateText = action.shortcuts()[1].toString()
|
alternateText = action.shortcuts()[1].toString()
|
||||||
else:
|
else:
|
||||||
shortcutText = action.shortcut().toString()
|
shortcutText = action.shortcut().toString()
|
||||||
alternateText = u''
|
alternateText = u''
|
||||||
actionItem = QtGui.QTreeWidgetItem(
|
self.assingedShortcuts.extend(action.shortcuts())
|
||||||
[actionText, shortcutText, alternateText])
|
treewidgetItem.setText(0, actionText)
|
||||||
|
treewidgetItem.setText(1, shortcutText)
|
||||||
|
treewidgetItem.setText(2, alternateText)
|
||||||
|
iterator += 1
|
||||||
|
|
||||||
|
def initialiseActionList(self):
|
||||||
|
for category in actionList.categories:
|
||||||
|
item = QtGui.QTreeWidgetItem([category.name])
|
||||||
|
for action in category.actions:
|
||||||
|
actionItem = QtGui.QTreeWidgetItem()
|
||||||
actionItem.setIcon(0, action.icon())
|
actionItem.setIcon(0, action.icon())
|
||||||
|
actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action))
|
||||||
item.addChild(actionItem)
|
item.addChild(actionItem)
|
||||||
item.setExpanded(True)
|
item.setExpanded(True)
|
||||||
self.treeWidget.addTopLevelItem(item)
|
self.treeWidget.addTopLevelItem(item)
|
||||||
|
|
||||||
def onShortcutButtonClicked(self, toggled):
|
def onShortcutButtonClicked(self, toggled):
|
||||||
self.captureShortcut = toggled
|
if toggled:
|
||||||
|
return
|
||||||
|
item = self.treeWidget.currentItem()
|
||||||
|
action = item.data(0, QtCore.Qt.UserRole).toPyObject()
|
||||||
|
if action is None:
|
||||||
|
return
|
||||||
|
# TODO: Sort out which shortcuts should be kept.
|
||||||
|
action.setShortcuts(QtGui.QKeySequence(self.shortcutButton.text()))
|
||||||
|
self.refreshActionList()
|
||||||
|
|
||||||
|
def onItemPressed(self, item, column):
|
||||||
|
item = self.treeWidget.currentItem()
|
||||||
|
action = item.data(0, QtCore.Qt.UserRole).toPyObject()
|
||||||
|
if action is None:
|
||||||
|
text = u''
|
||||||
|
else:
|
||||||
|
if len(action.shortcuts()) == 0:
|
||||||
|
text = u''
|
||||||
|
elif len(action.shortcuts()) == 2 and column == 2:
|
||||||
|
text = action.shortcuts()[1].toString()
|
||||||
|
else:
|
||||||
|
text = action.shortcuts()[0].toString()
|
||||||
|
self.shortcutButton.setText(text)
|
||||||
|
@ -34,6 +34,7 @@ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
|
|||||||
ItemCapabilities, translate
|
ItemCapabilities, translate
|
||||||
from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action
|
from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action
|
||||||
from openlp.core.ui import HideMode, MainDisplay
|
from openlp.core.ui import HideMode, MainDisplay
|
||||||
|
from openlp.core.utils.actions import actionList
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -362,14 +363,12 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
|
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
|
||||||
|
|
||||||
def setPreviewHotkeys(self, parent=None):
|
def setPreviewHotkeys(self, parent=None):
|
||||||
actionList = self.parent.actionList
|
|
||||||
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0])
|
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0])
|
||||||
actionList.add_action(self.previousItem, u'Preview')
|
actionList.add_action(self.previousItem, u'Preview')
|
||||||
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0])
|
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0])
|
||||||
actionList.add_action(self.nextItem, u'Preview')
|
actionList.add_action(self.nextItem, u'Preview')
|
||||||
|
|
||||||
def setLiveHotkeys(self, parent=None):
|
def setLiveHotkeys(self, parent=None):
|
||||||
actionList = self.parent.actionList
|
|
||||||
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp])
|
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp])
|
||||||
self.previousItem.setShortcutContext(
|
self.previousItem.setShortcutContext(
|
||||||
QtCore.Qt.WidgetWithChildrenShortcut)
|
QtCore.Qt.WidgetWithChildrenShortcut)
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
The :mod:`~openlp.core.utils.actions` module provides action list classes used
|
The :mod:`~openlp.core.utils.actions` module provides action list classes used
|
||||||
by the shortcuts system.
|
by the shortcuts system.
|
||||||
"""
|
"""
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
class ActionCategory(object):
|
class ActionCategory(object):
|
||||||
"""
|
"""
|
||||||
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
|
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
|
||||||
@ -173,6 +175,7 @@ class ActionList(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.categories = CategoryList()
|
self.categories = CategoryList()
|
||||||
|
self.signal = Emit()
|
||||||
|
|
||||||
def add_action(self, action, category=u'Default', weight=None):
|
def add_action(self, action, category=u'Default', weight=None):
|
||||||
if category not in self.categories:
|
if category not in self.categories:
|
||||||
@ -181,3 +184,11 @@ class ActionList(object):
|
|||||||
self.categories[category].actions.append(action)
|
self.categories[category].actions.append(action)
|
||||||
else:
|
else:
|
||||||
self.categories[category].actions.add(action, weight)
|
self.categories[category].actions.add(action, weight)
|
||||||
|
self.signal.emit(QtCore.SIGNAL(u'addedAction()'))
|
||||||
|
|
||||||
|
|
||||||
|
class Emit(QtCore.QObject):
|
||||||
|
def __init__(self):
|
||||||
|
QtCore.QObject.__init__(self)
|
||||||
|
|
||||||
|
actionList = ActionList()
|
||||||
|
@ -30,6 +30,8 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
||||||
from openlp.core.lib.db import Manager
|
from openlp.core.lib.db import Manager
|
||||||
|
from openlp.core.lib.ui import icon_action
|
||||||
|
from openlp.core.utils.actions import actionList
|
||||||
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
|
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
|
||||||
from openlp.plugins.alerts.lib.db import init_schema
|
from openlp.plugins.alerts.lib.db import init_schema
|
||||||
from openlp.plugins.alerts.forms import AlertForm
|
from openlp.plugins.alerts.forms import AlertForm
|
||||||
@ -58,9 +60,9 @@ class AlertsPlugin(Plugin):
|
|||||||
use it as their parent.
|
use it as their parent.
|
||||||
"""
|
"""
|
||||||
log.info(u'add tools menu')
|
log.info(u'add tools menu')
|
||||||
self.toolsAlertItem = QtGui.QAction(tools_menu)
|
self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem',
|
||||||
self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png'))
|
u':/plugins/plugin_alerts.png')
|
||||||
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
|
actionList.add_action(self.toolsAlertItem, u'Extra')
|
||||||
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
|
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
|
||||||
self.toolsAlertItem.setStatusTip(
|
self.toolsAlertItem.setStatusTip(
|
||||||
translate('AlertsPlugin', 'Show an alert message.'))
|
translate('AlertsPlugin', 'Show an alert message.'))
|
||||||
|
Loading…
Reference in New Issue
Block a user