removed things, as this did not work

This commit is contained in:
Andreas Preikschat 2011-03-29 21:52:21 +02:00
parent 6f3fd53419
commit b9b0cbbe9c
5 changed files with 43 additions and 46 deletions

View File

@ -177,11 +177,11 @@ class Ui_MainWindow(object):
self.ImportThemeItem = base_action(
mainWindow, u'ImportThemeItem', u'Import')
self.ImportLanguageItem = base_action(
mainWindow, u'ImportLanguageItem', u'Import')
mainWindow, u'ImportLanguageItem')#, u'Import')
self.ExportThemeItem = base_action(
mainWindow, u'ExportThemeItem', u'Export')
self.ExportLanguageItem = base_action(
mainWindow, u'ExportLanguageItem', u'Export')
mainWindow, u'ExportLanguageItem')#, u'Export')
self.ViewMediaManagerItem = icon_action(mainWindow,
u'ViewMediaManagerItem', u':/system/system_mediamanager.png',
self.mediaManagerDock.isVisible(), u'View')
@ -240,7 +240,7 @@ class Ui_MainWindow(object):
category=None)#u'Help')
self.HelpDocumentationItem.setEnabled(False)
self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem',
u':/system/system_about.png', category=None)#u'Help')
u':/system/system_about.png', category=u'Help')
self.HelpOnlineHelpItem = base_action(
mainWindow, u'HelpOnlineHelpItem', category=u'Help')
self.helpWebSiteItem = base_action(

View File

@ -30,6 +30,7 @@ from openlp.core.lib import translate, build_icon
class Ui_ShortcutListDialog(object):
def setupUi(self, shortcutListDialog):
shortcutListDialog.resize(440, 450)
shortcutListDialog.setObjectName(u'shortcutListDialog')
self.dialogLayout = QtGui.QVBoxLayout(shortcutListDialog)
self.dialogLayout.setObjectName(u'dialogLayout')
@ -52,6 +53,7 @@ class Ui_ShortcutListDialog(object):
build_icon(u':/system/system_configure_shortcuts.png'))
self.shortcutButton.setCheckable(True)
self.shortcutButton.setObjectName(u'shortcutButton')
self.shortcutButton.setFixedSize(150, 30)
self.customLayout.addWidget(self.shortcutButton)
self.clearShortcutButton = QtGui.QToolButton(shortcutListDialog)
self.clearShortcutButton.setIcon(

View File

@ -41,10 +41,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
"""
The shortcut list dialog
"""
#TODO: do not close on ESC
#TODO: ability to remove actions
#TODO: Save shortcuts
#TODO: doc
#TODO: do not close on ESC, ability to remove actions, save/load shortcuts, docs
#TODO: Fix Preview/Live controller (have the same shortcut)
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
@ -87,21 +84,17 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.shortcutButton.setChecked(False)
def exec_(self):
# The dialog is opened the first time
if self.treeWidget.topLevelItemCount() == 0:
QtCore.QObject.connect(actionList.signal,
QtCore.SIGNAL(u'addedAction()'), self.initialiseActionList)
self.initialiseActionList()
self.refreshActionList()
return QtGui.QDialog.exec_(self)
def refreshActionList(self):
# As refreshing does not work, the check does not work either.
self.assingedShortcuts = []
iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget)
while iterator.value():
treewidgetItem = iterator.value()
action = treewidgetItem.data(0, QtCore.Qt.UserRole).toPyObject()
if action is not None:
#self.treeWidget.clear()
for category in actionList.categories:
item = QtGui.QTreeWidgetItem([category.name])
for action in category.actions:
self.assingedShortcuts.extend(action.shortcuts())
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
if len(action.shortcuts()) == 2:
shortcutText = action.shortcuts()[0].toString()
@ -109,19 +102,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
else:
shortcutText = action.shortcut().toString()
alternateText = u''
self.assingedShortcuts.extend(action.shortcuts())
treewidgetItem.setText(0, actionText)
treewidgetItem.setText(1, shortcutText)
treewidgetItem.setText(2, alternateText)
iterator += 1
def initialiseActionList(self):
for category in actionList.categories:
item = QtGui.QTreeWidgetItem([category.name])
for action in category.actions:
actionItem = QtGui.QTreeWidgetItem()
actionItem = QtGui.QTreeWidgetItem(
[actionText, shortcutText, alternateText])
actionItem.setIcon(0, action.icon())
actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action))
actionItem.setData(0,
QtCore.Qt.UserRole, QtCore.QVariant(action))
item.addChild(actionItem)
item.setExpanded(True)
self.treeWidget.addTopLevelItem(item)
@ -135,13 +120,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
return
# TODO: Sort out which shortcuts should be kept.
action.setShortcuts(QtGui.QKeySequence(self.shortcutButton.text()))
item.setText(1, self.shortcutButton.text())
self.refreshActionList()
def onItemPressed(self, item, column):
item = self.treeWidget.currentItem()
action = item.data(0, QtCore.Qt.UserRole).toPyObject()
self.shortcutButton.setEnabled(action is not None)
if action is None:
text = u''
self.shortcutButton.setChecked(False)
else:
if len(action.shortcuts()) == 0:
text = u''
@ -150,3 +138,21 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
else:
text = action.shortcuts()[0].toString()
self.shortcutButton.setText(text)
def saveShortcuts(self):
"""
Save the shortcuts.
"""
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
# TODO: Save shortcuts
settings.endGroup()
def loadShortcuts(self):
"""
Load the shortcuts.
"""
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
# TODO: Load shortcuts
settings.endGroup()

View File

@ -27,8 +27,6 @@
The :mod:`~openlp.core.utils.actions` module provides action list classes used
by the shortcuts system.
"""
from PyQt4 import QtCore
class ActionCategory(object):
"""
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
@ -175,7 +173,6 @@ class ActionList(object):
"""
def __init__(self):
self.categories = CategoryList()
self.signal = Emit()
def add_action(self, action, category=u'Default', weight=None):
if category not in self.categories:
@ -184,11 +181,5 @@ class ActionList(object):
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
self.signal.emit(QtCore.SIGNAL(u'addedAction()'))
class Emit(QtCore.QObject):
def __init__(self):
QtCore.QObject.__init__(self)
actionList = ActionList()

View File

@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Receiver
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import UiStrings
from openlp.core.lib.ui import UiStrings, base_action, icon_action
from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat
@ -78,8 +78,8 @@ class SongsPlugin(Plugin):
use it as their parent.
"""
# Main song import menu item - will eventually be the only one
self.SongImportItem = QtGui.QAction(import_menu)
self.SongImportItem.setObjectName(u'SongImportItem')
self.SongImportItem = base_action(
import_menu, u'SongImportItem', u'Import')
self.SongImportItem.setText(translate(
'SongsPlugin', '&Song'))
self.SongImportItem.setToolTip(translate('SongsPlugin',
@ -99,8 +99,7 @@ class SongsPlugin(Plugin):
use it as their parent.
"""
# Main song import menu item - will eventually be the only one
self.SongExportItem = QtGui.QAction(export_menu)
self.SongExportItem.setObjectName(u'SongExportItem')
self.SongExportItem = base_action(export_menu, u'SongExportItem', u'Export')
self.SongExportItem.setText(translate(
'SongsPlugin', '&Song'))
self.SongExportItem.setToolTip(translate('SongsPlugin',
@ -120,9 +119,8 @@ class SongsPlugin(Plugin):
use it as their parent.
"""
log.info(u'add tools menu')
self.toolsReindexItem = QtGui.QAction(tools_menu)
self.toolsReindexItem.setIcon(build_icon(u':/plugins/plugin_songs.png'))
self.toolsReindexItem.setObjectName(u'toolsReindexItem')
self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem',
u':/plugins/plugin_songs.png', category=u'Tools')
self.toolsReindexItem.setText(
translate('SongsPlugin', '&Re-index Songs'))
self.toolsReindexItem.setStatusTip(