forked from openlp/openlp
basic saving and loading of shortcuts
This commit is contained in:
parent
5ef0cc12c0
commit
772bd8eb66
@ -762,7 +762,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
Show the shortcuts dialog
|
||||
"""
|
||||
if self.shortcutForm.exec_():
|
||||
self.shortcutForm.saveShortcuts()
|
||||
self.shortcutForm.save()
|
||||
|
||||
def onModeDefaultItemClicked(self):
|
||||
"""
|
||||
|
@ -87,10 +87,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
||||
self.shortcutButton.setChecked(False)
|
||||
|
||||
def exec_(self):
|
||||
self.refreshActionList()
|
||||
self.reloadActionList()
|
||||
return QtGui.QDialog.exec_(self)
|
||||
|
||||
def refreshActionList(self):
|
||||
def reloadActionList(self):
|
||||
self.assingedShortcuts = []
|
||||
self.treeWidget.clear()
|
||||
for category in actionList.categories:
|
||||
@ -147,36 +147,23 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
||||
action = item.data(0, QtCore.Qt.UserRole).toPyObject()
|
||||
self.shortcutButton.setEnabled(True)
|
||||
text = u''
|
||||
if action is None or column not in [1, 2] or \
|
||||
len(action.shortcuts()) == 0:
|
||||
if action is None or column not in [1, 2]:
|
||||
self.shortcutButton.setEnabled(False)
|
||||
elif column == 1:
|
||||
elif column == 1 and len(action.shortcuts()) != 0:
|
||||
text = action.shortcuts()[0].toString()
|
||||
elif len(action.shortcuts()) == 2:
|
||||
elif len(action.shortcuts()) == 2 and len(action.shortcuts()) != 0:
|
||||
text = action.shortcuts()[1].toString()
|
||||
self.shortcutButton.setText(text)
|
||||
|
||||
def saveShortcuts(self):
|
||||
def save(self):
|
||||
"""
|
||||
Save the shortcuts.
|
||||
Save the shortcuts. **Note**, that we do not have to load the shortcuts,
|
||||
as they are loaded in :class:`~openlp.core.utils.ActionList`.
|
||||
"""
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(u'shortcuts')
|
||||
for category in actionList.categories:
|
||||
break
|
||||
for action in category.actions:
|
||||
if action.defaultShortcuts != action.shortcuts():
|
||||
settings.setValue(action.text(),
|
||||
QtCore.QVariant(action.shortcuts()))
|
||||
settings.endGroup()
|
||||
|
||||
def loadShortcuts(self):
|
||||
"""
|
||||
Load the shortcuts.
|
||||
"""
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(u'shortcuts')
|
||||
for shortcut in settings.allKeys():
|
||||
pass
|
||||
# TODO: Load shortcuts
|
||||
settings.setValue(
|
||||
action.objectName(), QtCore.QVariant(action.shortcuts()))
|
||||
settings.endGroup()
|
||||
|
@ -27,6 +27,10 @@
|
||||
The :mod:`~openlp.core.utils.actions` module provides action list classes used
|
||||
by the shortcuts system.
|
||||
"""
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
|
||||
class ActionCategory(object):
|
||||
"""
|
||||
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
|
||||
@ -190,6 +194,14 @@ class ActionList(object):
|
||||
self.categories[category].actions.append(action)
|
||||
else:
|
||||
self.categories[category].actions.add(action, weight)
|
||||
# Load the shortcut from the config.
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(u'shortcuts')
|
||||
shortcuts = settings.value(action.objectName(),
|
||||
QtCore.QVariant(action.shortcuts())).toStringList()
|
||||
action.setShortcuts(
|
||||
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
|
||||
settings.endGroup()
|
||||
|
||||
def remove_action(self, action, category):
|
||||
if category not in self.categories:
|
||||
|
Loading…
Reference in New Issue
Block a user