forked from openlp/openlp
Add visual button to status bar for Song usage active / inactive and connect to F4 button.
Code cleanups bzr-revno: 1682
This commit is contained in:
commit
d58ed2da56
@ -48,8 +48,10 @@ class SongUsagePlugin(Plugin):
|
||||
Plugin.__init__(self, u'SongUsage', plugin_helpers)
|
||||
self.weight = -4
|
||||
self.icon = build_icon(u':/plugins/plugin_songusage.png')
|
||||
self.activeIcon = build_icon(u':/songusage/song_usage_active.png')
|
||||
self.inactiveIcon = build_icon(u':/songusage/song_usage_inactive.png')
|
||||
self.manager = None
|
||||
self.songusageActive = False
|
||||
self.songUsageActive = False
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
"""
|
||||
@ -84,17 +86,29 @@ class SongUsagePlugin(Plugin):
|
||||
self.songUsageStatus.setText(translate(
|
||||
'SongUsagePlugin', 'Toggle Tracking'))
|
||||
self.songUsageStatus.setStatusTip(translate('SongUsagePlugin',
|
||||
'Toggle the tracking of song usage.'))
|
||||
#Add Menus together
|
||||
'Toggle the tracking of song usage.'))
|
||||
# Add Menus together
|
||||
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
|
||||
self.songUsageMenu.addAction(self.songUsageStatus)
|
||||
self.songUsageMenu.addSeparator()
|
||||
self.songUsageMenu.addAction(self.songUsageDelete)
|
||||
self.songUsageMenu.addAction(self.songUsageReport)
|
||||
self.songUsageActiveButton = QtGui.QToolButton(
|
||||
self.formparent.statusBar)
|
||||
self.songUsageActiveButton.setCheckable(True)
|
||||
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin',
|
||||
'Toggle the tracking of song usage.'))
|
||||
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')
|
||||
self.formparent.statusBar.insertPermanentWidget(1,
|
||||
self.songUsageActiveButton)
|
||||
self.songUsageActiveButton.hide()
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.songUsageStatus,
|
||||
QtCore.SIGNAL(u'visibilityChanged(bool)'),
|
||||
self.songUsageStatus.setChecked)
|
||||
QtCore.QObject.connect(self.songUsageActiveButton,
|
||||
QtCore.SIGNAL(u'toggled(bool)'),
|
||||
self.toggleSongUsageState)
|
||||
QtCore.QObject.connect(self.songUsageDelete,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
|
||||
QtCore.QObject.connect(self.songUsageReport,
|
||||
@ -107,23 +121,25 @@ class SongUsagePlugin(Plugin):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
self.onReceiveSongUsage)
|
||||
self.SongUsageActive = QtCore.QSettings().value(
|
||||
self.songUsageActive = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/active',
|
||||
QtCore.QVariant(False)).toBool()
|
||||
self.songUsageStatus.setChecked(self.SongUsageActive)
|
||||
# Set the button and checkbox state
|
||||
self.setButtonState()
|
||||
action_list = ActionList.get_instance()
|
||||
action_list.add_action(self.songUsageStatus,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
action_list.add_action(self.songUsageDelete,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
action_list.add_action(self.songUsageReport,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
action_list.add_action(self.songUsageStatus,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
if self.manager is None:
|
||||
self.manager = Manager(u'songusage', init_schema)
|
||||
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager,
|
||||
self.formparent)
|
||||
self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent)
|
||||
self.songUsageMenu.menuAction().setVisible(True)
|
||||
self.songUsageActiveButton.show()
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
@ -134,26 +150,55 @@ class SongUsagePlugin(Plugin):
|
||||
Plugin.finalise(self)
|
||||
self.songUsageMenu.menuAction().setVisible(False)
|
||||
action_list = ActionList.get_instance()
|
||||
action_list.remove_action(self.songUsageStatus,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
action_list.remove_action(self.songUsageDelete,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
action_list.remove_action(self.songUsageReport,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
action_list.remove_action(self.songUsageStatus,
|
||||
translate('SongUsagePlugin', 'Song Usage'))
|
||||
#stop any events being processed
|
||||
self.SongUsageActive = False
|
||||
self.songUsageActiveButton.hide()
|
||||
# stop any events being processed
|
||||
self.songUsageActive = False
|
||||
|
||||
def toggleSongUsageState(self):
|
||||
self.SongUsageActive = not self.SongUsageActive
|
||||
"""
|
||||
Manage the state of the audit collection and amend
|
||||
the UI when necessary,
|
||||
"""
|
||||
self.songUsageActive = not self.songUsageActive
|
||||
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
||||
QtCore.QVariant(self.SongUsageActive))
|
||||
QtCore.QVariant(self.songUsageActive))
|
||||
self.setButtonState()
|
||||
|
||||
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:
|
||||
self.songUsageActiveButton.setIcon(self.activeIcon)
|
||||
self.songUsageStatus.setChecked(True)
|
||||
self.songUsageActiveButton.setChecked(True)
|
||||
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin',
|
||||
'Song usage tracking is active.'))
|
||||
else:
|
||||
self.songUsageActiveButton.setIcon(self.inactiveIcon)
|
||||
self.songUsageStatus.setChecked(False)
|
||||
self.songUsageActiveButton.setChecked(False)
|
||||
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin',
|
||||
'Song usage tracking is inactive.'))
|
||||
self.songUsageActiveButton.blockSignals(False)
|
||||
self.songUsageStatus.blockSignals(False)
|
||||
|
||||
|
||||
def onReceiveSongUsage(self, item):
|
||||
"""
|
||||
Song Usage for live song from SlideController
|
||||
"""
|
||||
audit = item[0].audit
|
||||
if self.SongUsageActive and audit:
|
||||
if self.songUsageActive and audit:
|
||||
song_usage_item = SongUsageItem()
|
||||
song_usage_item.usagedate = datetime.today()
|
||||
song_usage_item.usagetime = datetime.now().time()
|
||||
|
@ -138,6 +138,10 @@
|
||||
<file>messagebox_info.png</file>
|
||||
<file>messagebox_warning.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="songusage">
|
||||
<file>song_usage_active.png</file>
|
||||
<file>song_usage_inactive.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="tools">
|
||||
<file>tools_add.png</file>
|
||||
<file>tools_alert.png</file>
|
||||
|
BIN
resources/images/song_usage_active.png
Normal file
BIN
resources/images/song_usage_active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 757 B |
BIN
resources/images/song_usage_inactive.png
Normal file
BIN
resources/images/song_usage_inactive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 716 B |
Loading…
Reference in New Issue
Block a user