each search 'type' has its own place holder text instead of the generic 'Search...' place holder

This commit is contained in:
Andreas Preikschat 2012-03-25 23:09:44 +02:00
parent 384d61b302
commit 7f4664b69b
4 changed files with 40 additions and 20 deletions

View File

@ -64,12 +64,6 @@ class SearchEdit(QtGui.QLineEdit):
)
self._updateStyleSheet()
self.setAcceptDrops(False)
# setPlaceholderText has been implemented in Qt 4.7 and in at least
# PyQt 4.9 (I am not sure, if it was implemented in PyQt 4.8).
try:
self.setPlaceholderText(translate('OpenLP.searchedit', 'Search...'))
except AttributeError:
pass
def _updateStyleSheet(self):
"""
@ -128,6 +122,13 @@ class SearchEdit(QtGui.QLineEdit):
menu = self.menuButton.menu()
for action in menu.actions():
if identifier == action.data().toInt()[0]:
# setPlaceholderText has been implemented in Qt 4.7 and in at
# least PyQt 4.9 (I am not sure, if it was implemented in
# PyQt 4.8).
try:
self.setPlaceholderText(action.placeholderText)
except AttributeError:
pass
self.menuButton.setDefaultAction(action)
self._currentSearchType = identifier
self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), identifier)
@ -143,21 +144,22 @@ class SearchEdit(QtGui.QLineEdit):
identifier, an icon (QIcon instance or string) and a title for the
item in the menu. In short, they should look like this::
(<identifier>, <icon>, <title>)
(<identifier>, <icon>, <title>, <place holder text>)
For instance::
(1, <QIcon instance>, "Titles")
(1, <QIcon instance>, "Titles", "Search Song Titles...")
Or::
(2, ":/songs/authors.png", "Authors")
(2, ":/songs/authors.png", "Authors", "Search Authors...")
"""
menu = QtGui.QMenu(self)
first = None
for identifier, icon, title in items:
for identifier, icon, title, placeholder in items:
action = create_widget_action(menu, text=title, icon=icon,
data=identifier, triggers=self._onMenuActionTriggered)
action.placeholderText = placeholder
if first is None:
first = action
self._currentSearchType = identifier
@ -208,5 +210,12 @@ class SearchEdit(QtGui.QLineEdit):
action.setChecked(False)
self.menuButton.setDefaultAction(sender)
self._currentSearchType = sender.data().toInt()[0]
# setPlaceholderText has been implemented in Qt 4.7 and in at least
# PyQt 4.9 (I am not sure, if it was implemented in PyQt 4.8).
try:
self.setPlaceholderText(
self.menuButton.defaultAction().placeholderText)
except AttributeError:
pass
self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'),
self._currentSearchType)

View File

@ -354,9 +354,12 @@ class BibleMediaItem(MediaManagerItem):
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference')),
translate('BiblesPlugin.MediaItem', 'Scripture Reference'),
translate(
'BiblesPlugin.MediaItem', 'Search Scripture Reference...')),
(BibleSearch.Text, u':/bibles/bibles_search_text.png',
translate('BiblesPlugin.MediaItem', 'Text Search'))
translate('BiblesPlugin.MediaItem', 'Text Search'),
translate('BiblesPlugin.MediaItem', 'Search Text...'))
])
self.quickSearchEdit.setCurrentSearchType(QtCore.QSettings().value(
u'%s/last search type' % self.settingsSection,

View File

@ -92,9 +92,10 @@ class CustomMediaItem(MediaManagerItem):
def initialise(self):
self.searchTextEdit.setSearchTypes([
(CustomSearch.Titles, u':/songs/song_search_title.png',
translate('SongsPlugin.MediaItem', 'Titles')),
translate('SongsPlugin.MediaItem', 'Titles'),
translate('SongsPlugin.MediaItem', 'Search Titles...')),
(CustomSearch.Themes, u':/slides/slide_theme.png',
UiStrings().Themes)
UiStrings().Themes, translate('SongsPlugin.MediaItem', 'Search'))
])
self.loadList(self.manager.get_all_objects(
CustomSlide, order_by_ref=CustomSlide.title))

View File

@ -151,16 +151,23 @@ class SongMediaItem(MediaManagerItem):
def initialise(self):
self.searchTextEdit.setSearchTypes([
(SongSearch.Entire, u':/songs/song_search_all.png',
translate('SongsPlugin.MediaItem', 'Entire Song')),
translate('SongsPlugin.MediaItem', 'Entire Song'),
translate('SongsPlugin.MediaItem', 'Search Entire Song...')),
(SongSearch.Titles, u':/songs/song_search_title.png',
translate('SongsPlugin.MediaItem', 'Titles')),
translate('SongsPlugin.MediaItem', 'Titles'),
translate('SongsPlugin.MediaItem', 'Search Titles...')),
(SongSearch.Lyrics, u':/songs/song_search_lyrics.png',
translate('SongsPlugin.MediaItem', 'Lyrics')),
translate('SongsPlugin.MediaItem', 'Lyrics'),
translate('SongsPlugin.MediaItem', 'Search Lyrics...')),
(SongSearch.Authors, u':/songs/song_search_author.png',
SongStrings.Authors),
SongStrings.Authors,
translate('SongsPlugin.MediaItem', 'Search Authors...')),
(SongSearch.Books, u':/songs/song_book_edit.png',
SongStrings.SongBooks),
(SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes)
SongStrings.SongBooks,
translate('SongsPlugin.MediaItem', 'Search Song Books...')),
(SongSearch.Themes, u':/slides/slide_theme.png',
UiStrings().Themes,
translate('SongsPlugin.MediaItem', 'Search Themes...'))
])
self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value(
u'%s/last search type' % self.settingsSection,