mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
622887a1b4
@ -17,7 +17,7 @@ from calibre.gui2 import gprefs, warning_dialog, Dispatcher, error_dialog, \
|
|||||||
question_dialog, info_dialog
|
question_dialog, info_dialog
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
|
||||||
class LibraryUsageStats(object):
|
class LibraryUsageStats(object): # {{{
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.stats = {}
|
self.stats = {}
|
||||||
@ -73,7 +73,7 @@ class LibraryUsageStats(object):
|
|||||||
if stats is not None:
|
if stats is not None:
|
||||||
self.stats[newloc] = stats
|
self.stats[newloc] = stats
|
||||||
self.write_stats()
|
self.write_stats()
|
||||||
|
# }}}
|
||||||
|
|
||||||
class ChooseLibraryAction(InterfaceAction):
|
class ChooseLibraryAction(InterfaceAction):
|
||||||
|
|
||||||
@ -147,9 +147,11 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
self.qs_locations = [i[1] for i in locations]
|
self.qs_locations = [i[1] for i in locations]
|
||||||
self.rename_menu.clear()
|
self.rename_menu.clear()
|
||||||
self.delete_menu.clear()
|
self.delete_menu.clear()
|
||||||
|
quick_actions = []
|
||||||
for name, loc in locations:
|
for name, loc in locations:
|
||||||
self.quick_menu.addAction(name, Dispatcher(partial(self.switch_requested,
|
ac = self.quick_menu.addAction(name, Dispatcher(partial(self.switch_requested,
|
||||||
loc)))
|
loc)))
|
||||||
|
quick_actions.append(ac)
|
||||||
self.rename_menu.addAction(name, Dispatcher(partial(self.rename_requested,
|
self.rename_menu.addAction(name, Dispatcher(partial(self.rename_requested,
|
||||||
name, loc)))
|
name, loc)))
|
||||||
self.delete_menu.addAction(name, Dispatcher(partial(self.delete_requested,
|
self.delete_menu.addAction(name, Dispatcher(partial(self.delete_requested,
|
||||||
@ -164,6 +166,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
self.quick_menu_action.setVisible(bool(locations))
|
self.quick_menu_action.setVisible(bool(locations))
|
||||||
self.rename_menu_action.setVisible(bool(locations))
|
self.rename_menu_action.setVisible(bool(locations))
|
||||||
self.delete_menu_action.setVisible(bool(locations))
|
self.delete_menu_action.setVisible(bool(locations))
|
||||||
|
self.gui.location_manager.set_switch_actions(quick_actions)
|
||||||
|
|
||||||
|
|
||||||
def location_selected(self, loc):
|
def location_selected(self, loc):
|
||||||
@ -263,11 +266,6 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
c.exec_()
|
c.exec_()
|
||||||
|
|
||||||
def change_library_allowed(self):
|
def change_library_allowed(self):
|
||||||
if self.gui.device_connected:
|
|
||||||
warning_dialog(self.gui, _('Not allowed'),
|
|
||||||
_('You cannot change libraries when a device is'
|
|
||||||
' connected.'), 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'
|
||||||
|
@ -24,6 +24,7 @@ class LocationManager(QObject): # {{{
|
|||||||
locations_changed = pyqtSignal()
|
locations_changed = pyqtSignal()
|
||||||
unmount_device = pyqtSignal()
|
unmount_device = pyqtSignal()
|
||||||
location_selected = pyqtSignal(object)
|
location_selected = pyqtSignal(object)
|
||||||
|
switch_actions_set = pyqtSignal(object)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QObject.__init__(self, parent)
|
QObject.__init__(self, parent)
|
||||||
@ -60,7 +61,7 @@ class LocationManager(QObject): # {{{
|
|||||||
|
|
||||||
return ac
|
return ac
|
||||||
|
|
||||||
ac('library', _('Library'), 'lt.png',
|
self.library_action = ac('library', _('Library'), 'lt.png',
|
||||||
_('Show books in calibre library'))
|
_('Show books in calibre library'))
|
||||||
ac('main', _('Device'), 'reader.png',
|
ac('main', _('Device'), 'reader.png',
|
||||||
_('Show books in the main memory of the device'))
|
_('Show books in the main memory of the device'))
|
||||||
@ -69,6 +70,13 @@ class LocationManager(QObject): # {{{
|
|||||||
ac('cardb', _('Card B'), 'sd.png',
|
ac('cardb', _('Card B'), 'sd.png',
|
||||||
_('Show books in storage card B'))
|
_('Show books in storage card B'))
|
||||||
|
|
||||||
|
def set_switch_actions(self, actions):
|
||||||
|
self.switch_menu = QMenu()
|
||||||
|
for ac in actions:
|
||||||
|
self.switch_menu.addAction(ac)
|
||||||
|
self.library_action.setMenu(self.switch_menu)
|
||||||
|
self.switch_actions_set.emit(bool(actions))
|
||||||
|
|
||||||
def _location_selected(self, location, *args):
|
def _location_selected(self, location, *args):
|
||||||
if location != self.current_location and hasattr(self,
|
if location != self.current_location and hasattr(self,
|
||||||
'location_'+location):
|
'location_'+location):
|
||||||
@ -197,14 +205,14 @@ class SearchBar(QWidget): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Spacer(QWidget):
|
class Spacer(QWidget): # {{{
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
self.l = QHBoxLayout()
|
self.l = QHBoxLayout()
|
||||||
self.setLayout(self.l)
|
self.setLayout(self.l)
|
||||||
self.l.addStretch(10)
|
self.l.addStretch(10)
|
||||||
|
# }}}
|
||||||
|
|
||||||
class ToolBar(QToolBar): # {{{
|
class ToolBar(QToolBar): # {{{
|
||||||
|
|
||||||
|
@ -390,6 +390,13 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
if self.device_connected:
|
||||||
|
self.set_books_in_library(self.booklists(), reset=True)
|
||||||
|
self.refresh_ondevice()
|
||||||
|
self.memory_view.reset()
|
||||||
|
self.card_a_view.reset()
|
||||||
|
self.card_b_view.reset()
|
||||||
|
|
||||||
|
|
||||||
def set_window_title(self):
|
def set_window_title(self):
|
||||||
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user