From 8dca5b46477f4ec354b82785ae5a50ae137db002 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 24 Mar 2012 12:08:30 +0100 Subject: [PATCH 1/6] add placeholder text to the search edit --- openlp/core/lib/searchedit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 933dee43b..1ee5c0e52 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -27,9 +27,9 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt4 import QtCore, QtGui, Qt -from openlp.core.lib import build_icon +from openlp.core.lib import build_icon, translate from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) @@ -64,6 +64,11 @@ class SearchEdit(QtGui.QLineEdit): ) self._updateStyleSheet() self.setAcceptDrops(False) + #if Qt.PYQT_VERSION_STR >= u'4.9.1' and Qt.qVersion() >= u'4.7': + if True: + print u'pyqt:', Qt.PYQT_VERSION_STR + print u'qt:', Qt.qVersion() + self.setPlaceholderText(translate('OpenLP.searchedit', 'Search...')) def _updateStyleSheet(self): """ From 384d61b302800960762752ee973fc123b29c5b6c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 24 Mar 2012 12:26:37 +0100 Subject: [PATCH 2/6] use try instead of version sting checking --- openlp/core/lib/searchedit.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 1ee5c0e52..8aaf3132f 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -64,11 +64,12 @@ class SearchEdit(QtGui.QLineEdit): ) self._updateStyleSheet() self.setAcceptDrops(False) - #if Qt.PYQT_VERSION_STR >= u'4.9.1' and Qt.qVersion() >= u'4.7': - if True: - print u'pyqt:', Qt.PYQT_VERSION_STR - print u'qt:', Qt.qVersion() + # 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): """ From 7f4664b69b7c8f561f4367c5dec814753cc56ddb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 25 Mar 2012 23:09:44 +0200 Subject: [PATCH 3/6] each search 'type' has its own place holder text instead of the generic 'Search...' place holder --- openlp/core/lib/searchedit.py | 29 +++++++++++++++++--------- openlp/plugins/bibles/lib/mediaitem.py | 7 +++++-- openlp/plugins/custom/lib/mediaitem.py | 5 +++-- openlp/plugins/songs/lib/mediaitem.py | 19 +++++++++++------ 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 8aaf3132f..74a4599f8 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -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>, <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) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 223229fd6..a4227ea95 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -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, diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 3ef571889..f479fc363 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -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)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c2e14a999..7d995500d 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -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, From 9a53a8211e108d70885f6411ed36e7184fc008b6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat <googol@lavabit.com> Date: Sun, 25 Mar 2012 23:34:02 +0200 Subject: [PATCH 4/6] removed not needed import --- openlp/core/lib/searchedit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 74a4599f8..da68c06a7 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -27,7 +27,7 @@ import logging -from PyQt4 import QtCore, QtGui, Qt +from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate from openlp.core.lib.ui import create_widget_action From 3136ee475c50ead036791ca3ce81932d9508a73e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat <googol@lavabit.com> Date: Sun, 25 Mar 2012 23:36:09 +0200 Subject: [PATCH 5/6] remove not needed import --- openlp/core/lib/searchedit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index da68c06a7..0347cee74 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) From 390def1f61c7e3d1bcf2bc01fe421fbde062affc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat <googol@lavabit.com> Date: Mon, 26 Mar 2012 11:41:59 +0200 Subject: [PATCH 6/6] fixed 'Search Themes...' string --- openlp/core/lib/ui.py | 4 +++- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 63fc04153..038be08b9 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -115,6 +115,8 @@ class UiStrings(object): '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 @@ def create_widget_action(parent, name=u'', **kwargs): 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 diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index f479fc363..688e8bf82 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -95,7 +95,7 @@ class CustomMediaItem(MediaManagerItem): translate('SongsPlugin.MediaItem', 'Titles'), translate('SongsPlugin.MediaItem', 'Search Titles...')), (CustomSearch.Themes, u':/slides/slide_theme.png', - UiStrings().Themes, translate('SongsPlugin.MediaItem', 'Search')) + UiStrings().Themes, UiStrings().SearchThemes) ]) self.loadList(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 7d995500d..70d2e22d6 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -166,8 +166,7 @@ class SongMediaItem(MediaManagerItem): SongStrings.SongBooks, translate('SongsPlugin.MediaItem', 'Search Song Books...')), (SongSearch.Themes, u':/slides/slide_theme.png', - UiStrings().Themes, - translate('SongsPlugin.MediaItem', 'Search Themes...')) + UiStrings().Themes, UiStrings().SearchThemes) ]) self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( u'%s/last search type' % self.settingsSection,