From 958ae798392bd3e11f0f01b6c46ec5af7c05f519 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Apr 2011 20:19:40 -0600 Subject: [PATCH] Get books tweaks --- src/calibre/gui2/actions/store.py | 22 +++++++++---------- src/calibre/gui2/dialogs/confirm_delete.py | 4 +++- src/calibre/gui2/store/search.py | 25 ++++++++++++---------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/calibre/gui2/actions/store.py b/src/calibre/gui2/actions/store.py index 1c232f8483..aa54cbcc04 100644 --- a/src/calibre/gui2/actions/store.py +++ b/src/calibre/gui2/actions/store.py @@ -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'), '

' + + def show_disclaimer(self): + confirm(('

' + _('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.') + '

' + _('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.') + '

' + _('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 ' 'DRM.' - ), 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')) diff --git a/src/calibre/gui2/dialogs/confirm_delete.py b/src/calibre/gui2/dialogs/confirm_delete.py index fe4ad60ace..664afd507b 100644 --- a/src/calibre/gui2/dialogs/confirm_delete.py +++ b/src/calibre/gui2/dialogs/confirm_delete.py @@ -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 diff --git a/src/calibre/gui2/store/search.py b/src/calibre/gui2/store/search.py index 224fa852e7..69c3bd2f06 100644 --- a/src/calibre/gui2/store/search.py +++ b/src/calibre/gui2/store/search.py @@ -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: