Various fixes to improve behavior of calibre on small screens

This commit is contained in:
Kovid Goyal 2008-06-06 12:57:17 -07:00
parent fbc8832f27
commit f77c2ade9d
8 changed files with 237 additions and 232 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, QCoreApplication
QByteArray, QLocale, QUrl, QTranslator, QCoreApplication
from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
QIcon, QTableView, QDialogButtonBox, QApplication
@ -22,9 +22,13 @@ if iswindows:
def available_height():
desktop = QCoreApplication.instance().desktop()
desktop = QCoreApplication.instance().desktop()
return desktop.availableGeometry().height()
def available_width():
desktop = QCoreApplication.instance().desktop()
return desktop.availableGeometry().width()
def extension(path):
return os.path.splitext(path)[1][1:].lower()

View File

@ -72,7 +72,7 @@ if pictureflow is not None:
self.setSlideSize(QSize(int(2/3. * height), height))
self.setMinimumSize(QSize(int(2.35*0.67*height), (5/3.)*height+25))
self.setFocusPolicy(Qt.WheelFocus)
self.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum))
self.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
def wheelEvent(self, ev):
ev.accept()

View File

@ -18,7 +18,7 @@ from calibre.gui2.dialogs.tag_editor import TagEditor
from calibre.gui2.dialogs.password import PasswordDialog
from calibre.ebooks import BOOK_EXTENSIONS
from calibre.ebooks.metadata.library_thing import login, cover_from_isbn, LibraryThingError
from calibre import Settings
from calibre import Settings, islinux
class Format(QListWidgetItem):
def __init__(self, parent, ext, size, path=None):
@ -165,11 +165,7 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
comments = self.db.comments(row)
self.comments.setPlainText(comments if comments else '')
cover = self.db.cover(row)
if cover:
pm = QPixmap()
pm.loadFromData(cover)
if not pm.isNull():
self.cover.setPixmap(pm)
exts = self.db.formats(row)
if exts:
exts = exts.split(',')
@ -186,7 +182,18 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
QObject.connect(self.series, SIGNAL('editTextChanged(QString)'), self.enable_series_index)
QObject.connect(self.password_button, SIGNAL('clicked()'), self.change_password)
self.exec_()
self.show()
height_of_rest = self.frameGeometry().height() - self.cover.height()
width_of_rest = self.frameGeometry().width() - self.cover.width()
ag = QCoreApplication.instance().desktop().availableGeometry(self)
self.cover.MAX_HEIGHT = ag.height()-(25 if islinux else 0)-height_of_rest
self.cover.MAX_WIDTH = ag.width()-(25 if islinux else 0)-width_of_rest
if cover:
pm = QPixmap()
pm.loadFromData(cover)
if not pm.isNull():
self.cover.setPixmap(pm)
def cover_dropped(self):
self.cover_changed = True

View File

@ -5,18 +5,31 @@
<rect>
<x>0</x>
<y>0</y>
<width>777</width>
<height>656</height>
<width>668</width>
<height>663</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>Edit Meta Information</string>
</property>
<property name="windowIcon" >
<iconset resource="../images.qrc" >:/images/edit_input.svg</iconset>
<iconset resource="../images.qrc" >
<normaloff>:/images/edit_input.svg</normaloff>:/images/edit_input.svg</iconset>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<property name="modal" >
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@ -172,7 +185,8 @@
<string>Open Tag Editor</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/chapters.svg</iconset>
<iconset resource="../images.qrc" >
<normaloff>:/images/chapters.svg</normaloff>:/images/chapters.svg</iconset>
</property>
</widget>
</item>
@ -233,7 +247,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/trash.svg</iconset>
<iconset resource="../images.qrc" >
<normaloff>:/images/trash.svg</normaloff>:/images/trash.svg</iconset>
</property>
</widget>
</item>
@ -301,185 +316,130 @@
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Available Formats</string>
</property>
<layout class="QVBoxLayout" >
<widget class="QWidget" name="" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QListWidget" name="formats" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="iconSize" >
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>51</width>
<height>61</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="add_format_button" >
<property name="toolTip" >
<string>Add a new format for this book to the database</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/plus.svg</iconset>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="remove_format_button" >
<property name="toolTip" >
<string>Remove the selected formats for this book from the database.</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/trash.svg</iconset>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>61</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4" >
<property name="title" >
<string>Book Cover</string>
<widget class="QGroupBox" name="af_group_box" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" >
<property name="title" >
<string>Available Formats</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>81</width>
<height>181</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="ImageView" name="cover" >
<layout class="QGridLayout" name="gridLayout" >
<item rowspan="2" row="0" column="0" >
<widget class="QListWidget" name="formats" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>130</height>
</size>
</property>
<property name="pixmap" >
<pixmap resource="../images.qrc" >:/images/book.svg</pixmap>
</property>
<property name="scaledContents" >
<bool>true</bool>
<property name="iconSize" >
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<item row="0" column="1" >
<widget class="QToolButton" name="add_format_button" >
<property name="toolTip" >
<string>Add a new format for this book to the database</string>
</property>
<property name="sizeHint" >
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >
<normaloff>:/images/plus.svg</normaloff>:/images/plus.svg</iconset>
</property>
<property name="iconSize" >
<size>
<width>71</width>
<height>181</height>
<width>32</width>
<height>32</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="1" column="1" >
<widget class="QToolButton" name="remove_format_button" >
<property name="toolTip" >
<string>Remove the selected formats for this book from the database.</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >
<normaloff>:/images/trash.svg</normaloff>:/images/trash.svg</iconset>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
</layout>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
<zorder>groupBox_4</zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Book Cover</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<widget class="ImageView" name="cover" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap resource="../images.qrc" >:/images/book.svg</pixmap>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -497,16 +457,7 @@
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -525,7 +476,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/document_open.svg</iconset>
<iconset resource="../images.qrc" >
<normaloff>:/images/document_open.svg</normaloff>:/images/document_open.svg</iconset>
</property>
</widget>
</item>
@ -533,7 +485,7 @@
</item>
</layout>
</item>
<item>
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="fetch_cover_button" >
@ -561,13 +513,13 @@
</widget>
</widget>
</item>
<item row="1" column="0" >
<item>
<widget class="QDialogButtonBox" name="button_box" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -166,7 +166,7 @@ class Main(MainWindow, Ui_MainWindow):
self.graphics_view.resize_for(width+scrollbar_adjust, height+scrollbar_adjust)
desktop = QCoreApplication.instance().desktop()
screen_height = desktop.availableGeometry().height() - 25
screen_height = desktop.availableGeometry(self).height() - 25
height = min(screen_height, height+hdelta+scrollbar_adjust)
self.resize(width+scrollbar_adjust, height)
self.setWindowTitle(self.renderer.lrf.metadata.title + ' - ' + __appname__)

View File

@ -206,7 +206,6 @@ class Main(MainWindow, Ui_MainWindow):
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)

View File

@ -20,25 +20,25 @@
<string>__appname__</string>
</property>
<property name="windowIcon" >
<iconset resource="images.qrc" >:/library</iconset>
<iconset resource="images.qrc" >
<normaloff>:/library</normaloff>:/library</iconset>
</property>
<widget class="QWidget" name="centralwidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>74</y>
<width>865</width>
<height>723</height>
</rect>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -102,7 +102,7 @@
</size>
</property>
<property name="text" >
<string></string>
<string/>
</property>
<property name="textFormat" >
<enum>Qt::RichText</enum>
@ -119,16 +119,7 @@
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -140,7 +131,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/search.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/search.svg</normaloff>:/images/search.svg</iconset>
</property>
<property name="shortcut" >
<string>Alt+S</string>
@ -197,7 +189,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/clear_left.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/clear_left.svg</normaloff>:/images/clear_left.svg</iconset>
</property>
</widget>
</item>
@ -213,7 +206,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
@ -230,7 +223,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/config.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/config.svg</normaloff>:/images/config.svg</iconset>
</property>
</widget>
</item>
@ -248,6 +242,14 @@
<number>2</number>
</property>
<widget class="QWidget" name="library" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="BooksView" name="library_view" >
@ -283,6 +285,14 @@
</layout>
</widget>
<widget class="QWidget" name="main_memory" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="DeviceBooksView" name="memory_view" >
@ -318,12 +328,20 @@
</layout>
</widget>
<widget class="QWidget" name="page" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>857</width>
<height>571</height>
</rect>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="DeviceBooksView" name="card_view" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>100</horstretch>
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>10</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
@ -357,6 +375,14 @@
</layout>
</widget>
<widget class="QToolBar" name="tool_bar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>865</width>
<height>74</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
@ -396,13 +422,22 @@
<addaction name="action_view" />
</widget>
<widget class="QStatusBar" name="statusBar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>797</y>
<width>865</width>
<height>25</height>
</rect>
</property>
<property name="mouseTracking" >
<bool>true</bool>
</property>
</widget>
<action name="action_add" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/plus.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/plus.svg</normaloff>:/images/plus.svg</iconset>
</property>
<property name="text" >
<string>Add books</string>
@ -416,7 +451,8 @@
</action>
<action name="action_del" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/trash.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/trash.svg</normaloff>:/images/trash.svg</iconset>
</property>
<property name="text" >
<string>Remove books</string>
@ -430,7 +466,8 @@
</action>
<action name="action_edit" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/edit_input.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/edit_input.svg</normaloff>:/images/edit_input.svg</iconset>
</property>
<property name="text" >
<string>Edit meta information</string>
@ -447,7 +484,8 @@
<bool>false</bool>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/sync.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/sync.svg</normaloff>:/images/sync.svg</iconset>
</property>
<property name="text" >
<string>Send to device</string>
@ -455,7 +493,8 @@
</action>
<action name="action_save" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/save.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/save.svg</normaloff>:/images/save.svg</iconset>
</property>
<property name="text" >
<string>Save to disk</string>
@ -463,7 +502,8 @@
</action>
<action name="action_news" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/news.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/news.svg</normaloff>:/images/news.svg</iconset>
</property>
<property name="text" >
<string>Fetch news</string>
@ -471,7 +511,8 @@
</action>
<action name="action_convert" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/convert.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/convert.svg</normaloff>:/images/convert.svg</iconset>
</property>
<property name="text" >
<string>Convert E-books</string>
@ -479,7 +520,8 @@
</action>
<action name="action_view" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/view.svg</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/view.svg</normaloff>:/images/view.svg</iconset>
</property>
<property name="text" >
<string>View</string>

View File

@ -41,6 +41,9 @@ class BookInfoDisplay(QFrame):
QLabel.__init__(self)
#self.setTextInteractionFlags(Qt.TextSelectableByMouse)
self.setText('')
self.setWordWrap(True)
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum))
self.setMaximumHeight(100)
def mouseReleaseEvent(self, ev):
self.emit(SIGNAL('mr(int)'), 1)
@ -73,9 +76,7 @@ class BookInfoDisplay(QFrame):
self.data = data
for key in data.keys():
txt = data[key]
if len(txt) > 600:
txt = txt[:600]+'&hellip;'
txt = '<br />\n'.join(textwrap.wrap(txt, 120))
#txt = '<br />\n'.join(textwrap.wrap(txt, 120))
rows += '<tr><td><b>%s:</b></td><td>%s</td></tr>'%(key, txt)
self.book_data.setText('<table>'+rows+'</table>')