openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #08515
[Merge] lp:~googol-hush/openlp/tweaks into lp:openlp
Andreas Preikschat has proposed merging lp:~googol-hush/openlp/tweaks into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~googol-hush/openlp/tweaks/+merge/59621
Hello,
Two improvements to the shortcut dialog:
- When you are capturing a shortcut, "space" won't uncheck the button (so you can use "space" as shortcut as well) (lines 8-26, 64-66)
- Now you can remove a shortcut (just abort the capturing)
--
https://code.launchpad.net/~googol-hush/openlp/tweaks/+merge/59621
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/shortcutlistdialog.py'
--- openlp/core/ui/shortcutlistdialog.py 2011-04-10 07:07:02 +0000
+++ openlp/core/ui/shortcutlistdialog.py 2011-05-01 15:57:46 +0000
@@ -28,6 +28,24 @@
from openlp.core.lib import translate, build_icon
+class CaptureShortcutButton(QtGui.QPushButton):
+ """
+ A class to encapsulate a ``QPushButton``.
+ """
+ def __init__(self, *args):
+ QtGui.QPushButton.__init__(self, *args)
+ self.setCheckable(True)
+
+ def keyPressEvent(self, event):
+ """
+ Block the ``Key_Space`` key, so that the button will not change the
+ checked state.
+ """
+ if event.key() == QtCore.Qt.Key_Space and self.isChecked():
+ # Ignore the event, so that the parent can take care of this.
+ event.ignore()
+
+
class Ui_ShortcutListDialog(object):
def setupUi(self, shortcutListDialog):
shortcutListDialog.setObjectName(u'shortcutListDialog')
@@ -56,12 +74,11 @@
self.detailsLayout.addWidget(self.customRadioButton, 1, 0, 1, 1)
self.primaryLayout = QtGui.QHBoxLayout()
self.primaryLayout.setObjectName(u'primaryLayout')
- self.primaryPushButton = QtGui.QPushButton(shortcutListDialog)
+ self.primaryPushButton = CaptureShortcutButton(shortcutListDialog)
self.primaryPushButton.setObjectName(u'primaryPushButton')
self.primaryPushButton.setMinimumSize(QtCore.QSize(84, 0))
self.primaryPushButton.setIcon(
build_icon(u':/system/system_configure_shortcuts.png'))
- self.primaryPushButton.setCheckable(True)
self.primaryLayout.addWidget(self.primaryPushButton)
self.clearPrimaryButton = QtGui.QToolButton(shortcutListDialog)
self.clearPrimaryButton.setObjectName(u'clearPrimaryButton')
@@ -72,9 +89,8 @@
self.detailsLayout.addLayout(self.primaryLayout, 1, 1, 1, 1)
self.alternateLayout = QtGui.QHBoxLayout()
self.alternateLayout.setObjectName(u'alternateLayout')
- self.alternatePushButton = QtGui.QPushButton(shortcutListDialog)
+ self.alternatePushButton = CaptureShortcutButton(shortcutListDialog)
self.alternatePushButton.setObjectName(u'alternatePushButton')
- self.alternatePushButton.setCheckable(True)
self.alternatePushButton.setIcon(
build_icon(u':/system/system_configure_shortcuts.png'))
self.alternateLayout.addWidget(self.alternatePushButton)
=== modified file 'openlp/core/ui/shortcutlistform.py'
--- openlp/core/ui/shortcutlistform.py 2011-04-24 14:44:40 +0000
+++ openlp/core/ui/shortcutlistform.py 2011-05-01 15:57:46 +0000
@@ -71,7 +71,9 @@
QtCore.SIGNAL(u'clicked(bool)'), self.onCustomRadioButtonClicked)
def keyPressEvent(self, event):
- if self.primaryPushButton.isChecked() or \
+ if event.key() == QtCore.Qt.Key_Space:
+ self.keyReleaseEvent(event)
+ elif self.primaryPushButton.isChecked() or \
self.alternatePushButton.isChecked():
event.ignore()
elif event.key() == QtCore.Qt.Key_Escape:
@@ -163,6 +165,7 @@
self.customRadioButton.setChecked(True)
if toggled:
self.alternatePushButton.setChecked(False)
+ self.primaryPushButton.setText(u'')
return
action = self._currentItemAction()
if action is None:
@@ -181,6 +184,7 @@
self.customRadioButton.setChecked(True)
if toggled:
self.primaryPushButton.setChecked(False)
+ self.alternatePushButton.setText(u'')
return
action = self._currentItemAction()
if action is None:
@@ -211,10 +215,11 @@
self.primaryPushButton.setChecked(column in [0, 1])
self.alternatePushButton.setChecked(column not in [0, 1])
if column in [0, 1]:
+ self.primaryPushButton.setText(u'')
self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason)
else:
+ self.alternatePushButton.setText(u'')
self.alternatePushButton.setFocus(QtCore.Qt.OtherFocusReason)
- self.onCurrentItemChanged(item)
def onCurrentItemChanged(self, item=None, previousItem=None):
"""
@@ -247,6 +252,12 @@
elif len(shortcuts) == 2:
primary_text = shortcuts[0].toString()
alternate_text = shortcuts[1].toString()
+ # When we are capturing a new shortcut, we do not want, that the buttons
+ # display the current shortcut.
+ if self.primaryPushButton.isChecked():
+ primary_text = u''
+ if self.alternatePushButton.isChecked():
+ alternate_text = u''
self.primaryPushButton.setText(primary_text)
self.alternatePushButton.setText(alternate_text)
self.primaryLabel.setText(primary_label_text)
Follow ups