mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Fix previously used locations for file open dialogs not being remembered when edit book is launched from within the main calibre program
This commit is contained in:
parent
3f3e09d80d
commit
a2727ec253
@ -763,6 +763,12 @@ def pixmap_to_data(pixmap, format='JPEG', quality=90):
|
||||
pixmap.save(buf, format, quality=quality)
|
||||
return bytes(ba.data())
|
||||
|
||||
def decouple(prefix):
|
||||
' Ensure that config files used by utility code are not the same as those used by the main calibre GUI '
|
||||
dynamic.decouple(prefix)
|
||||
from calibre.gui2.widgets import history
|
||||
history.decouple(prefix)
|
||||
|
||||
class ResizableDialog(QDialog):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -11,7 +11,7 @@ import sys, os, importlib
|
||||
from PyQt4.Qt import QIcon
|
||||
|
||||
from calibre.constants import islinux, iswindows
|
||||
from calibre.gui2 import Application, ORG_NAME, APP_UID, setup_gui_option_parser, detach_gui
|
||||
from calibre.gui2 import Application, ORG_NAME, APP_UID, setup_gui_option_parser, detach_gui, decouple
|
||||
from calibre.ptempfile import reset_base_dir
|
||||
from calibre.utils.config import OptionParser
|
||||
|
||||
@ -54,6 +54,7 @@ def _run(args, notify=None):
|
||||
opts, args = parser.parse_args(args)
|
||||
if getattr(opts, 'detach', False):
|
||||
detach_gui()
|
||||
decouple('edit-book-')
|
||||
override = 'calibre-edit-book' if islinux else None
|
||||
app = Application(args, override_program_name=override)
|
||||
app.load_builtin_fonts()
|
||||
|
@ -202,7 +202,11 @@ class DynamicConfig(dict):
|
||||
self.file_path = os.path.join(config_dir, name+'.pickle')
|
||||
self.refresh()
|
||||
|
||||
def refresh(self):
|
||||
def decouple(self, prefix):
|
||||
self.file_path = os.path.join(os.path.dirname(self.file_path), prefix + os.path.basename(self.file_path))
|
||||
self.refresh(clear_current=False)
|
||||
|
||||
def refresh(self, clear_current=True):
|
||||
d = {}
|
||||
if os.path.exists(self.file_path):
|
||||
with ExclusiveFile(self.file_path) as f:
|
||||
@ -216,6 +220,7 @@ class DynamicConfig(dict):
|
||||
print 'Failed to unpickle stored object:'
|
||||
traceback.print_exc()
|
||||
d = {}
|
||||
if clear_current:
|
||||
self.clear()
|
||||
self.update(d)
|
||||
|
||||
@ -280,7 +285,11 @@ class XMLConfig(dict):
|
||||
def to_raw(self):
|
||||
return plistlib.writePlistToString(self)
|
||||
|
||||
def refresh(self):
|
||||
def decouple(self, prefix):
|
||||
self.file_path = os.path.join(os.path.dirname(self.file_path), prefix + os.path.basename(self.file_path))
|
||||
self.refresh(clear_current=False)
|
||||
|
||||
def refresh(self, clear_current=True):
|
||||
d = {}
|
||||
if os.path.exists(self.file_path):
|
||||
with ExclusiveFile(self.file_path) as f:
|
||||
@ -293,6 +302,7 @@ class XMLConfig(dict):
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
d = {}
|
||||
if clear_current:
|
||||
self.clear()
|
||||
self.update(d)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user