Dropped the results dropdowns in favour of a toggle button.

This commit is contained in:
Raoul Snyman 2011-05-12 01:59:04 +02:00
parent 5e954d86b6
commit e55e9f284a
2 changed files with 25 additions and 23 deletions

View File

@ -55,6 +55,8 @@ class BibleMediaItem(MediaManagerItem):
def __init__(self, parent, plugin, icon): def __init__(self, parent, plugin, icon):
self.IconPath = u'songs/song' self.IconPath = u'songs/song'
self.lockIcon = QtGui.QIcon(u':/bibles/bibles_search_lock.png')
self.unlockIcon = QtGui.QIcon(u':/bibles/bibles_search_unlock.png')
MediaManagerItem.__init__(self, parent, plugin, icon) MediaManagerItem.__init__(self, parent, plugin, icon)
# Place to store the search results for both bibles. # Place to store the search results for both bibles.
self.settings = self.parent.settings_tab self.settings = self.parent.settings_tab
@ -112,27 +114,27 @@ class BibleMediaItem(MediaManagerItem):
secondComboBox = media_item_combo_box(tab, prefix + u'SecondComboBox') secondComboBox = media_item_combo_box(tab, prefix + u'SecondComboBox')
versionLabel.setBuddy(secondComboBox) versionLabel.setBuddy(secondComboBox)
layout.addWidget(secondComboBox, idx + 1, 1, 1, 2) layout.addWidget(secondComboBox, idx + 1, 1, 1, 2)
clearLabel = QtGui.QLabel(tab)
clearLabel.setObjectName(prefix + u'ClearLabel')
layout.addWidget(clearLabel, idx + 2, 0, QtCore.Qt.AlignRight)
clearComboBox = media_item_combo_box(tab, prefix + u'ClearComboBox')
clearLabel.setBuddy(clearComboBox)
layout.addWidget(clearComboBox, idx + 2, 1, 1, 2)
searchButtonLayout = QtGui.QHBoxLayout() searchButtonLayout = QtGui.QHBoxLayout()
searchButtonLayout.setObjectName(prefix + u'SearchButtonLayout') searchButtonLayout.setObjectName(prefix + u'SearchButtonLayout')
searchButtonLayout.addStretch() searchButtonLayout.addStretch()
lockButton = QtGui.QToolButton(tab)
lockButton.setIcon(self.unlockIcon)
lockButton.setCheckable(True)
lockButton.setObjectName(prefix + u'LockButton')
searchButtonLayout.addWidget(lockButton)
searchButton = QtGui.QPushButton(tab) searchButton = QtGui.QPushButton(tab)
searchButton.setObjectName(prefix + u'SearchButton') searchButton.setObjectName(prefix + u'SearchButton')
searchButtonLayout.addWidget(searchButton) searchButtonLayout.addWidget(searchButton)
layout.addLayout(searchButtonLayout, idx + 3, 1, 1, 2) layout.addLayout(searchButtonLayout, idx + 2, 1, 1, 2)
self.pageLayout.addWidget(tab) self.pageLayout.addWidget(tab)
tab.setVisible(False) tab.setVisible(False)
QtCore.QObject.connect(lockButton, QtCore.SIGNAL(u'toggled(bool)'),
self.onLockButtonToggled)
setattr(self, prefix + u'VersionLabel', versionLabel) setattr(self, prefix + u'VersionLabel', versionLabel)
setattr(self, prefix + u'VersionComboBox', versionComboBox) setattr(self, prefix + u'VersionComboBox', versionComboBox)
setattr(self, prefix + u'SecondLabel', secondLabel) setattr(self, prefix + u'SecondLabel', secondLabel)
setattr(self, prefix + u'SecondComboBox', secondComboBox) setattr(self, prefix + u'SecondComboBox', secondComboBox)
setattr(self, prefix + u'ClearLabel', clearLabel) setattr(self, prefix + u'LockButton', lockButton)
setattr(self, prefix + u'ClearComboBox', clearComboBox)
setattr(self, prefix + u'SearchButtonLayout', searchButtonLayout) setattr(self, prefix + u'SearchButtonLayout', searchButtonLayout)
setattr(self, prefix + u'SearchButton', searchButton) setattr(self, prefix + u'SearchButton', searchButton)
@ -255,8 +257,8 @@ class BibleMediaItem(MediaManagerItem):
self.quickSearchLabel.setText( self.quickSearchLabel.setText(
translate('BiblesPlugin.MediaItem', 'Find:')) translate('BiblesPlugin.MediaItem', 'Find:'))
self.quickSearchButton.setText(UiStrings().Search) self.quickSearchButton.setText(UiStrings().Search)
self.quickClearLabel.setText( self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
translate('BiblesPlugin.MediaItem', 'Results:')) 'Toggle to keep or clear the previous results'))
self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version) self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version)
self.advancedSecondLabel.setText( self.advancedSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:')) translate('BiblesPlugin.MediaItem', 'Second:'))
@ -270,17 +272,9 @@ class BibleMediaItem(MediaManagerItem):
translate('BiblesPlugin.MediaItem', 'From:')) translate('BiblesPlugin.MediaItem', 'From:'))
self.advancedToLabel.setText( self.advancedToLabel.setText(
translate('BiblesPlugin.MediaItem', 'To:')) translate('BiblesPlugin.MediaItem', 'To:'))
self.advancedClearLabel.setText(
translate('BiblesPlugin.MediaItem', 'Results:'))
self.advancedSearchButton.setText(UiStrings().Search) self.advancedSearchButton.setText(UiStrings().Search)
self.quickClearComboBox.addItem( self.advancedLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
translate('BiblesPlugin.MediaItem', 'Clear')) 'Toggle to keep or clear the previous results'))
self.quickClearComboBox.addItem(
translate('BiblesPlugin.MediaItem', 'Keep'))
self.advancedClearComboBox.addItem(
translate('BiblesPlugin.MediaItem', 'Clear'))
self.advancedClearComboBox.addItem(
translate('BiblesPlugin.MediaItem', 'Keep'))
self.quickLayoutLabel.setText(UiStrings().LayoutStyle) self.quickLayoutLabel.setText(UiStrings().LayoutStyle)
self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerSlide, self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide) UiStrings().VersePerSlide)
@ -325,6 +319,12 @@ class BibleMediaItem(MediaManagerItem):
self.quickTab.setVisible(False) self.quickTab.setVisible(False)
self.advancedTab.setVisible(True) self.advancedTab.setVisible(True)
def onLockButtonToggled(self, checked):
if checked:
self.sender().setIcon(self.lockIcon)
else:
self.sender().setIcon(self.unlockIcon)
def loadBibles(self): def loadBibles(self):
log.debug(u'Loading Bibles') log.debug(u'Loading Bibles')
self.quickVersionComboBox.clear() self.quickVersionComboBox.clear()
@ -530,7 +530,7 @@ class BibleMediaItem(MediaManagerItem):
if second_bible: if second_bible:
self.second_search_results = self.parent.manager.get_verses( self.second_search_results = self.parent.manager.get_verses(
second_bible, versetext) second_bible, versetext)
if self.advancedClearComboBox.currentIndex() == 0: if not self.advancedLockButton.isChecked():
self.listView.clear() self.listView.clear()
if self.listView.count() != 0: if self.listView.count() != 0:
self.__checkSecondBible(bible, second_bible) self.__checkSecondBible(bible, second_bible)
@ -571,7 +571,7 @@ class BibleMediaItem(MediaManagerItem):
verse.verse)) verse.verse))
self.second_search_results = \ self.second_search_results = \
bibles[second_bible].get_verses(text) bibles[second_bible].get_verses(text)
if self.quickClearComboBox.currentIndex() == 0: if not self.quickLockButton.isChecked():
self.listView.clear() self.listView.clear()
if self.listView.count() != 0 and self.search_results: if self.listView.count() != 0 and self.search_results:
self.__checkSecondBible(bible, second_bible) self.__checkSecondBible(bible, second_bible)

View File

@ -24,6 +24,8 @@
<qresource prefix="bibles"> <qresource prefix="bibles">
<file>bibles_search_text.png</file> <file>bibles_search_text.png</file>
<file>bibles_search_reference.png</file> <file>bibles_search_reference.png</file>
<file>bibles_search_unlock.png</file>
<file>bibles_search_lock.png</file>
</qresource> </qresource>
<qresource prefix="plugins"> <qresource prefix="plugins">
<file>plugin_alerts.png</file> <file>plugin_alerts.png</file>