mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Make cover browsing more small-screen friendly
This commit is contained in:
parent
7e256cd3dc
commit
059041ebdf
@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
""" The GUI """
|
""" The GUI """
|
||||||
import sys, os, re, StringIO, traceback
|
import sys, os, re, StringIO, traceback
|
||||||
from PyQt4.QtCore import QVariant, QFileInfo, QObject, SIGNAL, QBuffer, \
|
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, \
|
from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
|
||||||
QIcon, QTableView, QDialogButtonBox, QApplication
|
QIcon, QTableView, QDialogButtonBox, QApplication
|
||||||
|
|
||||||
@ -21,6 +21,10 @@ if iswindows:
|
|||||||
warnings.simplefilter('ignore', DeprecationWarning)
|
warnings.simplefilter('ignore', DeprecationWarning)
|
||||||
|
|
||||||
|
|
||||||
|
def available_height():
|
||||||
|
desktop = QCoreApplication.instance().desktop()
|
||||||
|
return desktop.availableGeometry().height()
|
||||||
|
|
||||||
def extension(path):
|
def extension(path):
|
||||||
return os.path.splitext(path)[1][1:].lower()
|
return os.path.splitext(path)[1][1:].lower()
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from calibre.gui2 import APP_UID, warning_dialog, choose_files, error_dialog, \
|
|||||||
initialize_file_icon_provider, question_dialog,\
|
initialize_file_icon_provider, question_dialog,\
|
||||||
pixmap_to_data, choose_dir, ORG_NAME, \
|
pixmap_to_data, choose_dir, ORG_NAME, \
|
||||||
qstring_to_unicode, set_sidebar_directories, \
|
qstring_to_unicode, set_sidebar_directories, \
|
||||||
SingleApplication, Application
|
SingleApplication, Application, available_height
|
||||||
from calibre.gui2.cover_flow import CoverFlow, DatabaseImages
|
from calibre.gui2.cover_flow import CoverFlow, DatabaseImages
|
||||||
from calibre.library.database import LibraryDatabase
|
from calibre.library.database import LibraryDatabase
|
||||||
from calibre.gui2.update import CheckForUpdates
|
from calibre.gui2.update import CheckForUpdates
|
||||||
@ -202,13 +202,14 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
########################### Cover Flow ################################
|
########################### Cover Flow ################################
|
||||||
self.cover_flow = None
|
self.cover_flow = None
|
||||||
if CoverFlow is not 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.cover_flow.setVisible(False)
|
||||||
self.library.layout().addWidget(self.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('currentChanged(int)'), self.sync_cf_to_listview)
|
||||||
self.library_view.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding))
|
self.library_view.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding))
|
||||||
self.connect(self.cover_flow, SIGNAL('itemActivated(int)'), self.show_book_info)
|
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.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)'),
|
QObject.connect(self.library_view.selectionModel(), SIGNAL('currentRowChanged(QModelIndex, QModelIndex)'),
|
||||||
self.sync_cf_to_listview)
|
self.sync_cf_to_listview)
|
||||||
self.db_images = DatabaseImages(self.library_view.model())
|
self.db_images = DatabaseImages(self.library_view.model())
|
||||||
@ -228,7 +229,7 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
def toggle_cover_flow(self, show):
|
def toggle_cover_flow(self, show):
|
||||||
if 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.setVisible(True)
|
||||||
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
||||||
self.status_bar.book_info.book_data.setMaximumHeight(100)
|
self.status_bar.book_info.book_data.setMaximumHeight(100)
|
||||||
|
@ -64,6 +64,7 @@ signals:
|
|||||||
void itemActivated(int index);
|
void itemActivated(int index);
|
||||||
void inputReceived();
|
void inputReceived();
|
||||||
void currentChanged(int index);
|
void currentChanged(int index);
|
||||||
|
void stop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
@ -1213,6 +1213,13 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(event->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
|
emit stop();
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +187,7 @@ signals:
|
|||||||
void itemActivated(int index);
|
void itemActivated(int index);
|
||||||
void inputReceived();
|
void inputReceived();
|
||||||
void currentChanged(int index);
|
void currentChanged(int index);
|
||||||
|
void stop(); //Emitted when the user presses the Esc key
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user