From cff333ddc20e7e1c5e1b01381c0674acd8914532 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 7 Oct 2010 23:27:26 +0200 Subject: [PATCH 1/8] Added a shortcut list dialog shell. --- openlp/core/ui/__init__.py | 1 + openlp/core/ui/mainwindow.py | 122 ++++++------ openlp/core/ui/shortcutlistdialog.py | 116 ++++++++++++ openlp/core/ui/shortcutlistform.py | 43 +++++ resources/forms/shortcutlistdialog.ui | 179 ++++++++++++++++++ resources/images/clear_shortcut.png | Bin 0 -> 644 bytes resources/images/openlp-2.qrc | 2 + .../images/system_configure_shortcuts.png | Bin 0 -> 847 bytes 8 files changed, 410 insertions(+), 53 deletions(-) create mode 100644 openlp/core/ui/shortcutlistdialog.py create mode 100644 openlp/core/ui/shortcutlistform.py create mode 100644 resources/forms/shortcutlistdialog.ui create mode 100644 resources/images/clear_shortcut.png create mode 100644 resources/images/system_configure_shortcuts.png diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 80d677386..0224c9e15 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -52,6 +52,7 @@ from advancedtab import AdvancedTab from aboutform import AboutForm from pluginform import PluginForm from settingsform import SettingsForm +from shortcutlistform import ShortcutListForm from mediadockmanager import MediaDockManager from servicemanager import ServiceManager from thememanager import ThemeManager diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 81487e4f8..70618a3ce 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -29,7 +29,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ - ThemeManager, SlideController, PluginForm, MediaDockManager + ThemeManager, SlideController, PluginForm, MediaDockManager, \ + ShortcutListForm from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ SettingsManager, PluginManager, Receiver, translate from openlp.core.utils import AppLocation, add_actions, LanguageManager @@ -98,6 +99,12 @@ class Ui_MainWindow(object): self.screens) self.LiveController = SlideController(self, self.settingsmanager, self.screens, True) + previewVisible = QtCore.QSettings().value( + u'user interface/preview panel', QtCore.QVariant(True)).toBool() + self.PreviewController.Panel.setVisible(previewVisible) + liveVisible = QtCore.QSettings().value(u'user interface/live panel', + QtCore.QVariant(True)).toBool() + self.LiveController.Panel.setVisible(liveVisible) # Create menu self.MenuBar = QtGui.QMenuBar(MainWindow) self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27)) @@ -196,10 +203,6 @@ class Ui_MainWindow(object): self.ExportThemeItem.setObjectName(u'ExportThemeItem') self.ExportLanguageItem = QtGui.QAction(MainWindow) self.ExportLanguageItem.setObjectName(u'ExportLanguageItem') - self.SettingsConfigureItem = QtGui.QAction(MainWindow) - self.SettingsConfigureItem.setIcon( - build_icon(u':/system/system_settings.png')) - self.SettingsConfigureItem.setObjectName(u'SettingsConfigureItem') self.ViewMediaManagerItem = QtGui.QAction(MainWindow) self.ViewMediaManagerItem.setCheckable(True) self.ViewMediaManagerItem.setChecked(self.MediaManagerDock.isVisible()) @@ -219,24 +222,35 @@ class Ui_MainWindow(object): self.ViewServiceManagerItem.setIcon( build_icon(u':/system/system_servicemanager.png')) self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') + self.ViewPreviewPanel = QtGui.QAction(MainWindow) + self.ViewPreviewPanel.setCheckable(True) + self.ViewPreviewPanel.setChecked(previewVisible) + self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') + self.ViewLivePanel = QtGui.QAction(MainWindow) + self.ViewLivePanel.setCheckable(True) + self.ViewLivePanel.setChecked(liveVisible) + self.ViewLivePanel.setObjectName(u'ViewLivePanel') + self.ModeDefaultItem = QtGui.QAction(MainWindow) + self.ModeDefaultItem.setCheckable(True) + self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') + self.ModeSetupItem = QtGui.QAction(MainWindow) + self.ModeSetupItem.setCheckable(True) + self.ModeSetupItem.setObjectName(u'ModeLiveItem') + self.ModeLiveItem = QtGui.QAction(MainWindow) + self.ModeLiveItem.setCheckable(True) + self.ModeLiveItem.setObjectName(u'ModeLiveItem') + 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 = QtGui.QAction(MainWindow) + self.ToolsAddToolItem.setIcon(build_icon(u':/tools/tools_add.png')) + self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') self.SettingsPluginListItem = QtGui.QAction(MainWindow) self.SettingsPluginListItem.setIcon( build_icon(u':/system/settings_plugin_list.png')) self.SettingsPluginListItem.setObjectName(u'SettingsPluginListItem') - 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) - self.HelpAboutItem = QtGui.QAction(MainWindow) - self.HelpAboutItem.setIcon( - build_icon(u':/system/system_about.png')) - self.HelpAboutItem.setObjectName(u'HelpAboutItem') - self.HelpOnlineHelpItem = QtGui.QAction(MainWindow) - self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') - self.HelpOnlineHelpItem.setEnabled(False) - self.HelpWebSiteItem = QtGui.QAction(MainWindow) - self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') #i18n Language Items self.AutoLanguageItem = QtGui.QAction(MainWindow) self.AutoLanguageItem.setObjectName(u'AutoLanguageItem') @@ -253,37 +267,28 @@ class Ui_MainWindow(object): languageItem.setChecked(True) add_actions(self.LanguageGroup, [languageItem]) self.LanguageGroup.setDisabled(LanguageManager.auto_language) - self.ToolsAddToolItem = QtGui.QAction(MainWindow) - self.ToolsAddToolItem.setIcon(build_icon(u':/tools/tools_add.png')) - self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') - self.ViewPreviewPanel = QtGui.QAction(MainWindow) - self.ViewPreviewPanel.setCheckable(True) - previewVisible = QtCore.QSettings().value( - u'user interface/preview panel', QtCore.QVariant(True)).toBool() - self.ViewPreviewPanel.setChecked(previewVisible) - self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') - self.PreviewController.Panel.setVisible(previewVisible) - self.ViewLivePanel = QtGui.QAction(MainWindow) - self.ViewLivePanel.setCheckable(True) - liveVisible = QtCore.QSettings().value(u'user interface/live panel', - QtCore.QVariant(True)).toBool() - self.ViewLivePanel.setChecked(liveVisible) - self.ViewLivePanel.setObjectName(u'ViewLivePanel') - self.LiveController.Panel.setVisible(liveVisible) - self.ModeDefaultItem = QtGui.QAction(MainWindow) - self.ModeDefaultItem.setCheckable(True) - self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') - self.ModeSetupItem = QtGui.QAction(MainWindow) - self.ModeSetupItem.setCheckable(True) - self.ModeSetupItem.setObjectName(u'ModeLiveItem') - self.ModeLiveItem = QtGui.QAction(MainWindow) - self.ModeLiveItem.setCheckable(True) - self.ModeLiveItem.setObjectName(u'ModeLiveItem') - 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.SettingsShortcutsItem = QtGui.QAction(MainWindow) + self.SettingsShortcutsItem.setIcon( + build_icon(u':/system/system_configure_shortcuts.png')) + self.SettingsShortcutsItem.setObjectName(u'SettingsShortcutsItem') + self.SettingsConfigureItem = QtGui.QAction(MainWindow) + self.SettingsConfigureItem.setIcon( + build_icon(u':/system/system_settings.png')) + self.SettingsConfigureItem.setObjectName(u'SettingsConfigureItem') + 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) + self.HelpAboutItem = QtGui.QAction(MainWindow) + self.HelpAboutItem.setIcon( + build_icon(u':/system/system_about.png')) + self.HelpAboutItem.setObjectName(u'HelpAboutItem') + self.HelpOnlineHelpItem = QtGui.QAction(MainWindow) + self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') + self.HelpOnlineHelpItem.setEnabled(False) + self.HelpWebSiteItem = QtGui.QAction(MainWindow) + self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) add_actions(self.FileExportMenu, @@ -303,7 +308,7 @@ class Ui_MainWindow(object): add_actions(self.SettingsLanguageMenu, self.LanguageGroup.actions()) add_actions(self.SettingsMenu, (self.SettingsPluginListItem, self.SettingsLanguageMenu.menuAction(), None, - self.SettingsConfigureItem)) + self.SettingsShortcutsItem, self.SettingsConfigureItem)) add_actions(self.ToolsMenu, (self.ToolsAddToolItem, None)) add_actions(self.HelpMenu, @@ -394,6 +399,8 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', '&Theme')) self.ExportLanguageItem.setText( translate('OpenLP.MainWindow', '&Language')) + self.SettingsShortcutsItem.setText( + translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) self.SettingsConfigureItem.setText( translate('OpenLP.MainWindow', '&Configure OpenLP...')) self.ViewMediaManagerItem.setText( @@ -506,6 +513,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.settingsmanager = SettingsManager(screens) self.aboutForm = AboutForm(self, applicationVersion) self.settingsForm = SettingsForm(self.screens, self, self) + self.shortcutForm = ShortcutListForm(self) self.recentFiles = QtCore.QStringList() # Set up the path with plugins pluginpath = AppLocation.get_directory(AppLocation.PluginsDir) @@ -551,7 +559,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.SettingsPluginListItem, QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.QObject.connect(self.SettingsConfigureItem, - QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) + QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked) + QtCore.QObject.connect(self.SettingsShortcutsItem, + QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked) QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onNewService) QtCore.QObject.connect(self.FileOpenItem, @@ -712,12 +722,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.pluginForm.load() self.pluginForm.exec_() - def onOptionsSettingsItemClicked(self): + def onSettingsConfigureItemClicked(self): """ Show the Settings dialog """ self.settingsForm.exec_() + def onSettingsShortcutsItemClicked(self): + """ + Show the shortcuts dialog + """ + self.shortcutForm.exec_() + def onModeDefaultItemClicked(self): """ Put OpenLP into "Default" view mode. diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py new file mode 100644 index 000000000..972d0cf9c --- /dev/null +++ b/openlp/core/ui/shortcutlistdialog.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate, build_icon + +class Ui_ShortcutListDialog(object): + def setupUi(self, shortcutListDialog): + shortcutListDialog.setObjectName(u'shortcutListDialog') + shortcutListDialog.resize(500, 438) + self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog) + self.shortcutListLayout.setSpacing(8) + self.shortcutListLayout.setMargin(8) + self.shortcutListLayout.setObjectName(u'shortcutListLayout') + self.shortcutListTableWidget = QtGui.QTableWidget(shortcutListDialog) + self.shortcutListTableWidget.setAlternatingRowColors(True) + self.shortcutListTableWidget.setObjectName(u'shortcutListTableWidget') + self.shortcutListTableWidget.setColumnCount(2) + self.shortcutListTableWidget.setRowCount(0) + self.shortcutListTableWidget.setHorizontalHeaderItem(0, + QtGui.QTableWidgetItem()) + self.shortcutListTableWidget.setHorizontalHeaderItem(1, + QtGui.QTableWidgetItem()) + self.shortcutListTableWidget.verticalHeader().setVisible(False) + self.shortcutListLayout.addWidget(self.shortcutListTableWidget) + self.shortcutLayout = QtGui.QVBoxLayout() + self.shortcutLayout.setSpacing(8) + self.shortcutLayout.setContentsMargins(0, -1, -1, -1) + self.shortcutLayout.setObjectName(u'shortcutLayout') + self.defaultRadioButton = QtGui.QRadioButton(shortcutListDialog) + self.defaultRadioButton.setChecked(True) + self.defaultRadioButton.setObjectName(u'defaultRadioButton') + self.shortcutLayout.addWidget(self.defaultRadioButton) + self.customShortcutLayout = QtGui.QHBoxLayout() + self.customShortcutLayout.setSpacing(8) + self.customShortcutLayout.setObjectName(u'customShortcutLayout') + self.customRadioButton = QtGui.QRadioButton(shortcutListDialog) + self.customRadioButton.setObjectName(u'customRadioButton') + self.customShortcutLayout.addWidget(self.customRadioButton) + self.shortcutPushButton = QtGui.QPushButton(shortcutListDialog) + self.shortcutPushButton.setMinimumSize(QtCore.QSize(84, 0)) + self.shortcutPushButton.setIcon( + build_icon(u':/system/system_settings.png')) + self.shortcutPushButton.setCheckable(True) + self.shortcutPushButton.setChecked(False) + self.shortcutPushButton.setObjectName(u'shortcutPushButton') + self.customShortcutLayout.addWidget(self.shortcutPushButton) + self.clearShortcutToolButton = QtGui.QToolButton(shortcutListDialog) + self.clearShortcutToolButton.setMinimumSize(QtCore.QSize(0, 16)) + self.clearShortcutToolButton.setText(u'') + self.clearShortcutToolButton.setIcon( + build_icon(u':/system/clear_shortcut.png')) + self.clearShortcutToolButton.setObjectName(u'clearShortcutToolButton') + self.customShortcutLayout.addWidget(self.clearShortcutToolButton) + self.customShortcutSpacer = QtGui.QSpacerItem(40, 20, + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.customShortcutLayout.addItem(self.customShortcutSpacer) + self.shortcutLayout.addLayout(self.customShortcutLayout) + self.shortcutListLayout.addLayout(self.shortcutLayout) + self.shortcutListButtonBox = QtGui.QDialogButtonBox(shortcutListDialog) + self.shortcutListButtonBox.setOrientation(QtCore.Qt.Horizontal) + self.shortcutListButtonBox.setStandardButtons( + QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok | + QtGui.QDialogButtonBox.Reset) + self.shortcutListButtonBox.setObjectName(u'shortcutListButtonBox') + self.shortcutListLayout.addWidget(self.shortcutListButtonBox) + + self.retranslateUi(shortcutListDialog) + QtCore.QObject.connect( + self.shortcutListButtonBox, + QtCore.SIGNAL(u'accepted()'), + shortcutListDialog.accept + ) + QtCore.QObject.connect( + self.shortcutListButtonBox, + QtCore.SIGNAL(u'rejected()'), + shortcutListDialog.reject + ) + QtCore.QMetaObject.connectSlotsByName(shortcutListDialog) + + def retranslateUi(self, shortcutListDialog): + shortcutListDialog.setWindowTitle( + translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) + self.shortcutListTableWidget.horizontalHeaderItem(0).setText( + translate(u'OpenLP.ShortcutListDialog', 'Action')) + self.shortcutListTableWidget.horizontalHeaderItem(1).setText( + translate(u'OpenLP.ShortcutListDialog', 'Shortcut')) + self.defaultRadioButton.setText( + translate('OpenLP.ShortcutListDialog', 'Default: %s')) + self.customRadioButton.setText( + translate('OpenLP.ShortcutListDialog', 'Custom:')) + self.shortcutPushButton.setText('') diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py new file mode 100644 index 000000000..b3a98a380 --- /dev/null +++ b/openlp/core/ui/shortcutlistform.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from PyQt4 import QtCore, QtGui + +from shortcutlistdialog import Ui_ShortcutListDialog + +class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): + """ + The shortcut list dialog + """ + + def __init__(self, parent): + """ + Do some initialisation stuff + """ + QtGui.QDialog.__init__(self, parent) + self.setupUi(self) + #QtCore.QObject.connect(self.contributeButton, + # QtCore.SIGNAL(u'clicked()'), self.onContributeButtonClicked) diff --git a/resources/forms/shortcutlistdialog.ui b/resources/forms/shortcutlistdialog.ui new file mode 100644 index 000000000..519925560 --- /dev/null +++ b/resources/forms/shortcutlistdialog.ui @@ -0,0 +1,179 @@ + + + ShortcutListDialog + + + + 0 + 0 + 500 + 438 + + + + Dialog + + + + 8 + + + 8 + + + + + true + + + false + + + + Action + + + + + Shortcut + + + + + + + + 8 + + + 0 + + + + + Default: None + + + true + + + + + + + 8 + + + + + Custom: + + + + + + + + 84 + 0 + + + + None + + + + :/system/system_settings.png:/system/system_settings.png + + + true + + + false + + + + + + + + 0 + 16 + + + + + + + + :/system/clear_shortcut.png:/system/clear_shortcut.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset + + + + + + + + + + + shortcutListButtonBox + accepted() + ShortcutListDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + shortcutListButtonBox + rejected() + ShortcutListDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/resources/images/clear_shortcut.png b/resources/images/clear_shortcut.png new file mode 100644 index 0000000000000000000000000000000000000000..6c4b83b7ac6e451f461973dac0c9a6c53dedef25 GIT binary patch literal 644 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJbFq_W2nPqp?T7vkfLzW3kH}&M z2FBeW%xLxI@gtz1WQl7;NpOBzNqJ&XDnogBxn5>oc5!lIL8@MUQTpt6Hc~*(*`Bv~l~6?FSDYJaY8Nv17;1UpRl|%9VTf?mc|? z@cHxSFJHcV_3G8zw{Jgu`0)Aj=PzHr{QC9l_wV0-{`@KR`o0Pn77`^ve!&d#@_Ksq z_8}pusXI=cy7Kht(+?kh{P_EqYvr0*Ks9qcT^vIsBJkEM|1so z>*;dxIy;s3ojI&$kq&AP_I<(sjr system_close.png + clear_shortcut.png system_about.png system_help_contents.png system_mediamanager.png @@ -101,6 +102,7 @@ system_exit.png settings_plugin_list.png system_settings.png + system_configure_shortcuts.png media_time.png diff --git a/resources/images/system_configure_shortcuts.png b/resources/images/system_configure_shortcuts.png new file mode 100644 index 0000000000000000000000000000000000000000..6d9ef70af1ed22d1cfb081f1f729777f0cebaec6 GIT binary patch literal 847 zcmV-V1F-ywP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2iXAy z6*vWsLl-Il00PfRL_t(|+KrQ2NRwe4#-DHVu$I#))1eoFj-1UFhy?|Skdp$LAoxQsSUHjgwW-1pcV)oQUkpx4ZHG?f^?BhCkflET$DJty; ze|T^H&-*;j%S&Mos;aL^^YZdF6osQsr*q@O$M<~|<&{0On@Peh`wk~Wh0ZOSnbYNy?1`OjxWMpKBPFFwL(5TCrel^tvLJb4(-%TJOCRUa} z2!Xb?4tBd8a=HA7aNqtBafrBNXz1xY0Op?pB_)LlX@pezY-}8%p~d*9 zUS4khqIof=&0yeO!KId<2;+7TM>r z8NI&k1^{bPQWAthq3;dGF+v^45e>Pd`_JvViBbaA))0t*BJaCCQf zL$BAPrltmL9I$)aU2u-tjRv(+dAO3MJ Date: Fri, 8 Oct 2010 18:07:52 +0200 Subject: [PATCH 2/8] Added the ability to capture a shortcut. --- openlp/core/ui/shortcutlistdialog.py | 3 +- openlp/core/ui/shortcutlistform.py | 43 ++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 972d0cf9c..358a63d22 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -113,4 +113,5 @@ class Ui_ShortcutListDialog(object): translate('OpenLP.ShortcutListDialog', 'Default: %s')) self.customRadioButton.setText( translate('OpenLP.ShortcutListDialog', 'Custom:')) - self.shortcutPushButton.setText('') + self.shortcutPushButton.setText( + translate('OpenLP.ShortcutListDialog', 'None')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index b3a98a380..e34665f33 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -26,6 +26,7 @@ from PyQt4 import QtCore, QtGui +from openlp.core.utils import translate from shortcutlistdialog import Ui_ShortcutListDialog class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): @@ -39,5 +40,43 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - #QtCore.QObject.connect(self.contributeButton, - # QtCore.SIGNAL(u'clicked()'), self.onContributeButtonClicked) + QtCore.QObject.connect( + self.shortcutPushButton, + QtCore.SIGNAL(u'toggled(bool)'), + self.onShortcutPushButtonClicked + ) + + def keyReleaseEvent(self, event): + Qt = QtCore.Qt + if not self.captureShortcut: + return + key = event.key() + if key == Qt.Key_Shift or key == Qt.Key_Control or \ + key == Qt.Key_Meta or key == Qt.Key_Alt: + return + key_string = QtGui.QKeySequence(key).toString() + if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier: + key_string = u'Ctrl+' + key_string + if event.modifiers() & Qt.AltModifier == Qt.AltModifier: + key_string = u'Alt+' + key_string + if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: + key_string = u'Shift+' + key_string; + key_sequence = QtGui.QKeySequence(key_string) + existing_key = QtGui.QKeySequence("Ctrl+Shift+F8") + if key_sequence == existing_key: + QtGui.QMessageBox.warning( + self, + translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), + unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut ' + '"%s" is already assigned to another action, please ' + 'use a different shortcut.')) % key_sequence.toString(), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), + QtGui.QMessageBox.Ok + ) + else: + self.shortcutPushButton.setText(key_sequence.toString()) + self.shortcutPushButton.setChecked(False) + self.captureShortcut = False + + def onShortcutPushButtonClicked(self, toggled): + self.captureShortcut = toggled From 49faf7fb1fcf31819b122348bedcb19494e8e277 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 21 Oct 2010 09:42:13 +0200 Subject: [PATCH 3/8] Working on bringing actions into the shortcut form. --- openlp/core/ui/mainwindow.py | 29 +++++++++++++++++++++++++++- openlp/core/ui/shortcutlistdialog.py | 4 +++- openlp/core/ui/shortcutlistform.py | 26 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 70618a3ce..effc246bb 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -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): """ diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 358a63d22..dd1fc3374 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -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') diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index e34665f33..cd37388be 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -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 + From 574d108a8284745a1e45b6af5b59402e2b255eb3 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 27 Oct 2010 15:49:21 +0200 Subject: [PATCH 4/8] Started working on some list classes to create nice categorised action lists. --- openlp/core/utils/__init__.py | 121 ++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 119bf6b55..1d0b8a0fc 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -198,6 +198,127 @@ class AppLocation(object): return path +class ActionCategory(object): + """ + The :class:`~openlp.core.utils.ActionCategory` class encapsulates a + category for the :class:`~openlp.core.utils.CategoryList` class. + """ + def __init__(self, name, weight=0): + self.name = name + self.weight = weight + self.actions = CategoryActionList() + + +class CategoryActionList(object): + """ + The :class:`~openlp.core.utils.CategoryActionList` class provides a sorted + list of actions within a category. + """ + def __init__(self): + self.index = 0 + self.actions = [] + + def __iter__(self): + return self + + def __next__(self): + """ + Python 3 "next" method. + """ + if self.index >= len(self.actions): + raise StopIteration + else: + self.index += 1 + return self.actions[self.index - 1][0] + + def next(self): + """ + Python 2 "next" method. + """ + return self.__next__() + + def add(self, action, weight=0): + self.actions.append((weight, action)) + self.actions.sort(key=lambda act: act[0]) + + +class CategoryList(object): + """ + The :class:`~openlp.core.utils.ActionListCategory` class encapsulates a + category list for the :class:`~openlp.core.utils.ActionList` class and + provides an iterator interface for walking through the list of actions in + this category. + """ + + def __init__(self): + self.index = 0 + self.categories = [] + + def __iter__(self): + return self + + def __next__(self): + """ + Python 3 "next" method for iterator. + """ + if self.index >= len(self.categories): + raise StopIteration + else: + self.index += 1 + return self.categories[self.index - 1][0] + + def next(self): + """ + Python 2 "next" method for iterator. + """ + return self.__next__() + + def add(self, name, weight=0): + self.categories.append(ActionCategory(name, weight)) + self.categories.sort(key=lambda cat: cat.weight) + + +class ActionList(object): + """ + The :class:`~openlp.core.utils.ActionList` class contains a list of menu + actions and categories associated with those actions. Each category also + has a weight by which it is sorted when iterating through the list of + actions or categories. + """ + def __init__(self): + self.categories = CategoryList() + + def add_category(self, category, weight=0): + """ + Add a category to the action list, ordered by ``weight``. + + ``category`` + The name of the category. + + ``weight`` + **Defaults to 0.** The weight of the category. The weight + determines the sort order, with negative items appearing + higher than positive items. + """ + self.categories.add(category, weight) + + def has_category(self, category): + for cat in self.categories: + if cat[u'name'] == category: + return True + return False + + def add_action(self, action, category=u'Default', weight=0): + if not self.has_category: + self.add_category(category) + for index, cat in enumerate(self.categories): + if cat[u'name'] == category: + self.categories[index][u'actions'].append((weight, action)) + return + + + + def check_latest_version(current_version): """ Check the latest version of OpenLP against the version file on the OpenLP From fceb9d897898449ca3393a8f2e08165a517f7a71 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 27 Oct 2010 17:35:15 +0200 Subject: [PATCH 5/8] Separated action list stuff into its own file. --- openlp/core/utils/__init__.py | 121 --------------------------- openlp/core/utils/actions.py | 148 ++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 121 deletions(-) create mode 100644 openlp/core/utils/actions.py diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 1d0b8a0fc..119bf6b55 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -198,127 +198,6 @@ class AppLocation(object): return path -class ActionCategory(object): - """ - The :class:`~openlp.core.utils.ActionCategory` class encapsulates a - category for the :class:`~openlp.core.utils.CategoryList` class. - """ - def __init__(self, name, weight=0): - self.name = name - self.weight = weight - self.actions = CategoryActionList() - - -class CategoryActionList(object): - """ - The :class:`~openlp.core.utils.CategoryActionList` class provides a sorted - list of actions within a category. - """ - def __init__(self): - self.index = 0 - self.actions = [] - - def __iter__(self): - return self - - def __next__(self): - """ - Python 3 "next" method. - """ - if self.index >= len(self.actions): - raise StopIteration - else: - self.index += 1 - return self.actions[self.index - 1][0] - - def next(self): - """ - Python 2 "next" method. - """ - return self.__next__() - - def add(self, action, weight=0): - self.actions.append((weight, action)) - self.actions.sort(key=lambda act: act[0]) - - -class CategoryList(object): - """ - The :class:`~openlp.core.utils.ActionListCategory` class encapsulates a - category list for the :class:`~openlp.core.utils.ActionList` class and - provides an iterator interface for walking through the list of actions in - this category. - """ - - def __init__(self): - self.index = 0 - self.categories = [] - - def __iter__(self): - return self - - def __next__(self): - """ - Python 3 "next" method for iterator. - """ - if self.index >= len(self.categories): - raise StopIteration - else: - self.index += 1 - return self.categories[self.index - 1][0] - - def next(self): - """ - Python 2 "next" method for iterator. - """ - return self.__next__() - - def add(self, name, weight=0): - self.categories.append(ActionCategory(name, weight)) - self.categories.sort(key=lambda cat: cat.weight) - - -class ActionList(object): - """ - The :class:`~openlp.core.utils.ActionList` class contains a list of menu - actions and categories associated with those actions. Each category also - has a weight by which it is sorted when iterating through the list of - actions or categories. - """ - def __init__(self): - self.categories = CategoryList() - - def add_category(self, category, weight=0): - """ - Add a category to the action list, ordered by ``weight``. - - ``category`` - The name of the category. - - ``weight`` - **Defaults to 0.** The weight of the category. The weight - determines the sort order, with negative items appearing - higher than positive items. - """ - self.categories.add(category, weight) - - def has_category(self, category): - for cat in self.categories: - if cat[u'name'] == category: - return True - return False - - def add_action(self, action, category=u'Default', weight=0): - if not self.has_category: - self.add_category(category) - for index, cat in enumerate(self.categories): - if cat[u'name'] == category: - self.categories[index][u'actions'].append((weight, action)) - return - - - - def check_latest_version(current_version): """ Check the latest version of OpenLP against the version file on the OpenLP diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py new file mode 100644 index 000000000..6c63a0310 --- /dev/null +++ b/openlp/core/utils/actions.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`~openlp.core.utils.actions` module provides action list classes used +by the shortcuts system. +""" + +class ActionCategory(object): + """ + The :class:`~openlp.core.utils.ActionCategory` class encapsulates a + category for the :class:`~openlp.core.utils.CategoryList` class. + """ + def __init__(self, name, weight=0): + self.name = name + self.weight = weight + self.actions = CategoryActionList() + + +class CategoryActionList(object): + """ + The :class:`~openlp.core.utils.CategoryActionList` class provides a sorted + list of actions within a category. + """ + def __init__(self): + self.index = 0 + self.actions = [] + + def __iter__(self): + return self + + def __next__(self): + """ + Python 3 "next" method. + """ + if self.index >= len(self.actions): + raise StopIteration + else: + self.index += 1 + return self.actions[self.index - 1][1] + + def next(self): + """ + Python 2 "next" method. + """ + return self.__next__() + + def add(self, action, weight=0): + self.actions.append((weight, action)) + self.actions.sort(key=lambda act: act[0]) + + +class CategoryList(object): + """ + The :class:`~openlp.core.utils.ActionListCategory` class encapsulates a + category list for the :class:`~openlp.core.utils.ActionList` class and + provides an iterator interface for walking through the list of actions in + this category. + """ + + def __init__(self): + self.index = 0 + self.categories = CategoryActionList() + + def __iter__(self): + return self + + def __next__(self): + """ + Python 3 "next" method for iterator. + """ + if self.index >= len(self.categories): + raise StopIteration + else: + self.index += 1 + return self.categories[self.index - 1] + + def next(self): + """ + Python 2 "next" method for iterator. + """ + return self.__next__() + + def add(self, name, weight=0): + self.categories.append(ActionCategory(name, weight)) + self.categories.sort(key=lambda cat: cat.weight) + + +class ActionList(object): + """ + The :class:`~openlp.core.utils.ActionList` class contains a list of menu + actions and categories associated with those actions. Each category also + has a weight by which it is sorted when iterating through the list of + actions or categories. + """ + def __init__(self): + self.categories = CategoryList() + + def add_category(self, category, weight=0): + """ + Add a category to the action list, ordered by ``weight``. + + ``category`` + The name of the category. + + ``weight`` + **Defaults to 0.** The weight of the category. The weight + determines the sort order, with negative items appearing + higher than positive items. + """ + self.categories.add(category, weight) + + def has_category(self, category): + for cat in self.categories: + if cat[u'name'] == category: + return True + return False + + def add_action(self, action, category=u'Default', weight=0): + if not self.has_category: + self.add_category(category) + for index, cat in enumerate(self.categories): + if cat[u'name'] == category: + self.categories[index][u'actions'].append((weight, action)) + return + From 419b6469ce8f0e386f4f3e719b4562452ced18b9 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 28 Oct 2010 07:21:45 +0200 Subject: [PATCH 6/8] Finished up the actions list. --- openlp/core/utils/__init__.py | 3 +- openlp/core/utils/actions.py | 103 +++++++++++++++++++++++----------- 2 files changed, 71 insertions(+), 35 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 119bf6b55..23f77291c 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -276,6 +276,7 @@ def get_images_filter(): return images_filter 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'get_filesystem_encoding', u'LanguageManager', u'ActionList'] diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 6c63a0310..ef70b81d6 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -28,6 +28,8 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ +from PyQt4.QtGui import QAction + class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a @@ -48,6 +50,18 @@ class CategoryActionList(object): self.index = 0 self.actions = [] + def __getitem__(self, key): + for weight, action in self.actions: + if action.text() == key: + return action + raise KeyError(u'Action "%s" does not exist.' % key) + + def __contains__(self, item): + return self.has_key(item) + + def __len__(self): + return len(self.actions) + def __iter__(self): return self @@ -67,6 +81,18 @@ class CategoryActionList(object): """ return self.__next__() + def has_key(key): + for weight, action in self.actions: + if action.text() == key: + return True + return False + + def append(self, name): + weight = 0 + if len(self.actions) > 0: + weight = self.actions[-1][0] + 1 + self.add(name, weight) + def add(self, action, weight=0): self.actions.append((weight, action)) self.actions.sort(key=lambda act: act[0]) @@ -74,15 +100,26 @@ class CategoryActionList(object): class CategoryList(object): """ - The :class:`~openlp.core.utils.ActionListCategory` class encapsulates a - category list for the :class:`~openlp.core.utils.ActionList` class and - provides an iterator interface for walking through the list of actions in - this category. + The :class:`~openlp.core.utils.CategoryList` class encapsulates a category + list for the :class:`~openlp.core.utils.ActionList` class and provides an + iterator interface for walking through the list of actions in this category. """ def __init__(self): self.index = 0 - self.categories = CategoryActionList() + self.categories = [] + + def __getitem__(self, key): + for category in self.categories: + if category.name == key: + return category + raise KeyError(u'Category "%s" does not exist.' % key) + + def __contains__(self, item): + return self.has_key(item) + + def __len__(self): + return len(self.categories) def __iter__(self): return self @@ -103,8 +140,30 @@ class CategoryList(object): """ return self.__next__() - def add(self, name, weight=0): - self.categories.append(ActionCategory(name, weight)) + def has_key(name): + for category in self.categories: + if category.name == key: + return True + return False + + def append(self, name, actions=[]): + weight = 0 + if len(self.categories) > 0: + weight = self.categories[-1].weight + 1 + if actions: + self.add(name, weight, actions) + else: + self.add(name, weight) + + def add(self, name, weight=0, actions=[]): + category = ActionCategory(name, weight) + if actions: + for action in actions: + if isinstance(action, tuple): + category.actions.add(action[0], action[1]) + else: + category.actions.append(action) + self.categories.append(category) self.categories.sort(key=lambda cat: cat.weight) @@ -118,31 +177,7 @@ class ActionList(object): def __init__(self): self.categories = CategoryList() - def add_category(self, category, weight=0): - """ - Add a category to the action list, ordered by ``weight``. - - ``category`` - The name of the category. - - ``weight`` - **Defaults to 0.** The weight of the category. The weight - determines the sort order, with negative items appearing - higher than positive items. - """ - self.categories.add(category, weight) - - def has_category(self, category): - for cat in self.categories: - if cat[u'name'] == category: - return True - return False - def add_action(self, action, category=u'Default', weight=0): - if not self.has_category: - self.add_category(category) - for index, cat in enumerate(self.categories): - if cat[u'name'] == category: - self.categories[index][u'actions'].append((weight, action)) - return - + if category not in self.categories: + self.categories.add(category) + self.categories[category].actions.add(action, weight) From 0373f93130ad0ddf12b3b9d4a93e5a53f71dbc19 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 28 Oct 2010 08:36:18 +0200 Subject: [PATCH 7/8] Change the table to a tree. Hook the tree up to the shortcut list. Fix adding actions to shortcut list. --- openlp/core/ui/mainwindow.py | 55 ++++++++++++++-------------- openlp/core/ui/shortcutlistdialog.py | 29 +++++++-------- openlp/core/ui/shortcutlistform.py | 22 ++++++----- openlp/core/utils/actions.py | 13 ++++--- 4 files changed, 60 insertions(+), 59 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e6467db53..871f1afa2 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -33,7 +33,8 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ShortcutListForm from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ SettingsManager, PluginManager, Receiver, translate -from openlp.core.utils import AppLocation, add_actions, LanguageManager +from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ + ActionList log = logging.getLogger(__name__) @@ -184,34 +185,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) + MainWindow.actionList.add_action(self.FileNewItem, u'File') 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) + MainWindow.actionList.add_action(self.FileOpenItem, u'File') 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) + MainWindow.actionList.add_action(self.FileSaveItem, u'File') self.FileSaveAsItem = QtGui.QAction(MainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') - MainWindow.actionList.append(self.FileSaveAsItem) + MainWindow.actionList.add_action(self.FileSaveAsItem, u'File') 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) + MainWindow.actionList.add_action(self.FileExitItem, u'File') self.ImportThemeItem = QtGui.QAction(MainWindow) self.ImportThemeItem.setObjectName(u'ImportThemeItem') - MainWindow.actionList.append(self.ImportThemeItem) + MainWindow.actionList.add_action(self.ImportThemeItem, u'Import') self.ImportLanguageItem = QtGui.QAction(MainWindow) self.ImportLanguageItem.setObjectName(u'ImportLanguageItem') - MainWindow.actionList.append(self.ImportLanguageItem) + MainWindow.actionList.add_action(self.ImportLanguageItem, u'Import') self.ExportThemeItem = QtGui.QAction(MainWindow) self.ExportThemeItem.setObjectName(u'ExportThemeItem') - MainWindow.actionList.append(self.ExportThemeItem) + MainWindow.actionList.add_action(self.ExportThemeItem, u'Export') self.ExportLanguageItem = QtGui.QAction(MainWindow) self.ExportLanguageItem.setObjectName(u'ExportLanguageItem') - MainWindow.actionList.append(self.ExportLanguageItem) + MainWindow.actionList.add_action(self.ExportLanguageItem, u'Export') self.ViewMediaManagerItem = QtGui.QAction(MainWindow) self.ViewMediaManagerItem.setCheckable(True) self.ViewMediaManagerItem.setChecked(self.MediaManagerDock.isVisible()) @@ -224,7 +225,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) + MainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View') self.ViewServiceManagerItem = QtGui.QAction(MainWindow) self.ViewServiceManagerItem.setCheckable(True) self.ViewServiceManagerItem.setChecked( @@ -232,29 +233,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) + MainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View') self.ViewPreviewPanel = QtGui.QAction(MainWindow) self.ViewPreviewPanel.setCheckable(True) self.ViewPreviewPanel.setChecked(previewVisible) self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') - MainWindow.actionList.append(self.ViewPreviewPanel) + MainWindow.actionList.add_action(self.ViewPreviewPanel, u'View') self.ViewLivePanel = QtGui.QAction(MainWindow) self.ViewLivePanel.setCheckable(True) self.ViewLivePanel.setChecked(liveVisible) self.ViewLivePanel.setObjectName(u'ViewLivePanel') - MainWindow.actionList.append(self.ViewLivePanel) + MainWindow.actionList.add_action(self.ViewLivePanel, u'View') self.ModeDefaultItem = QtGui.QAction(MainWindow) self.ModeDefaultItem.setCheckable(True) self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') - MainWindow.actionList.append(self.ModeDefaultItem) + MainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode') self.ModeSetupItem = QtGui.QAction(MainWindow) self.ModeSetupItem.setCheckable(True) self.ModeSetupItem.setObjectName(u'ModeLiveItem') - MainWindow.actionList.append(self.ModeSetupItem) + MainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode') self.ModeLiveItem = QtGui.QAction(MainWindow) self.ModeLiveItem.setCheckable(True) self.ModeLiveItem.setObjectName(u'ModeLiveItem') - MainWindow.actionList.append(self.ModeLiveItem) + MainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode') self.ModeGroup = QtGui.QActionGroup(MainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) @@ -263,17 +264,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) + MainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools') 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) + MainWindow.actionList.add_action(self.SettingsPluginListItem, u'Settings') #i18n Language Items self.AutoLanguageItem = QtGui.QAction(MainWindow) self.AutoLanguageItem.setObjectName(u'AutoLanguageItem') self.AutoLanguageItem.setCheckable(True) - MainWindow.actionList.append(self.AutoLanguageItem) + MainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings') self.LanguageGroup = QtGui.QActionGroup(MainWindow) qmList = LanguageManager.get_qm_list() savedLanguage = LanguageManager.get_language() @@ -294,25 +295,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) + MainWindow.actionList.add_action(self.SettingsShortcutsItem, u'Settings') 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) + MainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help') 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) + MainWindow.actionList.add_action(self.HelpAboutItem, u'Help') self.HelpOnlineHelpItem = QtGui.QAction(MainWindow) self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') self.HelpOnlineHelpItem.setEnabled(False) - MainWindow.actionList.append(self.HelpOnlineHelpItem) + MainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help') self.HelpWebSiteItem = QtGui.QAction(MainWindow) self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') - MainWindow.actionList.append(self.HelpWebSiteItem) + MainWindow.actionList.add_action(self.HelpWebSiteItem, u'Help') add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) add_actions(self.FileExportMenu, @@ -519,7 +520,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.info(u'MainWindow loaded') - actionList = [] + actionList = ActionList() def __init__(self, screens, applicationVersion): """ @@ -528,7 +529,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ QtGui.QMainWindow.__init__(self) self.screens = screens - self.actionList = [] + self.actionList = ActionList() self.applicationVersion = applicationVersion # Set up settings sections for the main application # (not for use by plugins) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index dd1fc3374..49591188a 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -36,19 +36,16 @@ class Ui_ShortcutListDialog(object): self.shortcutListLayout.setSpacing(8) self.shortcutListLayout.setMargin(8) self.shortcutListLayout.setObjectName(u'shortcutListLayout') - self.shortcutListTableWidget = QtGui.QTableWidget(shortcutListDialog) - self.shortcutListTableWidget.setAlternatingRowColors(True) - self.shortcutListTableWidget.setObjectName(u'shortcutListTableWidget') - self.shortcutListTableWidget.setColumnCount(2) - self.shortcutListTableWidget.setRowCount(0) - self.shortcutListTableWidget.setSelectionBehavior( + self.shortcutListTreeWidget = QtGui.QTreeWidget(shortcutListDialog) + self.shortcutListTreeWidget.setAlternatingRowColors(True) + self.shortcutListTreeWidget.setObjectName(u'shortcutListTreeWidget') + self.shortcutListTreeWidget.setColumnCount(2) + self.shortcutListTreeWidget.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) - self.shortcutListTableWidget.setHorizontalHeaderItem(0, - QtGui.QTableWidgetItem()) - self.shortcutListTableWidget.setHorizontalHeaderItem(1, - QtGui.QTableWidgetItem()) - self.shortcutListTableWidget.verticalHeader().setVisible(False) - self.shortcutListLayout.addWidget(self.shortcutListTableWidget) + #self.shortcutListTreeWidget.setHeaderItem(0, QtGui.QTreeWidgetItem()) + #self.shortcutListTreeWidget.setHeaderItem(1, QtGui.QTreeWidgetItem()) + #self.shortcutListTreeWidget.verticalHeader().setVisible(False) + self.shortcutListLayout.addWidget(self.shortcutListTreeWidget) self.shortcutLayout = QtGui.QVBoxLayout() self.shortcutLayout.setSpacing(8) self.shortcutLayout.setContentsMargins(0, -1, -1, -1) @@ -107,10 +104,10 @@ class Ui_ShortcutListDialog(object): def retranslateUi(self, shortcutListDialog): shortcutListDialog.setWindowTitle( translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) - self.shortcutListTableWidget.horizontalHeaderItem(0).setText( - translate(u'OpenLP.ShortcutListDialog', 'Action')) - self.shortcutListTableWidget.horizontalHeaderItem(1).setText( - translate(u'OpenLP.ShortcutListDialog', 'Shortcut')) + self.shortcutListTreeWidget.setHeaderLabels([ + translate(u'OpenLP.ShortcutListDialog', 'Action'), + translate(u'OpenLP.ShortcutListDialog', 'Shortcut') + ]) self.defaultRadioButton.setText( translate('OpenLP.ShortcutListDialog', 'Default: %s')) self.customRadioButton.setText( diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index cd37388be..0316b0ee0 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -47,7 +47,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - self.actionList = [] + self.actionList = None self.captureShortcut = False QtCore.QObject.connect( self.shortcutPushButton, @@ -93,15 +93,17 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): 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() + self.shortcutListTreeWidget.clear() + for category in self.actionList.categories: + item = QtGui.QTreeWidgetItem([category.name]) + for action in category.actions: + actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) + shortcutText = action.shortcut().toString() + actionItem = QtGui.QTreeWidgetItem([actionText, shortcutText]) + actionItem.setIcon(0, action.icon()) + item.addChild(actionItem) + item.setExpanded(True) + self.shortcutListTreeWidget.addTopLevelItem(item) def onShortcutPushButtonClicked(self, toggled): self.captureShortcut = toggled diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index ef70b81d6..893e4adba 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -28,8 +28,6 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ -from PyQt4.QtGui import QAction - class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a @@ -140,7 +138,7 @@ class CategoryList(object): """ return self.__next__() - def has_key(name): + def has_key(self, key): for category in self.categories: if category.name == key: return True @@ -177,7 +175,10 @@ class ActionList(object): def __init__(self): self.categories = CategoryList() - def add_action(self, action, category=u'Default', weight=0): + def add_action(self, action, category=u'Default', weight=None): if category not in self.categories: - self.categories.add(category) - self.categories[category].actions.add(action, weight) + self.categories.append(category) + if weight is None: + self.categories[category].actions.append(action) + else: + self.categories[category].actions.add(action, weight) From 5327f9bc4c9fcd10a0661fcab18325e98bc8c2de Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 30 Oct 2010 09:51:34 +0200 Subject: [PATCH 8/8] Some minor fixes. --- openlp/core/ui/shortcutlistdialog.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 49591188a..d64f4e2fc 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -42,9 +42,6 @@ class Ui_ShortcutListDialog(object): self.shortcutListTreeWidget.setColumnCount(2) self.shortcutListTreeWidget.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) - #self.shortcutListTreeWidget.setHeaderItem(0, QtGui.QTreeWidgetItem()) - #self.shortcutListTreeWidget.setHeaderItem(1, QtGui.QTreeWidgetItem()) - #self.shortcutListTreeWidget.verticalHeader().setVisible(False) self.shortcutListLayout.addWidget(self.shortcutListTreeWidget) self.shortcutLayout = QtGui.QVBoxLayout() self.shortcutLayout.setSpacing(8) @@ -105,8 +102,8 @@ class Ui_ShortcutListDialog(object): shortcutListDialog.setWindowTitle( translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) self.shortcutListTreeWidget.setHeaderLabels([ - translate(u'OpenLP.ShortcutListDialog', 'Action'), - translate(u'OpenLP.ShortcutListDialog', 'Shortcut') + translate('OpenLP.ShortcutListDialog', 'Action'), + translate('OpenLP.ShortcutListDialog', 'Shortcut') ]) self.defaultRadioButton.setText( translate('OpenLP.ShortcutListDialog', 'Default: %s')) @@ -114,3 +111,4 @@ class Ui_ShortcutListDialog(object): translate('OpenLP.ShortcutListDialog', 'Custom:')) self.shortcutPushButton.setText( translate('OpenLP.ShortcutListDialog', 'None')) +