mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get Books: WHen downloading books show a popup message telling the user that the books will be added to the calibre library automatically, to help new users understand what is happening. The popup message can be disabled.
This commit is contained in:
parent
4a713b68f6
commit
74d45207f7
@ -14,12 +14,37 @@ from mechanize import MozillaCookieJar
|
||||
from calibre import browser
|
||||
from calibre.constants import __appname__, __version__
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.gui2 import Dispatcher
|
||||
from calibre.gui2 import Dispatcher, gprefs
|
||||
from calibre.gui2.dialogs.message_box import MessageBox
|
||||
from calibre.gui2.threaded_jobs import ThreadedJob
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.web import get_download_filename_from_response
|
||||
|
||||
|
||||
class DownloadInfo(MessageBox):
|
||||
|
||||
def __init__(self, filename, parent=None):
|
||||
MessageBox.__init__(
|
||||
self, MessageBox.INFO, _('Downloading book'), _(
|
||||
'The book {0} will be downloaded and added to your'
|
||||
' calibre library automatically.').format(filename),
|
||||
show_copy_button=False, parent=parent
|
||||
)
|
||||
self.toggle_checkbox.setChecked(True)
|
||||
self.toggle_checkbox.setVisible(True)
|
||||
self.toggle_checkbox.setText(_('Show this message again'))
|
||||
self.toggle_checkbox.toggled.connect(self.show_again_changed)
|
||||
self.resize_needed.emit()
|
||||
|
||||
def show_again_changed(self):
|
||||
gprefs.set('show_get_books_download_info', self.toggle_checkbox.isChecked())
|
||||
|
||||
def show_download_info(filename, parent=None):
|
||||
if not gprefs.get('show_get_books_download_info', True):
|
||||
return
|
||||
DownloadInfo(filename, parent).exec_()
|
||||
|
||||
def get_download_filename(response):
|
||||
filename = get_download_filename_from_response(response)
|
||||
filename, ext = os.path.splitext(filename)
|
||||
|
@ -14,6 +14,7 @@ from PyQt5.Qt import (Qt, QDialog, QDialogButtonBox, QTimer, QCheckBox, QLabel,
|
||||
|
||||
from calibre.gui2 import JSONConfig, info_dialog, error_dialog
|
||||
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
||||
from calibre.gui2.ebook_download import show_download_info
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.store.config.chooser.chooser_widget import StoreChooserWidget
|
||||
from calibre.gui2.store.config.search.search_widget import StoreConfigWidget
|
||||
@ -393,6 +394,7 @@ class SearchDialog(QDialog, Ui_Dialog):
|
||||
ext = d.format()
|
||||
fname = result.title[:60] + '.' + ext.lower()
|
||||
fname = ascii_filename(fname)
|
||||
show_download_info(result.title, parent=self)
|
||||
self.gui.download_ebook(result.downloads[ext], filename=fname)
|
||||
|
||||
def open_store(self, result):
|
||||
|
@ -15,6 +15,7 @@ from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||
from calibre import USER_AGENT, get_proxies
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.gui2 import choose_save_file
|
||||
from calibre.gui2.ebook_download import show_download_info
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.web import get_download_filename
|
||||
@ -91,6 +92,7 @@ class NPWebView(QWebView):
|
||||
if name:
|
||||
self.gui.download_ebook(url, cf, name, name, False)
|
||||
else:
|
||||
show_download_info(filename, self)
|
||||
self.gui.download_ebook(url, cf, filename, tags=self.tags)
|
||||
|
||||
def ignore_ssl_errors(self, reply, errors):
|
||||
|
Loading…
x
Reference in New Issue
Block a user