From 490f766c4a3cb42f3095f3e43e2c05d10c97f605 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 2 May 2015 10:33:45 +0530 Subject: [PATCH] Show previously used dirname in text control as well --- src/calibre/gui2/viewer/printing.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/viewer/printing.py b/src/calibre/gui2/viewer/printing.py index 74b3b67771..9727be4b91 100644 --- a/src/calibre/gui2/viewer/printing.py +++ b/src/calibre/gui2/viewer/printing.py @@ -15,7 +15,7 @@ from PyQt5.Qt import ( from calibre.ptempfile import PersistentTemporaryFile from calibre.ebooks.conversion.plugins.pdf_output import PAPER_SIZES -from calibre.gui2 import elided_text, error_dialog, choose_save_file, Application, open_local_file +from calibre.gui2 import elided_text, error_dialog, choose_save_file, Application, open_local_file, dynamic from calibre.gui2.widgets2 import Dialog from calibre.gui2.viewer.main import vprefs from calibre.utils.icu import numeric_sort_key @@ -23,6 +23,8 @@ from calibre.utils.ipc.simple_worker import start_pipe_worker class PrintDialog(Dialog): + OUTPUT_NAME = 'print-to-pdf-choose-file' + def __init__(self, book_title, parent=None, prefs=vprefs): self.book_title = book_title self.default_file_name = book_title[:75] + '.pdf' @@ -34,7 +36,12 @@ class PrintDialog(Dialog): l.addRow(QLabel(_('Print %s to a PDF file') % elided_text(self.book_title))) self.h = h = QHBoxLayout() self.file_name = f = QLineEdit(self) - f.setText(os.path.abspath(os.path.join(os.path.expanduser('~'), self.default_file_name))) + val = dynamic.get(self.OUTPUT_NAME, None) + if not val: + val = os.path.expanduser('~') + else: + val = os.path.dirname(val) + f.setText(os.path.abspath(os.path.join(val, self.default_file_name))) self.browse_button = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))), b.setToolTip(_('Choose location for PDF file')) b.clicked.connect(self.choose_file) @@ -84,7 +91,7 @@ class PrintDialog(Dialog): return ans def choose_file(self): - ans = choose_save_file(self, 'print-to-pdf-choose-file', _('PDF file'), filters=[(_('PDF file'), 'pdf')], + ans = choose_save_file(self, self.OUTPUT_NAME, _('PDF file'), filters=[(_('PDF file'), 'pdf')], all_files=False, initial_filename=self.default_file_name) if ans: self.file_name.setText(ans)