mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a right click menu to the cover browser. It allows you to view a book, edit metadata etc. from withing the cover browser. The menu can be customized in Preferences->Toolbars
This commit is contained in:
parent
8fc02ccdb0
commit
afc1a7e2d1
@ -74,6 +74,13 @@ gprefs.defaults['action-layout-context-menu-device'] = (
|
||||
'Add To Library', 'Edit Collections',
|
||||
)
|
||||
|
||||
gprefs.defaults['action-layout-context-menu-cover-browser'] = (
|
||||
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
||||
'Connect Share', 'Copy To Library', None,
|
||||
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
||||
'Similar Books', 'Tweak ePub', None, 'Remove Books',
|
||||
)
|
||||
|
||||
gprefs.defaults['show_splash_screen'] = True
|
||||
gprefs.defaults['toolbar_icon_size'] = 'medium'
|
||||
gprefs.defaults['automerge'] = 'ignore'
|
||||
|
@ -9,8 +9,8 @@ Module to implement the Cover Flow feature
|
||||
|
||||
import sys, os, time
|
||||
|
||||
from PyQt4.Qt import QImage, QSizePolicy, QTimer, QDialog, Qt, QSize, \
|
||||
QStackedLayout, QLabel, QByteArray, pyqtSignal
|
||||
from PyQt4.Qt import (QImage, QSizePolicy, QTimer, QDialog, Qt, QSize,
|
||||
QStackedLayout, QLabel, QByteArray, pyqtSignal)
|
||||
|
||||
from calibre import plugins
|
||||
from calibre.gui2 import config, available_height, available_width, gprefs
|
||||
@ -84,6 +84,7 @@ if pictureflow is not None:
|
||||
class CoverFlow(pictureflow.PictureFlow):
|
||||
|
||||
dc_signal = pyqtSignal()
|
||||
context_menu_requested = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
pictureflow.PictureFlow.__init__(self, parent,
|
||||
@ -94,6 +95,17 @@ if pictureflow is not None:
|
||||
QSizePolicy.Expanding))
|
||||
self.dc_signal.connect(self._data_changed,
|
||||
type=Qt.QueuedConnection)
|
||||
self.context_menu = None
|
||||
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||
|
||||
def set_context_menu(self, cm):
|
||||
self.context_menu = cm
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
if self.context_menu is not None:
|
||||
self.context_menu_requested.emit()
|
||||
self.context_menu.popup(event.globalPos())
|
||||
event.accept()
|
||||
|
||||
def sizeHint(self):
|
||||
return self.minimumSize()
|
||||
@ -149,6 +161,7 @@ class CoverFlowMixin(object):
|
||||
self.cover_flow_sync_flag = True
|
||||
self.cover_flow = CoverFlow(parent=self)
|
||||
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
|
||||
self.cover_flow.context_menu_requested.connect(self.cf_context_menu_requested)
|
||||
self.library_view.selectionModel().currentRowChanged.connect(
|
||||
self.sync_cf_to_listview)
|
||||
self.db_images = DatabaseImages(self.library_view.model())
|
||||
@ -234,6 +247,14 @@ class CoverFlowMixin(object):
|
||||
self.cover_flow.setCurrentSlide(current.row())
|
||||
self.cover_flow_sync_flag = True
|
||||
|
||||
def cf_context_menu_requested(self):
|
||||
row = self.cover_flow.currentSlide()
|
||||
m = self.library_view.model()
|
||||
index = m.index(row, 0)
|
||||
sm = self.library_view.selectionModel()
|
||||
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
||||
self.library_view.setCurrentIndex(index)
|
||||
|
||||
def cover_flow_do_sync(self):
|
||||
self.cover_flow_sync_flag = True
|
||||
try:
|
||||
|
@ -62,7 +62,6 @@ class LibraryViewMixin(object): # {{{
|
||||
view = getattr(self, view+'_view')
|
||||
view.verticalHeader().sectionDoubleClicked.connect(self.iactions['View'].view_specific_book)
|
||||
|
||||
self.build_context_menus()
|
||||
self.library_view.model().set_highlight_only(config['highlight_search_matches'])
|
||||
|
||||
def build_context_menus(self):
|
||||
@ -81,6 +80,11 @@ class LibraryViewMixin(object): # {{{
|
||||
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||
v.set_context_menu(dm, ec)
|
||||
|
||||
if self.cover_flow is not None:
|
||||
cm = QMenu(self.cover_flow)
|
||||
populate_menu(cm,
|
||||
gprefs['action-layout-context-menu-cover-browser'])
|
||||
self.cover_flow.set_context_menu(cm)
|
||||
|
||||
def search_done(self, view, ok):
|
||||
if view is self.current_view():
|
||||
|
@ -1332,6 +1332,7 @@ void PictureFlow::mousePressEvent(QMouseEvent* event)
|
||||
|
||||
void PictureFlow::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
bool accepted = false;
|
||||
int sideWidth = (d->buffer.width() - slideSize().width()) /2;
|
||||
|
||||
if (d->singlePress)
|
||||
@ -1339,13 +1340,20 @@ void PictureFlow::mouseReleaseEvent(QMouseEvent* event)
|
||||
if (event->x() < sideWidth )
|
||||
{
|
||||
showPrevious();
|
||||
accepted = true;
|
||||
} else if ( event->x() > sideWidth + slideSize().width() ) {
|
||||
showNext();
|
||||
accepted = true;
|
||||
} else {
|
||||
emit itemActivated(d->getTarget());
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
emit itemActivated(d->getTarget());
|
||||
accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
event->accept();
|
||||
if (accepted) {
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
emit inputReceived();
|
||||
|
@ -225,6 +225,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
'calibre library')),
|
||||
('context-menu-device', _('The context menu for the books on '
|
||||
'the device')),
|
||||
('context-menu-cover-browser', _('The context menu for the cover '
|
||||
'browser')),
|
||||
]
|
||||
|
||||
def genesis(self, gui):
|
||||
|
@ -308,6 +308,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.height())
|
||||
self.resize(self.width(), self._calculated_available_height)
|
||||
|
||||
self.build_context_menus()
|
||||
|
||||
for ac in self.iactions.values():
|
||||
try:
|
||||
ac.gui_layout_complete()
|
||||
|
Loading…
x
Reference in New Issue
Block a user