forked from openlp/openlp
Correct code
This commit is contained in:
parent
222d4c228c
commit
4d82e55ca0
@ -81,8 +81,16 @@ class SongUsagePlugin(Plugin):
|
|||||||
self.songUsageReport.setStatusTip(
|
self.songUsageReport.setStatusTip(
|
||||||
translate('SongUsagePlugin', 'Generate a report on song usage.'))
|
translate('SongUsagePlugin', 'Generate a report on song usage.'))
|
||||||
# SongUsage activation
|
# SongUsage activation
|
||||||
|
self.songUsageStatus = shortcut_action(tools_menu, u'songUsageStatus',
|
||||||
|
[QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False)
|
||||||
|
self.songUsageStatus.setText(translate(
|
||||||
|
'SongUsagePlugin', 'Toggle Tracking'))
|
||||||
|
self.songUsageStatus.setStatusTip(translate('SongUsagePlugin',
|
||||||
|
'Toggle the tracking of song usage.'))
|
||||||
# Add Menus together
|
# Add Menus together
|
||||||
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
|
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
|
||||||
|
self.songUsageMenu.addAction(self.songUsageStatus)
|
||||||
|
self.songUsageMenu.addSeparator()
|
||||||
self.songUsageMenu.addAction(self.songUsageDelete)
|
self.songUsageMenu.addAction(self.songUsageDelete)
|
||||||
self.songUsageMenu.addAction(self.songUsageReport)
|
self.songUsageMenu.addAction(self.songUsageReport)
|
||||||
self.songUsageActiveButton = QtGui.QToolButton(
|
self.songUsageActiveButton = QtGui.QToolButton(
|
||||||
@ -95,6 +103,9 @@ class SongUsagePlugin(Plugin):
|
|||||||
self.songUsageActiveButton)
|
self.songUsageActiveButton)
|
||||||
self.songUsageActiveButton.hide()
|
self.songUsageActiveButton.hide()
|
||||||
# Signals and slots
|
# Signals and slots
|
||||||
|
QtCore.QObject.connect(self.songUsageStatus,
|
||||||
|
QtCore.SIGNAL(u'visibilityChanged(bool)'),
|
||||||
|
self.songUsageStatus.setChecked)
|
||||||
QtCore.QObject.connect(self.songUsageActiveButton,
|
QtCore.QObject.connect(self.songUsageActiveButton,
|
||||||
QtCore.SIGNAL(u'toggled(bool)'),
|
QtCore.SIGNAL(u'toggled(bool)'),
|
||||||
self.toggleSongUsageState)
|
self.toggleSongUsageState)
|
||||||
@ -113,12 +124,8 @@ class SongUsagePlugin(Plugin):
|
|||||||
self.songUsageActive = QtCore.QSettings().value(
|
self.songUsageActive = QtCore.QSettings().value(
|
||||||
self.settingsSection + u'/active',
|
self.settingsSection + u'/active',
|
||||||
QtCore.QVariant(False)).toBool()
|
QtCore.QVariant(False)).toBool()
|
||||||
# Set the correct state and icon turn of signals as the state
|
# Set the button and checkbox state
|
||||||
# will get messed up
|
|
||||||
self.songUsageActiveButton.blockSignals(True)
|
|
||||||
self.songUsageActiveButton.setChecked(self.songUsageActive)
|
|
||||||
self.setButtonState()
|
self.setButtonState()
|
||||||
self.songUsageActiveButton.blockSignals(False)
|
|
||||||
action_list = ActionList.get_instance()
|
action_list = ActionList.get_instance()
|
||||||
action_list.add_action(self.songUsageDelete,
|
action_list.add_action(self.songUsageDelete,
|
||||||
translate('SongUsagePlugin', 'Song Usage'))
|
translate('SongUsagePlugin', 'Song Usage'))
|
||||||
@ -160,10 +167,23 @@ class SongUsagePlugin(Plugin):
|
|||||||
self.setButtonState()
|
self.setButtonState()
|
||||||
|
|
||||||
def setButtonState(self):
|
def setButtonState(self):
|
||||||
|
"""
|
||||||
|
Keep buttons inline. Turn of signals to stop dead loop but we need the
|
||||||
|
button and check box set correctly.
|
||||||
|
"""
|
||||||
|
self.songUsageActiveButton.blockSignals(True)
|
||||||
|
self.songUsageStatus.blockSignals(True)
|
||||||
if self.songUsageActive:
|
if self.songUsageActive:
|
||||||
self.songUsageActiveButton.setIcon(self.activeIcon)
|
self.songUsageActiveButton.setIcon(self.activeIcon)
|
||||||
|
self.songUsageStatus.setChecked(True)
|
||||||
|
self.songUsageActiveButton.setChecked(True)
|
||||||
else:
|
else:
|
||||||
self.songUsageActiveButton.setIcon(self.inactiveIcon)
|
self.songUsageActiveButton.setIcon(self.inactiveIcon)
|
||||||
|
self.songUsageStatus.setChecked(False)
|
||||||
|
self.songUsageActiveButton.setChecked(False)
|
||||||
|
self.songUsageActiveButton.blockSignals(False)
|
||||||
|
self.songUsageStatus.blockSignals(False)
|
||||||
|
|
||||||
|
|
||||||
def onReceiveSongUsage(self, item):
|
def onReceiveSongUsage(self, item):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user