Fixes #1922405 [Make the Create/edit a column icon rule window narrower](https://bugs.launchpad.net/calibre/+bug/1922405)
This commit is contained in:
Kovid Goyal 2021-04-03 18:28:13 +05:30
commit b4b2108546
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 48 additions and 17 deletions

View file

@ -224,7 +224,7 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="go_button">
<widget class="QToolButton" name="go_button">
<property name="text">
<string>&amp;Go</string>
</property>
@ -232,8 +232,8 @@ you the value as well as all the local variables&lt;/p&gt;</string>
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/sync-right.png</normaloff>:/images/sync-right.png</iconset>
</property>
<property name="styleSheet">
<string notr="true">padding: 5; padding-left: 1;</string>
<property name="toolButtonStyle">
<set>Qt::ToolButtonTextBesideIcon</set>
</property>
<property name="toolTip">
<string>If 'Enable breakpoints' is checked then click this button to run your template</string>
@ -286,12 +286,12 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="toggle_button">
<widget class="QToolButton" name="toggle_button">
<property name="text">
<string>&amp;Toggle</string>
</property>
<property name="styleSheet">
<string notr="true">padding: 5; padding-left: 1;</string>
<property name="toolButtonStyle">
<set>Qt::ToolButtonTextBesideIcon</set>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
@ -316,12 +316,12 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="remove_all_button">
<widget class="QToolButton" name="remove_all_button">
<property name="text">
<string>&amp;Remove all</string>
</property>
<property name="styleSheet">
<string notr="true">padding: 5; padding-left: 1;</string>
<property name="toolButtonStyle">
<set>Qt::ToolButtonTextBesideIcon</set>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
@ -333,12 +333,12 @@ you the value as well as all the local variables&lt;/p&gt;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="set_all_button">
<widget class="QToolButton" name="set_all_button">
<property name="text">
<string>&amp;Set all</string>
</property>
<property name="styleSheet">
<string notr="true">padding: 5; padding-left: 1;</string>
<property name="toolButtonStyle">
<set>Qt::ToolButtonTextBesideIcon</set>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">

View file

@ -12,7 +12,8 @@
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)
QApplication, QStandardItem, QStandardItemModel, QCheckBox, QMenu, QAbstractItemView,
QColor, QBrush, QPixmap, QPainter)
from calibre import prepare_string_for_xml, sanitize_file_name, as_unicode
from calibre.constants import config_dir
@ -21,7 +22,7 @@
choose_save_file, open_local_file)
from calibre.gui2.dialogs.template_dialog import TemplateDialog
from calibre.gui2.metadata.single_download import RichTextDelegate
from calibre.gui2.widgets2 import ColorButton
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.utils.localization import lang_map
@ -895,6 +896,33 @@ def currentChanged(self, new, prev):
# }}}
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()
@ -949,7 +977,7 @@ def __init__(self, parent=None):
self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')),
_('Add ad&vanced rule'), self)
b.clicked.connect(self.add_advanced)
self.hb = hb = QHBoxLayout()
self.hb = hb = FlowLayout()
l.addLayout(hb, l.rowCount(), 0, 1, 2)
hb.addWidget(b)
self.duplicate_rule_button = b = QPushButton(QIcon(I('edit-copy.png')),
@ -962,13 +990,16 @@ def __init__(self, parent=None):
b.clicked.connect(self.convert_to_advanced)
b.setEnabled(False)
hb.addWidget(b)
hb.addStretch(10)
sep = Separator(self, b)
hb.addWidget(sep)
self.open_icon_folder_button = b = QPushButton(QIcon(I('icon_choose.png')),
_('Open icon folder'), self)
connect_lambda(b.clicked, self,
lambda _: open_local_file(os.path.join(config_dir, 'cc_icons')))
hb.addWidget(b)
hb.addStretch(10)
sep = Separator(self, b)
hb.addWidget(sep)
self.export_button = b = QPushButton(_('E&xport'), self)
b.clicked.connect(self.export_rules)
b.setToolTip(_('Export these rules to a file'))