mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get books tweaks
This commit is contained in:
parent
f805cc60d6
commit
958ae79839
@ -10,8 +10,8 @@ from functools import partial
|
||||
|
||||
from PyQt4.Qt import QMenu
|
||||
|
||||
from calibre.gui2 import JSONConfig
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
|
||||
class StoreAction(InterfaceAction):
|
||||
|
||||
@ -19,8 +19,6 @@ class StoreAction(InterfaceAction):
|
||||
action_spec = (_('Get books'), 'store.png', None, None)
|
||||
|
||||
def genesis(self):
|
||||
self.config = JSONConfig('store/action')
|
||||
|
||||
self.qaction.triggered.connect(self.search)
|
||||
self.store_menu = QMenu()
|
||||
self.load_menu()
|
||||
@ -34,7 +32,7 @@ class StoreAction(InterfaceAction):
|
||||
self.qaction.setMenu(self.store_menu)
|
||||
|
||||
def search(self):
|
||||
self.first_run_check()
|
||||
self.show_disclaimer()
|
||||
from calibre.gui2.store.search import SearchDialog
|
||||
sd = SearchDialog(self.gui.istores, self.gui)
|
||||
sd.exec_()
|
||||
@ -43,18 +41,15 @@ class StoreAction(InterfaceAction):
|
||||
self.first_run_check()
|
||||
store_plugin.open(self.gui)
|
||||
|
||||
def first_run_check(self):
|
||||
if self.config.get('first_run', True):
|
||||
self.config['first_run'] = False
|
||||
from calibre.gui2 import info_dialog
|
||||
info_dialog(self.gui, _('About Get Books'), '<p>' +
|
||||
def show_disclaimer(self):
|
||||
confirm(('<p>' +
|
||||
_('Calibre helps you find the ebooks you want by searching '
|
||||
'the websites of a variety of commercial and public domain '
|
||||
'the websites of various commercial and public domain '
|
||||
'book sources for you.') +
|
||||
'<p>' +
|
||||
_('Using the integrated search you can easily find which '
|
||||
'store has the book you are looking for, at the best price. '
|
||||
'You will also get DRM status and other useful information.')
|
||||
'You also get DRM status and other useful information.')
|
||||
+ '<p>' +
|
||||
_('All transactions (paid or otherwise) are handled between '
|
||||
'you and the particular website. '
|
||||
@ -64,4 +59,7 @@ class StoreAction(InterfaceAction):
|
||||
'will work with your e-book reader, especially if the book you '
|
||||
'are buying has '
|
||||
'<a href="http://drmfree.calibre-ebook.com/about#drm">DRM</a>.'
|
||||
), show=True, show_copy_button=False)
|
||||
)), 'about_get_books_msg',
|
||||
parent=self.gui, show_cancel_button=False,
|
||||
confirm_msg=_('Show this message again'),
|
||||
pixmap='dialog_information.png', title=_('About Get Books'))
|
||||
|
@ -25,7 +25,7 @@ class Dialog(QDialog, Ui_Dialog):
|
||||
|
||||
|
||||
def confirm(msg, name, parent=None, pixmap='dialog_warning.png', title=None,
|
||||
show_cancel_button=True):
|
||||
show_cancel_button=True, confirm_msg=None):
|
||||
if not dynamic.get(confirm_config_name(name), True):
|
||||
return True
|
||||
d = Dialog(msg, name, parent)
|
||||
@ -35,5 +35,7 @@ def confirm(msg, name, parent=None, pixmap='dialog_warning.png', title=None,
|
||||
d.setWindowTitle(title)
|
||||
if not show_cancel_button:
|
||||
d.buttonBox.button(d.buttonBox.Cancel).setVisible(False)
|
||||
if confirm_msg is not None:
|
||||
d.again.setText(confirm_msg)
|
||||
d.resize(d.sizeHint())
|
||||
return d.exec_() == d.Accepted
|
||||
|
@ -396,7 +396,7 @@ class DetailsThreadPool(GenericDownloadThreadPool):
|
||||
|
||||
|
||||
class DetailsThread(Thread):
|
||||
|
||||
|
||||
def __init__(self, tasks, results):
|
||||
Thread.__init__(self)
|
||||
self.daemon = True
|
||||
@ -428,11 +428,14 @@ class Matches(QAbstractItemModel):
|
||||
|
||||
def __init__(self):
|
||||
QAbstractItemModel.__init__(self)
|
||||
|
||||
self.DRM_LOCKED_ICON = QPixmap(I('drm-locked.png')).scaledToHeight(64)
|
||||
self.DRM_UNLOCKED_ICON = QPixmap(I('drm-unlocked.png')).scaledToHeight(64)
|
||||
self.DRM_UNKNOWN_ICON = QPixmap(I('dialog_warning.png')).scaledToHeight(64)
|
||||
|
||||
|
||||
self.DRM_LOCKED_ICON = QPixmap(I('drm-locked.png')).scaledToHeight(64,
|
||||
Qt.SmoothTransformation)
|
||||
self.DRM_UNLOCKED_ICON = QPixmap(I('drm-unlocked.png')).scaledToHeight(64,
|
||||
Qt.SmoothTransformation)
|
||||
self.DRM_UNKNOWN_ICON = QPixmap(I('dialog_question.png')).scaledToHeight(64,
|
||||
Qt.SmoothTransformation)
|
||||
|
||||
# All matches. Used to determine the order to display
|
||||
# self.matches because the SearchFilter returns
|
||||
# matches unordered.
|
||||
@ -482,7 +485,7 @@ class Matches(QAbstractItemModel):
|
||||
return self.matches[row]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def filter_results(self):
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
if self.query:
|
||||
@ -611,13 +614,13 @@ class Matches(QAbstractItemModel):
|
||||
self.reorder_matches()
|
||||
if reset:
|
||||
self.reset()
|
||||
|
||||
|
||||
def reorder_matches(self):
|
||||
self.matches = sorted(self.matches, key=lambda x: self.all_matches.index(x))
|
||||
|
||||
|
||||
class SearchFilter(SearchQueryParser):
|
||||
|
||||
|
||||
USABLE_LOCATIONS = [
|
||||
'all',
|
||||
'author',
|
||||
@ -637,7 +640,7 @@ class SearchFilter(SearchQueryParser):
|
||||
|
||||
def add_search_result(self, search_result):
|
||||
self.srs.add(search_result)
|
||||
|
||||
|
||||
def clear_search_results(self):
|
||||
self.srs = set([])
|
||||
|
||||
@ -710,7 +713,7 @@ class SearchFilter(SearchQueryParser):
|
||||
m = CONTAINS_MATCH
|
||||
else:
|
||||
m = matchkind
|
||||
|
||||
|
||||
if locvalue == 'format':
|
||||
vals = accessor(sr).split(',')
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user