forked from openlp/openlp
- Added place holder texts to the search edit
bzr-revno: 1919
This commit is contained in:
commit
09ff933462
@ -122,6 +122,13 @@ class SearchEdit(QtGui.QLineEdit):
|
|||||||
menu = self.menuButton.menu()
|
menu = self.menuButton.menu()
|
||||||
for action in menu.actions():
|
for action in menu.actions():
|
||||||
if identifier == action.data().toInt()[0]:
|
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.menuButton.setDefaultAction(action)
|
||||||
self._currentSearchType = identifier
|
self._currentSearchType = identifier
|
||||||
self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), identifier)
|
self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), identifier)
|
||||||
@ -137,21 +144,22 @@ class SearchEdit(QtGui.QLineEdit):
|
|||||||
identifier, an icon (QIcon instance or string) and a title for the
|
identifier, an icon (QIcon instance or string) and a title for the
|
||||||
item in the menu. In short, they should look like this::
|
item in the menu. In short, they should look like this::
|
||||||
|
|
||||||
(<identifier>, <icon>, <title>)
|
(<identifier>, <icon>, <title>, <place holder text>)
|
||||||
|
|
||||||
For instance::
|
For instance::
|
||||||
|
|
||||||
(1, <QIcon instance>, "Titles")
|
(1, <QIcon instance>, "Titles", "Search Song Titles...")
|
||||||
|
|
||||||
Or::
|
Or::
|
||||||
|
|
||||||
(2, ":/songs/authors.png", "Authors")
|
(2, ":/songs/authors.png", "Authors", "Search Authors...")
|
||||||
"""
|
"""
|
||||||
menu = QtGui.QMenu(self)
|
menu = QtGui.QMenu(self)
|
||||||
first = None
|
first = None
|
||||||
for identifier, icon, title in items:
|
for identifier, icon, title, placeholder in items:
|
||||||
action = create_widget_action(menu, text=title, icon=icon,
|
action = create_widget_action(menu, text=title, icon=icon,
|
||||||
data=identifier, triggers=self._onMenuActionTriggered)
|
data=identifier, triggers=self._onMenuActionTriggered)
|
||||||
|
action.placeholderText = placeholder
|
||||||
if first is None:
|
if first is None:
|
||||||
first = action
|
first = action
|
||||||
self._currentSearchType = identifier
|
self._currentSearchType = identifier
|
||||||
@ -202,5 +210,12 @@ class SearchEdit(QtGui.QLineEdit):
|
|||||||
action.setChecked(False)
|
action.setChecked(False)
|
||||||
self.menuButton.setDefaultAction(sender)
|
self.menuButton.setDefaultAction(sender)
|
||||||
self._currentSearchType = sender.data().toInt()[0]
|
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.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||||
self._currentSearchType)
|
self._currentSearchType)
|
||||||
|
@ -115,6 +115,8 @@ class UiStrings(object):
|
|||||||
'The abbreviated unit for seconds')
|
'The abbreviated unit for seconds')
|
||||||
self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
|
self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
|
||||||
self.Search = translate('OpenLP.Ui', 'Search')
|
self.Search = translate('OpenLP.Ui', 'Search')
|
||||||
|
self.SearchThemes = translate(
|
||||||
|
'OpenLP.Ui', 'Search Themes...', 'Search bar place holder text ')
|
||||||
self.SelectDelete = translate('OpenLP.Ui', 'You must select an item '
|
self.SelectDelete = translate('OpenLP.Ui', 'You must select an item '
|
||||||
'to delete.')
|
'to delete.')
|
||||||
self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to '
|
self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to '
|
||||||
@ -374,7 +376,7 @@ def create_widget_action(parent, name=u'', **kwargs):
|
|||||||
The shortcut context defaults to ``QtCore.Qt.WidgetShortcut`` and the action
|
The shortcut context defaults to ``QtCore.Qt.WidgetShortcut`` and the action
|
||||||
is added to the parents action list.
|
is added to the parents action list.
|
||||||
"""
|
"""
|
||||||
kwargs.setdefault(u'context', QtCore.Qt.WidgetShortcut)
|
kwargs.setdefault(u'context', QtCore.Qt.WidgetShortcut)
|
||||||
action = create_action(parent, name, **kwargs)
|
action = create_action(parent, name, **kwargs)
|
||||||
parent.addAction(action)
|
parent.addAction(action)
|
||||||
return action
|
return action
|
||||||
|
@ -354,9 +354,12 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
|
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
|
||||||
self.quickSearchEdit.setSearchTypes([
|
self.quickSearchEdit.setSearchTypes([
|
||||||
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
|
(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',
|
(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(
|
self.quickSearchEdit.setCurrentSearchType(QtCore.QSettings().value(
|
||||||
u'%s/last search type' % self.settingsSection,
|
u'%s/last search type' % self.settingsSection,
|
||||||
|
@ -92,9 +92,10 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.searchTextEdit.setSearchTypes([
|
self.searchTextEdit.setSearchTypes([
|
||||||
(CustomSearch.Titles, u':/songs/song_search_title.png',
|
(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',
|
(CustomSearch.Themes, u':/slides/slide_theme.png',
|
||||||
UiStrings().Themes)
|
UiStrings().Themes, UiStrings().SearchThemes)
|
||||||
])
|
])
|
||||||
self.loadList(self.manager.get_all_objects(
|
self.loadList(self.manager.get_all_objects(
|
||||||
CustomSlide, order_by_ref=CustomSlide.title))
|
CustomSlide, order_by_ref=CustomSlide.title))
|
||||||
|
@ -151,16 +151,22 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.searchTextEdit.setSearchTypes([
|
self.searchTextEdit.setSearchTypes([
|
||||||
(SongSearch.Entire, u':/songs/song_search_all.png',
|
(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',
|
(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',
|
(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',
|
(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',
|
(SongSearch.Books, u':/songs/song_book_edit.png',
|
||||||
SongStrings.SongBooks),
|
SongStrings.SongBooks,
|
||||||
(SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes)
|
translate('SongsPlugin.MediaItem', 'Search Song Books...')),
|
||||||
|
(SongSearch.Themes, u':/slides/slide_theme.png',
|
||||||
|
UiStrings().Themes, UiStrings().SearchThemes)
|
||||||
])
|
])
|
||||||
self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value(
|
self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value(
|
||||||
u'%s/last search type' % self.settingsSection,
|
u'%s/last search type' % self.settingsSection,
|
||||||
|
Loading…
Reference in New Issue
Block a user