mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Show previously used dirname in text control as well
This commit is contained in:
parent
42cb126b01
commit
490f766c4a
@ -15,7 +15,7 @@ from PyQt5.Qt import (
|
|||||||
|
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.ebooks.conversion.plugins.pdf_output import PAPER_SIZES
|
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.widgets2 import Dialog
|
||||||
from calibre.gui2.viewer.main import vprefs
|
from calibre.gui2.viewer.main import vprefs
|
||||||
from calibre.utils.icu import numeric_sort_key
|
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):
|
class PrintDialog(Dialog):
|
||||||
|
|
||||||
|
OUTPUT_NAME = 'print-to-pdf-choose-file'
|
||||||
|
|
||||||
def __init__(self, book_title, parent=None, prefs=vprefs):
|
def __init__(self, book_title, parent=None, prefs=vprefs):
|
||||||
self.book_title = book_title
|
self.book_title = book_title
|
||||||
self.default_file_name = book_title[:75] + '.pdf'
|
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)))
|
l.addRow(QLabel(_('Print %s to a PDF file') % elided_text(self.book_title)))
|
||||||
self.h = h = QHBoxLayout()
|
self.h = h = QHBoxLayout()
|
||||||
self.file_name = f = QLineEdit(self)
|
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)
|
self.browse_button = b = QToolButton(self)
|
||||||
b.setIcon(QIcon(I('document_open.png'))), b.setToolTip(_('Choose location for PDF file'))
|
b.setIcon(QIcon(I('document_open.png'))), b.setToolTip(_('Choose location for PDF file'))
|
||||||
b.clicked.connect(self.choose_file)
|
b.clicked.connect(self.choose_file)
|
||||||
@ -84,7 +91,7 @@ class PrintDialog(Dialog):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
def choose_file(self):
|
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)
|
all_files=False, initial_filename=self.default_file_name)
|
||||||
if ans:
|
if ans:
|
||||||
self.file_name.setText(ans)
|
self.file_name.setText(ans)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user