From 870d0b51e98066e507d346447f7109145313baf9 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 29 Jun 2011 22:04:08 +0100 Subject: [PATCH] Move SongUsage active to toolbar --- openlp/plugins/songusage/songusageplugin.py | 43 ++++++++++++-------- resources/images/openlp-2.qrc | 4 ++ resources/images/song_usage_active.png | Bin 0 -> 757 bytes resources/images/song_usage_inactive.png | Bin 0 -> 716 bytes 4 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 resources/images/song_usage_active.png create mode 100644 resources/images/song_usage_inactive.png diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 7304b5196..c600aece3 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -48,6 +48,8 @@ class SongUsagePlugin(Plugin): Plugin.__init__(self, u'SongUsage', plugin_helpers) self.weight = -4 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.songusageActive = False @@ -79,22 +81,21 @@ class SongUsagePlugin(Plugin): self.songUsageReport.setStatusTip( translate('SongUsagePlugin', 'Generate a report on song usage.')) # 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.songUsageMenu.addAction(self.songUsageStatus) - self.songUsageMenu.addSeparator() self.songUsageMenu.addAction(self.songUsageDelete) 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 QtCore.QObject.connect(self.songUsageStatus, - QtCore.SIGNAL(u'visibilityChanged(bool)'), - self.songUsageStatus.setChecked) + QtCore.SIGNAL(u'toggled(bool)'), + self.toggleSongUsageState) QtCore.QObject.connect(self.songUsageDelete, QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) QtCore.QObject.connect(self.songUsageReport, @@ -116,14 +117,14 @@ class SongUsagePlugin(Plugin): 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.songUsageStatus.show() + self.songUsageStatus.setIcon(self.activeIcon) def finalise(self): """ @@ -138,22 +139,32 @@ class SongUsagePlugin(Plugin): 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.songUsageStatus.hide() + # stop any events being processed self.SongUsageActive = False def toggleSongUsageState(self): + """ + Manage the state of the audit collection and amend + the UI when necessary, + """ + print "toggle state" self.SongUsageActive = not self.SongUsageActive QtCore.QSettings().setValue(self.settingsSection + u'/active', QtCore.QVariant(self.SongUsageActive)) + if self.SongUsageActive: + self.songUsageStatus.setIcon(self.activeIcon) + else: + self.songUsageStatus.setIcon(self.inactiveIcon) def onReceiveSongUsage(self, item): """ Song Usage for live song from SlideController """ audit = item[0].audit + print audit if self.SongUsageActive and audit: + print "here" song_usage_item = SongUsageItem() song_usage_item.usagedate = datetime.today() song_usage_item.usagetime = datetime.now().time() diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index fc76ad434..89be90056 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -137,6 +137,10 @@ messagebox_info.png messagebox_warning.png + + song_usage_active.png + song_usage_inactive.png + tools_add.png tools_alert.png diff --git a/resources/images/song_usage_active.png b/resources/images/song_usage_active.png new file mode 100644 index 0000000000000000000000000000000000000000..1221e13103a3066b11a821e82e26f441fac9dc5d GIT binary patch literal 757 zcmV( zu7%a2Roh&aSgW9Is}@mYfvfg@U<>=ej6$bT8Fkc|dGF18_vGV=jf8)=+{HQP z$GzvAzo;tpvhG-?8{w8(j0g+^C@hF!&WD%gh516A4gqpTti(CFe=^6#=*=W z>Goa#^4lvc<`;SO>9zko|KmYzMxW|uHHUzx*dCFO_paQ{T_3%MZ3|)nLM#PU2x`jP znRh(<@O(O$)5{UW25892_>Bu!a~FrsvsKH3p$(u z2Cyq7Qe8MffiYWzY*VZ9wKPkA@)QV^i?I1qz#>)wx(1Y%ju^1K_l;yqk#))1z_8=M zYGsLFr%HGG309W{Zx66Q00p*|Ad^)#%j*=}Rh$+;7`6eB_-yP4w##c2Hk%2`32eIo z1VR&H2Q}Pkg}@IG`PX0@SnynOEd~I>Fd)&p!^XTEc|m4K2}3~RMtW61S+G=@b@znO z2R&#~TMwkOO0pf29grDS+R~tY91mTnmIO7-irkiHjPscRby7WGwSY8%I3NkY0t{#k z)B{t7ojh3Ynh6)-MnB~CVb2X_U+ay;JRFTwYih-#0la%(5K zuC&tJ2@OqP*?`1colW>@>#!uLAC_P%7dDJ`d~7 nbgZ4lVnnUj&SF^5W92nAaxE{#x9n?dXzXmN3N z(4{(baH^BELc6q3a2Dy%#nnkDbna+11at}oF(G2BVxpJ(``*6ar5p;S&3N7^7N z=77Ct%ggT2=qN15ffAC4C?SXdX6Psa3*#U_yVb(?^>zP>dD3=)`8?pN)6?Epvsuu< z0F)~$nM^7`VF>N};BFW8#Rc+~GP#ORb zA044kD4-v-8x3U5>4KnSr*D<&Tc9I*Av7@8st-VGjecSFcB2TU);1aH5LHIxMO}j9 zj|o0eyXq@bVI&{J_9CA+~~f*Lp$Jl-rks%(iO+WLdocnG+e?d_O6U zuC5XWoes|1Z8Sa4_n2SVOOox+O0Bix_=DqlAf3qx7Il;Va6cC}tJ zwYQ>tSEd2a{yWY@RDyubI5Yoqoc{m~r92WwE;k{~O literal 0 HcmV?d00001