Make the book info display area also freely resizable

This commit is contained in:
Kovid Goyal 2010-05-01 17:53:18 -06:00
parent 0bd19d1c2b
commit 98fa71af77
3 changed files with 274 additions and 245 deletions

View File

@ -28,8 +28,8 @@
<normaloff>:/images/library.png</normaloff>:/images/library.png</iconset> <normaloff>:/images/library.png</normaloff>:/images/library.png</iconset>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item row="0" column="0"> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="LocationView" name="location_view"> <widget class="LocationView" name="location_view">
@ -149,7 +149,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
@ -287,110 +287,159 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QStackedWidget" name="stack"> <widget class="QSplitter" name="vertical_splitter">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>100</horstretch> <horstretch>0</horstretch>
<verstretch>100</verstretch> <verstretch>100</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="orientation">
<number>0</number> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QWidget" name="library"> <widget class="QStackedWidget" name="stack">
<layout class="QVBoxLayout" name="verticalLayout_2"> <property name="sizePolicy">
<item> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<widget class="QSplitter" name="horizontal_splitter"> <horstretch>100</horstretch>
<property name="orientation"> <verstretch>100</verstretch>
<enum>Qt::Horizontal</enum> </sizepolicy>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <property name="currentIndex">
<layout class="QVBoxLayout" name="verticalLayout"> <number>0</number>
<item> </property>
<widget class="TagsView" name="tags_view"> <widget class="QWidget" name="library">
<property name="tabKeyNavigation"> <layout class="QVBoxLayout" name="verticalLayout_2">
<bool>true</bool> <item>
</property> <widget class="QSplitter" name="horizontal_splitter">
<property name="alternatingRowColors"> <property name="orientation">
<bool>true</bool> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="animated"> <widget class="QWidget" name="layoutWidget">
<bool>true</bool> <layout class="QVBoxLayout" name="verticalLayout">
</property> <item>
<property name="headerHidden"> <widget class="TagsView" name="tags_view">
<bool>true</bool> <property name="tabKeyNavigation">
</property> <bool>true</bool>
</widget> </property>
</item> <property name="alternatingRowColors">
<item> <bool>true</bool>
<widget class="QCheckBox" name="popularity"> </property>
<property name="text"> <property name="animated">
<string>Sort by &amp;popularity</string> <bool>true</bool>
</property> </property>
</widget> <property name="headerHidden">
</item> <bool>true</bool>
<item> </property>
<layout class="QHBoxLayout" name="horizontalLayout_3"> </widget>
<item> </item>
<widget class="QComboBox" name="tag_match"> <item>
<property name="currentIndex"> <widget class="QCheckBox" name="popularity">
<number>0</number> <property name="text">
</property> <string>Sort by &amp;popularity</string>
<item> </property>
<property name="text"> </widget>
<string>Match any</string> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="tag_match">
<property name="currentIndex">
<number>0</number>
</property> </property>
</item> <item>
<item> <property name="text">
<property name="text"> <string>Match any</string>
<string>Match all</string> </property>
</item>
<item>
<property name="text">
<string>Match all</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="edit_categories">
<property name="toolTip">
<string>Create, edit, and delete user categories</string>
</property> </property>
</item> <property name="text">
</widget> <string>Manage &amp;user categories</string>
</item> </property>
<item> </widget>
<widget class="QPushButton" name="edit_categories"> </item>
<property name="toolTip"> </layout>
<string>Create, edit, and delete user categories</string> </item>
</property> <item>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="10,50">
<string>Manage &amp;user categories</string> <item>
</property> <widget class="QLabel" name="restriction_label">
</widget> <property name="text">
</item> <string>&amp;Restrict to:</string>
</layout> </property>
</item> <property name="buddy">
<item> <cstring>search_restriction</cstring>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="10,50"> </property>
<item> </widget>
<widget class="QLabel" name="restriction_label"> </item>
<property name="text"> <item>
<string>&amp;Restrict to:</string> <widget class="QComboBox" name="search_restriction">
</property> <property name="sizePolicy">
<property name="buddy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<cstring>search_restriction</cstring> <horstretch>50</horstretch>
</property> <verstretch>0</verstretch>
</widget> </sizepolicy>
</item> </property>
<item> <property name="toolTip">
<widget class="QComboBox" name="search_restriction"> <string>Books display will be restricted to those matching the selected saved search</string>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> </widget>
<horstretch>50</horstretch> </item>
<verstretch>0</verstretch> </layout>
</sizepolicy> </item>
</property> </layout>
<property name="toolTip"> </widget>
<string>Books display will be restricted to those matching the selected saved search</string> <widget class="BooksView" name="library_view">
</property> <property name="sizePolicy">
</widget> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
</item> <horstretch>100</horstretch>
</layout> <verstretch>10</verstretch>
</item> </sizepolicy>
</layout> </property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</widget> </widget>
<widget class="BooksView" name="library_view"> </item>
</layout>
</widget>
<widget class="QWidget" name="main_memory">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="DeviceBooksView" name="memory_view">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -422,124 +471,87 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</widget> </item>
</item> </layout>
</layout> </widget>
</widget> <widget class="QWidget" name="card_a_memory">
<widget class="QWidget" name="main_memory"> <layout class="QGridLayout">
<layout class="QGridLayout"> <item row="0" column="0">
<item row="0" column="0"> <widget class="DeviceBooksView" name="card_a_view">
<widget class="DeviceBooksView" name="memory_view"> <property name="sizePolicy">
<property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>10</horstretch>
<horstretch>100</horstretch> <verstretch>10</verstretch>
<verstretch>10</verstretch> </sizepolicy>
</sizepolicy> </property>
</property> <property name="acceptDrops">
<property name="acceptDrops"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="dragEnabled">
<property name="dragEnabled"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="dragDropOverwriteMode">
<property name="dragDropOverwriteMode"> <bool>false</bool>
<bool>false</bool> </property>
</property> <property name="dragDropMode">
<property name="dragDropMode"> <enum>QAbstractItemView::DragDrop</enum>
<enum>QAbstractItemView::DragDrop</enum> </property>
</property> <property name="alternatingRowColors">
<property name="alternatingRowColors"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="selectionBehavior">
<property name="selectionBehavior"> <enum>QAbstractItemView::SelectRows</enum>
<enum>QAbstractItemView::SelectRows</enum> </property>
</property> <property name="showGrid">
<property name="showGrid"> <bool>false</bool>
<bool>false</bool> </property>
</property> <property name="wordWrap">
<property name="wordWrap"> <bool>false</bool>
<bool>false</bool> </property>
</property> </widget>
</widget> </item>
</item> </layout>
</layout> </widget>
</widget> <widget class="QWidget" name="card_b_memory">
<widget class="QWidget" name="card_a_memory"> <layout class="QGridLayout">
<layout class="QGridLayout"> <item row="0" column="0">
<item row="0" column="0"> <widget class="DeviceBooksView" name="card_b_view">
<widget class="DeviceBooksView" name="card_a_view"> <property name="sizePolicy">
<property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <horstretch>10</horstretch>
<horstretch>10</horstretch> <verstretch>10</verstretch>
<verstretch>10</verstretch> </sizepolicy>
</sizepolicy> </property>
</property> <property name="acceptDrops">
<property name="acceptDrops"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="dragEnabled">
<property name="dragEnabled"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="dragDropOverwriteMode">
<property name="dragDropOverwriteMode"> <bool>false</bool>
<bool>false</bool> </property>
</property> <property name="dragDropMode">
<property name="dragDropMode"> <enum>QAbstractItemView::DragDrop</enum>
<enum>QAbstractItemView::DragDrop</enum> </property>
</property> <property name="alternatingRowColors">
<property name="alternatingRowColors"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="selectionBehavior">
<property name="selectionBehavior"> <enum>QAbstractItemView::SelectRows</enum>
<enum>QAbstractItemView::SelectRows</enum> </property>
</property> <property name="showGrid">
<property name="showGrid"> <bool>false</bool>
<bool>false</bool> </property>
</property> <property name="wordWrap">
<property name="wordWrap"> <bool>false</bool>
<bool>false</bool> </property>
</property> </widget>
</widget> </item>
</item> </layout>
</layout> </widget>
</widget>
<widget class="QWidget" name="card_b_memory">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="DeviceBooksView" name="card_b_view">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>10</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
<widget class="StatusBar" name="status_bar" native="true"/>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -587,11 +599,6 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="action_preferences"/> <addaction name="action_preferences"/>
</widget> </widget>
<widget class="QStatusBar" name="statusBar">
<property name="mouseTracking">
<bool>true</bool>
</property>
</widget>
<action name="action_add"> <action name="action_add">
<property name="icon"> <property name="icon">
<iconset resource="../../../resources/images.qrc"> <iconset resource="../../../resources/images.qrc">
@ -813,6 +820,12 @@
<extends>QComboBox</extends> <extends>QComboBox</extends>
<header>calibre.gui2.search_box</header> <header>calibre.gui2.search_box</header>
</customwidget> </customwidget>
<customwidget>
<class>StatusBar</class>
<extends>QWidget</extends>
<header>calibre/gui2/status.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../../../resources/images.qrc"/> <include location="../../../resources/images.qrc"/>

View File

@ -4,7 +4,8 @@ import os, re, collections
from PyQt4.QtGui import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \ from PyQt4.QtGui import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \
QVBoxLayout, QSizePolicy, QToolButton, QIcon, QScrollArea, QFrame QVBoxLayout, QSizePolicy, QToolButton, QIcon, QScrollArea, QFrame
from PyQt4.QtCore import Qt, QSize, SIGNAL, QCoreApplication from PyQt4.QtCore import Qt, QSize, SIGNAL, QCoreApplication, pyqtSignal
from calibre import fit_image, preferred_encoding, isosx from calibre import fit_image, preferred_encoding, isosx
from calibre.gui2 import qstring_to_unicode, config from calibre.gui2 import qstring_to_unicode, config
from calibre.gui2.widgets import IMAGE_EXTENSIONS from calibre.gui2.widgets import IMAGE_EXTENSIONS
@ -48,35 +49,41 @@ class BookInfoDisplay(QWidget):
class BookCoverDisplay(QLabel): class BookCoverDisplay(QLabel):
WIDTH = 81
HEIGHT = 108
def __init__(self, coverpath=I('book.svg')): def __init__(self, coverpath=I('book.svg')):
QLabel.__init__(self) QLabel.__init__(self)
self.default_pixmap = QPixmap(coverpath).scaled(self.__class__.WIDTH, self.setMaximumWidth(81)
self.__class__.HEIGHT, self.setMaximumHeight(108)
self.default_pixmap = QPixmap(coverpath).scaled(self.maximumWidth(),
self.maximumHeight(),
Qt.IgnoreAspectRatio, Qt.IgnoreAspectRatio,
Qt.SmoothTransformation) Qt.SmoothTransformation)
self.setScaledContents(True) self.setScaledContents(True)
self.setMaximumHeight(self.HEIGHT) self.statusbar_height = 120
self.setPixmap(self.default_pixmap) self.setPixmap(self.default_pixmap)
def do_layout(self):
def setPixmap(self, pixmap): pixmap = self.pixmap()
width, height = fit_image(pixmap.width(), pixmap.height(), pwidth, pheight = pixmap.width(), pixmap.height()
self.WIDTH, self.HEIGHT)[1:] width, height = fit_image(pwidth, pheight,
pwidth, self.statusbar_height-12)[1:]
self.setMaximumHeight(height) self.setMaximumHeight(height)
self.setMaximumWidth(width)
QLabel.setPixmap(self, pixmap)
try: try:
aspect_ratio = pixmap.width()/float(pixmap.height()) aspect_ratio = pwidth/float(pheight)
except ZeroDivisionError: except ZeroDivisionError:
aspect_ratio = 1 aspect_ratio = 1
self.setMaximumWidth(int(aspect_ratio*self.HEIGHT)) self.setMaximumWidth(int(aspect_ratio*self.maximumHeight()))
def setPixmap(self, pixmap):
QLabel.setPixmap(self, pixmap)
self.do_layout()
def sizeHint(self): def sizeHint(self):
return QSize(self.__class__.WIDTH, self.__class__.HEIGHT) return QSize(self.maximumWidth(), self.maximumHeight())
def relayout(self, statusbar_size):
self.statusbar_height = statusbar_size.height()
self.do_layout()
class BookDataDisplay(QLabel): class BookDataDisplay(QLabel):
@ -208,8 +215,9 @@ class CoverFlowButton(QToolButton):
class StatusBar(QStatusBar): class StatusBar(QStatusBar):
def __init__(self, jobs_dialog, systray=None): resized = pyqtSignal(object)
QStatusBar.__init__(self)
def initialize(self, jobs_dialog, systray=None):
self.systray = systray self.systray = systray
self.notifier = get_notifier(systray) self.notifier = get_notifier(systray)
self.movie_button = MovieButton(jobs_dialog) self.movie_button = MovieButton(jobs_dialog)
@ -220,7 +228,6 @@ class StatusBar(QStatusBar):
self.book_info.setAcceptDrops(True) self.book_info.setAcceptDrops(True)
self.scroll_area = QScrollArea() self.scroll_area = QScrollArea()
self.scroll_area.setWidget(self.book_info) self.scroll_area.setWidget(self.book_info)
self.scroll_area.setMaximumHeight(120)
self.scroll_area.setWidgetResizable(True) self.scroll_area.setWidgetResizable(True)
self.connect(self.book_info, SIGNAL('show_book_info()'), self.show_book_info) self.connect(self.book_info, SIGNAL('show_book_info()'), self.show_book_info)
self.connect(self.book_info, self.connect(self.book_info,
@ -228,7 +235,11 @@ class StatusBar(QStatusBar):
self.files_dropped, Qt.QueuedConnection) self.files_dropped, Qt.QueuedConnection)
self.addWidget(self.scroll_area, 100) self.addWidget(self.scroll_area, 100)
self.setMinimumHeight(120) self.setMinimumHeight(120)
self.setMaximumHeight(120) self.resized.connect(self.book_info.cover_display.relayout)
self.book_info.cover_display.relayout(self.size())
def resizeEvent(self, ev):
self.resized.emit(self.size())
def files_dropped(self, event, paths): def files_dropped(self, event, paths):
self.emit(SIGNAL('files_dropped(PyQt_PyObject, PyQt_PyObject)'), event, self.emit(SIGNAL('files_dropped(PyQt_PyObject, PyQt_PyObject)'), event,

View File

@ -45,7 +45,6 @@ from calibre.gui2.update import CheckForUpdates
from calibre.gui2.main_window import MainWindow from calibre.gui2.main_window import MainWindow
from calibre.gui2.main_ui import Ui_MainWindow from calibre.gui2.main_ui import Ui_MainWindow
from calibre.gui2.device import DeviceManager, DeviceMenu, DeviceGUI, Emailer from calibre.gui2.device import DeviceManager, DeviceMenu, DeviceGUI, Emailer
from calibre.gui2.status import StatusBar
from calibre.gui2.jobs import JobManager, JobsDialog from calibre.gui2.jobs import JobManager, JobsDialog
from calibre.gui2.dialogs.metadata_single import MetadataSingleDialog from calibre.gui2.dialogs.metadata_single import MetadataSingleDialog
from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog
@ -263,8 +262,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
SIGNAL('update_found(PyQt_PyObject)'), self.update_found) SIGNAL('update_found(PyQt_PyObject)'), self.update_found)
self.update_checker.start(2000) self.update_checker.start(2000)
####################### Status Bar ##################### ####################### Status Bar #####################
self.status_bar = StatusBar(self.jobs_dialog, self.system_tray_icon) self.status_bar.initialize(self.jobs_dialog, self.system_tray_icon)
self.setStatusBar(self.status_bar) #self.setStatusBar(self.status_bar)
QObject.connect(self.job_manager, SIGNAL('job_added(int)'), QObject.connect(self.job_manager, SIGNAL('job_added(int)'),
self.status_bar.job_added, Qt.QueuedConnection) self.status_bar.job_added, Qt.QueuedConnection)
QObject.connect(self.job_manager, SIGNAL('job_done(int)'), QObject.connect(self.job_manager, SIGNAL('job_done(int)'),
@ -677,6 +676,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.horizontal_splitter.restoreState(tb_state) self.horizontal_splitter.restoreState(tb_state)
self.toggle_tags_view(True) self.toggle_tags_view(True)
bi_state = dynamic.get('book_info_state', None)
if bi_state is not None:
self.vertical_splitter.restoreState(bi_state)
self._add_filesystem_book = Dispatcher(self.__add_filesystem_book) self._add_filesystem_book = Dispatcher(self.__add_filesystem_book)
v = self.library_view v = self.library_view
if v.model().rowCount(None) > 1: if v.model().rowCount(None) > 1:
@ -2460,6 +2463,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
dynamic.set('cover_flow_visible', self.cover_flow.isVisible()) dynamic.set('cover_flow_visible', self.cover_flow.isVisible())
dynamic.set('tag_browser_state', dynamic.set('tag_browser_state',
str(self.horizontal_splitter.saveState())) str(self.horizontal_splitter.saveState()))
dynamic.set('book_info_state',
str(self.vertical_splitter.saveState()))
self.library_view.write_settings() self.library_view.write_settings()
if self.device_connected: if self.device_connected:
self.save_device_view_settings() self.save_device_view_settings()