Working on bringing actions into the shortcut form.

This commit is contained in:
Raoul Snyman 2010-10-21 09:42:13 +02:00
parent ecb2022df3
commit 49faf7fb1f
3 changed files with 57 additions and 2 deletions

View File

@ -184,25 +184,34 @@ class Ui_MainWindow(object):
self.FileNewItem = QtGui.QAction(MainWindow)
self.FileNewItem.setIcon(build_icon(u':/general/general_new.png'))
self.FileNewItem.setObjectName(u'FileNewItem')
MainWindow.actionList.append(self.FileNewItem)
self.FileOpenItem = QtGui.QAction(MainWindow)
self.FileOpenItem.setIcon(build_icon(u':/general/general_open.png'))
self.FileOpenItem.setObjectName(u'FileOpenItem')
MainWindow.actionList.append(self.FileOpenItem)
self.FileSaveItem = QtGui.QAction(MainWindow)
self.FileSaveItem.setIcon(build_icon(u':/general/general_save.png'))
self.FileSaveItem.setObjectName(u'FileSaveItem')
MainWindow.actionList.append(self.FileSaveItem)
self.FileSaveAsItem = QtGui.QAction(MainWindow)
self.FileSaveAsItem.setObjectName(u'FileSaveAsItem')
MainWindow.actionList.append(self.FileSaveAsItem)
self.FileExitItem = QtGui.QAction(MainWindow)
self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png'))
self.FileExitItem.setObjectName(u'FileExitItem')
MainWindow.actionList.append(self.FileExitItem)
self.ImportThemeItem = QtGui.QAction(MainWindow)
self.ImportThemeItem.setObjectName(u'ImportThemeItem')
MainWindow.actionList.append(self.ImportThemeItem)
self.ImportLanguageItem = QtGui.QAction(MainWindow)
self.ImportLanguageItem.setObjectName(u'ImportLanguageItem')
MainWindow.actionList.append(self.ImportLanguageItem)
self.ExportThemeItem = QtGui.QAction(MainWindow)
self.ExportThemeItem.setObjectName(u'ExportThemeItem')
MainWindow.actionList.append(self.ExportThemeItem)
self.ExportLanguageItem = QtGui.QAction(MainWindow)
self.ExportLanguageItem.setObjectName(u'ExportLanguageItem')
MainWindow.actionList.append(self.ExportLanguageItem)
self.ViewMediaManagerItem = QtGui.QAction(MainWindow)
self.ViewMediaManagerItem.setCheckable(True)
self.ViewMediaManagerItem.setChecked(self.MediaManagerDock.isVisible())
@ -215,6 +224,7 @@ class Ui_MainWindow(object):
self.ViewThemeManagerItem.setIcon(
build_icon(u':/system/system_thememanager.png'))
self.ViewThemeManagerItem.setObjectName(u'ViewThemeManagerItem')
MainWindow.actionList.append(self.ViewMediaManagerItem)
self.ViewServiceManagerItem = QtGui.QAction(MainWindow)
self.ViewServiceManagerItem.setCheckable(True)
self.ViewServiceManagerItem.setChecked(
@ -222,23 +232,29 @@ class Ui_MainWindow(object):
self.ViewServiceManagerItem.setIcon(
build_icon(u':/system/system_servicemanager.png'))
self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem')
MainWindow.actionList.append(self.ViewServiceManagerItem)
self.ViewPreviewPanel = QtGui.QAction(MainWindow)
self.ViewPreviewPanel.setCheckable(True)
self.ViewPreviewPanel.setChecked(previewVisible)
self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel')
MainWindow.actionList.append(self.ViewPreviewPanel)
self.ViewLivePanel = QtGui.QAction(MainWindow)
self.ViewLivePanel.setCheckable(True)
self.ViewLivePanel.setChecked(liveVisible)
self.ViewLivePanel.setObjectName(u'ViewLivePanel')
MainWindow.actionList.append(self.ViewLivePanel)
self.ModeDefaultItem = QtGui.QAction(MainWindow)
self.ModeDefaultItem.setCheckable(True)
self.ModeDefaultItem.setObjectName(u'ModeDefaultItem')
MainWindow.actionList.append(self.ModeDefaultItem)
self.ModeSetupItem = QtGui.QAction(MainWindow)
self.ModeSetupItem.setCheckable(True)
self.ModeSetupItem.setObjectName(u'ModeLiveItem')
MainWindow.actionList.append(self.ModeSetupItem)
self.ModeLiveItem = QtGui.QAction(MainWindow)
self.ModeLiveItem.setCheckable(True)
self.ModeLiveItem.setObjectName(u'ModeLiveItem')
MainWindow.actionList.append(self.ModeLiveItem)
self.ModeGroup = QtGui.QActionGroup(MainWindow)
self.ModeGroup.addAction(self.ModeDefaultItem)
self.ModeGroup.addAction(self.ModeSetupItem)
@ -247,14 +263,17 @@ class Ui_MainWindow(object):
self.ToolsAddToolItem = QtGui.QAction(MainWindow)
self.ToolsAddToolItem.setIcon(build_icon(u':/tools/tools_add.png'))
self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem')
MainWindow.actionList.append(self.ToolsAddToolItem)
self.SettingsPluginListItem = QtGui.QAction(MainWindow)
self.SettingsPluginListItem.setIcon(
build_icon(u':/system/settings_plugin_list.png'))
self.SettingsPluginListItem.setObjectName(u'SettingsPluginListItem')
MainWindow.actionList.append(self.SettingsPluginListItem)
#i18n Language Items
self.AutoLanguageItem = QtGui.QAction(MainWindow)
self.AutoLanguageItem.setObjectName(u'AutoLanguageItem')
self.AutoLanguageItem.setCheckable(True)
MainWindow.actionList.append(self.AutoLanguageItem)
self.LanguageGroup = QtGui.QActionGroup(MainWindow)
qmList = LanguageManager.get_qm_list()
savedLanguage = LanguageManager.get_language()
@ -275,20 +294,25 @@ class Ui_MainWindow(object):
self.SettingsConfigureItem.setIcon(
build_icon(u':/system/system_settings.png'))
self.SettingsConfigureItem.setObjectName(u'SettingsConfigureItem')
MainWindow.actionList.append(self.SettingsShortcutsItem)
self.HelpDocumentationItem = QtGui.QAction(MainWindow)
self.HelpDocumentationItem.setIcon(
build_icon(u':/system/system_help_contents.png'))
self.HelpDocumentationItem.setObjectName(u'HelpDocumentationItem')
self.HelpDocumentationItem.setEnabled(False)
MainWindow.actionList.append(self.HelpDocumentationItem)
self.HelpAboutItem = QtGui.QAction(MainWindow)
self.HelpAboutItem.setIcon(
build_icon(u':/system/system_about.png'))
self.HelpAboutItem.setObjectName(u'HelpAboutItem')
MainWindow.actionList.append(self.HelpAboutItem)
self.HelpOnlineHelpItem = QtGui.QAction(MainWindow)
self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem')
self.HelpOnlineHelpItem.setEnabled(False)
MainWindow.actionList.append(self.HelpOnlineHelpItem)
self.HelpWebSiteItem = QtGui.QAction(MainWindow)
self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem')
MainWindow.actionList.append(self.HelpWebSiteItem)
add_actions(self.FileImportMenu,
(self.ImportThemeItem, self.ImportLanguageItem))
add_actions(self.FileExportMenu,
@ -495,6 +519,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
log.info(u'MainWindow loaded')
actionList = []
def __init__(self, screens, applicationVersion):
"""
This constructor sets up the interface, the various managers, and the
@ -502,6 +528,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
QtGui.QMainWindow.__init__(self)
self.screens = screens
self.actionList = []
self.applicationVersion = applicationVersion
# Set up settings sections for the main application
# (not for use by plugins)
@ -732,7 +759,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
Show the shortcuts dialog
"""
self.shortcutForm.exec_()
self.shortcutForm.exec_(self.actionList)
def onModeDefaultItemClicked(self):
"""

View File

@ -41,6 +41,8 @@ class Ui_ShortcutListDialog(object):
self.shortcutListTableWidget.setObjectName(u'shortcutListTableWidget')
self.shortcutListTableWidget.setColumnCount(2)
self.shortcutListTableWidget.setRowCount(0)
self.shortcutListTableWidget.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows)
self.shortcutListTableWidget.setHorizontalHeaderItem(0,
QtGui.QTableWidgetItem())
self.shortcutListTableWidget.setHorizontalHeaderItem(1,
@ -64,7 +66,7 @@ class Ui_ShortcutListDialog(object):
self.shortcutPushButton = QtGui.QPushButton(shortcutListDialog)
self.shortcutPushButton.setMinimumSize(QtCore.QSize(84, 0))
self.shortcutPushButton.setIcon(
build_icon(u':/system/system_settings.png'))
build_icon(u':/system/system_configure_shortcuts.png'))
self.shortcutPushButton.setCheckable(True)
self.shortcutPushButton.setChecked(False)
self.shortcutPushButton.setObjectName(u'shortcutPushButton')

View File

@ -24,11 +24,18 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
import re
from PyQt4 import QtCore, QtGui
from openlp.core.utils import translate
from shortcutlistdialog import Ui_ShortcutListDialog
REMOVE_AMPERSAND = re.compile(r'&{1}')
log = logging.getLogger(__name__)
class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
"""
The shortcut list dialog
@ -40,6 +47,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.actionList = []
self.captureShortcut = False
QtCore.QObject.connect(
self.shortcutPushButton,
QtCore.SIGNAL(u'toggled(bool)'),
@ -78,5 +87,22 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.shortcutPushButton.setChecked(False)
self.captureShortcut = False
def exec_(self, actionList):
self.actionList = actionList
self.refreshActions()
return QtGui.QDialog.exec_(self)
def refreshActions(self):
self.shortcutListTableWidget.setRowCount(len(self.actionList))
for index, action in enumerate(self.actionList):
if action.menu().parentWidget():
log.debug(action.menu().parentWidget().objectName())
actionText = unicode(action.text())
actionText = REMOVE_AMPERSAND.sub('', actionText)
self.shortcutListTableWidget.setItem(index, 0, QtGui.QTableWidgetItem(action.icon(), actionText))
self.shortcutListTableWidget.setItem(index, 1, QtGui.QTableWidgetItem(action.shortcut().toString()))
self.shortcutListTableWidget.resizeRowsToContents()
def onShortcutPushButtonClicked(self, toggled):
self.captureShortcut = toggled