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)
|
pixmap.save(buf, format, quality=quality)
|
||||||
return bytes(ba.data())
|
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):
|
class ResizableDialog(QDialog):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -11,7 +11,7 @@ import sys, os, importlib
|
|||||||
from PyQt4.Qt import QIcon
|
from PyQt4.Qt import QIcon
|
||||||
|
|
||||||
from calibre.constants import islinux, iswindows
|
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.ptempfile import reset_base_dir
|
||||||
from calibre.utils.config import OptionParser
|
from calibre.utils.config import OptionParser
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ def _run(args, notify=None):
|
|||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
if getattr(opts, 'detach', False):
|
if getattr(opts, 'detach', False):
|
||||||
detach_gui()
|
detach_gui()
|
||||||
|
decouple('edit-book-')
|
||||||
override = 'calibre-edit-book' if islinux else None
|
override = 'calibre-edit-book' if islinux else None
|
||||||
app = Application(args, override_program_name=override)
|
app = Application(args, override_program_name=override)
|
||||||
app.load_builtin_fonts()
|
app.load_builtin_fonts()
|
||||||
|
@ -202,7 +202,11 @@ class DynamicConfig(dict):
|
|||||||
self.file_path = os.path.join(config_dir, name+'.pickle')
|
self.file_path = os.path.join(config_dir, name+'.pickle')
|
||||||
self.refresh()
|
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 = {}
|
d = {}
|
||||||
if os.path.exists(self.file_path):
|
if os.path.exists(self.file_path):
|
||||||
with ExclusiveFile(self.file_path) as f:
|
with ExclusiveFile(self.file_path) as f:
|
||||||
@ -216,7 +220,8 @@ class DynamicConfig(dict):
|
|||||||
print 'Failed to unpickle stored object:'
|
print 'Failed to unpickle stored object:'
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
d = {}
|
d = {}
|
||||||
self.clear()
|
if clear_current:
|
||||||
|
self.clear()
|
||||||
self.update(d)
|
self.update(d)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
@ -280,7 +285,11 @@ class XMLConfig(dict):
|
|||||||
def to_raw(self):
|
def to_raw(self):
|
||||||
return plistlib.writePlistToString(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 = {}
|
d = {}
|
||||||
if os.path.exists(self.file_path):
|
if os.path.exists(self.file_path):
|
||||||
with ExclusiveFile(self.file_path) as f:
|
with ExclusiveFile(self.file_path) as f:
|
||||||
@ -293,7 +302,8 @@ class XMLConfig(dict):
|
|||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
d = {}
|
d = {}
|
||||||
self.clear()
|
if clear_current:
|
||||||
|
self.clear()
|
||||||
self.update(d)
|
self.update(d)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user