mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Make the book info display area also freely resizable
This commit is contained in:
parent
0bd19d1c2b
commit
98fa71af77
@ -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,7 +287,17 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item>
|
||||||
|
<widget class="QSplitter" name="vertical_splitter">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>100</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
<widget class="QStackedWidget" name="stack">
|
<widget class="QStackedWidget" name="stack">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
@ -541,6 +551,8 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="StatusBar" name="status_bar" native="true"/>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -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"/>
|
||||||
|
@ -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,
|
||||||
|
@ -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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user