mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Disable multiple libraries while env var CALIBRE_OVERRIDE_DATABASE_PATH is set
This commit is contained in:
parent
639d6c9c06
commit
6c2ea46ce3
@ -160,15 +160,17 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
self.action_choose.triggered.connect(self.choose_library,
|
self.action_choose.triggered.connect(self.choose_library,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
self.choose_menu = QMenu(self.gui)
|
self.choose_menu = QMenu(self.gui)
|
||||||
self.choose_menu.addAction(self.action_choose)
|
|
||||||
self.qaction.setMenu(self.choose_menu)
|
self.qaction.setMenu(self.choose_menu)
|
||||||
|
|
||||||
self.quick_menu = QMenu(_('Quick switch'))
|
if not os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', None):
|
||||||
self.quick_menu_action = self.choose_menu.addMenu(self.quick_menu)
|
self.choose_menu.addAction(self.action_choose)
|
||||||
self.rename_menu = QMenu(_('Rename library'))
|
|
||||||
self.rename_menu_action = self.choose_menu.addMenu(self.rename_menu)
|
self.quick_menu = QMenu(_('Quick switch'))
|
||||||
self.delete_menu = QMenu(_('Delete library'))
|
self.quick_menu_action = self.choose_menu.addMenu(self.quick_menu)
|
||||||
self.delete_menu_action = self.choose_menu.addMenu(self.delete_menu)
|
self.rename_menu = QMenu(_('Rename library'))
|
||||||
|
self.rename_menu_action = self.choose_menu.addMenu(self.rename_menu)
|
||||||
|
self.delete_menu = QMenu(_('Delete library'))
|
||||||
|
self.delete_menu_action = self.choose_menu.addMenu(self.delete_menu)
|
||||||
|
|
||||||
self.rename_separator = self.choose_menu.addSeparator()
|
self.rename_separator = self.choose_menu.addSeparator()
|
||||||
|
|
||||||
@ -223,6 +225,8 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
self.library_changed(self.gui.library_view.model().db)
|
self.library_changed(self.gui.library_view.model().db)
|
||||||
|
|
||||||
def build_menus(self):
|
def build_menus(self):
|
||||||
|
if os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', None):
|
||||||
|
return
|
||||||
db = self.gui.library_view.model().db
|
db = self.gui.library_view.model().db
|
||||||
locations = list(self.stats.locations(db))
|
locations = list(self.stats.locations(db))
|
||||||
for ac in self.switch_actions:
|
for ac in self.switch_actions:
|
||||||
@ -387,6 +391,11 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
c.exec_()
|
c.exec_()
|
||||||
|
|
||||||
def change_library_allowed(self):
|
def change_library_allowed(self):
|
||||||
|
if os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', None):
|
||||||
|
warning_dialog(self.gui, _('Not allowed'),
|
||||||
|
_('You cannot change libraries while using the environment'
|
||||||
|
' variable CALIBRE_OVERRIDE_DATABASE_PATH.'), show=True)
|
||||||
|
return False
|
||||||
if self.gui.job_manager.has_jobs():
|
if self.gui.job_manager.has_jobs():
|
||||||
warning_dialog(self.gui, _('Not allowed'),
|
warning_dialog(self.gui, _('Not allowed'),
|
||||||
_('You cannot change libraries while jobs'
|
_('You cannot change libraries while jobs'
|
||||||
|
@ -12,7 +12,7 @@ from threading import Thread
|
|||||||
from PyQt4.Qt import QMenu, QToolButton
|
from PyQt4.Qt import QMenu, QToolButton
|
||||||
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2 import error_dialog, Dispatcher
|
from calibre.gui2 import error_dialog, Dispatcher, warning_dialog
|
||||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
|
|
||||||
@ -106,6 +106,9 @@ class CopyToLibraryAction(InterfaceAction):
|
|||||||
|
|
||||||
def build_menus(self):
|
def build_menus(self):
|
||||||
self.menu.clear()
|
self.menu.clear()
|
||||||
|
if os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', None):
|
||||||
|
self.menu.addAction('disabled', self.cannot_do_dialog)
|
||||||
|
return
|
||||||
db = self.gui.library_view.model().db
|
db = self.gui.library_view.model().db
|
||||||
locations = list(self.stats.locations(db))
|
locations = list(self.stats.locations(db))
|
||||||
for name, loc in locations:
|
for name, loc in locations:
|
||||||
@ -160,5 +163,9 @@ class CopyToLibraryAction(InterfaceAction):
|
|||||||
self.gui.iactions['Remove Books'].library_ids_deleted(
|
self.gui.iactions['Remove Books'].library_ids_deleted(
|
||||||
self.worker.processed, row)
|
self.worker.processed, row)
|
||||||
|
|
||||||
|
def cannot_do_dialog(self):
|
||||||
|
warning_dialog(self.gui, _('Not allowed'),
|
||||||
|
_('You cannot use other libraries while using the environment'
|
||||||
|
' variable CALIBRE_OVERRIDE_DATABASE_PATH.'), show=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,3 +72,5 @@ Precautions
|
|||||||
--------------
|
--------------
|
||||||
|
|
||||||
Portable media can occasionally fail so you should make periodic backups of you Calibre library. This can be done by making a copy of the CalibreLibrary folder and all its contents. There are many freely available tools around that can optimise such back processes, well known ones being RoboCopy and RichCopy. However you can simply use a Windows copy facility if you cannot be bothered to use a specialised tools.
|
Portable media can occasionally fail so you should make periodic backups of you Calibre library. This can be done by making a copy of the CalibreLibrary folder and all its contents. There are many freely available tools around that can optimise such back processes, well known ones being RoboCopy and RichCopy. However you can simply use a Windows copy facility if you cannot be bothered to use a specialised tools.
|
||||||
|
|
||||||
|
Using the environment variable CALIBRE_OVERRIDE_DATABASE_PATH disables multiple-library support in |app|. Avoid setting this variable in calibre-portable.bat unless you really need it.
|
Loading…
x
Reference in New Issue
Block a user