diff --git a/src/calibre/gui2/main.ui b/src/calibre/gui2/main.ui index 2021e1bc88..6cf7ed077a 100644 --- a/src/calibre/gui2/main.ui +++ b/src/calibre/gui2/main.ui @@ -28,8 +28,8 @@ :/images/library.png:/images/library.png - - + + @@ -149,7 +149,7 @@ - + 6 @@ -287,110 +287,159 @@ - - + + - - 100 + + 0 100 - - 0 + + Qt::Vertical - - - - - - Qt::Horizontal - - - - - - - true - - - true - - - true - - - true - - - - - - - Sort by &popularity - - - - - - - - - 0 - - - - Match any + + + + 100 + 100 + + + + 0 + + + + + + + Qt::Horizontal + + + + + + + true + + + true + + + true + + + true + + + + + + + Sort by &popularity + + + + + + + + + 0 - - - - Match all + + + Match any + + + + + Match all + + + + + + + + Create, edit, and delete user categories - - - - - - - Create, edit, and delete user categories - - - Manage &user categories - - - - - - - - - - - &Restrict to: - - - search_restriction - - - - - - - - 50 - 0 - - - - Books display will be restricted to those matching the selected saved search - - - - - - + + Manage &user categories + + + + + + + + + + + &Restrict to: + + + search_restriction + + + + + + + + 50 + 0 + + + + Books display will be restricted to those matching the selected saved search + + + + + + + + + + + 100 + 10 + + + + true + + + true + + + false + + + QAbstractItemView::DragDrop + + + true + + + QAbstractItemView::SelectRows + + + false + + + false + + - + + + + + + + 100 @@ -422,124 +471,87 @@ false - - - - - - - - - - - 100 - 10 - - - - true - - - true - - - false - - - QAbstractItemView::DragDrop - - - true - - - QAbstractItemView::SelectRows - - - false - - - false - - - - - - - - - - - - 10 - 10 - - - - true - - - true - - - false - - - QAbstractItemView::DragDrop - - - true - - - QAbstractItemView::SelectRows - - - false - - - false - - - - - - - - - - - - 10 - 10 - - - - true - - - true - - - false - - - QAbstractItemView::DragDrop - - - true - - - QAbstractItemView::SelectRows - - - false - - - false - - - - + + + + + + + + + + 10 + 10 + + + + true + + + true + + + false + + + QAbstractItemView::DragDrop + + + true + + + QAbstractItemView::SelectRows + + + false + + + false + + + + + + + + + + + + 10 + 10 + + + + true + + + true + + + false + + + QAbstractItemView::DragDrop + + + true + + + QAbstractItemView::SelectRows + + + false + + + false + + + + + + @@ -587,11 +599,6 @@ - - - true - - @@ -813,6 +820,12 @@ QComboBox
calibre.gui2.search_box
+ + StatusBar + QWidget +
calibre/gui2/status.h
+ 1 +
diff --git a/src/calibre/gui2/status.py b/src/calibre/gui2/status.py index 371efddb44..d23384855d 100644 --- a/src/calibre/gui2/status.py +++ b/src/calibre/gui2/status.py @@ -4,7 +4,8 @@ import os, re, collections from PyQt4.QtGui import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \ 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.gui2 import qstring_to_unicode, config from calibre.gui2.widgets import IMAGE_EXTENSIONS @@ -48,35 +49,41 @@ class BookInfoDisplay(QWidget): class BookCoverDisplay(QLabel): - WIDTH = 81 - HEIGHT = 108 - def __init__(self, coverpath=I('book.svg')): QLabel.__init__(self) - self.default_pixmap = QPixmap(coverpath).scaled(self.__class__.WIDTH, - self.__class__.HEIGHT, + self.setMaximumWidth(81) + self.setMaximumHeight(108) + self.default_pixmap = QPixmap(coverpath).scaled(self.maximumWidth(), + self.maximumHeight(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation) self.setScaledContents(True) - self.setMaximumHeight(self.HEIGHT) + self.statusbar_height = 120 self.setPixmap(self.default_pixmap) - - def setPixmap(self, pixmap): - width, height = fit_image(pixmap.width(), pixmap.height(), - self.WIDTH, self.HEIGHT)[1:] + def do_layout(self): + pixmap = self.pixmap() + pwidth, pheight = pixmap.width(), pixmap.height() + width, height = fit_image(pwidth, pheight, + pwidth, self.statusbar_height-12)[1:] self.setMaximumHeight(height) - self.setMaximumWidth(width) - QLabel.setPixmap(self, pixmap) - try: - aspect_ratio = pixmap.width()/float(pixmap.height()) + aspect_ratio = pwidth/float(pheight) except ZeroDivisionError: 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): - 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): @@ -208,8 +215,9 @@ class CoverFlowButton(QToolButton): class StatusBar(QStatusBar): - def __init__(self, jobs_dialog, systray=None): - QStatusBar.__init__(self) + resized = pyqtSignal(object) + + def initialize(self, jobs_dialog, systray=None): self.systray = systray self.notifier = get_notifier(systray) self.movie_button = MovieButton(jobs_dialog) @@ -220,7 +228,6 @@ class StatusBar(QStatusBar): self.book_info.setAcceptDrops(True) self.scroll_area = QScrollArea() self.scroll_area.setWidget(self.book_info) - self.scroll_area.setMaximumHeight(120) self.scroll_area.setWidgetResizable(True) self.connect(self.book_info, SIGNAL('show_book_info()'), self.show_book_info) self.connect(self.book_info, @@ -228,7 +235,11 @@ class StatusBar(QStatusBar): self.files_dropped, Qt.QueuedConnection) self.addWidget(self.scroll_area, 100) 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): self.emit(SIGNAL('files_dropped(PyQt_PyObject, PyQt_PyObject)'), event, diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 6e0c5e333f..40f5b5b57e 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -45,7 +45,6 @@ from calibre.gui2.update import CheckForUpdates from calibre.gui2.main_window import MainWindow from calibre.gui2.main_ui import Ui_MainWindow 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.dialogs.metadata_single import MetadataSingleDialog 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) self.update_checker.start(2000) ####################### Status Bar ##################### - self.status_bar = StatusBar(self.jobs_dialog, self.system_tray_icon) - self.setStatusBar(self.status_bar) + self.status_bar.initialize(self.jobs_dialog, self.system_tray_icon) + #self.setStatusBar(self.status_bar) QObject.connect(self.job_manager, SIGNAL('job_added(int)'), self.status_bar.job_added, Qt.QueuedConnection) 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.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) v = self.library_view 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('tag_browser_state', str(self.horizontal_splitter.saveState())) + dynamic.set('book_info_state', + str(self.vertical_splitter.saveState())) self.library_view.write_settings() if self.device_connected: self.save_device_view_settings()