mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
aa57c4f8cf
@ -170,9 +170,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>T&emplate:</string>
|
||||
@ -184,20 +182,9 @@
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<layout class="FlowLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="break_box">
|
||||
<property name="text">
|
||||
@ -211,15 +198,9 @@ you the value as well as all the local variables</p></string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::VLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
<widget class="Separator">
|
||||
<property name="buddy">
|
||||
<cstring>go_button</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -241,15 +222,9 @@ you the value as well as all the local variables</p></string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::VLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
<widget class="Separator">
|
||||
<property name="buddy">
|
||||
<cstring>go_button</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -303,15 +278,9 @@ you the value as well as all the local variables</p></string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::VLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
<widget class="Separator">
|
||||
<property name="buddy">
|
||||
<cstring>go_button</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -773,11 +742,21 @@ you the value as well as all the local variables</p></string>
|
||||
<extends>QPushButton</extends>
|
||||
<header>calibre/gui2/widgets2.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>FlowLayout</class>
|
||||
<extends>QLayout</extends>
|
||||
<header>calibre/gui2/widgets2.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BoxLayout</class>
|
||||
<extends>QBoxLayout</extends>
|
||||
<header>calibre/gui2/dialogs/template_dialog_box_layout.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Separator</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>calibre/gui2/widgets2.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CodeEditor</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
|
@ -533,9 +533,10 @@ class CoverDelegate(QStyledItemDelegate):
|
||||
for i, (kind, column, rule) in enumerate(emblem_rules):
|
||||
icon_name, mi = self.render_emblem(book_id, rule, i, m.cover_grid_emblem_cache, mi, db, m.formatter, m.cover_grid_template_cache)
|
||||
if icon_name is not None:
|
||||
pixmap = self.cached_emblem(m.cover_grid_bitmap_cache, icon_name)
|
||||
if pixmap is not None:
|
||||
emblems.append(pixmap)
|
||||
for one_icon in filter(None, (i.strip() for i in icon_name.split(':'))):
|
||||
pixmap = self.cached_emblem(m.cover_grid_bitmap_cache, one_icon)
|
||||
if pixmap is not None:
|
||||
emblems.append(pixmap)
|
||||
if marked:
|
||||
emblems.insert(0, self.cached_emblem(m.cover_grid_bitmap_cache, ':marked', m.marked_icon))
|
||||
if on_device:
|
||||
|
@ -6,27 +6,33 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, textwrap, json
|
||||
import json
|
||||
import os
|
||||
import textwrap
|
||||
from qt.core import (
|
||||
QAbstractItemView, QAbstractListModel, QApplication, QCheckBox, QComboBox,
|
||||
QDialog, QDialogButtonBox, QDoubleValidator, QFrame, QGridLayout, QIcon,
|
||||
QIntValidator, QItemSelectionModel, QLabel, QLineEdit, QListView, QMenu,
|
||||
QPalette, QPushButton, QScrollArea, QSize, QSizePolicy, QSpacerItem,
|
||||
QStandardItem, QStandardItemModel, Qt, QToolButton, QVBoxLayout, QWidget,
|
||||
pyqtSignal
|
||||
)
|
||||
|
||||
from qt.core import (QWidget, QDialog, QLabel, QGridLayout, QComboBox, QSize,
|
||||
QLineEdit, QIntValidator, QDoubleValidator, QFrame, Qt, QIcon, QHBoxLayout,
|
||||
QScrollArea, QPushButton, QVBoxLayout, QDialogButtonBox, QToolButton, QItemSelectionModel,
|
||||
QListView, QAbstractListModel, pyqtSignal, QSizePolicy, QSpacerItem, QPalette,
|
||||
QApplication, QStandardItem, QStandardItemModel, QCheckBox, QMenu, QAbstractItemView,
|
||||
QColor, QBrush, QPixmap, QPainter)
|
||||
|
||||
from calibre import prepare_string_for_xml, sanitize_file_name, as_unicode
|
||||
from calibre import as_unicode, prepare_string_for_xml, sanitize_file_name
|
||||
from calibre.constants import config_dir
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.gui2 import (error_dialog, choose_files, pixmap_to_data, gprefs,
|
||||
choose_save_file, open_local_file)
|
||||
from calibre.gui2 import (
|
||||
choose_files, choose_save_file, error_dialog, gprefs, open_local_file,
|
||||
pixmap_to_data
|
||||
)
|
||||
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||
from calibre.gui2.metadata.single_download import RichTextDelegate
|
||||
from calibre.gui2.widgets2 import ColorButton, FlowLayout
|
||||
from calibre.library.coloring import (Rule, conditionable_columns,
|
||||
displayable_columns, rule_from_template, color_row_key)
|
||||
from calibre.gui2.widgets2 import ColorButton, FlowLayout, Separator
|
||||
from calibre.library.coloring import (
|
||||
Rule, color_row_key, conditionable_columns, displayable_columns,
|
||||
rule_from_template
|
||||
)
|
||||
from calibre.utils.icu import lower, sort_key
|
||||
from calibre.utils.localization import lang_map
|
||||
from calibre.utils.icu import lower
|
||||
from polyglot.builtins import iteritems, unicode_type
|
||||
|
||||
all_columns_string = _('All columns')
|
||||
@ -896,33 +902,6 @@ class RulesView(QListView): # {{{
|
||||
# }}}
|
||||
|
||||
|
||||
class Separator(QWidget): # {{{
|
||||
|
||||
def __init__(self, parent, widget_for_height):
|
||||
QWidget.__init__(self, parent)
|
||||
self.bcol = QColor(QPalette.ColorRole.Text)
|
||||
self.update_brush()
|
||||
self.widget_for_height = widget_for_height
|
||||
self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.MinimumExpanding)
|
||||
|
||||
def update_brush(self):
|
||||
self.brush = QBrush(self.bcol)
|
||||
self.update()
|
||||
|
||||
def sizeHint(self):
|
||||
return QSize(1, self.widget_for_height.height())
|
||||
|
||||
def paintEvent(self, ev):
|
||||
painter = QPainter(self)
|
||||
# Purely subjective: shorten the line a bit to look 'better'
|
||||
r = ev.rect()
|
||||
r.setTop(r.top() + 3)
|
||||
r.setBottom(r.bottom() - 3)
|
||||
painter.fillRect(r, self.brush)
|
||||
painter.end()
|
||||
# }}}
|
||||
|
||||
|
||||
class EditRules(QWidget): # {{{
|
||||
|
||||
changed = pyqtSignal()
|
||||
|
@ -10,7 +10,7 @@ from qt.core import (
|
||||
QFontInfo, QFontMetrics, QIcon, QKeySequence, QLabel, QLayout, QMenu, QMimeData,
|
||||
QPalette, QPixmap, QPoint, QPushButton, QRect, QScrollArea, QSize, QSizePolicy,
|
||||
QStyle, QStyledItemDelegate, Qt, QTabWidget, QTextBrowser, QToolButton, QTextCursor,
|
||||
QUndoCommand, QUndoStack, QUrl, QWidget, pyqtSignal
|
||||
QUndoCommand, QUndoStack, QUrl, QWidget, pyqtSignal, QBrush, QPainter
|
||||
)
|
||||
|
||||
from calibre.ebooks.metadata import rating_to_stars
|
||||
@ -440,6 +440,43 @@ class FlowLayout(QLayout): # {{{
|
||||
# }}}
|
||||
|
||||
|
||||
class Separator(QWidget): # {{{
|
||||
|
||||
''' Vertical separator lines usable in FlowLayout '''
|
||||
|
||||
def __init__(self, parent, widget_for_height=None):
|
||||
'''
|
||||
You must provide a widget in the layout either here or with setBuddy.
|
||||
The height of the separator is computed using this widget,
|
||||
'''
|
||||
QWidget.__init__(self, parent)
|
||||
self.bcol = QColor(QPalette.ColorRole.Text)
|
||||
self.update_brush()
|
||||
self.widget_for_height = widget_for_height
|
||||
self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.MinimumExpanding)
|
||||
|
||||
def update_brush(self):
|
||||
self.brush = QBrush(self.bcol)
|
||||
self.update()
|
||||
|
||||
def setBuddy(self, widget_for_height):
|
||||
''' See __init__. This is repurposed to support Qt Designer .ui files. '''
|
||||
self.widget_for_height = widget_for_height
|
||||
|
||||
def sizeHint(self):
|
||||
return QSize(1, 1 if self.widget_for_height is None else self.widget_for_height.height())
|
||||
|
||||
def paintEvent(self, ev):
|
||||
painter = QPainter(self)
|
||||
# Purely subjective: shorten the line a bit to look 'better'
|
||||
r = ev.rect()
|
||||
r.setTop(r.top() + 3)
|
||||
r.setBottom(r.bottom() - 3)
|
||||
painter.fillRect(r, self.brush)
|
||||
painter.end()
|
||||
# }}}
|
||||
|
||||
|
||||
class HTMLDisplay(QTextBrowser):
|
||||
|
||||
anchor_clicked = pyqtSignal(object)
|
||||
|
Loading…
x
Reference in New Issue
Block a user