mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Various minor fixes
This commit is contained in:
parent
f5ead89608
commit
0214d576d4
@ -43,6 +43,10 @@ class AddAction(InterfaceAction):
|
|||||||
self.qaction.setMenu(self.add_menu)
|
self.qaction.setMenu(self.add_menu)
|
||||||
self.qaction.triggered.connect(self.add_books)
|
self.qaction.triggered.connect(self.add_books)
|
||||||
|
|
||||||
|
def location_selected(self, loc):
|
||||||
|
enabled = loc == 'library'
|
||||||
|
for action in list(self.add_menu.actions())[1:]:
|
||||||
|
action.setEnabled(enabled)
|
||||||
|
|
||||||
def add_recursive(self, single):
|
def add_recursive(self, single):
|
||||||
root = choose_dir(self.gui, 'recursive book import root dir dialog',
|
root = choose_dir(self.gui, 'recursive book import root dir dialog',
|
||||||
|
@ -91,7 +91,7 @@ class FetchAnnotationsAction(InterfaceAction):
|
|||||||
|
|
||||||
self.am = annotation_map
|
self.am = annotation_map
|
||||||
self.done_callback = done_callback
|
self.done_callback = done_callback
|
||||||
self.pd.canceled.connect(self.canceled)
|
self.pd.canceled_signal.connect(self.canceled)
|
||||||
self.pd.setModal(True)
|
self.pd.setModal(True)
|
||||||
self.pd.show()
|
self.pd.show()
|
||||||
self.update_progress.connect(self.pd.set_value,
|
self.update_progress.connect(self.pd.set_value,
|
||||||
|
@ -58,6 +58,11 @@ class SaveToDiskAction(InterfaceAction):
|
|||||||
self.save_sub_menu.save_fmt.connect(self.save_specific_format_disk)
|
self.save_sub_menu.save_fmt.connect(self.save_specific_format_disk)
|
||||||
self.qaction.setMenu(self.save_menu)
|
self.qaction.setMenu(self.save_menu)
|
||||||
|
|
||||||
|
def location_selected(self, loc):
|
||||||
|
enabled = loc == 'library'
|
||||||
|
for action in list(self.save_menu.actions())[1:]:
|
||||||
|
action.setEnabled(enabled)
|
||||||
|
|
||||||
def reread_prefs(self):
|
def reread_prefs(self):
|
||||||
self.save_menu.actions()[2].setText(
|
self.save_menu.actions()[2].setText(
|
||||||
_('Save only %s format to disk')%
|
_('Save only %s format to disk')%
|
||||||
@ -88,8 +93,9 @@ class SaveToDiskAction(InterfaceAction):
|
|||||||
_('Choose destination directory'))
|
_('Choose destination directory'))
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
dpath = os.path.abspath(path).replace('/', os.sep)
|
dpath = os.path.abspath(path).replace('/', os.sep)+os.sep
|
||||||
lpath = self.gui.library_view.model().db.library_path.replace('/', os.sep)
|
lpath = self.gui.library_view.model().db.library_path.replace('/',
|
||||||
|
os.sep)+os.sep
|
||||||
if dpath.startswith(lpath):
|
if dpath.startswith(lpath):
|
||||||
return error_dialog(self.gui, _('Not allowed'),
|
return error_dialog(self.gui, _('Not allowed'),
|
||||||
_('You are trying to save files into the calibre '
|
_('You are trying to save files into the calibre '
|
||||||
|
@ -443,7 +443,7 @@ class Saver(QObject):
|
|||||||
from calibre.ebooks.metadata.worker import SaveWorker
|
from calibre.ebooks.metadata.worker import SaveWorker
|
||||||
self.worker = SaveWorker(self.rq, db, self.ids, path, self.opts,
|
self.worker = SaveWorker(self.rq, db, self.ids, path, self.opts,
|
||||||
spare_server=self.spare_server)
|
spare_server=self.spare_server)
|
||||||
self.pd.canceled.connect(self.canceled)
|
self.pd.canceled_signal.connect(self.canceled)
|
||||||
self.timer = QTimer(self)
|
self.timer = QTimer(self)
|
||||||
self.connect(self.timer, SIGNAL('timeout()'), self.update)
|
self.connect(self.timer, SIGNAL('timeout()'), self.update)
|
||||||
self.timer.start(200)
|
self.timer.start(200)
|
||||||
|
@ -11,7 +11,7 @@ from calibre.gui2.dialogs.progress_ui import Ui_Dialog
|
|||||||
|
|
||||||
class ProgressDialog(QDialog, Ui_Dialog):
|
class ProgressDialog(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
canceled = pyqtSignal()
|
canceled_signal = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, title, msg='', min=0, max=99, parent=None):
|
def __init__(self, title, msg='', min=0, max=99, parent=None):
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
@ -52,7 +52,7 @@ class ProgressDialog(QDialog, Ui_Dialog):
|
|||||||
self.canceled = True
|
self.canceled = True
|
||||||
self.button_box.setDisabled(True)
|
self.button_box.setDisabled(True)
|
||||||
self.title.setText(_('Aborting...'))
|
self.title.setText(_('Aborting...'))
|
||||||
self.canceled.emit()
|
self.canceled_signal.emit()
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
if ev.key() == Qt.Key_Escape:
|
if ev.key() == Qt.Key_Escape:
|
||||||
|
@ -50,9 +50,10 @@ class LibraryViewMixin(object): # {{{
|
|||||||
populate_menu(lm, LIBRARY_CONTEXT_MENU)
|
populate_menu(lm, LIBRARY_CONTEXT_MENU)
|
||||||
dm = QMenu(self)
|
dm = QMenu(self)
|
||||||
populate_menu(dm, DEVICE_CONTEXT_MENU)
|
populate_menu(dm, DEVICE_CONTEXT_MENU)
|
||||||
self.library_view.set_context_menu(lm)
|
ec = self.iactions['Edit Collections'].qaction
|
||||||
|
self.library_view.set_context_menu(lm, ec)
|
||||||
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||||
v.set_context_menu(dm)
|
v.set_context_menu(dm, ec)
|
||||||
|
|
||||||
self.library_view.files_dropped.connect(self.iactions['Add Books'].files_dropped, type=Qt.QueuedConnection)
|
self.library_view.files_dropped.connect(self.iactions['Add Books'].files_dropped, type=Qt.QueuedConnection)
|
||||||
for func, args in [
|
for func, args in [
|
||||||
|
@ -389,9 +389,10 @@ class BooksView(QTableView): # {{{
|
|||||||
#}}}
|
#}}}
|
||||||
|
|
||||||
# Context Menu {{{
|
# Context Menu {{{
|
||||||
def set_context_menu(self, menu):
|
def set_context_menu(self, menu, edit_collections_action):
|
||||||
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||||
self.context_menu = menu
|
self.context_menu = menu
|
||||||
|
self.edit_collections_action = edit_collections_action
|
||||||
|
|
||||||
def contextMenuEvent(self, event):
|
def contextMenuEvent(self, event):
|
||||||
self.context_menu.popup(event.globalPos())
|
self.context_menu.popup(event.globalPos())
|
||||||
@ -500,10 +501,11 @@ class DeviceBooksView(BooksView): # {{{
|
|||||||
self.setAcceptDrops(False)
|
self.setAcceptDrops(False)
|
||||||
|
|
||||||
def contextMenuEvent(self, event):
|
def contextMenuEvent(self, event):
|
||||||
self.edit_collections_menu.setVisible(
|
edit_collections = callable(getattr(self._model.db, 'supports_collections', None)) and \
|
||||||
callable(getattr(self._model.db, 'supports_collections', None)) and \
|
|
||||||
self._model.db.supports_collections() and \
|
self._model.db.supports_collections() and \
|
||||||
prefs['manage_device_metadata'] == 'manual')
|
prefs['manage_device_metadata'] == 'manual'
|
||||||
|
|
||||||
|
self.edit_collections_action.setVisible(edit_collections)
|
||||||
self.context_menu.popup(event.globalPos())
|
self.context_menu.popup(event.globalPos())
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user