From 37c35128e4405e187471fb255e36b44549a6f8bc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Jan 2009 17:27:19 -0800 Subject: [PATCH] Add config option to show cover browser in larger, separate window. Fixes #1437 (Bigger cover browser) --- src/calibre/gui2/__init__.py | 8 +++- src/calibre/gui2/cover_flow.py | 4 +- src/calibre/gui2/dialogs/config.py | 2 + src/calibre/gui2/dialogs/config.ui | 17 ++++++--- src/calibre/gui2/main.py | 59 +++++++++++++++++++++++------- 5 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index a393843156..ccc14b8d1f 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -54,8 +54,12 @@ def _config(): c.add_opt('autolaunch_server', default=False, help=_('Automatically launch content server on application startup')) c.add_opt('oldest_news', default=60, help=_('Oldest news kept in database')) c.add_opt('systray_icon', default=True, help=_('Show system tray icon')) - c.add_opt('upload_news_to_device', default=True, help=_('Upload downloaded news to device')) - c.add_opt('delete_news_from_library_on_upload', default=False, help=_('Delete books from library after uploading to device')) + c.add_opt('upload_news_to_device', default=True, + help=_('Upload downloaded news to device')) + c.add_opt('delete_news_from_library_on_upload', default=False, + help=_('Delete books from library after uploading to device')) + c.add_opt('separate_cover_flow', default=False, + help=_('Show the cover flow in a separate window instead of in the main calibre window')) return ConfigProxy(c) config = _config() diff --git a/src/calibre/gui2/cover_flow.py b/src/calibre/gui2/cover_flow.py index 196e723be7..220e368a04 100644 --- a/src/calibre/gui2/cover_flow.py +++ b/src/calibre/gui2/cover_flow.py @@ -69,11 +69,11 @@ if pictureflow is not None: class CoverFlow(pictureflow.PictureFlow): - def __init__(self, height=300, parent=None): + def __init__(self, height=300, parent=None, text_height=25): pictureflow.PictureFlow.__init__(self, parent, config['cover_flow_queue_length']+1) self.setSlideSize(QSize(int(2/3. * height), height)) - self.setMinimumSize(QSize(int(2.35*0.67*height), (5/3.)*height+25)) + self.setMinimumSize(QSize(int(2.35*0.67*height), (5/3.)*height+text_height)) self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) diff --git a/src/calibre/gui2/dialogs/config.py b/src/calibre/gui2/dialogs/config.py index 5e63bcdfd5..8acbb2a825 100644 --- a/src/calibre/gui2/dialogs/config.py +++ b/src/calibre/gui2/dialogs/config.py @@ -244,6 +244,7 @@ class ConfigDialog(QDialog, Ui_Dialog): self.connect(self.remove_plugin, SIGNAL('clicked()'), lambda : self.modify_plugin(op='remove')) self.connect(self.button_plugin_browse, SIGNAL('clicked()'), self.find_plugin) self.connect(self.button_plugin_add, SIGNAL('clicked()'), self.add_plugin) + self.separate_cover_flow.setChecked(config['separate_cover_flow']) def add_plugin(self): path = unicode(self.plugin_path.text()) @@ -392,6 +393,7 @@ class ConfigDialog(QDialog, Ui_Dialog): config['column_map'] = cols config['toolbar_icon_size'] = self.ICON_SIZES[self.toolbar_button_size.currentIndex()] config['show_text_in_toolbar'] = bool(self.show_toolbar_text.isChecked()) + config['separate_cover_flow'] = bool(self.separate_cover_flow.isChecked()) pattern = self.filename_pattern.commit() prefs['filename_pattern'] = pattern p = {0:'normal', 1:'high', 2:'low'}[self.priority.currentIndex()] diff --git a/src/calibre/gui2/dialogs/config.ui b/src/calibre/gui2/dialogs/config.ui index 0bfbfd73c4..7f678ce8ea 100644 --- a/src/calibre/gui2/dialogs/config.ui +++ b/src/calibre/gui2/dialogs/config.ui @@ -7,7 +7,7 @@ 0 0 800 - 563 + 570 @@ -356,7 +356,7 @@ - + Toolbar @@ -404,7 +404,7 @@ - + Select visible &columns in library view @@ -492,20 +492,27 @@ - + Automatically send downloaded &news to ebook reader - + &Delete news from library when it is sent to reader + + + + Show cover &browser in a separate window (needs restart) + + + diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 38f558404f..279dab42aa 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -7,7 +7,7 @@ from PyQt4.Qt import Qt, SIGNAL, QObject, QCoreApplication, QUrl, QTimer, \ QModelIndex, QPixmap, QColor, QPainter, QMenu, QIcon, \ QToolButton, QDialog, QDesktopServices, QFileDialog, \ QSystemTrayIcon, QApplication, QKeySequence, QAction, \ - QProgressDialog, QMessageBox + QProgressDialog, QMessageBox, QStackedLayout from PyQt4.QtSvg import QSvgRenderer from calibre import __version__, __appname__, islinux, sanitize_file_name, \ @@ -22,7 +22,8 @@ from calibre.gui2 import APP_UID, warning_dialog, choose_files, error_dialog, \ pixmap_to_data, choose_dir, ORG_NAME, \ set_sidebar_directories, Dispatcher, \ SingleApplication, Application, available_height, \ - max_available_height, config, info_dialog + max_available_height, config, info_dialog, \ + available_width from calibre.gui2.cover_flow import CoverFlow, DatabaseImages, pictureflowerror from calibre.library.database import LibraryDatabase from calibre.gui2.dialogs.scheduler import Scheduler @@ -342,9 +343,16 @@ class Main(MainWindow, Ui_MainWindow): ########################### Cover Flow ################################ self.cover_flow = None if CoverFlow is not None: - self.cover_flow = CoverFlow(height=220 if available_height() > 950 else 170 if available_height() > 850 else 140) + text_height = 40 if config['separate_cover_flow'] else 25 + ah = available_height() + cfh = ah-100 + cfh = 3./5 * cfh - text_height + if not config['separate_cover_flow']: + cfh = 220 if ah > 950 else 170 if ah > 850 else 140 + self.cover_flow = CoverFlow(height=cfh, text_height=text_height) self.cover_flow.setVisible(False) - self.library.layout().addWidget(self.cover_flow) + if not config['separate_cover_flow']: + self.library.layout().addWidget(self.cover_flow) self.connect(self.cover_flow, SIGNAL('currentChanged(int)'), self.sync_cf_to_listview) self.connect(self.cover_flow, SIGNAL('itemActivated(int)'), self.show_book_info) self.connect(self.status_bar.cover_flow_button, SIGNAL('toggled(bool)'), self.toggle_cover_flow) @@ -410,17 +418,40 @@ class Main(MainWindow, Ui_MainWindow): def toggle_cover_flow(self, show): - if show: - self.library_view.setCurrentIndex(self.library_view.currentIndex()) - self.cover_flow.setVisible(True) - self.cover_flow.setFocus(Qt.OtherFocusReason) - #self.status_bar.book_info.book_data.setMaximumHeight(100) - #self.status_bar.setMaximumHeight(120) - self.library_view.scrollTo(self.library_view.currentIndex()) + if config['separate_cover_flow']: + if show: + d = QDialog(self) + ah, aw = available_height(), available_width() + d.resize(int(aw/2.), ah-60) + d._layout = QStackedLayout() + d.setLayout(d._layout) + d.setWindowTitle(_('Browse by covers')) + d.layout().addWidget(self.cover_flow) + self.cover_flow.setVisible(True) + self.cover_flow.setFocus(Qt.OtherFocusReason) + self.library_view.scrollTo(self.library_view.currentIndex()) + d.show() + self.connect(d, SIGNAL('finished(int)'), + lambda x: self.status_bar.cover_flow_button.setChecked(False)) + self.cf_dialog = d + else: + cfd = getattr(self, 'cf_dialog', None) + if cfd is not None: + self.cover_flow.setVisible(False) + cfd.hide() + self.cf_dialog = None else: - self.cover_flow.setVisible(False) - #self.status_bar.book_info.book_data.setMaximumHeight(1000) - self.setMaximumHeight(available_height()) + if show: + self.library_view.setCurrentIndex(self.library_view.currentIndex()) + self.cover_flow.setVisible(True) + self.cover_flow.setFocus(Qt.OtherFocusReason) + #self.status_bar.book_info.book_data.setMaximumHeight(100) + #self.status_bar.setMaximumHeight(120) + self.library_view.scrollTo(self.library_view.currentIndex()) + else: + self.cover_flow.setVisible(False) + #self.status_bar.book_info.book_data.setMaximumHeight(1000) + self.setMaximumHeight(available_height()) def toggle_tags_view(self, show): if show: