mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get Books: Fix searching for current book/title/author by right clicking the get books icon
This commit is contained in:
commit
a1fd361f81
@ -88,9 +88,7 @@ class StoreAction(InterfaceAction):
|
|||||||
if row == None:
|
if row == None:
|
||||||
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
|
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
|
||||||
return
|
return
|
||||||
|
self.search({ 'author': self._get_author(row) })
|
||||||
query = 'author:"%s"' % self._get_author(row)
|
|
||||||
self.search(query)
|
|
||||||
|
|
||||||
def _get_title(self, row):
|
def _get_title(self, row):
|
||||||
title = ''
|
title = ''
|
||||||
@ -107,18 +105,14 @@ class StoreAction(InterfaceAction):
|
|||||||
if row == None:
|
if row == None:
|
||||||
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
|
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
|
||||||
return
|
return
|
||||||
|
self.search({ 'title': self._get_title(row) })
|
||||||
query = 'title:"%s"' % self._get_title(row)
|
|
||||||
self.search(query)
|
|
||||||
|
|
||||||
def search_author_title(self):
|
def search_author_title(self):
|
||||||
row = self._get_selected_row()
|
row = self._get_selected_row()
|
||||||
if row == None:
|
if row == None:
|
||||||
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
|
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
|
||||||
return
|
return
|
||||||
|
self.search({ 'author': self._get_author(row), 'title': self._get_title(row) })
|
||||||
query = 'author:"%s" title:"%s"' % (self._get_author(row), self._get_title(row))
|
|
||||||
self.search(query)
|
|
||||||
|
|
||||||
def choose(self):
|
def choose(self):
|
||||||
from calibre.gui2.store.config.chooser.chooser_dialog import StoreChooserDialog
|
from calibre.gui2.store.config.chooser.chooser_dialog import StoreChooserDialog
|
||||||
|
@ -62,16 +62,20 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
self.setup_store_checks()
|
self.setup_store_checks()
|
||||||
|
|
||||||
# Set the search query
|
# Set the search query
|
||||||
|
if isinstance(query, (str, unicode)):
|
||||||
|
self.search_edit.setText(query)
|
||||||
|
elif isinstance(query, dict):
|
||||||
|
if 'author' in query:
|
||||||
|
self.search_author.setText(query['author'])
|
||||||
|
if 'title' in query:
|
||||||
|
self.search_title.setText(query['title'])
|
||||||
# Title
|
# Title
|
||||||
self.search_title.setText(query)
|
|
||||||
self.search_title.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
self.search_title.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
self.search_title.setMinimumContentsLength(25)
|
self.search_title.setMinimumContentsLength(25)
|
||||||
# Author
|
# Author
|
||||||
self.search_author.setText(query)
|
|
||||||
self.search_author.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
self.search_author.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
self.search_author.setMinimumContentsLength(25)
|
self.search_author.setMinimumContentsLength(25)
|
||||||
# Keyword
|
# Keyword
|
||||||
self.search_edit.setText(query)
|
|
||||||
self.search_edit.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
self.search_edit.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
self.search_edit.setMinimumContentsLength(25)
|
self.search_edit.setMinimumContentsLength(25)
|
||||||
|
|
||||||
@ -408,7 +412,7 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
self.save_state()
|
self.save_state()
|
||||||
|
|
||||||
def exec_(self):
|
def exec_(self):
|
||||||
if unicode(self.search_edit.text()).strip():
|
if unicode(self.search_edit.text()).strip() or unicode(self.search_title.text()).strip() or unicode(self.search_author.text()).strip():
|
||||||
self.do_search()
|
self.do_search()
|
||||||
return QDialog.exec_(self)
|
return QDialog.exec_(self)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user