forked from openlp/openlp
Songs Plugin get search as you type
This commit is contained in:
parent
cbb17039d5
commit
025d7c86d2
@ -83,6 +83,9 @@ class EventReceiver(QtCore.QObject):
|
||||
|
||||
``audit_changed``
|
||||
Audit information may have changed
|
||||
|
||||
``config_updated``
|
||||
Informs components the config has changed
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'EventReceiver')
|
||||
|
@ -27,7 +27,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, translate, SongXMLParser, \
|
||||
BaseListWithDnD, Receiver
|
||||
BaseListWithDnD, Receiver, str_to_bool
|
||||
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
|
||||
|
||||
class SongListView(BaseListWithDnD):
|
||||
@ -113,6 +113,12 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.onSearchTextEditChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'config_updated'), self.configUpdated)
|
||||
|
||||
def configUpdated(self):
|
||||
self.searchAsYouType = str_to_bool(
|
||||
self.parent.config.get_config(u'search as type', u'False'))
|
||||
|
||||
def retranslateUi(self):
|
||||
self.SearchTypeLabel.setText(
|
||||
@ -126,6 +132,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Titles'))
|
||||
self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Lyrics'))
|
||||
self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Authors'))
|
||||
self.configUpdated()
|
||||
|
||||
def onSearchTextButtonClick(self):
|
||||
search_keywords = unicode(self.SearchTextEdit.displayText())
|
||||
@ -181,6 +188,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.SearchTextEdit.clear()
|
||||
|
||||
def onSearchTextEditChanged(self, text):
|
||||
if self.searchAsYouType:
|
||||
search_length = 1
|
||||
if self.SearchTypeComboBox.currentIndex() == 1:
|
||||
search_length = 7
|
||||
|
@ -22,14 +22,53 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from openlp.core.lib import SettingsTab, translate
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, str_to_bool, translate, Receiver
|
||||
|
||||
class SongsTab(SettingsTab):
|
||||
"""
|
||||
SongsTab is the songs settings tab in the settings dialog.
|
||||
SongsTab is the Songs settings tab in the settings dialog.
|
||||
"""
|
||||
def __init__(self):
|
||||
SettingsTab.__init__(self, translate(u'SongsTab', u'Songs'), u'Songs')
|
||||
|
||||
def setupUi(self):
|
||||
self.setObjectName(u'SongsTab')
|
||||
self.SongsLayout = QtGui.QFormLayout(self)
|
||||
self.SongsLayout.setObjectName(u'SongsLayout')
|
||||
self.SongsModeGroupBox = QtGui.QGroupBox(self)
|
||||
self.SongsModeGroupBox.setObjectName(u'SongsModeGroupBox')
|
||||
self.SongsModeLayout = QtGui.QVBoxLayout(self.SongsModeGroupBox)
|
||||
self.SongsModeLayout.setSpacing(8)
|
||||
self.SongsModeLayout.setMargin(8)
|
||||
self.SongsModeLayout.setObjectName(u'SongsModeLayout')
|
||||
self.SearchAsTypeCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox)
|
||||
self.SearchAsTypeCheckBox.setObjectName(u'SearchAsTypeCheckBox')
|
||||
self.SongsModeLayout.addWidget(self.SearchAsTypeCheckBox)
|
||||
self.SongsLayout.setWidget(
|
||||
0, QtGui.QFormLayout.LabelRole, self.SongsModeGroupBox)
|
||||
QtCore.QObject.connect(self.SearchAsTypeCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onSearchAsTypeCheckBoxChanged)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.SongsModeGroupBox.setTitle(translate(u'SongsTab', u'Songs Mode'))
|
||||
self.SearchAsTypeCheckBox.setText(
|
||||
translate(u'SongsTab', u'Enable search as you type:'))
|
||||
|
||||
def onSearchAsTypeCheckBoxChanged(self, check_state):
|
||||
self.bible_search = False
|
||||
# we have a set value convert to True/False
|
||||
if check_state == QtCore.Qt.Checked:
|
||||
self.bible_search = True
|
||||
|
||||
def load(self):
|
||||
self.bible_search = str_to_bool(
|
||||
self.config.get_config(u'search as type', u'False'))
|
||||
self.SearchAsTypeCheckBox.setChecked(self.bible_search)
|
||||
|
||||
def save(self):
|
||||
self.config.set_config(u'search as type', unicode(self.bible_search))
|
||||
Receiver().send_message(u'config_updated')
|
||||
|
||||
|
@ -27,7 +27,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, translate, buildIcon
|
||||
from openlp.plugins.songs.lib import SongManager, SongMediaItem
|
||||
from openlp.plugins.songs.lib import SongManager, SongMediaItem, SongsTab
|
||||
from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
|
||||
OpenSongImportForm, OpenLPExportForm
|
||||
|
||||
@ -62,6 +62,9 @@ class SongsPlugin(Plugin):
|
||||
def can_be_disabled(self):
|
||||
return True
|
||||
|
||||
def get_settings_tab(self):
|
||||
return SongsTab()
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Songs Initialising')
|
||||
#if self.songmanager is None:
|
||||
|
Loading…
Reference in New Issue
Block a user