Make cover browsing more small-screen friendly

This commit is contained in:
Kovid Goyal 2008-05-25 12:42:32 -07:00
parent 7e256cd3dc
commit 059041ebdf
5 changed files with 20 additions and 6 deletions

View File

@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
""" The GUI """
import sys, os, re, StringIO, traceback
from PyQt4.QtCore import QVariant, QFileInfo, QObject, SIGNAL, QBuffer, \
QByteArray, QLocale, QTranslator, QUrl, QTranslator
QByteArray, QLocale, QTranslator, QUrl, QTranslator, QCoreApplication
from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
QIcon, QTableView, QDialogButtonBox, QApplication
@ -21,6 +21,10 @@ if iswindows:
warnings.simplefilter('ignore', DeprecationWarning)
def available_height():
desktop = QCoreApplication.instance().desktop()
return desktop.availableGeometry().height()
def extension(path):
return os.path.splitext(path)[1][1:].lower()

View File

@ -18,7 +18,7 @@ from calibre.gui2 import APP_UID, warning_dialog, choose_files, error_dialog, \
initialize_file_icon_provider, question_dialog,\
pixmap_to_data, choose_dir, ORG_NAME, \
qstring_to_unicode, set_sidebar_directories, \
SingleApplication, Application
SingleApplication, Application, available_height
from calibre.gui2.cover_flow import CoverFlow, DatabaseImages
from calibre.library.database import LibraryDatabase
from calibre.gui2.update import CheckForUpdates
@ -202,13 +202,14 @@ class Main(MainWindow, Ui_MainWindow):
########################### Cover Flow ################################
self.cover_flow = None
if CoverFlow is not None:
self.cover_flow = CoverFlow(height=220)
self.cover_flow = CoverFlow(height=220 if available_height() > 800 else 170)
self.cover_flow.setVisible(False)
self.library.layout().addWidget(self.cover_flow)
self.connect(self.cover_flow, SIGNAL('currentChanged(int)'), self.sync_cf_to_listview)
self.library_view.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding))
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)
self.connect(self.cover_flow, SIGNAL('stop()'), self.status_bar.cover_flow_button.toggle)
QObject.connect(self.library_view.selectionModel(), SIGNAL('currentRowChanged(QModelIndex, QModelIndex)'),
self.sync_cf_to_listview)
self.db_images = DatabaseImages(self.library_view.model())
@ -228,7 +229,7 @@ class Main(MainWindow, Ui_MainWindow):
def toggle_cover_flow(self, show):
if show:
self.cover_flow.setCurrentSlide(self.library_view.currentIndex().row())
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)

View File

@ -64,6 +64,7 @@ signals:
void itemActivated(int index);
void inputReceived();
void currentChanged(int index);
void stop();
protected:
void paintEvent(QPaintEvent *event);

View File

@ -1213,6 +1213,13 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
return;
}
if(event->key() == Qt::Key_Escape)
{
emit stop();
event->accept();
return;
}
event->ignore();
}

View File

@ -187,6 +187,7 @@ signals:
void itemActivated(int index);
void inputReceived();
void currentChanged(int index);
void stop(); //Emitted when the user presses the Esc key
protected:
void paintEvent(QPaintEvent *event);