This commit is contained in:
Andreas Preikschat 2011-03-29 18:44:36 +02:00
parent 32240f7bbe
commit d9c2d92c8c
7 changed files with 90 additions and 87 deletions

View File

@ -239,41 +239,47 @@ def create_up_down_push_button_set(parent):
QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked)
return up_button, down_button
def base_action(parent, name):
def base_action(parent, name, category=None):
"""
Return the most basic action with the object name set.
"""
action = QtGui.QAction(parent)
action.setObjectName(name)
if category is not None:
actionList.add_action(action, category)
return action
def checkable_action(parent, name, checked=None):
def checkable_action(parent, name, checked=None, category=None):
"""
Return a standard action with the checkable attribute set.
"""
action = base_action(parent, name)
action = base_action(parent, name, category)
action.setCheckable(True)
if checked is not None:
action.setChecked(checked)
return action
def icon_action(parent, name, icon, checked=None):
def icon_action(parent, name, icon, checked=None, category=None):
"""
Return a standard action with an icon.
``category``
The category the action should be listed in the shortcut dialog. If you
not wish, that this action is added to the shortcut dialog, then do not
state any.
"""
if checked is not None:
action = checkable_action(parent, name, checked)
action = checkable_action(parent, name, checked, category)
else:
action = base_action(parent, name)
action = base_action(parent, name, category)
action.setIcon(build_icon(icon))
#actionList.add_action(action, name)
return action
def shortcut_action(parent, text, shortcuts, function):
def shortcut_action(parent, text, shortcuts, function, category=None):
"""
Return a shortcut enabled action.
"""
action = QtGui.QAction(text, parent)
action = base_action(parent, text, category)
action.setShortcuts(shortcuts)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function)

View File

@ -39,7 +39,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
get_application_version
from openlp.core.utils.actions import actionList
#from openlp.core.utils.actions import actionList
log = logging.getLogger(__name__)
@ -163,72 +163,60 @@ class Ui_MainWindow(object):
self.themeManagerDock)
# Create the menu items
self.FileNewItem = icon_action(mainWindow, u'FileNewItem',
u':/general/general_new.png')
actionList.add_action(self.FileNewItem, u'File')
u':/general/general_new.png', category=u'File')
self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem',
u':/general/general_open.png')
actionList.add_action(self.FileOpenItem, u'File')
u':/general/general_open.png', category=u'File')
self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem',
u':/general/general_save.png')
actionList.add_action(self.FileSaveItem, u'File')
self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem')
actionList.add_action(self.FileSaveAsItem, u'File')
u':/general/general_save.png', category=u'File')
self.FileSaveAsItem = base_action(
mainWindow, u'FileSaveAsItem', u'File')
self.printServiceOrderItem = base_action(
mainWindow, u'printServiceItem')
actionList.add_action(self.printServiceOrderItem, u'File')
mainWindow, u'printServiceItem', u'File')
self.FileExitItem = icon_action(mainWindow, u'FileExitItem',
u':/system/system_exit.png')
actionList.add_action(self.FileExitItem, u'File')
self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem')
actionList.add_action(self.ImportThemeItem, u'Import')
self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem')
actionList.add_action(self.ImportLanguageItem, u'Import')
self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem')
actionList.add_action(self.ExportThemeItem, u'Export')
self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem')
actionList.add_action(self.ExportLanguageItem, u'Export')
u':/system/system_exit.png', category=u'File')
self.ImportThemeItem = base_action(
mainWindow, u'ImportThemeItem', u'Import')
self.ImportLanguageItem = base_action(
mainWindow, u'ImportLanguageItem', u'Import')
self.ExportThemeItem = base_action(
mainWindow, u'ExportThemeItem', u'Export')
self.ExportLanguageItem = base_action(
mainWindow, u'ExportLanguageItem', u'Export')
self.ViewMediaManagerItem = icon_action(mainWindow,
u'ViewMediaManagerItem', u':/system/system_mediamanager.png',
self.mediaManagerDock.isVisible())
self.mediaManagerDock.isVisible(), u'View')
self.ViewThemeManagerItem = icon_action(mainWindow,
u'ViewThemeManagerItem', u':/system/system_thememanager.png',
self.themeManagerDock.isVisible())
actionList.add_action(self.ViewMediaManagerItem, u'View')
self.themeManagerDock.isVisible(), u'View')
self.ViewServiceManagerItem = icon_action(mainWindow,
u'ViewServiceManagerItem', u':/system/system_servicemanager.png',
self.serviceManagerDock.isVisible())
actionList.add_action(self.ViewServiceManagerItem, u'View')
self.serviceManagerDock.isVisible(), u'View')
self.ViewPreviewPanel = checkable_action(mainWindow,
u'ViewPreviewPanel', previewVisible)
actionList.add_action(self.ViewPreviewPanel, u'View')
self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel',
liveVisible)
actionList.add_action(self.ViewLivePanel, u'View')
self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem')
actionList.add_action(self.ModeDefaultItem, u'View Mode')
self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem')
actionList.add_action(self.ModeSetupItem, u'View Mode')
self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True)
actionList.add_action(self.ModeLiveItem, u'View Mode')
u'ViewPreviewPanel', previewVisible, u'View')
self.ViewLivePanel = checkable_action(
mainWindow, u'ViewLivePanel', liveVisible, u'View')
self.ModeDefaultItem = checkable_action(
mainWindow, u'ModeDefaultItem', category=u'View Mode')
self.ModeSetupItem = checkable_action(
mainWindow, u'ModeLiveItem', category=u'View Mode')
self.ModeLiveItem = checkable_action(
mainWindow, u'ModeLiveItem', True, u'View Mode')
self.ModeGroup = QtGui.QActionGroup(mainWindow)
self.ModeGroup.addAction(self.ModeDefaultItem)
self.ModeGroup.addAction(self.ModeSetupItem)
self.ModeGroup.addAction(self.ModeLiveItem)
self.ModeDefaultItem.setChecked(True)
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
u':/tools/tools_add.png')
actionList.add_action(self.ToolsAddToolItem, u'Tools')
self.ToolsOpenDataFolder = icon_action(mainWindow,
u'ToolsOpenDataFolder', u':/general/general_open.png')
actionList.add_action(self.ToolsOpenDataFolder, u'Tools')
u':/tools/tools_add.png', category=u'Tools')
self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder',
u':/general/general_open.png', category=u'Tools')
self.settingsPluginListItem = icon_action(mainWindow,
u'settingsPluginListItem', u':/system/settings_plugin_list.png')
actionList.add_action(self.settingsPluginListItem,
u'Settings')
u'settingsPluginListItem', u':/system/settings_plugin_list.png',
category=u'Settings')
# i18n Language Items
self.AutoLanguageItem = checkable_action(mainWindow,
u'AutoLanguageItem', LanguageManager.auto_language)
actionList.add_action(self.AutoLanguageItem, u'Settings')
#actionList.add_action(self.AutoLanguageItem, u'Settings')
self.LanguageGroup = QtGui.QActionGroup(mainWindow)
self.LanguageGroup.setExclusive(True)
self.LanguageGroup.setObjectName(u'LanguageGroup')
@ -241,24 +229,22 @@ class Ui_MainWindow(object):
add_actions(self.LanguageGroup, [languageItem])
self.SettingsShortcutsItem = icon_action(mainWindow,
u'SettingsShortcutsItem',
u':/system/system_configure_shortcuts.png')
u':/system/system_configure_shortcuts.png', category=u'Settings')
self.DisplayTagItem = icon_action(mainWindow,
u'DisplayTagItem', u':/system/tag_editor.png')
u'DisplayTagItem', u':/system/tag_editor.png', category=u'Settings')
self.SettingsConfigureItem = icon_action(mainWindow,
u'SettingsConfigureItem', u':/system/system_settings.png')
actionList.add_action(self.SettingsShortcutsItem,
u'Settings')
u'SettingsConfigureItem', u':/system/system_settings.png',
category=u'Settings')
self.HelpDocumentationItem = icon_action(mainWindow,
u'HelpDocumentationItem', u':/system/system_help_contents.png')
u'HelpDocumentationItem', u':/system/system_help_contents.png',
category=None)#u'Help')
self.HelpDocumentationItem.setEnabled(False)
actionList.add_action(self.HelpDocumentationItem, u'Help')
self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem',
u':/system/system_about.png')
actionList.add_action(self.HelpAboutItem, u'Help')
self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem')
actionList.add_action(self.HelpOnlineHelpItem, u'Help')
self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem')
actionList.add_action(self.helpWebSiteItem, u'Help')
u':/system/system_about.png', category=None)#u'Help')
self.HelpOnlineHelpItem = base_action(
mainWindow, u'HelpOnlineHelpItem', category=u'Help')
self.helpWebSiteItem = base_action(
mainWindow, u'helpWebSiteItem', category=u'Help')
add_actions(self.FileImportMenu,
(self.ImportThemeItem, self.ImportLanguageItem))
add_actions(self.FileExportMenu,

View File

@ -45,6 +45,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
#TODO: ability to remove actions
#TODO: Save shortcuts
#TODO: doc
#TODO: Fix Preview/Live controller (have the same shortcut)
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
@ -89,7 +90,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
# The dialog is opened the first time
if self.treeWidget.topLevelItemCount() == 0:
QtCore.QObject.connect(actionList.signal,
QtCore.SIGNAL(u'addedAction()'), self.initialiseActionList)
QtCore.SIGNAL(u'addedAction()'), self.asdf)
self.initialiseActionList()
self.refreshActionList()
return QtGui.QDialog.exec_(self)
@ -125,6 +126,18 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
item.setExpanded(True)
self.treeWidget.addTopLevelItem(item)
def asdf(self, action, category):
print action
for category in actionList.categories:
item = QtGui.QTreeWidgetItem([category.name])
for action in category.actions:
actionItem = QtGui.QTreeWidgetItem()
actionItem.setIcon(0, action.icon())
actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action))
item.addChild(actionItem)
item.setExpanded(True)
self.treeWidget.addTopLevelItem(item)
def onShortcutButtonClicked(self, toggled):
if toggled:
return

View File

@ -156,15 +156,15 @@ class SlideController(QtGui.QWidget):
self.hideMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Hide'), self.toolbar))
self.blankScreen = icon_action(self.hideMenu, u'Blank Screen',
u':/slides/slide_blank.png', False)
u':/slides/slide_blank.png', False, u'Live Toolbar')
self.blankScreen.setText(
translate('OpenLP.SlideController', 'Blank Screen'))
self.themeScreen = icon_action(self.hideMenu, u'Blank Theme',
u':/slides/slide_theme.png', False)
u':/slides/slide_theme.png', False, u'Live Toolbar')
self.themeScreen.setText(
translate('OpenLP.SlideController', 'Blank to Theme'))
self.desktopScreen = icon_action(self.hideMenu, u'Desktop Screen',
u':/slides/slide_desktop.png', False)
u':/slides/slide_desktop.png', False, u'Live Toolbar')
self.desktopScreen.setText(
translate('OpenLP.SlideController', 'Show Desktop'))
self.hideMenu.setDefaultAction(self.blankScreen)
@ -364,30 +364,27 @@ class SlideController(QtGui.QWidget):
def setPreviewHotkeys(self, parent=None):
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0])
actionList.add_action(self.previousItem, u'Preview')
actionList.add_action(self.previousItem, u'Preview Toolbar')
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0])
actionList.add_action(self.nextItem, u'Preview')
actionList.add_action(self.nextItem, u'Preview Toolbar')
def setLiveHotkeys(self, parent=None):
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp])
self.previousItem.setShortcutContext(
QtCore.Qt.WidgetWithChildrenShortcut)
actionList.add_action(self.previousItem, u'Live')
actionList.add_action(self.previousItem, u'Live Toolbar')
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown])
self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
actionList.add_action(self.nextItem, u'Live')
actionList.add_action(self.nextItem, u'Live Toolbar')
self.previousService = shortcut_action(parent,
translate('OpenLP.SlideController', 'Previous Service'),
[QtCore.Qt.Key_Left, 0], self.servicePrevious)
actionList.add_action(self.previousService, u'Live')
[QtCore.Qt.Key_Left, 0], self.servicePrevious, u'Live Toolbar')
self.nextService = shortcut_action(parent,
translate('OpenLP.SlideController', 'Next Service'),
[QtCore.Qt.Key_Right, 0], self.serviceNext)
actionList.add_action(self.nextService, u'Live')
[QtCore.Qt.Key_Right, 0], self.serviceNext, u'Live Toolbar')
self.escapeItem = shortcut_action(parent,
translate('OpenLP.SlideController', 'Escape Item'),
[QtCore.Qt.Key_Escape, 0], self.liveEscape)
actionList.add_action(self.escapeItem, u'Live')
[QtCore.Qt.Key_Escape, 0], self.liveEscape, u'Live Toolbar')
def liveEscape(self):
self.display.setVisible(False)

View File

@ -495,7 +495,7 @@ def get_uno_instance(resolver):
from languagemanager import LanguageManager
from actions import ActionList
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
u'get_filesystem_encoding', u'LanguageManager', u'ActionList',
u'get_web_page', u'file_is_unicode', u'string_is_unicode',
__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version',
u'add_actions', u'get_filesystem_encoding', u'LanguageManager',
u'ActionList', u'get_web_page', u'file_is_unicode', u'string_is_unicode',
u'get_uno_command', u'get_uno_instance', u'delete_file']

View File

@ -184,7 +184,7 @@ class ActionList(object):
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
self.signal.emit(QtCore.SIGNAL(u'addedAction()'))
self.signal.emit(QtCore.SIGNAL(u'addedAction(QtGui.QAction, QString)'), action, QtCore.QString(category))
class Emit(QtCore.QObject):

View File

@ -62,7 +62,6 @@ class AlertsPlugin(Plugin):
log.info(u'add tools menu')
self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem',
u':/plugins/plugin_alerts.png')
actionList.add_action(self.toolsAlertItem, u'Extra')
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
self.toolsAlertItem.setStatusTip(
translate('AlertsPlugin', 'Show an alert message.'))
@ -76,6 +75,7 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Initialising')
Plugin.initialise(self)
self.toolsAlertItem.setVisible(True)
actionList.add_action(self.toolsAlertItem, u'Tools')
self.liveController.alertTab = self.settings_tab
def finalise(self):
@ -86,6 +86,7 @@ class AlertsPlugin(Plugin):
self.manager.finalise()
Plugin.finalise(self)
self.toolsAlertItem.setVisible(False)
#TODO: remove the action from the actionList
def toggleAlertsState(self):
self.alertsActive = not self.alertsActive