forked from openlp/openlp
Move SongUsage active to toolbar
This commit is contained in:
parent
b77094beb6
commit
870d0b51e9
@ -48,6 +48,8 @@ class SongUsagePlugin(Plugin):
|
|||||||
Plugin.__init__(self, u'SongUsage', plugin_helpers)
|
Plugin.__init__(self, u'SongUsage', plugin_helpers)
|
||||||
self.weight = -4
|
self.weight = -4
|
||||||
self.icon = build_icon(u':/plugins/plugin_songusage.png')
|
self.icon = build_icon(u':/plugins/plugin_songusage.png')
|
||||||
|
self.activeIcon = QtGui.QIcon(u':/songusage/song_usage_active.png')
|
||||||
|
self.inactiveIcon = QtGui.QIcon(u':/songusage/song_usage_inactive.png')
|
||||||
self.manager = None
|
self.manager = None
|
||||||
self.songusageActive = False
|
self.songusageActive = False
|
||||||
|
|
||||||
@ -79,22 +81,21 @@ 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',
|
# Add Menus together
|
||||||
[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
|
|
||||||
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.songUsageStatus = QtGui.QToolButton(self.formparent.statusBar)
|
||||||
|
self.songUsageStatus.setCheckable(True)
|
||||||
|
self.songUsageStatus.setStatusTip(translate('SongUsagePlugin',
|
||||||
|
'Toggle the tracking of song usage.'))
|
||||||
|
self.songUsageStatus.setObjectName(u'songUsageStatus')
|
||||||
|
self.formparent.statusBar.insertPermanentWidget(1, self.songUsageStatus)
|
||||||
|
self.songUsageStatus.hide()
|
||||||
# Signals and slots
|
# Signals and slots
|
||||||
QtCore.QObject.connect(self.songUsageStatus,
|
QtCore.QObject.connect(self.songUsageStatus,
|
||||||
QtCore.SIGNAL(u'visibilityChanged(bool)'),
|
QtCore.SIGNAL(u'toggled(bool)'),
|
||||||
self.songUsageStatus.setChecked)
|
self.toggleSongUsageState)
|
||||||
QtCore.QObject.connect(self.songUsageDelete,
|
QtCore.QObject.connect(self.songUsageDelete,
|
||||||
QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
|
QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
|
||||||
QtCore.QObject.connect(self.songUsageReport,
|
QtCore.QObject.connect(self.songUsageReport,
|
||||||
@ -116,14 +117,14 @@ class SongUsagePlugin(Plugin):
|
|||||||
translate('SongUsagePlugin', 'Song Usage'))
|
translate('SongUsagePlugin', 'Song Usage'))
|
||||||
action_list.add_action(self.songUsageReport,
|
action_list.add_action(self.songUsageReport,
|
||||||
translate('SongUsagePlugin', 'Song Usage'))
|
translate('SongUsagePlugin', 'Song Usage'))
|
||||||
action_list.add_action(self.songUsageStatus,
|
|
||||||
translate('SongUsagePlugin', 'Song Usage'))
|
|
||||||
if self.manager is None:
|
if self.manager is None:
|
||||||
self.manager = Manager(u'songusage', init_schema)
|
self.manager = Manager(u'songusage', init_schema)
|
||||||
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager,
|
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager,
|
||||||
self.formparent)
|
self.formparent)
|
||||||
self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent)
|
self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent)
|
||||||
self.songUsageMenu.menuAction().setVisible(True)
|
self.songUsageMenu.menuAction().setVisible(True)
|
||||||
|
self.songUsageStatus.show()
|
||||||
|
self.songUsageStatus.setIcon(self.activeIcon)
|
||||||
|
|
||||||
def finalise(self):
|
def finalise(self):
|
||||||
"""
|
"""
|
||||||
@ -138,22 +139,32 @@ class SongUsagePlugin(Plugin):
|
|||||||
translate('SongUsagePlugin', 'Song Usage'))
|
translate('SongUsagePlugin', 'Song Usage'))
|
||||||
action_list.remove_action(self.songUsageReport,
|
action_list.remove_action(self.songUsageReport,
|
||||||
translate('SongUsagePlugin', 'Song Usage'))
|
translate('SongUsagePlugin', 'Song Usage'))
|
||||||
action_list.remove_action(self.songUsageStatus,
|
self.songUsageStatus.hide()
|
||||||
translate('SongUsagePlugin', 'Song Usage'))
|
# stop any events being processed
|
||||||
#stop any events being processed
|
|
||||||
self.SongUsageActive = False
|
self.SongUsageActive = False
|
||||||
|
|
||||||
def toggleSongUsageState(self):
|
def toggleSongUsageState(self):
|
||||||
|
"""
|
||||||
|
Manage the state of the audit collection and amend
|
||||||
|
the UI when necessary,
|
||||||
|
"""
|
||||||
|
print "toggle state"
|
||||||
self.SongUsageActive = not self.SongUsageActive
|
self.SongUsageActive = not self.SongUsageActive
|
||||||
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
||||||
QtCore.QVariant(self.SongUsageActive))
|
QtCore.QVariant(self.SongUsageActive))
|
||||||
|
if self.SongUsageActive:
|
||||||
|
self.songUsageStatus.setIcon(self.activeIcon)
|
||||||
|
else:
|
||||||
|
self.songUsageStatus.setIcon(self.inactiveIcon)
|
||||||
|
|
||||||
def onReceiveSongUsage(self, item):
|
def onReceiveSongUsage(self, item):
|
||||||
"""
|
"""
|
||||||
Song Usage for live song from SlideController
|
Song Usage for live song from SlideController
|
||||||
"""
|
"""
|
||||||
audit = item[0].audit
|
audit = item[0].audit
|
||||||
|
print audit
|
||||||
if self.SongUsageActive and audit:
|
if self.SongUsageActive and audit:
|
||||||
|
print "here"
|
||||||
song_usage_item = SongUsageItem()
|
song_usage_item = SongUsageItem()
|
||||||
song_usage_item.usagedate = datetime.today()
|
song_usage_item.usagedate = datetime.today()
|
||||||
song_usage_item.usagetime = datetime.now().time()
|
song_usage_item.usagetime = datetime.now().time()
|
||||||
|
@ -137,6 +137,10 @@
|
|||||||
<file>messagebox_info.png</file>
|
<file>messagebox_info.png</file>
|
||||||
<file>messagebox_warning.png</file>
|
<file>messagebox_warning.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
<qresource prefix="songusage">
|
||||||
|
<file>song_usage_active.png</file>
|
||||||
|
<file>song_usage_inactive.png</file>
|
||||||
|
</qresource>
|
||||||
<qresource prefix="tools">
|
<qresource prefix="tools">
|
||||||
<file>tools_add.png</file>
|
<file>tools_add.png</file>
|
||||||
<file>tools_alert.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