Andreas Preikschat has proposed merging lp:~googol/openlp/search-placeholder 
into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol/openlp/search-placeholder/+merge/99279

Hello,

I have added place holder texts to the search edit. The place holder text is 
different/changes depending on the selected "search type".

The setPlaceholderText method has been implemented in Qt 4.7. However, it was 
not available in PyQt since 4.8 (I think). I just remember, that it did not 
work, but now it does (and I assume that it was introduced in PyQt 4.9).

If you know when exactly it was introduced in PyQt please let me know (I'd like 
to clarify this in the comment, so that we can remove the try block in case we 
increase our PyQt minimum version).

The place holder texts are (structured) like this:
- Search <whatever>...

For example:
- Search Titles...
- Search Authors...
- Search Entire Song...

Or:
- Search Scripture Reference... (<-- very long string, but the place holder is 
shortened if it is too long)
- Search Text...

-- 
https://code.launchpad.net/~googol/openlp/search-placeholder/+merge/99279
Your team OpenLP Core is requested to review the proposed merge of 
lp:~googol/openlp/search-placeholder into lp:openlp.
=== modified file 'openlp/core/lib/searchedit.py'
--- openlp/core/lib/searchedit.py	2012-03-03 13:52:57 +0000
+++ openlp/core/lib/searchedit.py	2012-03-26 10:05:43 +0000
@@ -122,6 +122,13 @@
         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)
@@ -137,21 +144,22 @@
             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
@@ -202,5 +210,12 @@
             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)

=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py	2012-03-05 10:09:07 +0000
+++ openlp/core/lib/ui.py	2012-03-26 10:05:43 +0000
@@ -115,6 +115,8 @@
             'The abbreviated unit for seconds')
         self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
         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 '
             'to delete.')
         self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to '
@@ -374,7 +376,7 @@
     The shortcut context defaults to ``QtCore.Qt.WidgetShortcut`` and the action
     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)
     parent.addAction(action)
     return action

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2012-03-15 06:15:21 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2012-03-26 10:05:43 +0000
@@ -354,9 +354,12 @@
         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,

=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py	2012-03-17 21:30:53 +0000
+++ openlp/plugins/custom/lib/mediaitem.py	2012-03-26 10:05:43 +0000
@@ -92,9 +92,10 @@
     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, UiStrings().SearchThemes)
         ])
         self.loadList(self.manager.get_all_objects(
             CustomSlide, order_by_ref=CustomSlide.title))

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2012-03-16 22:56:06 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2012-03-26 10:05:43 +0000
@@ -151,16 +151,22 @@
     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, UiStrings().SearchThemes)
         ])
         self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value(
             u'%s/last search type' % self.settingsSection,

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to