Give the media items the ability to do something when they are "focused".

Make the search edits on the Songs, Bibles and Custom media items focus when the item is selected.
This commit is contained in:
Raoul Snyman 2011-05-26 08:23:22 +02:00
parent 548e41f15c
commit 38000b5e56
5 changed files with 28 additions and 0 deletions

View File

@ -431,6 +431,13 @@ class MediaManagerItem(QtGui.QWidget):
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
u'be defined by the plugin')
def onFocus(self):
"""
Run when a tab in the media manager gains focus. This gives the media
item a chance to focus any elements it wants to.
"""
pass
def generateSlideData(self, serviceItem, item=None, xmlVersion=False):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin')

View File

@ -537,6 +537,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage)
# Media Manager
QtCore.QObject.connect(self.mediaToolBox,
QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
Receiver.send_message(u'cursor_busy')
# Simple message boxes
QtCore.QObject.connect(Receiver.get_receiver(),
@ -602,6 +605,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
LanguageManager.auto_language = value
LanguageManager.set_language(self.languageGroup.checkedAction())
def onMediaToolBoxChanged(self, index):
widget = self.mediaToolBox.widget(index)
if widget:
widget.onFocus()
def versionNotice(self, version):
"""
Notifies the user that a newer version of OpenLP is available.

View File

@ -273,6 +273,12 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'currentChanged(int)'),
self.onSearchTabBarCurrentChanged)
def onFocus(self):
if self.quickTab.isVisible():
self.quickSearchEdit.setFocus()
else:
self.advancedBookComboBox.setFocus()
def configUpdated(self):
log.debug(u'configUpdated')
if QtCore.QSettings().value(self.settingsSection + u'/second bibles',
@ -463,6 +469,7 @@ class BibleMediaItem(MediaManagerItem):
else:
self.quickTab.setVisible(False)
self.advancedTab.setVisible(True)
self.advancedBookComboBox.setFocus()
def onLockButtonToggled(self, checked):
if checked:

View File

@ -199,6 +199,9 @@ class CustomMediaItem(MediaManagerItem):
for row in row_list:
self.listView.takeItem(row)
def onFocus(self):
self.searchTextEdit.setFocus()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
raw_slides = []
raw_footer = []

View File

@ -125,6 +125,9 @@ class SongMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.onSearchTextButtonClick)
def onFocus(self):
self.searchTextEdit.setFocus()
def configUpdated(self):
self.searchAsYouType = QtCore.QSettings().value(
self.settingsSection + u'/search as type',